Bläddra i källkod

首次提交部门代码

tags/v1.0.0^2
wanjing 1 år sedan
förälder
incheckning
6a7f034b7a
12 ändrade filer med 725 tillägg och 0 borttagningar
  1. +9
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java
  2. +23
    -0
      tuoheng-service/tuoheng-admin/pom.xml
  3. +73
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java
  4. +64
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Dept.java
  5. +63
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java
  6. +43
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/AddDeptRequest.java
  7. +60
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/EditDeptRequest.java
  8. +29
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/RoadSection.java
  9. +102
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java
  10. +65
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java
  11. +78
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java
  12. +116
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml

+ 9
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java Visa fil

@@ -96,4 +96,13 @@ public class JsonResult<T> implements Serializable {
this.data = data;
}


@Override
public String toString() {
return "JsonResult{" +
"code=" + code +
", msg='" + msg + '\'' +
", data=" + data +
'}';
}
}

+ 23
- 0
tuoheng-service/tuoheng-admin/pom.xml Visa fil

@@ -32,6 +32,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Springboot test依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- MySql驱动 -->
<dependency>
<groupId>mysql</groupId>
@@ -104,6 +112,21 @@
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/aliyun-java-vod-upload-1.4.14.jar</systemPath>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>


+ 73
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java Visa fil

@@ -0,0 +1,73 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.service.dept.IDeptService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 部门前端控制器
*
* @author wanjing
* @team tuoheng
* @date 2022-11-16
*/
@Slf4j
@RestController
@RequestMapping("/dept")
public class DeptController {

@Autowired
private IDeptService deptService;

/**
* 查询部门列表
*/
@GetMapping("/list/tree")
public JsonResult getListTree(Dept dept) {
log.info("进入获取部门列表接口");
return deptService.selectListTree(dept);
}

/**
* 获取部门详细信息
*/
@GetMapping(value = "/{id}")
public JsonResult getInfo(@PathVariable("id") Integer id) {
log.info("进入获取部门信息接口");
return deptService.selectOne(id);
}

/**
* 新增部门
*/
@PostMapping
public JsonResult add(@RequestBody AddDeptRequest addDeptRequest) {
log.info("进入新增部门接口");
return deptService.insert(addDeptRequest);
}

/**
* 修改部门
*/
@PutMapping
public JsonResult edit(@RequestBody Dept dept) {
log.info("进入修改部门接口");
return deptService.update(dept);
}

/**
* 删除部门
*/
@DeleteMapping("/{id}")
public JsonResult delete(@PathVariable String id) {
log.info("进入删除部门接口");
return deptService.deleteById(id);
}
}

+ 64
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Dept.java Visa fil

@@ -0,0 +1,64 @@
package com.tuoheng.admin.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.core.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 部门对象
*
* @author wanjing
* @team tuoheng
* @date 2022-11-16
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("th_dept")
public class Dept extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户ID
*/
private Integer tenantId;
/**
* 部门名称
*/
private String name;
/**
* 部门编码
*/
private String code;
/**
* 部门全称
*/
private String fullname;
/**
* 类型:1公司 2子公司 3部门 4小组
*/
private Integer type;
/**
* 上级ID
*/
private Integer pid;
/**
* 排序
*/
private Integer sort;
/**
* 备注说明
*/
private String note;
}

+ 63
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java Visa fil

@@ -0,0 +1,63 @@
package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.Dept;

import java.util.List;

