Browse Source

标签管理

dev
yinzuomei 3 years ago
parent
commit
8931e8622d
  1. 7
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java
  2. 33
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java
  3. 56
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java
  4. 44
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java
  5. 61
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java
  6. 9
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java
  7. 23
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java
  8. 105
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java
  9. 10
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml

7
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java

@ -17,8 +17,11 @@
package com.epmet.dto;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@ -34,9 +37,12 @@ public class TagCustomerDTO implements Serializable {
private static final long serialVersionUID = 1L;
public interface ChangeShowFlagGroup extends CustomerClientShowGroup {
}
/**
* 主键ID
*/
@NotBlank(message = "id不能为空",groups = ChangeShowFlagGroup.class)
private String id;
/**
@ -57,6 +63,7 @@ public class TagCustomerDTO implements Serializable {
/**
* 1展示0隐藏;0302因烟台需求增加此列默认1
*/
@NotNull(message = "showFlag不能为空",groups = ChangeShowFlagGroup.class)
private Integer showFlag;
/**

33
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java

@ -0,0 +1,33 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author yzm
* @Date 2023/3/2 13:52
*/
@Data
public class TagScopeDTO implements Serializable {
/**
* 标签ID
*/
private String tagId;
/**
* 应用范围这里只能是社区id
*/
private String agencyId;
/**
* agency_id全路径包含自身
*/
private String orgIdPath;
/**
* 组织名称
*/
private String agencyName;
}

56
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java

@ -0,0 +1,56 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import com.epmet.dto.TagScopeDTO;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @Author yzm
* @Date 2023/3/2 12:47
*/
@Data
public class TagCustomerFormDTO implements Serializable {
private static final long serialVersionUID = -5631868409077026783L;
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
public interface UpdateUserInternalGroup {
}
public interface UpdateUserShowGroup extends CustomerClientShowGroup {
}
/**
* 主键ID
*/
@NotBlank(message = "id不能为空", groups = {UpdateUserInternalGroup.class})
private String id;
/**
* 标签名称
*/
@Length(max = 30, message = "标签名称最多输入30字", groups = {AddUserShowGroup.class, UpdateUserShowGroup.class})
@NotBlank(message = "标签名称不能为空", groups = {AddUserShowGroup.class, UpdateUserShowGroup.class})
private String tagName;
/**
* 应用范围,只能选社区
*/
private List<TagScopeDTO> agencyIds;
/**
* 客户ID
*/
private String customerId;
}

44
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java

@ -0,0 +1,44 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Description pc标签管理-分页查询入参
* @Author yzm
* @Date 2023/3/2 11:34
*/
@Data
public class TagCustomerPageFormDTO implements Serializable {
private static final long serialVersionUID = -2311491158902019019L;
public interface PageUserInternalGroup {
}
public interface PageUserShowGroup extends CustomerClientShowGroup {
}
/**
* 客户ID
*/
@NotBlank(message = "customerId不能为空", groups = PageUserInternalGroup.class)
private String customerId;
/**
* 标签名称
*/
private String tagName;
@NotNull(message = "页码不能为空", groups = PageUserInternalGroup.class)
private Integer pageNo;
@NotNull(message = "每页数量不能为空", groups = PageUserInternalGroup.class)
private Integer pageSize;
}

61
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java

@ -1,15 +1,15 @@
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.ValidatorUtils;
import com.epmet.dto.form.CorrelationTagListFormDTO;
import com.epmet.dto.form.InitTagFormDTO;
import com.epmet.dto.form.ResiTagListFormDTO;
import com.epmet.dto.form.TagCascadeListFormDTO;
import com.epmet.dto.TagCustomerDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CorrelationTagListResultDTO;
import com.epmet.dto.result.TagInfoResultDTO;
import com.epmet.service.TagCustomerService;
import com.epmet.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -25,6 +25,8 @@ public class TagController {
@Autowired
private TagService tagService;
@Autowired
private TagCustomerService tagCustomerService;
/**
* @Description 已发布列表页的标签政府端
@ -81,4 +83,55 @@ public class TagController {
return new Result<Boolean>().ok(tagService.initTag(formDto));
}
/**
* pc标签管理-分页查询
* @param formDTO
* @return
*/
@PostMapping("page-list")
public Result<PageData<TagCustomerDTO>> pageList(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerPageFormDTO formDTO){
tokenDto.setCustomerId(formDTO.getCustomerId());
ValidatorUtils.validateEntity(formDTO,TagCustomerPageFormDTO.PageUserInternalGroup.class,TagCustomerPageFormDTO.PageUserShowGroup.class);
return new Result<PageData<TagCustomerDTO>>().ok(tagCustomerService.page(formDTO));
}
/**
* 新增标签
* @param tokenDto
* @param formDTO
* @return
*/
@PostMapping("save")
public Result save(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,TagCustomerFormDTO.AddUserShowGroup.class,TagCustomerFormDTO.AddUserInternalGroup.class);
tagCustomerService.save(formDTO);
return new Result();
}
/**
* 修改标签
* @param tokenDto
* @param formDTO
* @return
*/
@PostMapping("update")
public Result update(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,TagCustomerFormDTO.UpdateUserShowGroup.class,TagCustomerFormDTO.UpdateUserInternalGroup.class);
tagCustomerService.update(formDTO);
return new Result();
}
/**
* 隐藏显示
* @param tagCustomerDTO
* @return
*/
@PostMapping("change-show-flag")
public Result changeShowFlag(@RequestBody TagCustomerDTO tagCustomerDTO){
tagCustomerService.changeShowFlag(tagCustomerDTO.getId(),tagCustomerDTO.getShowFlag());
return new Result();
}
}

