Parcourir la source

:Merge branch 'wanjing' into develop

tags/v1.0.0^2
wanjing il y a 1 an
Parent
révision
0f613dc4cf
9 fichiers modifiés avec 285 ajouts et 159 suppressions
  1. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java
  2. +7
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/EditDeptCodeEnum.java
  3. +0
    -15
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java
  4. +4
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java
  5. +3
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java
  6. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java
  7. +214
    -75
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/update/UpdateDeptService.java
  8. +52
    -52
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml
  9. +2
    -4
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/SectionDeptMapper.xml

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java Voir le fichier

@@ -54,9 +54,9 @@ public class DeptController {
* 修改部门
*/
@PutMapping
public JsonResult update(@RequestBody EditDeptRequest editDeptRequest) {
public JsonResult update(@RequestBody EditDeptRequest oldEditDeptRequest, @RequestBody EditDeptRequest newEditDeptRequest) {
log.info("进入修改部门接口");
return deptService.update(editDeptRequest);
return deptService.update(oldEditDeptRequest, newEditDeptRequest);
}

/**

+ 7
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/EditDeptCodeEnum.java Voir le fichier

@@ -15,11 +15,13 @@ public enum EditDeptCodeEnum {
DEPT_PID_IS_NULL(1200401, "请选择上级部门"),
DEPT_ID_IS_NOT_NULL(1200402, "部门ID为空"),
DEPT_NAME_IS_NOT_NULL(1200403, "部门名为空"),
DEPT_IS_NOT_EXIST(1200404, "部门不存在"),
PARENT_DEPT_IS_NOT_EXIST(1200405, "上级部门不存在"),
DEPT_NAME_IS_ALREADY_EXIST(1200306, "该部门下已存该部门名称"),
ROAD_IS_NULL(1200407, "公路信息为空"),
SECTION_IS_NULL(1200408, "路段信息为空");
DEPT_ID_IS_NOT_SAME(1200404, "修改部门ID与原部门ID不一致"),
DEPT_PID_IS_NOT_SAME(1200405, "修改部门PID与原部门PID不一致"),
DEPT_IS_NOT_EXIST(1200406, "部门不存在"),
PARENT_DEPT_IS_NOT_EXIST(1200407, "上级部门不存在"),
DEPT_NAME_IS_ALREADY_EXIST(1200308, "该部门下已存该部门名称"),
ROAD_IS_NULL(1200409, "公路信息为空"),
SECTION_IS_NULL(1200410, "路段信息为空");

/**
* 错误码

+ 0
- 15
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java Voir le fichier

@@ -13,21 +13,6 @@ import java.util.List;
* @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);

/**
* 修改部门

+ 4
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java Voir le fichier

@@ -78,12 +78,13 @@ public class DeptServiceImpl implements IDeptService {
/**
* 修改部门
*
* @param editDeptRequest 修改部门对象
* @param oldEditDeptRequest 原部门对象
* @param newEditDeptRequest 新部门对象
* @return 结果
*/
@Override
public JsonResult update(EditDeptRequest editDeptRequest) {
return updateDeptService.update(editDeptRequest);
public JsonResult update(EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest) {
return updateDeptService.update(oldEditDeptRequest, newEditDeptRequest);
}
/**

+ 3
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java Voir le fichier

@@ -42,10 +42,11 @@ public interface IDeptService {
/**
* 修改部门
*
* @param editDeptRequest 修改部门对象
* @param oldEditDeptRequest 原部门对象
* @param newEditDeptRequest 新部门对象
* @return 结果
*/
JsonResult update(EditDeptRequest editDeptRequest);
JsonResult update(EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest);
/**

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/add/AddDeptService.java Voir le fichier

@@ -204,7 +204,7 @@ public class AddDeptService {
}

/**
* 新增路段部门数据
* 新增路段部门数据
* 1、先删除原有记录数据
* 2、新增此次提交的数据
*

+ 214
- 75
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/update/UpdateDeptService.java Voir le fichier

@@ -20,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

/**
@@ -47,37 +44,33 @@ public class UpdateDeptService {
private SectionDeptMapper sectionDeptMapper;

/**
* 修改部门数据
* 修改部门信息,涉及公路、路段数据
*
* @param oldEditDeptRequest
* @param newEditDeptRequest
* @return
*/
public JsonResult update(EditDeptRequest editDeptRequest) {
public JsonResult update(EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest) {
log.info("进入修改部门业务接口");
String tenantId = ShiroUtils.getTenantId();
JsonResult result = this.check(tenantId, editDeptRequest);
JsonResult result = this.check(tenantId, oldEditDeptRequest, newEditDeptRequest);
if (0 != result.getCode()) {
log.info("修改部门业务接口:校验失败:{}", result.getMsg());
return result;
}

Dept dept = new Dept();
dept.setId(editDeptRequest.getId());
dept.setTenantId(tenantId);
dept.setName(editDeptRequest.getName());
dept.setFullname(editDeptRequest.getName());
// dept.setUpdateUser(ShiroUtils.getUserId());
dept.setUpdateTime(DateUtils.now());

Integer rowId = deptMapper.update(dept);
log.info("修改部门, 返回结果: deptId={}", dept.getId());

if (rowId <= 0) {
// 修改部门数据
result = this.updateDept(tenantId, oldEditDeptRequest, newEditDeptRequest);
if (0 != result.getCode()) {
log.info("修改部门业务接口:修改部门失败:{}", result.getMsg());
return JsonResult.error(EditDeptCodeEnum.EDIT_DEPT_IS_FAILED.getCode(), EditDeptCodeEnum.EDIT_DEPT_IS_FAILED.getMsg());
}

// 递归修改该部门下所有公路/路段与部门数据
// 处理公路与部门数据
this.roadHandle(tenantId, oldEditDeptRequest, newEditDeptRequest);

// 处理路段与部门数据
this.sectionhandle(tenantId, oldEditDeptRequest, newEditDeptRequest);

log.info("修改部门业务接口:修改部门成功:{}");
return JsonResult.success("修改部门成功");
@@ -85,37 +78,46 @@ public class UpdateDeptService {

/**
* 检查参数
*
* @param tenantId
* @param editDeptRequest
* @param newEditDeptRequest
* @return
*/
private JsonResult check(String tenantId, EditDeptRequest editDeptRequest) {
if (StringUtils.isEmpty(editDeptRequest.getPid())) {
private JsonResult check(String tenantId, EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest) {
if (StringUtils.isEmpty(newEditDeptRequest.getPid())) {
return JsonResult.error(EditDeptCodeEnum.DEPT_PID_IS_NULL.getCode(), EditDeptCodeEnum.DEPT_PID_IS_NULL.getMsg());
}

if (StringUtils.isEmpty(editDeptRequest.getId())) {
if (StringUtils.isEmpty(newEditDeptRequest.getId())) {
return JsonResult.error(EditDeptCodeEnum.DEPT_ID_IS_NOT_NULL.getCode(), EditDeptCodeEnum.DEPT_ID_IS_NOT_NULL.getMsg());
}

if (StringUtils.isEmpty(editDeptRequest.getName())) {
if (StringUtils.isEmpty(newEditDeptRequest.getName())) {
return JsonResult.error(EditDeptCodeEnum.DEPT_NAME_IS_NOT_NULL.getCode(), EditDeptCodeEnum.DEPT_NAME_IS_NOT_NULL.getMsg());
}

if (oldEditDeptRequest.getId().equals(newEditDeptRequest.getId())) {
return JsonResult.error(EditDeptCodeEnum.DEPT_ID_IS_NOT_SAME.getCode(), EditDeptCodeEnum.DEPT_ID_IS_NOT_SAME.getMsg());
}

if (oldEditDeptRequest.getPid().equals(newEditDeptRequest.getPid())) {
return JsonResult.error(EditDeptCodeEnum.DEPT_PID_IS_NOT_SAME.getCode(), EditDeptCodeEnum.DEPT_PID_IS_NOT_SAME.getMsg());
}

// 判断部门是否存在
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, editDeptRequest.getId())
.eq(Dept::getId, newEditDeptRequest.getId())
.eq(Dept::getMark, 1));
if (null == dept) {
return JsonResult.error(EditDeptCodeEnum.DEPT_IS_NOT_EXIST.getCode(), EditDeptCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}

if ("0".equals(editDeptRequest.getPid())) {
if ("0".equals(newEditDeptRequest.getPid())) {
// 判断部门是否存在
Dept parentDept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, editDeptRequest.getId())
.eq(Dept::getId, newEditDeptRequest.getId())
.eq(Dept::getMark, 1));
if (null == parentDept) {
return JsonResult.error(EditDeptCodeEnum.DEPT_IS_NOT_EXIST.getCode(), EditDeptCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
@@ -126,9 +128,9 @@ public class UpdateDeptService {
// 注意要增加id不能与自己的相同的判断
Integer count = deptMapper.selectCount(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getPid, editDeptRequest.getPid())
.ne(Dept::getId, editDeptRequest.getId())
.eq(Dept::getName, editDeptRequest.getName())
.eq(Dept::getPid, newEditDeptRequest.getPid())
.ne(Dept::getId, newEditDeptRequest.getId())
.eq(Dept::getName, newEditDeptRequest.getName())
.eq(Dept::getMark, 1));

// 系统中已存在
@@ -137,12 +139,12 @@ public class UpdateDeptService {
}

// 新增部门,公路和路段信息不能为空
if (CollectionUtils.isEmpty(editDeptRequest.getRoadSectionDtoList())) {
if (CollectionUtils.isEmpty(newEditDeptRequest.getRoadSectionDtoList())) {
return JsonResult.error(EditDeptCodeEnum.ROAD_IS_NULL.getCode(), EditDeptCodeEnum.ROAD_IS_NULL.getMsg());
}

List<Section> sectionList;
List<RoadSectionDto> roadSectionDtoList = editDeptRequest.getRoadSectionDtoList();
List<RoadSectionDto> roadSectionDtoList = newEditDeptRequest.getRoadSectionDtoList();
for (RoadSectionDto roadSectionDto : roadSectionDtoList) {
sectionList = roadSectionDto.getSectionList();
if (CollectionUtils.isEmpty(sectionList)) {
@@ -152,24 +154,58 @@ public class UpdateDeptService {
return JsonResult.success();
}

private void addRoadAndSectionToDept(String tenantId, String deptId, List<RoadSectionDto> roadSectionDtoList) {
List<RoadInformation> roadInformationList = new ArrayList<>();
List<Section> sectionList = new ArrayList<>();

RoadInformation road;
List<Section> sectionListTmp;
for (RoadSectionDto roadSectionDto : roadSectionDtoList) {
road = roadSectionDto.getRoad();
sectionListTmp = roadSectionDto.getSectionList();
/**
* 修改部门信息
* 根据业务修改,部门只能修改部门名称,若部门名称和原来一致,可不用修改
*
* @param tenantId
* @param oldEditDeptRequest
* @param newEditDeptRequest
* @return
*/
private JsonResult updateDept(String tenantId, EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest) {
if (oldEditDeptRequest.getName().equals(newEditDeptRequest.getName())) {
Dept dept = new Dept();
dept.setId(newEditDeptRequest.getId());
dept.setTenantId(tenantId);
dept.setName(newEditDeptRequest.getName());
dept.setFullname(newEditDeptRequest.getName());
// dept.setUpdateUser(ShiroUtils.getUserId());
dept.setUpdateTime(DateUtils.now());

roadInformationList.add(road);
sectionList.addAll(sectionListTmp);
Integer rowId = deptMapper.update(dept);
log.info("修改部门, 返回结果: deptId={}", dept.getId());
if (rowId <= 0) {
return JsonResult.error(EditDeptCodeEnum.EDIT_DEPT_IS_FAILED.getCode(), EditDeptCodeEnum.EDIT_DEPT_IS_FAILED.getMsg());
}
}
return JsonResult.success();
}

// 添加部门和公路数据
this.addRoadToDept(tenantId, deptId, roadInformationList);
/**
* 处理公路和部门数据
*
* @param tenantId
* @param oldEditDeptRequest
* @param newEditDeptRequest
*/
private void roadHandle(String tenantId, EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest) {
List<RoadSectionDto> oldRoadSectionList = oldEditDeptRequest.getRoadSectionDtoList();
List<String> oldRoadIdList = oldRoadSectionList.stream().map(o -> o.getRoad().getId()).collect(Collectors.toList());

List<RoadSectionDto> newRoadSectionList = newEditDeptRequest.getRoadSectionDtoList();
List<String> newRoadIdList = newRoadSectionList.stream().map(o -> o.getRoad().getId()).collect(Collectors.toList());

this.addSectionToDept(tenantId, deptId, sectionList);
// 交集:存在公路, 不做处理
// Collection<String> union = org.apache.commons.collections4.CollectionUtils.union(oldRoadIdList, newRoadIdList);

// 差集:新增公路
Collection<String> addRoadIdList = org.apache.commons.collections4.CollectionUtils.subtract(newRoadIdList, oldRoadIdList);
this.addRoadToDept(tenantId, newEditDeptRequest.getId(), addRoadIdList);

// 差集:删除公路
Collection<String> subRoadIdList = org.apache.commons.collections4.CollectionUtils.subtract(oldRoadIdList, newRoadIdList);
this.removeRoadToDept(tenantId, newEditDeptRequest.getId(), subRoadIdList);
}

/**
@@ -177,59 +213,126 @@ public class UpdateDeptService {
* 1、先删除原有记录数据
* 2、新增此次提交的数据
*
* @param tenantId 租户Id
* @param deptId 部门Id
* @param roadInformationList 公路集合
* @param tenantId 租户Id
* @param deptId 部门Id
* @param roadIdList 公路Id集合
* @return 结果
*/
private void addRoadToDept(String tenantId, String deptId, List<RoadInformation> roadInformationList) {
List<String> roadIdList = roadInformationList.stream().map(o -> o.getId()).collect(Collectors.toList());
Map<String, Object> map = new HashMap<>();
map.put("tenantId", tenantId);
map.put("deptId", deptId);
map.put("roadIdList", roadIdList);
roadDeptMapper.deleteBatchByMap(map);

private void addRoadToDept(String tenantId, String deptId, Collection<String> roadIdList) {
List<RoadDept> list = new ArrayList<>();
RoadDept roadDept;
for (RoadInformation roadInformation : roadInformationList) {
RoadDept roadDeptTmp;
for (String roadId : roadIdList) {
roadDept = new RoadDept();
roadDept.setTenantId(tenantId);
roadDept.setDeptId(deptId);
roadDept.setRoadId(roadInformation.getId());
roadDept.setRoadId(roadId);

// 判断是否存在, 存在则不用再次添加
roadDeptTmp = roadDeptMapper.selectOne(new LambdaQueryWrapper<RoadDept>()
.eq(RoadDept::getTenantId, tenantId)
.eq(RoadDept::getDeptId, deptId)
.eq(RoadDept::getRoadId, roadId));
if (null != roadDeptTmp) {
continue;
}
list.add(roadDept);
}

if (!CollectionUtils.isEmpty(list)) {
roadDeptMapper.insertBatch(list);
}
}

/**
* 新增公路段部门数据
* 移除公路部门数据
* 如若是该公路被分配给了子部门或子子部门,同样一并删除
*
* @param tenantId 租户Id
* @param deptId 部门Id
* @param roadIdList 公路Id集合
* @return 结果
*/
private void removeRoadToDept(String tenantId, String deptId, Collection<String> roadIdList) {
// 查找部门id及下面所有的子部门
Dept parentDept = new Dept();
parentDept.setTenantId(tenantId);
parentDept.setId(deptId);

List<Dept> deptList = new ArrayList<>();
deptList.add(parentDept);
queryChildDeptList(deptList, parentDept);

for (Dept dept : deptList) {
Map<String, Object> map = new HashMap<>();
map.put("tenantId", tenantId);
map.put("deptId", dept.getId());
map.put("roadIdList", roadIdList);
roadDeptMapper.deleteBatchByMap(map);
}
}

/**
* 处理路段和部门数据
*
* @param tenantId
* @param oldEditDeptRequest
* @param newEditDeptRequest
*/
private void sectionhandle(String tenantId, EditDeptRequest oldEditDeptRequest, EditDeptRequest newEditDeptRequest) {
List<RoadSectionDto> oldRoadSectionList = oldEditDeptRequest.getRoadSectionDtoList();
List<Section> oldSectionList = new ArrayList<>();
for (RoadSectionDto roadSectionDto : oldRoadSectionList) {
oldSectionList.addAll(roadSectionDto.getSectionList());
}

List<RoadSectionDto> newRoadSectionList = newEditDeptRequest.getRoadSectionDtoList();
List<Section> newSectionList = new ArrayList<>();
for (RoadSectionDto roadSectionDto : newRoadSectionList) {
newSectionList.addAll(roadSectionDto.getSectionList());
}

List<String> oldSectionIdList = oldSectionList.stream().map(o -> o.getId()).collect(Collectors.toList());
List<String> newSectionIdList = newSectionList.stream().map(o -> o.getId()).collect(Collectors.toList());

// 差集:新增公路
Collection<String> addSectionIdList = org.apache.commons.collections4.CollectionUtils.subtract(newSectionIdList, oldSectionIdList);
// 添加路段和部门数据
this.addSectionToDept(tenantId, newEditDeptRequest.getId(), addSectionIdList);

// 差集:删除公路
Collection<String> subSectionIdList = org.apache.commons.collections4.CollectionUtils.subtract(oldSectionIdList, newSectionIdList);
// 删除路段和部门数据
this.removeSectionToDept(tenantId, newEditDeptRequest.getId(), subSectionIdList);
}

/**
* 新增路段部门数据
* 1、先删除原有记录数据
* 2、新增此次提交的数据
*
* @param tenantId 租户Id
* @param deptId 部门Id
* @param sectionList 路段集合
* @param tenantId 租户Id
* @param deptId 部门Id
* @param sectionIdList 路段id集合
* @return 结果
*/
private void addSectionToDept(String tenantId, String deptId, List<Section> sectionList) {
List<String> sectionIdList = sectionList.stream().map(o -> o.getId()).collect(Collectors.toList());
Map<String, Object> map = new HashMap<>();
map.put("tenantId", tenantId);
map.put("deptId", deptId);
map.put("sectionIdList", sectionIdList);
sectionDeptMapper.deleteBatchByMap(map);

private void addSectionToDept(String tenantId, String deptId, Collection<String> sectionIdList) {
List<SectionDept> list = new ArrayList<>();
SectionDept sectionDept;
for (Section section : sectionList) {
SectionDept sectionDeptTmp;
for (String sectionId : sectionIdList) {
sectionDept = new SectionDept();
sectionDept.setTenantId(tenantId);
sectionDept.setDeptId(deptId);
sectionDept.setSectionId(section.getId());
sectionDept.setSectionId(sectionId);

// 判断是否存在, 存在则不用再次添加
sectionDeptTmp = sectionDeptMapper.selectOne(new LambdaQueryWrapper<SectionDept>()
.eq(SectionDept::getTenantId, tenantId)
.eq(SectionDept::getDeptId, deptId)
.eq(SectionDept::getSectionId, sectionId));
if (null != sectionDeptTmp) {
continue;
}
list.add(sectionDept);
}

@@ -238,4 +341,40 @@ public class UpdateDeptService {
}
}

/**
* 移除路段部门数据
*
* @param tenantId 租户Id
* @param deptId 部门Id
* @param sectionIdList 路段Id集合
* @return 结果
*/
private void removeSectionToDept(String tenantId, String deptId, Collection<String> sectionIdList) {
Map<String, Object> map = new HashMap<>();
map.put("tenantId", tenantId);
map.put("deptId", deptId);
map.put("sectionIdList", sectionIdList);
sectionDeptMapper.deleteBatchByMap(map);
}

/**
* 递归查询子部门信息
* 1、递归算法,效率比较低,考虑时间数据量不会太多,后期可优化
* 2、另一方案,通过数据库查询,根据pid,查询该部门下所有子部门及子子部门数据
*
* @param deptList
* @param parentDept
*/
private void queryChildDeptList(List<Dept> deptList, Dept parentDept) {
List<Dept> childDeptlist = deptMapper.selectList(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, 0)
.eq(Dept::getPid, parentDept.getId())
.eq(Dept::getMark, 1));

for (Dept dept : childDeptlist) {
queryChildDeptList(deptList, dept);
}
deptList.addAll(childDeptlist);
}

}

+ 52
- 52
tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml Voir le fichier

@@ -1,53 +1,53 @@
<?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="Base_Column_List">
id, tenant_id, name, code, fullname, type, pid, sort, note, create_user, create_time, update_user, update_time, mark
</sql>
<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="com.tuoheng.admin.entity.Dept">
update th_dept
set mark = 0
where id = #{id}
</delete>
<?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 id="DeptResult" type="com.tuoheng.admin.entity.Dept" >
<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="Base_Column_List">
id, tenant_id, name, code, fullname, type, pid, sort, note, create_user, create_time, update_user, update_time, mark
</sql>
<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="com.tuoheng.admin.entity.Dept">
update th_dept
set mark = 0
where id = #{id}
</delete>
</mapper>

+ 2
- 4
tuoheng-service/tuoheng-admin/src/main/resources/mapper/SectionDeptMapper.xml Voir le fichier

@@ -16,12 +16,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 批量新增数据 -->
<insert id="insertBatch" parameterType="com.tuoheng.admin.entity.SectionDept">
insert into th_section_dept
(<include refid="Base_Column_List"/>)
insert into th_section_dept (<include refid="Base_Column_List"/>)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
( #{item.tenantId, jdbcType=INTEGER}, #{item.sectionId,jdbcType=VARCHAR}, #{item.deptId, jdbcType=VARCHAR}
)
( #{item.tenantId, jdbcType=INTEGER}, #{item.sectionId,jdbcType=VARCHAR}, #{item.deptId, jdbcType=VARCHAR} )
</foreach>
</insert>

Chargement…
Annuler
Enregistrer