Browse Source

web分类列表查询不分页,分类下拉框通用接口

dev_shibei_match
yinzuomei 4 years ago
parent
commit
e59701c4de
  1. 11
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
  2. 43
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/GuideCategoryDTO.java
  3. 28
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryDropDownFormDTO.java
  4. 21
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideCategoryPageFormDTO.java
  5. 36
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/GuideDictResDTO.java
  6. 43
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java
  7. 27
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java
  8. 34
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideCategoryEntity.java
  9. 25
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCategoryService.java
  10. 78
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCategoryServiceImpl.java
  11. 59
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml

11
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 // resi_footbar_highlight_num
// gov_footbar_highlight_num // gov_footbar_highlight_num
String FOOTBAR_HIGHLIGHT_NUM="_footbar_highlight_num"; String FOOTBAR_HIGHLIGHT_NUM="_footbar_highlight_num";
/**
* 未被禁用标识
* */
String ENABLE = "enable";
/**
* 被禁用标识
* */
String DISABLE = "disable";
} }

43
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/GuideCategoryDTO.java

@ -17,16 +17,18 @@
package com.epmet.dto; package com.epmet.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import lombok.Data;
/** /**
* 指南分类 * 指南分类
* *
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2021-09-06 * @since v1.0.0 2021-09-08
*/ */
@Data @Data
public class GuideCategoryDTO implements Serializable { 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;
/** /**
* 分类名 * 分类编码分类的全拼; eggongjijin
*/ */
private String categoryName; private String categoryCode;
/** /**
* 排序 * 排序
*/ */
private Integer sort; private Integer sort;
/** /**
* 状态 禁用disable 启用enable * 状态 禁用disable 启用enable
*/ */
private String status; private String status;
/** /**
* 删除标识 0未删除1已删除 * 删除标识 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;
} }

28
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;
}

21
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;
}

36
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;
/**
* 分类编码分类名的全拼; eggongjijin
*/
private String categoryCode;
/**
* 排序
*/
private Integer sort;
/**
* 状态 禁用disable 启用enable
*/
private String status;
}

43
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCategoryController.java

@ -17,7 +17,9 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData; 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.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils; 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.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.GuideCategoryDTO; 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 com.epmet.service.GuideCategoryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map; import java.util.List;
/** /**
@ -45,12 +50,42 @@ public class GuideCategoryController {
@Autowired @Autowired
private GuideCategoryService guideCategoryService; private GuideCategoryService guideCategoryService;
@GetMapping("page") /**
public Result<PageData<GuideCategoryDTO>> page(@RequestParam Map<String, Object> params){ * 办事指南分类列表-工作端PC和运营端用不分页
PageData<GuideCategoryDTO> page = guideCategoryService.page(params); *
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.commons.tools.page.PageData<com.epmet.dto.GuideCategoryDTO>>
* @author yinzuomei
* @date 2021/9/8 1:33 下午
*/
@PostMapping("page")
public Result<PageData<GuideCategoryDTO>> page(@RequestBody GuideCategoryPageFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, GuideCategoryPageFormDTO.AddUserInternalGroup.class);
PageData<GuideCategoryDTO> page = guideCategoryService.page(formDTO);
return new Result<PageData<GuideCategoryDTO>>().ok(page); return new Result<PageData<GuideCategoryDTO>>().ok(page);
} }
/**
* 办事指南可用分类列表 新增编辑指南时的下拉框展示未禁用的分类 查询指南列表如果禁用的分类下存在指南列表则展示不存在直接不展示
*
* @param tokenDto
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.GuideDictResDTO>>
* @author yinzuomei
* @date 2021/9/8 2:47 下午
*/
@PostMapping("getcategory")
public Result<List<GuideDictResDTO>> getCategory(@LoginUser TokenDto tokenDto,@RequestBody GuideCategoryDropDownFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,GuideCategoryDropDownFormDTO.AddUserInternalGroup.class);
return new Result<List<GuideDictResDTO>>().ok(guideCategoryService.getCategory(formDTO));
}
@GetMapping("{id}") @GetMapping("{id}")
public Result<GuideCategoryDTO> get(@PathVariable("id") String id){ public Result<GuideCategoryDTO> get(@PathVariable("id") String id){
GuideCategoryDTO data = guideCategoryService.get(id); GuideCategoryDTO data = guideCategoryService.get(id);

27
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideCategoryDao.java

@ -18,8 +18,13 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.GuideCategoryDTO;
import com.epmet.dto.result.GuideDictResDTO;
import com.epmet.entity.GuideCategoryEntity; import com.epmet.entity.GuideCategoryEntity;
import org.apache.ibatis.annotations.Mapper; 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 @Mapper
public interface GuideCategoryDao extends BaseDao<GuideCategoryEntity> { public interface GuideCategoryDao extends BaseDao<GuideCategoryEntity> {
/**
* 工作端PC或者运营端分类列表查询不分页
*
* @param customerId
* @return java.util.List<com.epmet.dto.GuideCategoryDTO>
* @author yinzuomei
* @date 2021/9/8 1:57 下午
*/
List<GuideCategoryDTO> selectPageByCid(String customerId);
/**
* 办事指南可用分类列表 新增编辑指南时的下拉框展示未禁用的分类 查询指南列表如果禁用的分类下存在指南列表则展示不存在直接不展示
*
* @param customerId
* @param queryOrigin
* @return java.util.List<com.epmet.dto.result.GuideDictResDTO>
* @author yinzuomei
* @date 2021/9/8 3:15 下午
*/
List<GuideDictResDTO> selectCategoryDict(@Param("customerId") String customerId, @Param("queryOrigin") String queryOrigin);
} }

34
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/GuideCategoryEntity.java

@ -18,18 +18,15 @@
package com.epmet.entity; package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
/** /**
* 指南分类 * 指南分类
* *
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2021-09-06 * @since v1.0.0 2021-09-08
*/ */
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@ -38,24 +35,29 @@ public class GuideCategoryEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 客户id * 客户id产品默认配置此列存储default
*/ */
private String customerId; private String customerId;
/** /**
* 分类名 * 分类名,客户内唯一
*/ */
private String categoryName; private String categoryName;
/** /**
* 排序 * 分类编码分类名的全拼; eggongjijin
*/ */
private String categoryCode;
/**
* 排序
*/
private Integer sort; private Integer sort;
/** /**
* 状态 禁用disable 启用enable * 状态 禁用disable 启用enable
*/ */
private String status; private String status;
} }