9
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.TagCustomerDTO;
import com.epmet.dto.form.InitTagsFormDTO;
import com.epmet.dto.form.UpdateTagFormDTO;
import com.epmet.entity.TagCustomerEntity;
@ -55,4 +56,12 @@ public interface TagCustomerDao extends BaseDao<TagCustomerEntity> {
* @return
*/
List<TagCustomerEntity> selectInitData(@Param("customerIdList") List<String> customerIdList);
/**
* pc标签管理-分页查询
* @param customerId
* @param tagName
* @return
*/
List<TagCustomerDTO> pageList(@Param("customerId") String customerId, @Param("tagName")String tagName);
}

23
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java

@ -20,6 +20,8 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.TagCustomerDTO;
import com.epmet.dto.form.TagCustomerFormDTO;
import com.epmet.dto.form.TagCustomerPageFormDTO;
import com.epmet.dto.result.UpdateTagUseCountsResultDTO;
import com.epmet.entity.TagCustomerEntity;
@ -35,14 +37,14 @@ import java.util.Map;
public interface TagCustomerService extends BaseService<TagCustomerEntity> {
/**
* 默认分页
* pc标签管理-分页查询
*
* @param params
* @param formDTO
* @return PageData<TagCustomerDTO>
* @author generator
* @date 2020-06-02
*/
PageData<TagCustomerDTO> page(Map<String, Object> params);
PageData<TagCustomerDTO> page(TagCustomerPageFormDTO formDTO);
/**
* 默认查询
@ -65,24 +67,24 @@ public interface TagCustomerService extends BaseService<TagCustomerEntity> {
TagCustomerDTO get(String id);
/**
* 默认保存
* 新增标签
*
* @param dto
* @return void
* @author generator
* @date 2020-06-02
*/
void save(TagCustomerDTO dto);
void save(TagCustomerFormDTO dto);
/**
* 默认更新
* 修改标签
*
* @param dto
* @return void
* @author generator
* @date 2020-06-02
*/
void update(TagCustomerDTO dto);
void update(TagCustomerFormDTO dto);
/**
* 批量删除
@ -100,4 +102,11 @@ public interface TagCustomerService extends BaseService<TagCustomerEntity> {
* @author zxc
*/
UpdateTagUseCountsResultDTO checkTagInfo(String tagName,String customerId,String userId);
/**
* 隐藏显示
* @param id
* @param showFlag
*/
void changeShowFlag(String id, Integer showFlag);
}

105
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java

