From 39f08dd934cde1a02f1c243faa43174fa474c87f Mon Sep 17 00:00:00 2001 From: wl <173@qq.com> Date: 星期二, 08 十一月 2022 11:11:35 +0800 Subject: [PATCH] 消息中心展示 --- ycl-platform/src/main/java/com/ycl/controller/message/MessageColumnSetController.java | 9 ++-- ycl-platform/src/main/java/com/ycl/service/message/impl/MessageColumnSetServiceImpl.java | 11 +++++ ycl-platform/src/main/java/com/ycl/service/message/IMessageColumnSetService.java | 4 ++ ycl-platform/src/main/java/com/ycl/mapper/message/MessageColumnSetMapper.java | 5 ++ ycl-platform/src/main/resources/mapper/message/MessageColumnSetMapper.xml | 31 +++++++++++++++ ycl-platform/src/main/java/com/ycl/vo/message/MessageColumnSetVO.java | 16 ++++++++ 6 files changed, 71 insertions(+), 5 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/controller/message/MessageColumnSetController.java b/ycl-platform/src/main/java/com/ycl/controller/message/MessageColumnSetController.java index a4a46b8..cfc1583 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/message/MessageColumnSetController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/message/MessageColumnSetController.java @@ -5,6 +5,7 @@ import com.ycl.api.CommonResult; import com.ycl.entity.message.MessageColumnSet; import com.ycl.service.message.IMessageColumnSetService; +import com.ycl.vo.message.MessageColumnSetVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -47,15 +48,13 @@ return CommonResult.success(columnSet); } @ApiOperation("鑾峰彇鐢ㄦ埛鏍忕洰璁剧疆") - @RequestMapping(value = "/getUserColumnSet/{userId}", method = RequestMethod.GET) + @RequestMapping(value = "/getUserColumnSet", method = RequestMethod.GET) @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "鐢ㄦ埛Id",required = true, dataType = "Long") }) @ResponseBody - public CommonResult<List<MessageColumnSet>> getUserColumnSet(@PathVariable Long userId) { - QueryWrapper<MessageColumnSet> setQueryWrapper = new QueryWrapper<>(); - setQueryWrapper.eq("user_id", userId); - List<MessageColumnSet> sets = iMessageColumnSetService.list(setQueryWrapper); + public CommonResult<List<MessageColumnSetVO>> getUserColumnSet(@RequestParam Long userId) { + List<MessageColumnSetVO> sets = iMessageColumnSetService.listColumnAndPage(userId); return CommonResult.success(sets); } diff --git a/ycl-platform/src/main/java/com/ycl/mapper/message/MessageColumnSetMapper.java b/ycl-platform/src/main/java/com/ycl/mapper/message/MessageColumnSetMapper.java index 170e623..7670a55 100644 --- a/ycl-platform/src/main/java/com/ycl/mapper/message/MessageColumnSetMapper.java +++ b/ycl-platform/src/main/java/com/ycl/mapper/message/MessageColumnSetMapper.java @@ -2,6 +2,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.entity.message.MessageColumnSet; +import com.ycl.vo.message.MessageColumnSetVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -12,4 +16,5 @@ * @since 2022-10-12 */ public interface MessageColumnSetMapper extends BaseMapper<MessageColumnSet> { + List<MessageColumnSetVO> selectColumnAndCount(@Param(value = "userId") Long userId); } diff --git a/ycl-platform/src/main/java/com/ycl/service/message/IMessageColumnSetService.java b/ycl-platform/src/main/java/com/ycl/service/message/IMessageColumnSetService.java index 1ed8fcc..0cebb24 100644 --- a/ycl-platform/src/main/java/com/ycl/service/message/IMessageColumnSetService.java +++ b/ycl-platform/src/main/java/com/ycl/service/message/IMessageColumnSetService.java @@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.entity.message.MessageColumnSet; +import com.ycl.vo.message.MessageColumnSetVO; + +import java.util.List; /** * <p> @@ -12,4 +15,5 @@ * @since 2022-10-12 */ public interface IMessageColumnSetService extends IService<MessageColumnSet> { + List<MessageColumnSetVO> listColumnAndPage(Long userId); } diff --git a/ycl-platform/src/main/java/com/ycl/service/message/impl/MessageColumnSetServiceImpl.java b/ycl-platform/src/main/java/com/ycl/service/message/impl/MessageColumnSetServiceImpl.java index be23e71..37346a0 100644 --- a/ycl-platform/src/main/java/com/ycl/service/message/impl/MessageColumnSetServiceImpl.java +++ b/ycl-platform/src/main/java/com/ycl/service/message/impl/MessageColumnSetServiceImpl.java @@ -4,7 +4,11 @@ import com.ycl.entity.message.MessageColumnSet; import com.ycl.mapper.message.MessageColumnSetMapper; import com.ycl.service.message.IMessageColumnSetService; +import com.ycl.vo.message.MessageColumnSetVO; import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; /** * <p> @@ -17,4 +21,11 @@ @Service public class MessageColumnSetServiceImpl extends ServiceImpl<MessageColumnSetMapper, MessageColumnSet> implements IMessageColumnSetService { + @Resource + MessageColumnSetMapper messageColumnSetMapper; + + @Override + public List<MessageColumnSetVO> listColumnAndPage(Long userId) { + return messageColumnSetMapper.selectColumnAndCount(userId); + } } diff --git a/ycl-platform/src/main/java/com/ycl/vo/message/MessageColumnSetVO.java b/ycl-platform/src/main/java/com/ycl/vo/message/MessageColumnSetVO.java new file mode 100644 index 0000000..371db17 --- /dev/null +++ b/ycl-platform/src/main/java/com/ycl/vo/message/MessageColumnSetVO.java @@ -0,0 +1,16 @@ +package com.ycl.vo.message; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel +public class MessageColumnSetVO { + + @ApiModelProperty(value = "娑堟伅鏍忕洰Id") + private String columnName; + + @ApiModelProperty(value = "鏄惁鎺ユ敹0-涓嶆帴鏀�1-鎺ユ敹") + private Integer messageNumber; +} diff --git a/ycl-platform/src/main/resources/mapper/message/MessageColumnSetMapper.xml b/ycl-platform/src/main/resources/mapper/message/MessageColumnSetMapper.xml new file mode 100644 index 0000000..d47078c --- /dev/null +++ b/ycl-platform/src/main/resources/mapper/message/MessageColumnSetMapper.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ycl.mapper.message.MessageColumnSetMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.ycl.entity.message.MessageColumnSet"> + <id column="id" property="id" /> + <result column="user_id" property="userId" /> + <result column="message_column_id" property="messageColumnId" /> + <result column="is_receive" property="isReceive" /> + </resultMap> + + <!-- 閫氱敤鏌ヨ缁撴灉鍒� --> + <sql id="Base_Column_List"> + id, user_id, message_column_id, is_receive + </sql> + + <select id="selectColumnAndCount" resultType="com.ycl.vo.message.MessageColumnSetVO" > + SELECT + COUNT( 1 ) AS messageNumber, + t2.column_name As columnName + FROM + `ums_message_column_set` t1 + LEFT JOIN ums_message_column t2 ON t1.message_column_id = t2.id + WHERE + t1.user_id = #{userId} + GROUP BY + t2.column_name + </select> + +</mapper> -- Gitblit v1.8.0