25
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.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.GuideCategoryDTO; 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.entity.GuideCategoryEntity;
import java.util.List; import java.util.List;
@ -34,14 +37,24 @@ import java.util.Map;
public interface GuideCategoryService extends BaseService<GuideCategoryEntity> { public interface GuideCategoryService extends BaseService<GuideCategoryEntity> {
/** /**
* 默认分页 * 办事指南分类列表-工作端PC和运营端用不分页
* *
* @param params * @param formDTO
* @return PageData<GuideCategoryDTO> * @return com.epmet.commons.tools.utils.Result<com.epmet.commons.tools.page.PageData<com.epmet.dto.GuideCategoryDTO>>
* @author generator * @author yinzuomei
* @date 2021-09-06 * @date 2021/9/8 1:33 下午
*/
PageData<GuideCategoryDTO> page(GuideCategoryPageFormDTO formDTO);
/**
* 办事指南可用分类列表 新增编辑指南时的下拉框展示未禁用的分类 查询指南列表如果禁用的分类下存在指南列表则展示不存在直接不展示
*
* @param formDTO
* @return java.util.List<com.epmet.dto.result.GuideDictResDTO>
* @author yinzuomei
* @date 2021/9/8 3:06 下午
*/ */
PageData<GuideCategoryDTO> page(Map<String, Object> params); List<GuideDictResDTO> getCategory(GuideCategoryDropDownFormDTO formDTO);
/** /**
* 默认查询 * 默认查询

78
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; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.GuideCategoryDao; import com.epmet.dao.GuideCategoryDao;
import com.epmet.dto.GuideCategoryDTO; 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.entity.GuideCategoryEntity;
import com.epmet.service.GuideCategoryService; import com.epmet.service.GuideCategoryService;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -45,15 +50,74 @@ import java.util.Map;
public class GuideCategoryServiceImpl extends BaseServiceImpl<GuideCategoryDao, GuideCategoryEntity> implements GuideCategoryService { public class GuideCategoryServiceImpl extends BaseServiceImpl<GuideCategoryDao, GuideCategoryEntity> implements GuideCategoryService {
/**
* 办事指南分类列表-工作端PC和运营端用不分页
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.commons.tools.page.PageData<com.epmet.dto.GuideCategoryDTO>>
* @author yinzuomei
* @date 2021/9/8 1:33 下午
*/
@Transactional(rollbackFor = Exception.class)
@Override
public PageData<GuideCategoryDTO> page(GuideCategoryPageFormDTO formDTO) {
List<GuideCategoryDTO> list = baseDao.selectPageByCid(formDTO.getCustomerId());
if (CollectionUtils.isEmpty(list) && !formDTO.getCustomerId().equals(Constant.DEFAULT_CUSTOMER)) {
//初始化默认的给客户
initCustomerGuideCategory(formDTO.getCustomerId());
list = baseDao.selectPageByCid(formDTO.getCustomerId());
}
PageInfo<GuideCategoryDTO> 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<GuideCategoryDTO> 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<com.epmet.dto.result.GuideDictResDTO>
* @author yinzuomei
* @date 2021/9/8 3:06 下午
*/
@Override @Override
public PageData<GuideCategoryDTO> page(Map<String, Object> params) { public List<GuideDictResDTO> getCategory(GuideCategoryDropDownFormDTO formDTO) {
IPage<GuideCategoryEntity> page = baseDao.selectPage( List<GuideDictResDTO> list=baseDao.selectCategoryDict(formDTO.getCustomerId(),formDTO.getQueryOrigin());
getPage(params, FieldConstant.CREATED_TIME, false), if (CollectionUtils.isEmpty(list) && !formDTO.getCustomerId().equals(Constant.DEFAULT_CUSTOMER)) {
getWrapper(params) //初始化默认的给客户
); initCustomerGuideCategory(formDTO.getCustomerId());
return getPageData(page, GuideCategoryDTO.class); list=baseDao.selectCategoryDict(formDTO.getCustomerId(),formDTO.getQueryOrigin());
}
return list;
} }
@Override @Override
public List<GuideCategoryDTO> list(Map<String, Object> params) { public List<GuideCategoryDTO> list(Map<String, Object> params) {
List<GuideCategoryEntity> entityList = baseDao.selectList(getWrapper(params)); List<GuideCategoryEntity> entityList = baseDao.selectList(getWrapper(params));

59
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideCategoryDao.xml

@ -3,19 +3,50 @@
<mapper namespace="com.epmet.dao.GuideCategoryDao"> <mapper namespace="com.epmet.dao.GuideCategoryDao">
<resultMap type="com.epmet.entity.GuideCategoryEntity" id="guideCategoryMap"> <!-- 工作端PC或者运营端分类列表查询,不分页 -->
<result property="id" column="ID"/> <select id="selectPageByCid" parameterType="java.lang.String" resultType="com.epmet.dto.GuideCategoryDTO">
<result property="customerId" column="CUSTOMER_ID"/> SELECT
<result property="categoryName" column="CATEGORY_NAME"/> gc.ID,
<result property="sort" column="SORT"/> gc.CUSTOMER_ID,
<result property="status" column="STATUS"/> gc.CATEGORY_NAME,
<result property="delFlag" column="DEL_FLAG"/> gc.category_code,
<result property="revision" column="REVISION"/> gc.SORT,
<result property="createdBy" column="CREATED_BY"/> gc.`STATUS`
<result property="createdTime" column="CREATED_TIME"/> FROM
<result property="updatedBy" column="UPDATED_BY"/> guide_category gc
<result property="updatedTime" column="UPDATED_TIME"/> WHERE
</resultMap> gc.DEL_FLAG = '0'
AND gc.CUSTOMER_ID =#{customerId}
ORDER BY
gc.SORT ASC
</select>
<!-- 新增指南:saveorupdate;查询指南列表:query -->
<select id="selectCategoryDict" parameterType="map" resultType="com.epmet.dto.result.GuideDictResDTO">
SELECT
*
FROM
(
SELECT
gc.CATEGORY_NAME,
gc.category_code,
gc.`STATUS`,
gc.sort,
( SELECT count( g.id ) FROM guide g WHERE g.CUSTOMER_ID = '' AND g.DEL_FLAG = '0' AND g.CATEGORY_CODE = gc.CATEGORY_CODE ) AS guideTotal
FROM
guide_category gc
WHERE
gc.DEL_FLAG = '0'
AND CUSTOMER_ID = 'default'
) temp
<if test="queryOrigin == 'saveorupdate' ">
WHERE temp.`STATUS` = 'enable'
</if>
<if test="queryOrigin == 'query' ">
WHERE temp.`STATUS` = 'enable'
OR ( temp.`STATUS` = 'disable' AND temp.guideTotal > 0 )
</if>
ORDER BY
temp.sort ASC
</select>
</mapper> </mapper>
Loading…
Cancel
Save