@ -17,24 +17,39 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.dao.TagCustomerDao;
import com.epmet.dao.TagScopeDao;
import com.epmet.dto.TagCustomerDTO;
import com.epmet.dto.form.TagCustomerFormDTO;
import com.epmet.dto.form.TagCustomerPageFormDTO;
import com.epmet.dto.form.UpdateTagFormDTO;
import com.epmet.dto.result.UpdateTagUseCountsResultDTO;
import com.epmet.entity.TagCustomerEntity;
import com.epmet.entity.TagScopeEntity;
import com.epmet.service.TagCustomerService;
import com.epmet.utils.TagColorUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -46,14 +61,21 @@ import java.util.Map;
*/
@Service
public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagCustomerEntity> implements TagCustomerService {
@Autowired
private TagScopeDao tagScopeDao;
/**
* pc标签管理-分页查询
* @param formDTO
* @return
*/
@Override
public PageData<TagCustomerDTO> page(Map<String, Object> params) {
IPage<TagCustomerEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, TagCustomerDTO.class);
public PageData<TagCustomerDTO> page(TagCustomerPageFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize());
List<TagCustomerDTO> list=baseDao.pageList(formDTO.getCustomerId(),formDTO.getTagName());
PageInfo<TagCustomerDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());
}
@Override
@ -78,18 +100,68 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC
return ConvertUtils.sourceToTarget(entity, TagCustomerDTO.class);
}
/**
* pc标签管理-新增
* @param dto
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void save(TagCustomerDTO dto) {
public void save(TagCustomerFormDTO dto) {
// 标签名称是否存在
LambdaQueryWrapper<TagCustomerEntity> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(TagCustomerEntity::getCustomerId,dto.getCustomerId())
.eq(TagCustomerEntity::getTagName,dto.getTagName());
if(baseDao.selectCount(queryWrapper)>0){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"标签名称已存在","标签名称已存在");
}
TagCustomerEntity entity = ConvertUtils.sourceToTarget(dto, TagCustomerEntity.class);
entity.setTagColor(StrConstant.EPMETY_STR);
entity.setUseCount(NumConstant.ZERO);
entity.setShowFlag(NumConstant.ONE);
insert(entity);
if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){
dto.getAgencyIds().forEach(tagScopeDTO->{
TagScopeEntity tagScopeEntity=new TagScopeEntity();
tagScopeEntity.setCustomerId(entity.getCustomerId());
tagScopeEntity.setTagId(entity.getId());
tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId());
tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName());
tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath());
tagScopeDao.insert(tagScopeEntity);
});
}
}
/**
* pc标签管理-修改
* @param dto
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TagCustomerDTO dto) {
public void update(TagCustomerFormDTO dto) {
// 标签名称是否存在
LambdaQueryWrapper<TagCustomerEntity> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(TagCustomerEntity::getCustomerId,dto.getCustomerId())
.eq(TagCustomerEntity::getTagName,dto.getTagName())
.ne(TagCustomerEntity::getId,dto.getId());
if(baseDao.selectCount(queryWrapper)>0){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"标签名称已存在","标签名称已存在");
}
TagCustomerEntity entity = ConvertUtils.sourceToTarget(dto, TagCustomerEntity.class);
updateById(entity);
//删除应用范围
tagScopeDao.deleteByTagId(entity.getId(),entity.getCustomerId());
if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){
dto.getAgencyIds().forEach(tagScopeDTO->{
TagScopeEntity tagScopeEntity=new TagScopeEntity();
tagScopeEntity.setCustomerId(entity.getCustomerId());
tagScopeEntity.setTagId(entity.getId());
tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId());
tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName());
tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath());
tagScopeDao.insert(tagScopeEntity);
});
}
}
@Override
@ -126,4 +198,19 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC
return resultDTO;
}
/**
* 隐藏显示
*
* @param id
* @param showFlag
*/
@Override
public void changeShowFlag(String id, Integer showFlag) {
LambdaUpdateWrapper<TagCustomerEntity> tagCustomerUpdateWrapper = new LambdaUpdateWrapper<>();
tagCustomerUpdateWrapper.eq(TagCustomerEntity::getId, id)
.set(TagCustomerEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId())
.set(TagCustomerEntity::getUpdatedTime, new Date())
.set(TagCustomerEntity::getShowFlag,showFlag);
baseDao.update(null,tagCustomerUpdateWrapper);
}
}

10
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml

@ -56,4 +56,14 @@
ORDER BY CUSTOMER_ID
</select>
<!-- pc标签管理-分页查询 -->
<select id="pageList" parameterType="map" resultType="com.epmet.dto.TagCustomerDTO">
select tc.*
from tag_customer tc
where tc.del_flag='0'
and tc.CUSTOMER_ID=#{customerId}
<if test='null != tagName and "" != tagName'>
and tc.TAG_NAME like concat('%',#{tagName},'%')
</if>
</select>
</mapper>

Loading…
Cancel
Save