From 005487aebaf9e1a533c3f5d0547aabf7d60e4c7f Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 8 Sep 2021 16:47:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 1 + .../dto/form/EditGuideCategoryFormDTO.java | 47 ++++++++++++++ .../epmet/dto/form/GuideCateOrderFormDTO.java | 56 ++++++++++++++++ .../controller/GuideCategoryController.java | 65 ++++++++++++++----- .../java/com/epmet/dao/GuideCategoryDao.java | 34 ++++++++++ .../epmet/service/GuideCategoryService.java | 40 ++++++------ .../impl/GuideCategoryServiceImpl.java | 59 ++++++++++++----- .../resources/mapper/GuideCategoryDao.xml | 41 ++++++++++++ 8 files changed, 294 insertions(+), 49 deletions(-) create mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/EditGuideCategoryFormDTO.java create mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCateOrderFormDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 4d717f919e..81350a74ba 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -74,6 +74,7 @@ public enum EpmetErrorCode { AREA_CODE_ALREADY_EXISTS(8208,"组织区划已被占用,请重新选择"), AGENCY_NAME_ALREADY_EXISTS(8209,"当前组织名称已存在,请重新修改"), SET_PARENT_AREA_CODE(8210,"请先设置上级组织区划"), + HAVE_GUIDE_CANNOT_DEL(8211,"当前分类已经存在办事指南,不允许删除"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/EditGuideCategoryFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/EditGuideCategoryFormDTO.java new file mode 100644 index 0000000000..eedb988ffe --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/EditGuideCategoryFormDTO.java @@ -0,0 +1,47 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 编辑、禁用、删除统一入参 + * @Author yinzuomei + * @Date 2021/9/8 4:15 下午 + */ +@Data +public class EditGuideCategoryFormDTO implements Serializable { + private static final long serialVersionUID = -6853534660181580456L; + + public interface AddUserInternalGroup { + } + + public interface StatusGroup { + } + + public interface UpdateInfoGroup extends CustomerClientShowGroup { + } + + public interface DelGroup { + } + @NotBlank(message = "当前操作人id不能为空", groups = AddUserInternalGroup.class) + private String staffId; + + @NotBlank(message = "客户id不能为空",groups = DelGroup.class) + private String customerId; + + @NotBlank(message = "id不能为空", groups = AddUserInternalGroup.class) + private String id; + + @NotBlank(message = "status不能为空", groups = StatusGroup.class) + private String status; + + @NotBlank(message = "分类名称不能为空不能为空", groups = UpdateInfoGroup.class) + @Length(max = 10, message = "分类名称最多填入10个字", groups = UpdateInfoGroup.class) + private String categoryName; + +} + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCateOrderFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCateOrderFormDTO.java new file mode 100644 index 0000000000..6b66e9f7c5 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCateOrderFormDTO.java @@ -0,0 +1,56 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 分类排序入参DTO + * @Author yinzuomei + * @Date 2021/9/8 4:03 下午 + */ +@Data +public class GuideCateOrderFormDTO implements Serializable { + private static final long serialVersionUID = 8671295475212569124L; + + public interface AddUserInternalGroup { + } + + @NotBlank(message = "当前操作人id不能为空", groups = AddUserInternalGroup.class) + private String staffId; + + + @NotEmpty(message = "顺序不能为空", groups = {AddUserInternalGroup.class}) + private List orderList; + + /** + * 排序索引号dto + */ + public static class OrderIndexDTO { + private String id; + private Integer orderIndex; + + public OrderIndexDTO() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getOrderIndex() { + return orderIndex; + } + + public void setOrderIndex(Integer orderIndex) { + this.orderIndex = orderIndex; + } + } +} + diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java index e34e38770a..b29c853eec 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java @@ -21,12 +21,13 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.GuideCategoryDTO; +import com.epmet.dto.form.EditGuideCategoryFormDTO; +import com.epmet.dto.form.GuideCateOrderFormDTO; import com.epmet.dto.form.GuideCategoryDropDownFormDTO; import com.epmet.dto.form.GuideCategoryPageFormDTO; import com.epmet.dto.result.GuideDictResDTO; @@ -81,17 +82,58 @@ public class GuideCategoryController { } + /** + * 保存排序 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @date 2021/9/8 4:09 下午 + */ + @PostMapping("saveorder") + public Result saveOrder(@LoginUser TokenDto tokenDto,@RequestBody GuideCateOrderFormDTO formDTO){ + formDTO.setStaffId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,GuideCateOrderFormDTO.AddUserInternalGroup.class); + guideCategoryService.saveOrder(formDTO); + return new Result(); + } + /** + * 禁用或者启用分类 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @date 2021/9/8 4:19 下午 + */ + @PostMapping("disable") + public Result disable(@LoginUser TokenDto tokenDto,@RequestBody EditGuideCategoryFormDTO formDTO){ + formDTO.setStaffId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,EditGuideCategoryFormDTO.AddUserInternalGroup.class,EditGuideCategoryFormDTO.StatusGroup.class); + guideCategoryService.disableGuideCategory(formDTO); + return new Result(); + } - - - - @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - GuideCategoryDTO data = guideCategoryService.get(id); - return new Result().ok(data); + /** + * 删除分类,已经存在指南的不允许删除,给予提示 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @date 2021/9/8 4:45 下午 + */ + @PostMapping("delete") + public Result delete(@LoginUser TokenDto tokenDto,@RequestBody EditGuideCategoryFormDTO formDTO){ + formDTO.setStaffId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,EditGuideCategoryFormDTO.AddUserInternalGroup.class,EditGuideCategoryFormDTO.DelGroup.class); + guideCategoryService.delete(formDTO); + return new Result(); } + @PostMapping public Result save(@RequestBody GuideCategoryDTO dto){ //效验数据 @@ -108,12 +150,5 @@ public class GuideCategoryController { return new Result(); } - @DeleteMapping - public Result delete(@RequestBody String[] ids){ - //效验数据 - AssertUtils.isArrayEmpty(ids, "id"); - guideCategoryService.delete(ids); - return new Result(); - } } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java index 02d8bcbe43..7f66753eca 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java @@ -55,4 +55,38 @@ public interface GuideCategoryDao extends BaseDao { * @date 2021/9/8 3:15 下午 */ List selectCategoryDict(@Param("customerId") String customerId, @Param("queryOrigin") String queryOrigin); + + /** + * 保存排序 + * + * @param id + * @param orderIndex + * @param staffId + * @return int + * @author yinzuomei + * @date 2021/9/8 4:11 下午 + */ + int updateOrder(@Param("id") String id, @Param("orderIndex") Integer orderIndex, @Param("staffId") String staffId); + + /** + * 启用或者禁用 + * + * @param id + * @param status + * @param staffId + * @return int + * @author yinzuomei + * @date 2021/9/8 4:22 下午 + */ + int updateStatus(@Param("id") String id, @Param("status")String status, @Param("staffId")String staffId); + + /** + * 查询这个分类下的项目数 + * + * @param id + * @return int + * @author yinzuomei + * @date 2021/9/8 4:36 下午 + */ + int selectGuideTotal(@Param("id") String id,@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java index 22f9ecbc61..905ea44517 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java @@ -20,13 +20,14 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.GuideCategoryDTO; +import com.epmet.dto.form.EditGuideCategoryFormDTO; +import com.epmet.dto.form.GuideCateOrderFormDTO; import com.epmet.dto.form.GuideCategoryDropDownFormDTO; import com.epmet.dto.form.GuideCategoryPageFormDTO; import com.epmet.dto.result.GuideDictResDTO; import com.epmet.entity.GuideCategoryEntity; import java.util.List; -import java.util.Map; /** * 指南分类 @@ -57,24 +58,25 @@ public interface GuideCategoryService extends BaseService { List getCategory(GuideCategoryDropDownFormDTO formDTO); /** - * 默认查询 + * 保存排序 * - * @param params - * @return java.util.List - * @author generator - * @date 2021-09-06 + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/9/8 4:09 下午 */ - List list(Map params); + void saveOrder(GuideCateOrderFormDTO formDTO); + /** - * 单条查询 + * 启用或者禁用分类 * - * @param id - * @return GuideCategoryDTO - * @author generator - * @date 2021-09-06 + * @param formDTO + * @return int + * @author yinzuomei + * @date 2021/9/8 4:20 下午 */ - GuideCategoryDTO get(String id); + void disableGuideCategory(EditGuideCategoryFormDTO formDTO); /** * 默认保存 @@ -97,12 +99,12 @@ public interface GuideCategoryService extends BaseService { void update(GuideCategoryDTO dto); /** - * 批量删除 + * 删除分类,存在办事指南的不允许删除,给予提示 * - * @param ids - * @return void - * @author generator - * @date 2021-09-06 + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021/9/8 4:34 下午 */ - void delete(String[] ids); + void delete(EditGuideCategoryFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java index c876885d6c..020ee7848b 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java @@ -21,10 +21,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.GuideCategoryDao; import com.epmet.dto.GuideCategoryDTO; +import com.epmet.dto.form.EditGuideCategoryFormDTO; +import com.epmet.dto.form.GuideCateOrderFormDTO; import com.epmet.dto.form.GuideCategoryDropDownFormDTO; import com.epmet.dto.form.GuideCategoryPageFormDTO; import com.epmet.dto.result.GuideDictResDTO; @@ -36,7 +40,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -117,12 +120,33 @@ public class GuideCategoryServiceImpl extends BaseServiceImpl list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); + public void saveOrder(GuideCateOrderFormDTO formDTO) { + for (GuideCateOrderFormDTO.OrderIndexDTO idx : formDTO.getOrderList()) { + baseDao.updateOrder(idx.getId(), idx.getOrderIndex(),formDTO.getStaffId()); + } + } - return ConvertUtils.sourceToTarget(entityList, GuideCategoryDTO.class); + /** + * 启用或者禁用分类 + * + * @param formDTO + * @return int + * @author yinzuomei + * @date 2021/9/8 4:20 下午 + */ + @Override + public void disableGuideCategory(EditGuideCategoryFormDTO formDTO) { + baseDao.updateStatus(formDTO.getId(), formDTO.getStatus(),formDTO.getStaffId()); } private QueryWrapper getWrapper(Map params){ @@ -134,12 +158,6 @@ public class GuideCategoryServiceImpl extends BaseServiceImpl0){ + throw new RenException(EpmetErrorCode.HAVE_GUIDE_CANNOT_DEL.getCode(),EpmetErrorCode.HAVE_GUIDE_CANNOT_DEL.getMsg()); + } + baseDao.deleteById(formDTO.getId()); } + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml index 08243e6558..6baff0aed8 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml @@ -49,4 +49,45 @@ ORDER BY temp.sort ASC + + + + + update guide_category + set SORT=#{orderIndex}, + UPDATED_BY=#{staffId}, + UPDATED_TIME=NOW() + where id=#{id} + and del_flag='0' + + + + + update guide_category + set status=#{status}, + UPDATED_BY=#{staffId}, + UPDATED_TIME=NOW() + where id=#{id} + and del_flag='0' + + + + \ No newline at end of file