Merge branch 'message-board' into master
# Conflicts: # xhpc-modules/pom.xml
This commit is contained in:
commit
e403cd4942
5
pom.xml
5
pom.xml
@ -51,6 +51,11 @@
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.0.13.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud 微服务 -->
|
||||
<dependency>
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
<module>xhpc-tradebill</module>
|
||||
<module>xhpc-message-board</module>
|
||||
<module>xhpc-card</module>
|
||||
<module>xhpc-data-big-screen</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>xhpc-modules</artifactId>
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
package com.xhpc.common.util;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 进行日期处理的工具类
|
||||
*
|
||||
* @author WH
|
||||
* @date 2022/1/15 15:59
|
||||
* @since version-1.0
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class MyDateUtil {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println(getCurrentDateStr());
|
||||
}
|
||||
|
||||
/**
|
||||
* 以xxxx年x月xx日 星期x的字符串格式展示当前时间
|
||||
*
|
||||
* @author WH
|
||||
* @date 2022/1/15 16:15
|
||||
* @since version-1.0
|
||||
*/
|
||||
public static String getCurrentDateStr() {
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
int year = now.get(Calendar.YEAR);
|
||||
int month = now.get(Calendar.MONTH) + 1;
|
||||
int day = now.get(Calendar.DAY_OF_MONTH);
|
||||
String dayNames[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||
int dayOfWeek = now.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (dayOfWeek < 0) dayOfWeek = 0;
|
||||
String week = dayNames[dayOfWeek];
|
||||
String nowDateStr = year + "年" + month + "月" + day + "日 " + week;
|
||||
|
||||
return nowDateStr;
|
||||
|
||||
}
|
||||
|
||||
public static final String DATE_FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 获取表示所传入的Date对象的Calendar对象
|
||||
*
|
||||
* @param date 要转换的Date对象
|
||||
* @return 表示所传入的Date对象的Calendar对象
|
||||
* @author WH
|
||||
* @date 2022/1/15 16:11
|
||||
* @since version-1.0
|
||||
*/
|
||||
public static Calendar getCalendar(Date date) {
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个yyyy-MM-dd HH:mm:ss格式的当前时间字符串
|
||||
*
|
||||
* @author WH
|
||||
* @date 2022/1/15 16:04
|
||||
* @since version-1.0
|
||||
*/
|
||||
public static String getCurrentDateStrInYyyyMmDdHhMmSsFormat() {
|
||||
|
||||
return DateTime.now().toString(DATE_FORMAT_DATE_TIME);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.xhpc.common.util;
|
||||
|
||||
/**
|
||||
* 用于进行分页的工具类
|
||||
*
|
||||
* @author WH
|
||||
* @date 2022/1/15 15:25
|
||||
* @since version-1.0
|
||||
*/
|
||||
public class MyPagingUtil {
|
||||
|
||||
/**
|
||||
* 用于计算MySQL数据库中的limit子句的startIndex值
|
||||
*
|
||||
* @param currentPage 当前要显示的记录的页数
|
||||
* @param items 当前页要显示多少条记录
|
||||
* @return 返回MySQL数据库中的limit子句的startIndex值
|
||||
* @throws IllegalArgumentException 传入的参数不符合要求,发生此异常
|
||||
* @author WH
|
||||
* @date 2022/1/15 15:27
|
||||
* @since version-1.0
|
||||
*/
|
||||
public static int calculateStartIndex(int currentPage, int items) throws IllegalArgumentException {
|
||||
|
||||
if ((currentPage - 1) < 0) {
|
||||
throw new IllegalArgumentException("当前页数最小为1");
|
||||
}
|
||||
if (items < 1) {
|
||||
throw new IllegalArgumentException("当前页要显示的记录数最小为1");
|
||||
}
|
||||
return (currentPage - 1) * items;
|
||||
}
|
||||
|
||||
}
|
||||
143
xhpc-modules/xhpc-data-big-screen/pom.xml
Normal file
143
xhpc-modules/xhpc-data-big-screen/pom.xml
Normal file
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>xhpc-modules</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>xhpc-data-big-screen</artifactId>
|
||||
|
||||
<description>
|
||||
数据大屏服务
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--单元测试依赖-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>xhpc-common</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.10.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,37 @@
|
||||
package com.xhpc;
|
||||
|
||||
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
||||
import com.xhpc.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author WH
|
||||
* @date 2021/12/7 14:55
|
||||
* @since version-1.0
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.xhpc.databigscreen.mapper")
|
||||
public class XhpcDataBigScreenApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(XhpcDataBigScreenApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 数据大屏模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_ __ _ _
|
||||
(_) / _|(_)| |
|
||||
_ __ _ _ ___ _ _ _ ______ | |_ _ | | ___
|
||||
| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \
|
||||
| | | |_| || (_) || |_| || | | | | || || __/
|
||||
|_| \__,_| \___/ \__, ||_| |_| |_||_| \___|
|
||||
__/ |
|
||||
|___/
|
||||
@ -0,0 +1,28 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9806
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: xhpc-data-big-screen
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.xhpc.databigscreen.mapper: debug
|
||||
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/xhpc-data-big-screen"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern"
|
||||
value="%d{MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.xhpc" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@ -391,9 +391,15 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
||||
if (xhpcInvoice.getIsRead().equals(IsReadStatusConst.READED)) {
|
||||
return specificInvoicedResponse;
|
||||
}
|
||||
//一旦调了详情接口,就去掉该已开发票的未读状态,同时redis中的未读数量数据-1
|
||||
//一旦调了详情接口,就去掉该已开发票的未读状态,同时再次查询用户未读的数量,并将其设置到redis当中
|
||||
xhpcInvoiceMapper.updateByInvoiceId(invoiceId);
|
||||
reduceNoReadInvoiceCount(xhpcInvoice);
|
||||
Long notReadCount = xhpcInvoiceMapper.findNotReadCount(xhpcInvoice.getCreatorId(), xhpcInvoice.getCreatorType());
|
||||
String redisKey = generateRedisKey(xhpcInvoice);
|
||||
if (notReadCount == 0) {
|
||||
redisService.deleteObject(redisKey);
|
||||
} else {
|
||||
redisService.setCacheObject(redisKey, notReadCount);
|
||||
}
|
||||
return specificInvoicedResponse;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
package com.xhpc.board.controller;
|
||||
|
||||
import com.xhpc.board.domain.PlatformSendMessageToUserRequest;
|
||||
import com.xhpc.board.domain.QueryUserListRequest;
|
||||
import com.xhpc.board.domain.QueryUserListResponse;
|
||||
import com.xhpc.board.domain.*;
|
||||
import com.xhpc.board.service.XhpcMessageBoardService;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -48,7 +47,7 @@ public class XhpcMessageBoardController {
|
||||
* @since version-1.0
|
||||
*/
|
||||
@GetMapping("/user/list")
|
||||
public AjaxResult queryUserList(QueryUserListRequest param) {
|
||||
public AjaxResult queryUserList(@Validated QueryUserListRequest param) throws Exception {
|
||||
|
||||
QueryUserListResponse queryUserListResponse = xhpcMessageBoardService.queryUserList(param);
|
||||
|
||||
@ -56,4 +55,20 @@ public class XhpcMessageBoardController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台查询指定用户消息
|
||||
*
|
||||
* @author WH
|
||||
* @date 2022/1/15 18:47
|
||||
* @since version-1.0
|
||||
*/
|
||||
@GetMapping("/user/message")
|
||||
public AjaxResult platformQueryMessage(UserQueryCondition userQueryCondition) throws Exception {
|
||||
|
||||
QueryUserMassageResponse queryUserMassageResponse = xhpcMessageBoardService.platformQueryMessage(userQueryCondition);
|
||||
|
||||
return AjaxResult.success(queryUserMassageResponse);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ -32,29 +33,28 @@ public class QueryUserListRequest {
|
||||
* currentPage
|
||||
*/
|
||||
@JsonProperty("currentPage")
|
||||
@NotNull(message = "currentPage的参数名不正确或者currentPage的值为空,检查传入参数")
|
||||
@NotBlank(message = "currentPage的参数为''字符串,请检查传入参数")
|
||||
@NotNull(message = "currentPage的参数名不正确或者currentPage的值为空,请检查传入参数")
|
||||
@Min(value = 1, message = "分页参数最小为1")
|
||||
private Integer currentPage;
|
||||
/**
|
||||
* items
|
||||
*/
|
||||
@JsonProperty("items")
|
||||
@NotNull(message = "items的参数名不正确或者items的值为空,检查传入参数")
|
||||
@NotBlank(message = "items的参数为''字符串,请检查传入参数")
|
||||
@NotNull(message = "items的参数名不正确或者items的值为空,请检查传入参数")
|
||||
@Min(value = 1, message = "每页至少需要显示1条数据")
|
||||
private Integer items;
|
||||
/**
|
||||
* tenantId
|
||||
*/
|
||||
@JsonProperty("tenantId")
|
||||
@NotNull(message = "tenantId的参数名不正确或者tenantId的值为空,检查传入参数")
|
||||
@NotNull(message = "tenantId的参数名不正确或者tenantId的值为空,请检查传入参数")
|
||||
@NotBlank(message = "tenantId的参数为''字符串,请检查传入参数")
|
||||
private String tenantId;
|
||||
/**
|
||||
* tenantType
|
||||
*/
|
||||
@JsonProperty("tenantType")
|
||||
@NotNull(message = "tenantType的参数名不正确或者tenantType的值为空,检查传入参数")
|
||||
@NotBlank(message = "tenantType的参数为''字符串,请检查传入参数")
|
||||
@NotNull(message = "tenantType的参数名不正确或者tenantType的值为空,请检查传入参数")
|
||||
private Integer tenantType;
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.xhpc.board.mapper;
|
||||
|
||||
import com.xhpc.board.domain.QueryUserListRequest;
|
||||
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
||||
import com.xhpc.board.domain.UserQueryCondition;
|
||||
import com.xhpc.board.pojo.XhpcMessageBoardReceiveUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* the mapper of the xhpc_message_board_receive_user
|
||||
*
|
||||
@ -37,4 +41,36 @@ public interface XhpcMessageBoardReceiveUserMapper {
|
||||
*/
|
||||
void updateHaveNewInfoFiledByUserCondition(SendMessageToPlatformRequest userMessage);
|
||||
|
||||
/**
|
||||
* 查询给平台发消息的用户列表
|
||||
*
|
||||
* @param param 租户查询条件
|
||||
* @return 返回一个装着所有发送过信息的用户列表
|
||||
* @author WH
|
||||
* @date 2022/1/14 16:45
|
||||
* @since version-1.0
|
||||
*/
|
||||
List<XhpcMessageBoardReceiveUser> findAllBy(QueryUserListRequest param);
|
||||
|
||||
/**
|
||||
* 查询给平台发消息的用户总数
|
||||
*
|
||||
* @param param 租户查询条件
|
||||
* @return 给平台发消息的用户总数
|
||||
* @author WH
|
||||
* @date 2022/1/15 15:44
|
||||
* @since version-1.0
|
||||
*/
|
||||
Long totalUserNumber(QueryUserListRequest param);
|
||||
|
||||
/**
|
||||
* 消除留言板对应用户的红点
|
||||
*
|
||||
* @param userQueryCondition 用户信息
|
||||
* @author WH
|
||||
* @date 2022/1/16 20:13
|
||||
* @since version-1.0
|
||||
*/
|
||||
void updateHaveNewInfoIsNull(UserQueryCondition userQueryCondition);
|
||||
|
||||
}
|
||||
@ -36,6 +36,7 @@ public interface XhpcMessageBoardService {
|
||||
*
|
||||
* @param userQueryCondition 用户传入的条件
|
||||
* @return 用户在数据库中发送的记录
|
||||
*
|
||||
* @author WH
|
||||
* @date 2022/1/12 15:30
|
||||
* @since version-1.0
|
||||
@ -59,11 +60,22 @@ public interface XhpcMessageBoardService {
|
||||
*
|
||||
* @param param query list condition
|
||||
* @return 发了信息的用户列表
|
||||
* @throws Exception 当出现空指针异常时,抛出此异常
|
||||
* @author WH
|
||||
* @date 2022/1/14 11:25
|
||||
* @since version-1.0
|
||||
*/
|
||||
QueryUserListResponse queryUserList(QueryUserListRequest param);
|
||||
QueryUserListResponse queryUserList(QueryUserListRequest param) throws Exception;
|
||||
|
||||
/**
|
||||
* 平台查询用户发送过来的信息,与用户查看它自己的信息逻辑是一致的
|
||||
*
|
||||
* @param userQueryCondition 要查询的用户的信息
|
||||
* @return 返回用户与平台用户的一个月的聊天记录
|
||||
* @author WH
|
||||
* @date 2022/1/16 15:39
|
||||
* @since version-1.0
|
||||
*/
|
||||
QueryUserMassageResponse platformQueryMessage(UserQueryCondition userQueryCondition);
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import com.xhpc.common.core.utils.bean.BeanUtils;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.common.util.DateUtil;
|
||||
import com.xhpc.common.util.MyPagingUtil;
|
||||
import com.xhpc.system.api.domain.SysUser;
|
||||
import com.xhpc.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -153,18 +154,28 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
|
||||
platformRequest.setTenantId(sysUser.getTenantId());
|
||||
platformRequest.setTenantType(0);
|
||||
messageBoardMapper.insertPlatformMessage(platformRequest);
|
||||
|
||||
//往Redis中放置用户未读数量
|
||||
String userNotReadCount = "userNotReadMessageCount:" + platformRequest.getSenderType() + ":" + platformRequest.getSenderAccount() + ":" + "0:" + sysUser.getTenantId();
|
||||
Object cacheObject1 = redisService.getCacheObject(userNotReadCount);
|
||||
if (cacheObject1 == null) {
|
||||
redisService.setCacheObject(userNotReadCount, 1);
|
||||
} else {
|
||||
Integer userNotReadNum = (Integer) cacheObject1 + 1;
|
||||
redisService.setCacheObject(userNotReadCount, userNotReadNum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户条件,查询指定的数据库中的记录
|
||||
*
|
||||
* @param userQueryCondition 用户传入的条件
|
||||
* @return 用户在数据库中发送的记录
|
||||
* @author WH
|
||||
* @date 2022/1/12 15:30
|
||||
* @since version-1.0
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QueryUserMassageResponse queryUserMessage(UserQueryCondition userQueryCondition) {
|
||||
//完善条件集合
|
||||
LoginUser loginUser = tokenService.getLoginUser();
|
||||
@ -208,8 +219,9 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
|
||||
Long messageId = aMonthRecords.get(index).getMessageId();
|
||||
messageIdList.add(messageId);
|
||||
}
|
||||
//设置查询出来的记录为已读状态
|
||||
//设置查询出来的记录为已读状态,然后再查询,保证查询出来的是否有新信息状态被改变
|
||||
messageBoardMapper.setUserReadedStatus(messageIdList);
|
||||
aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
|
||||
//封装数据
|
||||
ArrayList<QueryUserMassageResponse.DataDTO> dataDTOS = new ArrayList<>();
|
||||
for (XhpcMessageBoard aMonthRecord : aMonthRecords) {
|
||||
@ -219,7 +231,6 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
|
||||
dataDTOS.add(dataDTO);
|
||||
}
|
||||
//处理下次查询时间
|
||||
//todo 截取时间
|
||||
response.setNextQueryTime(nextTimeStr);
|
||||
response.setData(dataDTOS);
|
||||
return response;
|
||||
@ -251,9 +262,108 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
|
||||
* @since version-1.0
|
||||
*/
|
||||
@Override
|
||||
public QueryUserListResponse queryUserList(QueryUserListRequest param) {
|
||||
public QueryUserListResponse queryUserList(QueryUserListRequest param) throws Exception {
|
||||
//计算分页索引
|
||||
int startIndex = MyPagingUtil.calculateStartIndex(param.getCurrentPage(), param.getItems());
|
||||
param.setCurrentPage(startIndex);
|
||||
//查询用户列表
|
||||
SysUser receiverInfo = tokenService.getLoginUser().getSysUser();
|
||||
if (receiverInfo == null) {
|
||||
throw new Exception("查询不到指定的租户,receiverInfo为null,请检查传递的参数");
|
||||
}
|
||||
QueryUserListResponse queryUserListResponse = new QueryUserListResponse();
|
||||
//查询出该租户拥有的所有用户列表
|
||||
List<XhpcMessageBoardReceiveUser> userList = xhpcMessageBoardReceiveUserMapper.findAllBy(param);
|
||||
if (userList.size() == 0) {
|
||||
return queryUserListResponse;
|
||||
}
|
||||
List<QueryUserListResponse.DataDTO> dataDtoList = new ArrayList<>();
|
||||
for (XhpcMessageBoardReceiveUser receiveUser : userList) {
|
||||
QueryUserListResponse.DataDTO dataDTO = new QueryUserListResponse.DataDTO();
|
||||
BeanUtils.copyProperties(receiveUser, dataDTO);
|
||||
dataDTO.setUserAccount(receiveUser.getSenderAccount());
|
||||
dataDTO.setUserType(receiveUser.getSenderType());
|
||||
dataDtoList.add(dataDTO);
|
||||
}
|
||||
queryUserListResponse.setData(dataDtoList);
|
||||
//获取该租户总共有多少个用户给他发送了留言
|
||||
Long totalUserNumber = xhpcMessageBoardReceiveUserMapper.totalUserNumber(param);
|
||||
queryUserListResponse.setTotalItems(totalUserNumber);
|
||||
return queryUserListResponse;
|
||||
}
|
||||
|
||||
return null;
|
||||
/**
|
||||
* 平台查询用户发送过来的信息,与用户查看它自己的信息的代码逻辑一致
|
||||
*
|
||||
* @param userQueryCondition 要查询的用户的信息
|
||||
* @return 返回用户与平台用户的一个月的聊天记录
|
||||
* @author WH
|
||||
* @date 2022/1/16 15:39
|
||||
* @since version-1.0
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QueryUserMassageResponse platformQueryMessage(UserQueryCondition userQueryCondition) {
|
||||
//完善条件集合
|
||||
SysUser sysUser = tokenService.getLoginUser().getSysUser();
|
||||
userQueryCondition.setTenantId(sysUser.getTenantId());
|
||||
userQueryCondition.setTenantType(0);
|
||||
String nextTimeStr = null;
|
||||
if ("".equals(userQueryCondition.getSendMessageTime()) || userQueryCondition.getSendMessageTime() == null || "null".equals(userQueryCondition.getSendMessageTime())) {
|
||||
userQueryCondition.setSendMessageTime(DateUtil.getYyyyMmDdHhMmSs());
|
||||
//查询用户是否有数据,即查询该用户的所有时间记录(有时间记录表示该用户发送过信息)
|
||||
List<XhpcMessageBoard> allTimeRecords = messageBoardMapper.selectTimeRecords(userQueryCondition);
|
||||
QueryUserMassageResponse queryUserMassageResponse = new QueryUserMassageResponse();
|
||||
if (allTimeRecords.size() == 0) {
|
||||
return queryUserMassageResponse;
|
||||
}
|
||||
//获取最后一个时间记录,将其减去一个月,放入查询条件中
|
||||
XhpcMessageBoard xhpcMessageBoard = allTimeRecords.get(allTimeRecords.size() - 1);
|
||||
Date finalTime = xhpcMessageBoard.getSendMessageTime();
|
||||
userQueryCondition.setSendMessageTime(DateUtils.parseDateToStr(finalTime));
|
||||
Calendar finalTimeCalendar = DateUtil.getCalendar(finalTime);
|
||||
finalTimeCalendar.add(Calendar.MONTH, -1);
|
||||
Date nextTime = finalTimeCalendar.getTime();
|
||||
nextTimeStr = DateUtils.parseDateToStr(nextTime);
|
||||
} else {
|
||||
//如果有值过来,说明有之前的记录,计算上一个月的值,作为查询条件,并返回
|
||||
String sendMessageTimeStr = userQueryCondition.getSendMessageTime();
|
||||
Date sendMessageTimeDate = DateUtils.parseDate(sendMessageTimeStr);
|
||||
Calendar nextTimeCalendar = DateUtil.getCalendar(sendMessageTimeDate);
|
||||
nextTimeCalendar.add(Calendar.MONTH, -1);
|
||||
Date nextTime = nextTimeCalendar.getTime();
|
||||
nextTimeStr = DateUtils.parseDateToStr(nextTime);
|
||||
}
|
||||
//根据用户信息中所保存的时间,与上个月时间进行区间查询
|
||||
List<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
|
||||
//如果没有数据,则返回空实体类对象
|
||||
QueryUserMassageResponse response = new QueryUserMassageResponse();
|
||||
if (aMonthRecords.size() == 0) {
|
||||
return response;
|
||||
}
|
||||
List<Long> messageIdList = new ArrayList<>();
|
||||
for (int index = 0; index <= aMonthRecords.size() - 1; index++) {
|
||||
Long messageId = aMonthRecords.get(index).getMessageId();
|
||||
messageIdList.add(messageId);
|
||||
}
|
||||
//设置查询出来的记录为已读状态,然后再查询,保证查询出来的信息状态被改变
|
||||
messageBoardMapper.setUserReadedStatus(messageIdList);
|
||||
aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
|
||||
//消除后台留言板红点
|
||||
xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoIsNull(userQueryCondition);
|
||||
//封装数据
|
||||
ArrayList<QueryUserMassageResponse.DataDTO> dataDTOS = new ArrayList<>();
|
||||
for (XhpcMessageBoard aMonthRecord : aMonthRecords) {
|
||||
QueryUserMassageResponse.DataDTO dataDTO = new QueryUserMassageResponse.DataDTO();
|
||||
BeanUtils.copyProperties(aMonthRecord, dataDTO);
|
||||
dataDTO.setSendMessageTime(DateUtils.parseDateToStr(aMonthRecord.getSendMessageTime()));
|
||||
dataDTOS.add(dataDTO);
|
||||
}
|
||||
//处理下次查询时间
|
||||
//todo 截取时间
|
||||
response.setNextQueryTime(nextTimeStr);
|
||||
response.setData(dataDTOS);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -131,8 +131,8 @@
|
||||
</insert>
|
||||
<insert id="insertUserTimeMessageRecord">
|
||||
insert into xhpc_message_board
|
||||
(sender_type, sender_account, send_message_time, tenant_type, tenant_id, sender)
|
||||
values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 1)
|
||||
(sender_type, sender_account, send_message_time, tenant_type, tenant_id, have_new_info, sender)
|
||||
values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 0, 1)
|
||||
</insert>
|
||||
<insert id="insertUserMessage">
|
||||
insert into xhpc_message_board
|
||||
@ -230,8 +230,8 @@
|
||||
</insert>
|
||||
<insert id="insertPlatformTimeMessageRecord">
|
||||
insert into xhpc_message_board
|
||||
(sender_type, sender_account, send_message_time, tenant_type, tenant_id, sender)
|
||||
values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 1)
|
||||
(sender_type, sender_account, send_message_time, tenant_type, tenant_id, have_new_info, sender)
|
||||
values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 0, 1)
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.board.pojo.XhpcMessageBoard">
|
||||
update xhpc_message_board
|
||||
|
||||
@ -87,6 +87,15 @@
|
||||
AND sender_type = #{senderType}
|
||||
AND del_flag IS NULL;
|
||||
</update>
|
||||
<update id="updateHaveNewInfoIsNull">
|
||||
UPDATE xhpc_message_board_receive_user
|
||||
SET have_new_info = null
|
||||
WHERE tenant_type = #{tenantType}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND sender_account = #{senderAccount}
|
||||
AND sender_type = #{senderType}
|
||||
AND del_flag IS NULL;
|
||||
</update>
|
||||
<select id="findOneByCondition" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
@ -99,4 +108,36 @@
|
||||
AND sender_type = #{senderType}
|
||||
AND del_flag IS NULL
|
||||
</select>
|
||||
<select id="findAllBy" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM
|
||||
`xhpc_message_board_receive_user`
|
||||
WHERE
|
||||
tenant_id = #{tenantId}
|
||||
AND tenant_type = #{tenantType}
|
||||
AND del_flag IS NULL
|
||||
AND have_new_info = 0
|
||||
<if test="userType!=null">
|
||||
AND sender_type = #{userType}
|
||||
</if>
|
||||
<if test="senderAccount">
|
||||
AND sender_account = #{senderAccount}
|
||||
</if>
|
||||
LIMIT #{currentPage},#{items}
|
||||
</select>
|
||||
<select id="totalUserNumber" resultType="java.lang.Long">
|
||||
SELECT count(tenant_id)
|
||||
FROM `xhpc_message_board_receive_user`
|
||||
WHERE tenant_id = #{tenantId}
|
||||
AND tenant_type = #{tenantType}
|
||||
AND del_flag IS NULL
|
||||
AND have_new_info = 0
|
||||
<if test="userType!=null">
|
||||
AND sender_type = #{userType}
|
||||
</if>
|
||||
<if test="senderAccount">
|
||||
AND sender_account = #{senderAccount}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user