Browse Source

标签缓存和DB更新使用次数

dev_shibei_match
zxc 5 years ago
parent
commit
467df40c1a
  1. 21
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  2. 53
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UpdateTagFormDTO.java
  3. 26
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UpdateTagUseCountsFormDTO.java
  4. 66
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateGridTagsFormDTO.java
  5. 26
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/UpdateCustomerTagCacheDTO.java
  6. 27
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/UpdateGridTagCacheDTO.java
  7. 25
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/UpdateTagUseCountsResultDTO.java
  8. 4
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/TagConstant.java
  9. 8
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticlePublishRangeDao.java
  10. 11
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java
  11. 11
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagGridDao.java
  12. 52
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/redis/TagRedis.java
  13. 8
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java
  14. 124
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  15. 18
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java
  16. 14
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticlePublishRangeDao.xml
  17. 20
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml
  18. 14
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagGridDao.xml

21
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java

@ -9,18 +9,15 @@
package com.epmet.commons.tools.redis;
import com.epmet.commons.tools.constant.NumConstant;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@ -307,4 +304,16 @@ public class RedisUtils {
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisTemplate.opsForZSet().reverseRangeWithScores(key, start, end);
return typedTuples;
}
/**
* @Description 标签使用数量缓存更新
* @param key
* @param value
* @param delta
* @author zxc
*/
public Double zIncrementScore(String key, Object value, double delta) {
return redisTemplate.opsForZSet().incrementScore(key, value, delta);
}
}

53
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UpdateTagFormDTO.java

@ -0,0 +1,53 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @CreateTime 2020/6/4 15:12
*/
@Data
public class UpdateTagFormDTO implements Serializable {
private static final long serialVersionUID = 1686362744399106982L;
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* 标签名称
*/
private String tagName;
/**
* 使用计数
*/
private Integer useCount = 1;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag = 0;
/**
* 乐观锁
*/
private Integer revision = 0;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy;
}

26
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UpdateTagUseCountsFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @CreateTime 2020/6/4 15:12
*/
@Data
public class UpdateTagUseCountsFormDTO implements Serializable {
private static final long serialVersionUID = 1686362744399106982L;
/**
* 标签id
*/
private String tagId;
/**
* 标签名称
*/
private String tagName;
}

66
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/UpdateGridTagsFormDTO.java

@ -0,0 +1,66 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @CreateTime 2020/6/5 10:20
*/
@Data
public class UpdateGridTagsFormDTO implements Serializable {
private static final long serialVersionUID = 2876626163349728237L;
/**
* 主键ID
*/
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* 网格ID
*/
private String gridId;
/**
* 标签ID
*/
private String tagId;
/**
* 标签名称
*/
private String tagName;
/**
* 使用计数
*/
private Integer useCount = 1;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag = 0;
/**
* 乐观锁
*/
private Integer revision = 0;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy;
}

26
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/UpdateCustomerTagCacheDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @CreateTime 2020/6/5 9:54
*/
@Data
public class UpdateCustomerTagCacheDTO implements Serializable {
private static final long serialVersionUID = -5544311005334312224L;
/**
* 客户id
*/
private String customerId;
/**
* 标签信息集合
*/
private List<UpdateTagUseCountsResultDTO> tagsInfo;
}

27
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/UpdateGridTagCacheDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @CreateTime 2020/6/5 10:49
*/
@Data
public class UpdateGridTagCacheDTO implements Serializable {
private static final long serialVersionUID = 367220409651119904L;
/**
* 网格id
*/
private String gridId;
/**
* 标签集合
* tagIdtagName
*/
private List<UpdateTagUseCountsResultDTO> tagsInfo;
}

25
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/UpdateTagUseCountsResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @CreateTime 2020/6/4 17:20
*/
@Data
public class UpdateTagUseCountsResultDTO implements Serializable {
private static final long serialVersionUID = -6331586672885417576L;
/**
* 标签id
*/
private String tagId;
/**
* 标签名称
*/
private String tagName;
}

4
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/constant/TagConstant.java

@ -40,6 +40,10 @@ public interface TagConstant {
*/
String COLON = ":";
String BEGIN_UPDATE = "开始更新标签缓存... ...";
String SUCCESS_UPDATE = "更新标签缓存成功... ...";
String FAILURE_UPDATE = "更新标签缓存失败... ...";
}

8
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticlePublishRangeDao.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ArticlePublishRangeDTO;
import com.epmet.entity.ArticlePublishRangeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -40,4 +41,11 @@ public interface ArticlePublishRangeDao extends BaseDao<ArticlePublishRangeEntit
* @Description 根据文章Id查询发布范围数据
**/
List<ArticlePublishRangeEntity> selectByArticleId(ArticlePublishRangeEntity rangeEntity);
/**
* @Description 根据草稿id查询发布范围id集合
* @param draftId
* @author zxc
*/
List<String> selectGridIdByDraftId(@Param("draftId")String draftId);
}

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