/**
* 部门接口
*
* @author wanjing
* @team tuoheng
* @date 2022-11-16
*/
public interface DeptMapper extends BaseMapper<Dept> {
/**
* 查询部门
*
* @param id 部门主键
* @return 部门
*/
Dept selectOne(Integer id);

/**
* 查询部门列表
*
* @param dept 部门
* @return 部门集合
*/
List<Dept> selectList(Dept dept);

/**
* 新增部门
*
* @param dept 部门
* @return 结果
*/
int insert(Dept dept);

/**
* 修改部门
*
* @param dept 部门
* @return 结果
*/
int update(Dept dept);

/**
* 删除部门
*
* @param id 部门主键
* @return 结果
*/
int deleteById(String id);

/**
* 批量删除部门
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteByIds(String[] ids);
}

+ 43
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/AddDeptRequest.java Visa fil

@@ -0,0 +1,43 @@
package com.tuoheng.admin.request.dept;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* 新增部门请求参数
*
* @author wanjing
* @team tuoheng
* @date 2022-11-17
*/
@Data
public class AddDeptRequest {

private static final long serialVersionUID = 1L;

/**
* 部门id
*/
private Integer pid;

/**
*部门编号
*/
private String code;

/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空!")
private String name;

/**
* 公路,路段数据
*/
private List<RoadSection> roadSectionList;


}

+ 60
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/EditDeptRequest.java Visa fil

@@ -0,0 +1,60 @@
package com.tuoheng.admin.request.dept;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
* 修改部门请求参数
*
* @author wanjing
* @team tuoheng
* @date 2022-11-17
*/
@Data
public class EditDeptRequest {

private static final long serialVersionUID = 1L;

/**
* 部门id
*/
private Integer id;

/**
* 部门编号
*/
private String code;

/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空!")
private String name;

/**
* 部门全称名称
*/
@NotBlank(message = "部门全称不能为空!")
private String fullname;

/**
* 巡检任务类型 1 常规;2 日常
*/
@NotNull(message = "巡检任务类型不能为空!")
private Integer type;

/**
* 巡检方式 1 无人机
*/
@NotNull(message = "巡检方式不能为空!")
private Integer inspectionType;

/**
* 挂载设备名称(多选逗号","分隔)
*/
private String equipmentMountName;


}

+ 29
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/RoadSection.java Visa fil

@@ -0,0 +1,29 @@
package com.tuoheng.admin.request.dept;

import com.tuoheng.admin.entity.RoadInformation;
import com.tuoheng.admin.entity.Section;
import lombok.Data;

import java.util.List;

/**
* 公路路段对应
*
* @author wanjing
* @team tuoheng
* @date 2022-11-17
*/
@Data
public class RoadSection {

/**
* 公路
*/
private RoadInformation road;

/**
* 路段
*/
private List<Section> sectionList;

}

+ 102
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java Visa fil

@@ -0,0 +1,102 @@
package com.tuoheng.admin.service.dept;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.service.dept.add.AddDeptService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 部门业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-11-16
*/
@Slf4j
@Service
public class DeptServiceImpl implements IDeptService {
@Autowired
private DeptMapper deptMapper;
@Autowired
private AddDeptService addDeptService;
/**
* 查询部门
*
* @param id 部门主键
* @return 部门
*/
@Override
public JsonResult selectOne(Integer id) {
deptMapper.selectOne(id);
return JsonResult.success();
}
/**
* 查询部门列表
*
* @param dept 部门
* @return 部门
*/
@Override
public JsonResult selectListTree(Dept dept) {
deptMapper.selectList(dept);
return JsonResult.success();
}
/**
* 新增部门
*
* @param addDeptRequest 部门
* @return 结果
*/
@Override
public JsonResult insert(AddDeptRequest addDeptRequest) {
return addDeptService.add(addDeptRequest);
}
/**
* 修改部门
*
* @param dept 部门
* @return 结果
*/
@Override
public JsonResult update(Dept dept) {
deptMapper.update(dept);
return JsonResult.success();
}
/**
* 批量删除部门
*
* @param ids 需要删除的部门主键
* @return 结果
*/
@Override
public JsonResult deleteByIds(String[] ids) {
deptMapper.deleteByIds(ids);
return JsonResult.success();
}
/**
* 删除部门信息
*
* @param id 部门主键
* @return 结果
*/
@Override
public JsonResult deleteById(String id) {
deptMapper.deleteById(id);
return JsonResult.success();
}
}

+ 65
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java Visa fil

@@ -0,0 +1,65 @@
package com.tuoheng.admin.service.dept;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.common.core.utils.JsonResult;
import java.util.List;
/**
* 部门Service接口
*
* @author wanjing
* @team tuoheng
* @date 2022-11-16
*/
public interface IDeptService {
/**
* 查询部门
*
* @param id 部门主键
* @return 部门
*/
JsonResult selectOne(Integer id);
/**
* 查询部门列表
*
* @param dept 部门
* @return 部门集合
*/
JsonResult selectListTree(Dept dept);
/**
* 新增部门
*
* @param addDeptRequest 部门
* @return 结果
*/
JsonResult insert(AddDeptRequest addDeptRequest);
/**
* 修改部门
*
* @param dept 部门
* @return 结果
*/
JsonResult update(Dept dept);
/**
* 批量删除部门
*
* @param ids 需要删除的部门主键集合
* @return 结果
*/
JsonResult deleteByIds(String[] ids);
/**
* 删除部门信息
*
* @param id 部门主键
* @return 结果
*/
JsonResult deleteById(String id);
}

+ 78
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java Visa fil

@@ -0,0 +1,78 @@
package com.tuoheng.admin.service.dept.add;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.request.dept.RoadSection;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 添加部门业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-11-17
*/
@Slf4j
@Service
public class AddDeptService {

@Autowired
private DeptMapper deptMapper;

public JsonResult add(AddDeptRequest addDeptRequest) {
// Integer tenantId = ShiroUtils.getTenantId();
// dept.setTenantId(tenantId);

// 判断是否已存在该部门编号
Integer count = deptMapper.selectCount(new LambdaQueryWrapper<Dept>()
// .eq(Dept::getTenantId, tenantId)
.eq(Dept::getCode, addDeptRequest.getCode())
.eq(Dept::getMark, 1));

// 系统中已存在
if (count > 0) {
return JsonResult.error(2000, "系统中已存在相同的角色编码");
}

Dept dept = new Dept();
dept.setCode(addDeptRequest.getCode());
dept.setName(addDeptRequest.getName());
dept.setFullname(addDeptRequest.getName());
dept.setPid(addDeptRequest.getPid());

// dept.setCreateUser(ShiroUtils.getUserId());
dept.setCreateTime(DateUtils.now());

Integer result = deptMapper.insert(dept);
log.info("新增部门, 返回结果: {}", result);

return JsonResult.success("新增部门成功");
}

private void addRoadAndSectionToDept(int deptId, List<RoadSection> roadSectionList) {
RoadInformation road;
List<Section> sectionList;
for (RoadSection roadSection : roadSectionList) {
road = roadSection.getRoad();
sectionList = roadSection.getSectionList();
}
}

private void addRoadToDept(int deptId, RoadInformation roadInformation) {

}

private void addSectionToDept(int deptId, List<Section> sectionList) {
SectionDept sectionDept = new SectionDept();

}

}

+ 116
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml Visa fil

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.admin.mapper.DeptMapper">
<resultMap type="com.tuoheng.admin.entity.Dept" id="DeptResult">
<result property="id" column="id" />
<result property="tenantId" column="tenant_id" />
<result property="name" column="name" />
<result property="code" column="code" />
<result property="fullname" column="fullname" />
<result property="type" column="type" />
<result property="pid" column="pid" />
<result property="sort" column="sort" />
<result property="note" column="note" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>
<sql id="selectThDeptVo">
select id, tenant_id, name, code, fullname, type, pid, sort, note, create_user, create_time, update_user, update_time, mark from th_dept
</sql>
<select id="selectList" parameterType="com.tuoheng.admin.entity.Dept" resultMap="DeptResult">
<include refid="selectThDeptVo"/>
<where>
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="fullname != null and fullname != ''"> and fullname like concat('%', #{fullname}, '%')</if>
<if test="type != null "> and type = #{type}</if>
<if test="pid != null and pid != ''"> and pid = #{pid}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="note != null and note != ''"> and note = #{note}</if>
<if test="createUser != null and createUser != ''"> and create_user = #{createUser}</if>
<if test="updateUser != null and updateUser != ''"> and update_user = #{updateUser}</if>
<if test="mark != null "> and mark = #{mark}</if>
</where>
</select>
<select id="selectOne" parameterType="Integer" resultMap="DeptResult">
<include refid="selectThDeptVo"/>
where id = #{id}
</select>
<insert id="insert" parameterType="com.tuoheng.admin.entity.Dept"
keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into th_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="code != null">code,</if>
<if test="fullname != null">fullname,</if>
<if test="type != null">type,</if>
<if test="pid != null and pid != ''">pid,</if>
<if test="sort != null">sort,</if>
<if test="note != null">note,</if>
<if test="createUser != null and createUser != ''">create_user,</if>
<if test="createTime != null">create_time,</if>
<if test="updateUser != null">update_user,</if>
<if test="updateTime != null">update_time,</if>
<if test="mark != null">mark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="code != null">#{code},</if>
<if test="fullname != null">#{fullname},</if>
<if test="type != null">#{type},</if>
<if test="pid != null and pid != ''">#{pid},</if>
<if test="sort != null">#{sort},</if>
<if test="note != null">#{note},</if>
<if test="createUser != null and createUser != ''">#{createUser},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateUser != null">#{updateUser},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="mark != null">#{mark},</if>
</trim>
</insert>
<update id="update" parameterType="com.tuoheng.admin.entity.Dept">
update th_dept
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="code != null">code = #{code},</if>
<if test="fullname != null">fullname = #{fullname},</if>
<if test="type != null">type = #{type},</if>
<if test="pid != null and pid != ''">pid = #{pid},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="note != null">note = #{note},</if>
<if test="createUser != null and createUser != ''">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateUser != null">update_user = #{updateUser},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="mark != null">mark = #{mark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteById" parameterType="String">
delete from th_dept where id = #{id}
</delete>
<delete id="deleteByIds" parameterType="String">
delete from th_dept where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

Laddar…
Avbryt
Spara