增加数据类别字段

This commit is contained in:
zhangqinbin
2021-08-04 14:27:45 +08:00
parent a6fdc14c80
commit 4f96dc9306
7 changed files with 42 additions and 10 deletions

View File

@ -3,10 +3,13 @@ package com.chinaunicom.mall.ebtp.extend.bizmessage.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage; import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage;
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessageVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
public interface BizMessageMapper extends BaseMapper<BizMessage> { public interface BizMessageMapper extends BaseMapper<BizMessage> {
IPage<BizMessage> findMessage(@Param("param") IPage<BizMessage> page, @Param("userId") String userId); IPage<BizMessage> findMessage(@Param("param") IPage<BizMessage> page, @Param("userId") String userId);
IPage<BizMessageVo> findMessageVo(@Param("param") IPage<BizMessageVo> page, @Param("userId") String userId);
} }

View File

@ -3,17 +3,14 @@
<mapper namespace="com.chinaunicom.mall.ebtp.extend.bizmessage.dao.BizMessageMapper"> <mapper namespace="com.chinaunicom.mall.ebtp.extend.bizmessage.dao.BizMessageMapper">
<select id="findMessage" resultType="com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage"> <select id="findMessage" resultType="com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage">
SELECT biz_message.*,biz_message_template.type as templatetype SELECT biz_message.*
FROM biz_message FROM biz_message WHERE authorize = 0
left join biz_message_template on biz_message.templatecode = biz_message_template.code
WHERE authorize = 0
<if test="userId!=null and userId!=''"> <if test="userId!=null and userId!=''">
UNION ALL UNION ALL
SELECT a.* SELECT a.*
FROM ( SELECT biz_message.*,biz_message_template.type templatetype FROM biz_message FROM ( SELECT biz_message.* FROM biz_message
left join biz_message_template on biz_message.templatecode = biz_message_template.code
WHERE authorize = 1) a WHERE authorize = 1) a
INNER JOIN INNER JOIN
( SELECT * FROM biz_message_authorize WHERE user_id = #{userId}) b ON a.id = b.message_id ( SELECT * FROM biz_message_authorize WHERE user_id = #{userId}) b ON a.id = b.message_id
@ -21,4 +18,23 @@
ORDER BY createtime DESC ORDER BY createtime DESC
</select> </select>
<select id="findMessageVo" resultType="com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessageVo">
SELECT biz_message.*,biz_message_template.type as templatetype,'1' as authorizestate
FROM biz_message
left join biz_message_template on biz_message.templatecode = biz_message_template.code
WHERE authorize = 0
<if test="userId!=null and userId!=''">
UNION ALL
SELECT a.*,IFNULL(b.state,1) as authorizestate
FROM ( SELECT biz_message.*,biz_message_template.type templatetype
FROM biz_message
left join biz_message_template on biz_message.templatecode = biz_message_template.code
WHERE authorize = 1) a
INNER JOIN
( SELECT * FROM biz_message_authorize WHERE user_id = #{userId}) b ON a.id = b.message_id
</if>
ORDER BY createtime DESC
</select>
</mapper> </mapper>

View File

@ -18,8 +18,6 @@ public class BizMessage {
private String params; private String params;
private Timestamp createtime; private Timestamp createtime;
private String templatecode; private String templatecode;
@TableField(exist = false)
private String templatetype;
/* 该值为1则标识开启授权控制只有授权列表( biz_message_authorize )内的用户可见 */ /* 该值为1则标识开启授权控制只有授权列表( biz_message_authorize )内的用户可见 */
private Integer authorize; private Integer authorize;

View File

@ -11,5 +11,6 @@ public class BizMessageAuthorize {
private String userId; private String userId;
private String messageId; private String messageId;
private String state;
} }

View File

@ -0,0 +1,11 @@
package com.chinaunicom.mall.ebtp.extend.bizmessage.entity;
import lombok.Data;
@Data
public class BizMessageVo extends BizMessage{
private String templatetype;
private String authorizestate;
}

View File

@ -6,6 +6,7 @@ import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
import com.chinaunicom.mall.ebtp.extend.bizmessage.dao.BizMessageMapper; import com.chinaunicom.mall.ebtp.extend.bizmessage.dao.BizMessageMapper;
import com.chinaunicom.mall.ebtp.extend.bizmessage.dto.PageDTO; import com.chinaunicom.mall.ebtp.extend.bizmessage.dto.PageDTO;
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage; import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage;
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessageVo;
import com.chinaunicom.mall.ebtp.extend.bizmessage.mybatis.BizMessagePage; import com.chinaunicom.mall.ebtp.extend.bizmessage.mybatis.BizMessagePage;
import com.chinaunicom.mall.ebtp.extend.bizmessage.mybatis.IBizMessagePage; import com.chinaunicom.mall.ebtp.extend.bizmessage.mybatis.IBizMessagePage;
import com.chinaunicom.mall.ebtp.extend.bizmessage.service.BizMessageConsumerService; import com.chinaunicom.mall.ebtp.extend.bizmessage.service.BizMessageConsumerService;
@ -14,6 +15,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -39,7 +41,7 @@ public class BizMessageConsumerServiceImpl implements BizMessageConsumerService
public IBizMessagePage<DescribeSiteMsgVO> listOutline(PageDTO page) { public IBizMessagePage<DescribeSiteMsgVO> listOutline(PageDTO page) {
page = createPageCondition(page); page = createPageCondition(page);
IPage<BizMessage> pageEntity = mapper.findMessage(new Page<BizMessage>(page.getPageNo(), page.getPageSize()), IPage<BizMessageVo> pageEntity = mapper.findMessageVo(new Page<BizMessageVo>(page.getPageNo(), page.getPageSize()),
service.getCacheUser().getUserId()); service.getCacheUser().getUserId());
// DAT -> VO 转换 // DAT -> VO 转换
@ -49,8 +51,8 @@ public class BizMessageConsumerServiceImpl implements BizMessageConsumerService
DescribeSiteMsgVO vo = new DescribeSiteMsgVO(); DescribeSiteMsgVO vo = new DescribeSiteMsgVO();
vo.setMsgId(source.getId()); vo.setMsgId(source.getId());
vo.setTemplatetype(source.getTemplatetype()); vo.setTemplatetype(source.getTemplatetype());
vo.setAuthorizestate(source.getAuthorizestate());
BeanUtils.copyProperties(source, vo); BeanUtils.copyProperties(source, vo);
return vo; return vo;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));

View File

@ -17,6 +17,7 @@ public class DescribeSiteMsgVO {
private String title; private String title;
private String category; private String category;
private String templatetype; private String templatetype;
private String authorizestate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp createtime; private Timestamp createtime;