@ -18,8 +18,10 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.UpdateTagFormDTO;
import com.epmet.entity.TagCustomerEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 客户标签表
@ -29,5 +31,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface TagCustomerDao extends BaseDao<TagCustomerEntity> {
/**
* @Description 校验此标签数据库是否存在 不存在insert 存在update useCount+1 返回id
* @param formDTO
* @author zxc
*/
void checkTagInfo(UpdateTagFormDTO formDTO);
}

11
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagGridDao.java

@ -18,8 +18,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.UpdateGridTagsFormDTO;
import com.epmet.entity.TagGridEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网格标签表
@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface TagGridDao extends BaseDao<TagGridEntity> {
/**
* @Description 更新网格下的标签标签存在使用次数+1插入新数据
* @param gridTags
* @author zxc
*/
void updateGridTag(@Param("gridTags") List<UpdateGridTagsFormDTO> gridTags,@Param("userId")String userId);
}

52
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/redis/TagRedis.java

@ -18,6 +18,7 @@
package com.epmet.redis;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.constant.TagConstant;
import com.epmet.dto.form.CorrelationTagListFormDTO;
@ -25,28 +26,34 @@ import com.epmet.dto.form.TagCascadeListFormDTO;
import com.epmet.dto.result.CorrelationTagListResultDTO;
import com.epmet.dto.result.TagInfoResultDTO;
import com.epmet.dto.result.TagRankResultDTO;
import com.epmet.dto.result.UpdateTagUseCountsResultDTO;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.poi.ss.formula.functions.T;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
@Component
public class TagRedis {
@Autowired
private RedisUtils redisUtils;
@Autowired
private RedisTemplate redisTemplate;
public void delete(Object[] ids) {
}
public void set(){
}
/**
@ -81,6 +88,7 @@ public class TagRedis {
for (Object object : objects) {
resultList.add(objectToDTO(object,CorrelationTagListResultDTO.class));
}
// resultList = JSONObject.parseArray(objects.toString(), CorrelationTagListResultDTO.class);
//级联标签排序
//1.取出 zset 中的有序标签,根据级联标签,筛选有序标签
List<TagRankResultDTO> resultEquals = new ArrayList<>();
@ -128,6 +136,7 @@ public class TagRedis {
for (Object object : objects) {
result.add(objectToDTO(object,TagInfoResultDTO.class));
}
// List<TagInfoResultDTO> tagInfoResultDTOS = JSONObject.parseArray(objects.toString(), TagInfoResultDTO.class);
return result;
}
@ -224,4 +233,41 @@ public class TagRedis {
return t;
}
/**
* @Description 更新标签使用次数
* @param key
* @param formDTO
* @author zxc
*/
public Double updateTagUseCounts(String key, Object formDTO){
return redisUtils.zIncrementScore(key, formDTO, NumConstant.ONE);
}
/**
* @Description set 更新标签级联
* @param key
* @param value
* @author zxc
*/
public void updateMoreTag(String key, Set<UpdateTagUseCountsResultDTO> value) {
try {
log.info(TagConstant.BEGIN_UPDATE);
redisTemplate.executePipelined(new RedisCallback<Set<UpdateTagUseCountsResultDTO>>() {
@Override
public Set doInRedis(RedisConnection connection) throws DataAccessException {
for (UpdateTagUseCountsResultDTO tag : value) {
connection.sAdd(redisTemplate.getKeySerializer().serialize(key),redisTemplate.getValueSerializer().serialize(tag));
}
return null;
}
});
log.info(TagConstant.SUCCESS_UPDATE);
}catch (Exception e){
log.info(TagConstant.FAILURE_UPDATE);
throw new RenException(TagConstant.FAILURE_UPDATE);
}
}
}

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

@ -20,6 +20,7 @@ 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.result.UpdateTagUseCountsResultDTO;
import com.epmet.entity.TagCustomerEntity;
import java.util.List;
@ -92,4 +93,11 @@ public interface TagCustomerService extends BaseService<TagCustomerEntity> {
* @date 2020-06-02
*/
void delete(String[] ids);
/**
* @Description 查询标签信息
* @param tagName
* @author zxc
*/
UpdateTagUseCountsResultDTO checkTagInfo(String tagName,String customerId,String userId);
}

124
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

