diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java index 29a7dcda6b..400e3893e4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java @@ -160,4 +160,15 @@ public interface Constant { // resi_footbar_highlight_num // gov_footbar_highlight_num String FOOTBAR_HIGHLIGHT_NUM="_footbar_highlight_num"; + + + /** + * 未被禁用标识 + * */ + String ENABLE = "enable"; + + /** + * 被禁用标识 + * */ + String DISABLE = "disable"; } diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/GuideCategoryDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/GuideCategoryDTO.java index ccd59bc862..7d0ed1eef4 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/GuideCategoryDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/GuideCategoryDTO.java @@ -17,16 +17,18 @@ package com.epmet.dto; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** * 指南分类 * * @author generator generator@elink-cn.com - * @since v1.0.0 2021-09-06 + * @since v1.0.0 2021-09-08 */ @Data public class GuideCategoryDTO implements Serializable { @@ -36,56 +38,67 @@ public class GuideCategoryDTO implements Serializable { /** * 主键 */ - private String id; + private String id; + + /** + * 客户id,产品默认配置此列存储default + */ + private String customerId; /** - * 客户id + * 分类名,客户内唯一 */ - private String customerId; + private String categoryName; /** - * 分类名 + * 分类编码:分类名的全拼; eg:gongjijin */ - private String categoryName; + private String categoryCode; /** * 排序 */ - private Integer sort; + private Integer sort; /** * 状态 禁用disable 启用enable */ - private String status; + private String status; /** * 删除标识 0未删除、1已删除 */ - private String delFlag; + @JsonIgnore + private String delFlag; /** * 乐观锁 */ - private Integer revision; + @JsonIgnore + private Integer revision; /** * 创建人 */ - private String createdBy; + @JsonIgnore + private String createdBy; /** * 创建时间 */ - private Date createdTime; + @JsonIgnore + private Date createdTime; /** * 更新人 */ - private String updatedBy; + @JsonIgnore + private String updatedBy; /** * 更新时间 */ - private Date updatedTime; + @JsonIgnore + private Date updatedTime; } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryDropDownFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryDropDownFormDTO.java new file mode 100644 index 0000000000..a92e1c2e09 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryDropDownFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 发布指南、编辑指南、查询指南列表 分类下拉框 + * @Author yinzuomei + * @Date 2021/9/8 2:57 下午 + */ +@Data +public class GuideCategoryDropDownFormDTO implements Serializable { + private static final long serialVersionUID = 9122708701080412461L; + public interface AddUserInternalGroup { + } + /** + * 新增指南:saveorupdate;查询指南列表:query + */ + @NotBlank(message = "新增指南:saveorupdate;查询指南列表:query",groups = AddUserInternalGroup.class) + private String queryOrigin; + + @NotBlank(message = "当前工作人员所属客户id不能为空",groups = AddUserInternalGroup.class) + private String customerId; + +} + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryPageFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryPageFormDTO.java new file mode 100644 index 0000000000..b67686e451 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryPageFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 工作端PC或者运营端分页 + * @Author yinzuomei + * @Date 2021/9/8 1:35 下午 + */ +@Data +public class GuideCategoryPageFormDTO implements Serializable { + private static final long serialVersionUID = -7551388716349439643L; + public interface AddUserInternalGroup { + } + @NotBlank(message = "客户id不能为空,运营端传default", groups = AddUserInternalGroup.class) + private String customerId; +} + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GuideDictResDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GuideDictResDTO.java new file mode 100644 index 0000000000..8b1cbdf94f --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GuideDictResDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 办事指南】可用分类列表 新增、编辑指南时的下拉框:展示未禁用的分类; 查询指南列表:如果禁用的分类下存在指南列表,则展示,不存在直接不展示 + * @Author yinzuomei + * @Date 2021/9/8 2:44 下午 + */ +@Data +public class GuideDictResDTO implements Serializable { + + /** + * 分类名,客户内唯一 + */ + private String categoryName; + + /** + * 分类编码:分类名的全拼; eg:gongjijin + */ + private String categoryCode; + + /** + * 排序 + */ + private Integer sort; + + /** + * 状态 禁用disable 启用enable + */ + private String status; +} + + 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 03bd231c0b..e34e38770a 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 @@ -17,7 +17,9 @@ package com.epmet.controller; +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; @@ -25,11 +27,14 @@ 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.GuideCategoryDropDownFormDTO; +import com.epmet.dto.form.GuideCategoryPageFormDTO; +import com.epmet.dto.result.GuideDictResDTO; import com.epmet.service.GuideCategoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.Map; +import java.util.List; /** @@ -45,12 +50,42 @@ public class GuideCategoryController { @Autowired private GuideCategoryService guideCategoryService; - @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = guideCategoryService.page(params); + /** + * 【办事指南】分类列表-工作端PC和运营端用不分页 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @date 2021/9/8 1:33 下午 + */ + @PostMapping("page") + public Result> page(@RequestBody GuideCategoryPageFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, GuideCategoryPageFormDTO.AddUserInternalGroup.class); + PageData page = guideCategoryService.page(formDTO); return new Result>().ok(page); } + /** + * 办事指南】可用分类列表 新增、编辑指南时的下拉框:展示未禁用的分类; 查询指南列表:如果禁用的分类下存在指南列表,则展示,不存在直接不展示 + * + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @date 2021/9/8 2:47 下午 + */ + @PostMapping("getcategory") + public Result> getCategory(@LoginUser TokenDto tokenDto,@RequestBody GuideCategoryDropDownFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,GuideCategoryDropDownFormDTO.AddUserInternalGroup.class); + return new Result>().ok(guideCategoryService.getCategory(formDTO)); + } + + + + + + + @GetMapping("{id}") public Result get(@PathVariable("id") String id){ GuideCategoryDTO data = guideCategoryService.get(id); 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 a6b9a24cc8..02d8bcbe43 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 @@ -18,8 +18,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.GuideCategoryDTO; +import com.epmet.dto.result.GuideDictResDTO; import com.epmet.entity.GuideCategoryEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 指南分类 @@ -29,5 +34,25 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface GuideCategoryDao extends BaseDao { - + + /** + * 工作端PC或者运营端分类列表查询,不分页 + * + * @param customerId + * @return java.util.List + * @author yinzuomei + * @date 2021/9/8 1:57 下午 + */ + List selectPageByCid(String customerId); + + /** + * 办事指南】可用分类列表 新增、编辑指南时的下拉框:展示未禁用的分类; 查询指南列表:如果禁用的分类下存在指南列表,则展示,不存在直接不展示 + * + * @param customerId + * @param queryOrigin + * @return java.util.List + * @author yinzuomei + * @date 2021/9/8 3:15 下午 + */ + List selectCategoryDict(@Param("customerId") String customerId, @Param("queryOrigin") String queryOrigin); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideCategoryEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideCategoryEntity.java index 8231f9d5ef..c13a7a3df9 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideCategoryEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideCategoryEntity.java @@ -18,18 +18,15 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 指南分类 * * @author generator generator@elink-cn.com - * @since v1.0.0 2021-09-06 + * @since v1.0.0 2021-09-08 */ @Data @EqualsAndHashCode(callSuper=false) @@ -38,24 +35,29 @@ public class GuideCategoryEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; - /** - * 客户id - */ + /** + * 客户id,产品默认配置此列存储default + */ private String customerId; - /** - * 分类名 - */ + /** + * 分类名,客户内唯一 + */ private String categoryName; - /** - * 排序 - */ + /** + * 分类编码:分类名的全拼; eg:gongjijin + */ + private String categoryCode; + + /** + * 排序 + */ private Integer sort; - /** - * 状态 禁用disable 启用enable - */ + /** + * 状态 禁用disable 启用enable + */ private String status; } 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 84f995d0fd..22f9ecbc61 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,6 +20,9 @@ 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.GuideCategoryDropDownFormDTO; +import com.epmet.dto.form.GuideCategoryPageFormDTO; +import com.epmet.dto.result.GuideDictResDTO; import com.epmet.entity.GuideCategoryEntity; import java.util.List; @@ -34,14 +37,24 @@ import java.util.Map; public interface GuideCategoryService extends BaseService { /** - * 默认分页 + * 【办事指南】分类列表-工作端PC和运营端用不分页 * - * @param params - * @return PageData - * @author generator - * @date 2021-09-06 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @date 2021/9/8 1:33 下午 + */ + PageData page(GuideCategoryPageFormDTO formDTO); + + /** + * 办事指南】可用分类列表 新增、编辑指南时的下拉框:展示未禁用的分类; 查询指南列表:如果禁用的分类下存在指南列表,则展示,不存在直接不展示 + * + * @param formDTO + * @return java.util.List + * @author yinzuomei + * @date 2021/9/8 3:06 下午 */ - PageData page(Map params); + List getCategory(GuideCategoryDropDownFormDTO formDTO); /** * 默认查询 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 502f18571a..32e879790a 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 @@ -18,15 +18,20 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; 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.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.GuideCategoryDao; import com.epmet.dto.GuideCategoryDTO; +import com.epmet.dto.form.GuideCategoryDropDownFormDTO; +import com.epmet.dto.form.GuideCategoryPageFormDTO; +import com.epmet.dto.result.GuideDictResDTO; import com.epmet.entity.GuideCategoryEntity; import com.epmet.service.GuideCategoryService; +import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,15 +50,74 @@ import java.util.Map; public class GuideCategoryServiceImpl extends BaseServiceImpl implements GuideCategoryService { + /** + * 【办事指南】分类列表-工作端PC和运营端用不分页 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author yinzuomei + * @date 2021/9/8 1:33 下午 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public PageData page(GuideCategoryPageFormDTO formDTO) { + List list = baseDao.selectPageByCid(formDTO.getCustomerId()); + if (CollectionUtils.isEmpty(list) && !formDTO.getCustomerId().equals(Constant.DEFAULT_CUSTOMER)) { + //初始化默认的给客户 + initCustomerGuideCategory(formDTO.getCustomerId()); + list = baseDao.selectPageByCid(formDTO.getCustomerId()); + } + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + + /** + * 产品默认分类同步给客户,已经禁用的不同步 + * + * @param customerId + * @return void + * @author yinzuomei + * @date 2021/9/8 2:17 下午 + */ + private void initCustomerGuideCategory(String customerId) { + List list = baseDao.selectPageByCid(Constant.DEFAULT_CUSTOMER); + int sort = 1; + for (GuideCategoryDTO dto : list) { + // 已经禁用的,不同步给客户 + if (Constant.DISABLE.equals(dto.getStatus())) { + continue; + } + dto.setCustomerId(customerId); + //清空主键 + dto.setId(null); + dto.setSort(sort); + GuideCategoryEntity entity = ConvertUtils.sourceToTarget(dto, GuideCategoryEntity.class); + insert(entity); + sort++; + } + } + + + /** + * 办事指南】可用分类列表 新增、编辑指南时的下拉框:展示未禁用的分类; 查询指南列表:如果禁用的分类下存在指南列表,则展示,不存在直接不展示 + * + * @param formDTO + * @return java.util.List + * @author yinzuomei + * @date 2021/9/8 3:06 下午 + */ @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, GuideCategoryDTO.class); + public List getCategory(GuideCategoryDropDownFormDTO formDTO) { + List list=baseDao.selectCategoryDict(formDTO.getCustomerId(),formDTO.getQueryOrigin()); + if (CollectionUtils.isEmpty(list) && !formDTO.getCustomerId().equals(Constant.DEFAULT_CUSTOMER)) { + //初始化默认的给客户 + initCustomerGuideCategory(formDTO.getCustomerId()); + list=baseDao.selectCategoryDict(formDTO.getCustomerId(),formDTO.getQueryOrigin()); + } + return list; } + @Override public List list(Map params) { List entityList = baseDao.selectList(getWrapper(params)); 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 dad8bb6c4c..6af20116bc 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 @@ -3,19 +3,50 @@ - - - - - - - - - - - - - - + + + + \ No newline at end of file