@ -37,6 +37,7 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.constant.ArticleConstant;
import com.epmet.constant.DraftConstant;
import com.epmet.constant.RoleKeyConstants;
import com.epmet.constant.TagConstant;
import com.epmet.dao.*;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
@ -46,12 +47,14 @@ import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.redis.ArticleRedis;
import com.epmet.service.*;
import com.epmet.redis.TagRedis;
import com.epmet.utils.ModuleConstant;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -98,6 +101,14 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
private ArticleContentDao articleContentDao;
@Autowired
private ArticleCoverDao articleCoverDao;
@Autowired
private DraftService draftService;
@Autowired
private TagCustomerService tagCustomerService;
@Autowired
private TagRedis tagRedis;
@Autowired
private TagGridDao tagGridDao;
private static final String AGENCY = "agency";
private static final String GRID = "grid";
@ -884,4 +895,117 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
throw new RenException(String.format(ModuleConstant.SPECIFIED_DRAFT_NOT_FOUNT_EXCEPTION_TEMPLATE,draftId));
}
/**
* @Description 更新DB的标签使用次数
* @param draftId
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public UpdateCustomerTagCacheDTO updateCustomerTag(TokenDto tokenDto, String draftId){
//获取草稿基本信息
DraftDTO draft = draftService.get(draftId);
String tags = draft.getTags();
String customerId = draft.getCustomerId();
String userId = tokenDto.getUserId();
List<String> tagsList = Arrays.asList(tags.split("\\|"));
List<UpdateTagUseCountsResultDTO> tagsInfo = new ArrayList<>();
//政府端的 标签使用次数 DB和redis更新(zSet)
for (String tag : tagsList) {
UpdateTagUseCountsResultDTO updateTagUseCount = tagCustomerService.checkTagInfo(tag, customerId, userId);
tagsInfo.add(updateTagUseCount);
}
UpdateCustomerTagCacheDTO result = new UpdateCustomerTagCacheDTO();
result.setCustomerId(customerId);
result.setTagsInfo(tagsInfo);
return result;
}
/**
* @Description 更新redis 标签使用数量 标签级联
* @param formDto
* @author zxc
*/
public void updateCacheCustomerTag(UpdateCustomerTagCacheDTO formDto){
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo();
String customerId = formDto.getCustomerId();
//更新缓存标签使用数量
for (UpdateTagUseCountsResultDTO resultDTO : tagsInfo) {
String customerKey = TagConstant.GOV_TAG_KEY+customerId;
tagRedis.updateTagUseCounts(customerKey,resultDTO);
}
//政府端更新redis的级联标签(set)
List<UpdateTagUseCountsResultDTO> tagsInfoCopy = new ArrayList<>();
for (int i = 0; i < tagsInfo.size(); i++) {
tagsInfoCopy.addAll(tagsInfo);
String key = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagsInfo.get(i).getTagId();
tagsInfoCopy.remove(tagsInfo.get(i));
Set<UpdateTagUseCountsResultDTO> setTag = new HashSet<>(tagsInfoCopy);
tagRedis.updateMoreTag(key,setTag);
tagsInfoCopy.clear();
}
}
/**
* @Description 更新数据库 网格下的标签使用数量
* @param draftId
* @param formDto
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public List<UpdateGridTagCacheDTO> updateGridTag(TokenDto tokenDto,String draftId,UpdateCustomerTagCacheDTO formDto){
//获取草稿基本信息
DraftDTO draft = draftService.get(draftId);
String customerId = draft.getCustomerId();
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo();
String userId = tokenDto.getUserId();
List<String> gridIds = articlePublishRangeDao.selectGridIdByDraftId(draftId);
List<UpdateGridTagsFormDTO> gridTags = new ArrayList<>();
List<UpdateGridTagCacheDTO> gridTagCache = new ArrayList<>();
for (String gridId : gridIds) {
UpdateGridTagCacheDTO cache = new UpdateGridTagCacheDTO();
cache.setGridId(gridId);
cache.setTagsInfo(tagsInfo);
gridTagCache.add(cache);
for (UpdateTagUseCountsResultDTO resultDTO : tagsInfo) {
UpdateGridTagsFormDTO tag = new UpdateGridTagsFormDTO();
BeanUtils.copyProperties(resultDTO,tag);
tag.setCreatedBy(userId);
tag.setUpdatedBy(userId);
tag.setCustomerId(customerId);
tag.setGridId(gridId);
gridTags.add(tag);
}
}
tagGridDao.updateGridTag(gridTags,userId);
return gridTagCache;
}
/**
* @Description 更新redis 网格下的 标签使用数量 级联标签
* @param gridTagCache
* @author zxc
*/
public void updateCacheGridTag(List<UpdateGridTagCacheDTO> gridTagCache){
//更新 网格下 标签使用数量
List<UpdateTagUseCountsResultDTO> gridTagCacheCopy = new ArrayList<>();
for (UpdateGridTagCacheDTO cacheDTO : gridTagCache) {
String gridId = cacheDTO.getGridId();
String key = TagConstant.GRID_TAG_KEY+gridId;
List<UpdateTagUseCountsResultDTO> tagsInfo = cacheDTO.getTagsInfo();
for (UpdateTagUseCountsResultDTO resultDTO : tagsInfo) {
tagRedis.updateTagUseCounts(key,resultDTO);
}
//级联
for (int i = 0; i < tagsInfo.size(); i++) {
gridTagCacheCopy.addAll(tagsInfo);
String moreKey = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagsInfo.get(i).getTagId();
gridTagCacheCopy.remove(tagsInfo.get(i));
Set<UpdateTagUseCountsResultDTO> setTag = new HashSet<>(gridTagCacheCopy);
tagRedis.updateMoreTag(moreKey,setTag);
gridTagCacheCopy.clear();
}
}
}
}

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

@ -25,6 +25,8 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.TagCustomerDao;
import com.epmet.dto.TagCustomerDTO;
import com.epmet.dto.form.UpdateTagFormDTO;
import com.epmet.dto.result.UpdateTagUseCountsResultDTO;
import com.epmet.entity.TagCustomerEntity;
import com.epmet.redis.TagCustomerRedis;
import com.epmet.service.TagCustomerService;
@ -101,4 +103,20 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
@Transactional(rollbackFor = Exception.class)
public UpdateTagUseCountsResultDTO checkTagInfo(String tagName,String customerId,String userId) {
UpdateTagFormDTO formDTO = new UpdateTagFormDTO();
formDTO.setCreatedBy(userId);
formDTO.setCustomerId(customerId);
formDTO.setUpdatedBy(userId);
formDTO.setTagName(tagName);
baseDao.checkTagInfo(formDTO);
UpdateTagUseCountsResultDTO resultDTO = new UpdateTagUseCountsResultDTO();
resultDTO.setTagId(formDTO.getId());
resultDTO.setTagName(tagName);
return resultDTO;
}
}

14
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticlePublishRangeDao.xml

@ -18,4 +18,18 @@
</if>
ORDER BY created_time ASC
</select>
<!-- 根据草稿id查询发布范围id集合 -->
<select id="selectGridIdByDraftId" resultType="java.lang.String">
SELECT
apr.grid_id AS gridId
FROM
article_publish_range apr
LEFT JOIN article a ON a.id = apr.article_id
WHERE
a.del_flag = 0
AND apr.del_flag = 0
AND a.draft_id = #{draftId}
AND publish_status = "published"
</select>
</mapper>

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

@ -3,5 +3,25 @@
<mapper namespace="com.epmet.dao.TagCustomerDao">
<insert id="checkTagInfo" parameterType="com.epmet.dto.form.UpdateTagFormDTO">
<selectKey keyProperty="id" order="AFTER" resultType="String">
select id from tag_customer where tag_name = #{tagName}
</selectKey>
INSERT INTO tag_customer ( ID, CUSTOMER_ID, TAG_NAME, USE_COUNT, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
(REPLACE ( UUID(), '-', '' ),
#{customerId},
#{tagName},
#{useCount},
#{delFlag},
#{revision},
#{createdBy},
NOW(),
#{updatedBy},
NOW())
ON DUPLICATE KEY UPDATE USE_COUNT = ( USE_COUNT + 1 ),
UPDATED_TIME = NOW(),
UPDATED_BY = #{updatedBy};
</insert>
</mapper>

14
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagGridDao.xml

@ -3,5 +3,19 @@
<mapper namespace="com.epmet.dao.TagGridDao">
<!-- 更新网格下的标签,标签存在?使用次数+1:插入 -->
<insert id="updateGridTag">
INSERT INTO tag_grid ( ID, CUSTOMER_ID, GRID_ID, TAG_ID, TAG_NAME, USE_COUNT, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="gridTags" item="tag" separator=",">
( REPLACE ( UUID(), '-', '' ),#{tag.customerId}, #{tag.gridId}, #{tag.tagId}, #{tag.tagName}, #{
tag.useCount}, #{tag.delFlag},
#{tag.revision}, #{tag.createdBy}, NOW(),#{tag.updatedBy}, NOW())
</foreach>
ON DUPLICATE KEY UPDATE
USE_COUNT = ( USE_COUNT + 1 ),
UPDATED_TIME = NOW(),
UPDATED_BY = #{userId}
</insert>
</mapper>
Loading…
Cancel
Save