feat(消息模块与部门模块): 修改了消息模块的bug并从新建消息接口中独立出添加附件接口,部门模块新添加了部门树返回接口
This commit is contained in:
parent
dbbc9e82db
commit
30338520cf
@ -0,0 +1,25 @@
|
||||
package com.zsc.edu.gateway.framework.jackson;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
@Configuration
|
||||
public class JacksonConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
|
||||
return builder -> builder.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.serializationInclusion(JsonInclude.Include.NON_EMPTY);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.zsc.edu.gateway.framework.response;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Http状态返回枚举
|
||||
*
|
||||
* @author javadog
|
||||
**/
|
||||
@Getter
|
||||
public enum HttpStatusEnum {
|
||||
|
||||
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
SUCCESS(200, "操作成功"),
|
||||
/**
|
||||
* 对象创建成功
|
||||
*/
|
||||
CREATED(201, "对象创建成功"),
|
||||
/**
|
||||
* 请求已经被接受
|
||||
*/
|
||||
ACCEPTED(202, "请求已经被接受"),
|
||||
/**
|
||||
* 操作已经执行成功,但是没有返回数据
|
||||
*/
|
||||
NO_CONTENT(204, "操作已经执行成功,但是没有返回数据"),
|
||||
/**
|
||||
* 资源已被移除
|
||||
*/
|
||||
MOVED_PERM(301, "资源已被移除"),
|
||||
/**
|
||||
* 重定向
|
||||
*/
|
||||
SEE_OTHER(303, "重定向"),
|
||||
/**
|
||||
* 资源没有被修改
|
||||
*/
|
||||
NOT_MODIFIED(304, "资源没有被修改"),
|
||||
/**
|
||||
* 参数列表错误(缺少,格式不匹配)
|
||||
*/
|
||||
BAD_REQUEST(400, "参数列表错误(缺少,格式不匹配)"),
|
||||
/**
|
||||
* 未授权
|
||||
*/
|
||||
UNAUTHORIZED(401, "未授权"),
|
||||
/**
|
||||
* 访问受限,授权过期
|
||||
*/
|
||||
FORBIDDEN(403, "访问受限,授权过期"),
|
||||
/**
|
||||
* 资源,服务未找到
|
||||
*/
|
||||
NOT_FOUND(404, "资源,服务未找!"),
|
||||
/**
|
||||
* 不允许的http方法
|
||||
*/
|
||||
BAD_METHOD(405, "不允许的http方法"),
|
||||
/**
|
||||
* 资源冲突,或者资源被锁
|
||||
*/
|
||||
CONFLICT(409, "资源冲突,或者资源被锁"),
|
||||
/**
|
||||
* 不支持的数据,媒体类型
|
||||
*/
|
||||
UNSUPPORTED_TYPE(415, "不支持的数据,媒体类型"),
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
ERROR(500, "系统内部错误"),
|
||||
/**
|
||||
* 接口未实现
|
||||
*/
|
||||
NOT_IMPLEMENTED(501, "接口未实现"),
|
||||
/**
|
||||
* 系统警告消息
|
||||
*/
|
||||
WARN(601, "系统警告消息");
|
||||
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
||||
HttpStatusEnum(Integer code, String message) {
|
||||
|
||||
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,265 @@
|
||||
package com.zsc.edu.gateway.framework.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 返回结果集
|
||||
*
|
||||
* @author javadog
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResponseResult<T> {
|
||||
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 状态信息
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* 全参数方法
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param status 状态
|
||||
* @param message 返回信息
|
||||
* @param data 返回数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
private static <T> ResponseResult<T> response(Integer code, Boolean status, String message, T data) {
|
||||
|
||||
|
||||
ResponseResult<T> responseResult = new ResponseResult<>();
|
||||
responseResult.setCode(code);
|
||||
responseResult.setStatus(status);
|
||||
responseResult.setMessage(message);
|
||||
responseResult.setData(data);
|
||||
return responseResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全参数方法
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param status 状态
|
||||
* @param message 返回信息
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
private static <T> ResponseResult<T> response(Integer code, Boolean status, String message) {
|
||||
|
||||
|
||||
ResponseResult<T> responseResult = new ResponseResult<>();
|
||||
responseResult.setCode(code);
|
||||
responseResult.setStatus(status);
|
||||
responseResult.setMessage(message);
|
||||
return responseResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(无参)
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success() {
|
||||
|
||||
// return response(HttpStatus.OK.value(), true, HttpStatus.OK.getReasonPhrase(), null);
|
||||
return response(HttpStatusEnum.SUCCESS.getCode(), true, HttpStatusEnum.SUCCESS.getMessage(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(枚举参数)
|
||||
*
|
||||
* @param httpResponseEnum 枚举参数
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success(HttpStatusEnum httpResponseEnum) {
|
||||
|
||||
|
||||
return response(httpResponseEnum.getCode(), true, httpResponseEnum.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(状态码+返回信息)
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param message 返回信息
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success(Integer code, String message) {
|
||||
|
||||
|
||||
return response(code, true, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(返回信息 + 数据)
|
||||
*
|
||||
* @param message 返回信息
|
||||
* @param data 数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success(String message, T data) {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.SUCCESS.getCode(), true, message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(状态码+返回信息+数据)
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param message 返回信息
|
||||
* @param data 数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success(Integer code, String message, T data) {
|
||||
|
||||
|
||||
return response(code, true, message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(数据)
|
||||
*
|
||||
* @param data 数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success(T data) {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.SUCCESS.getCode(), true, HttpStatusEnum.SUCCESS.getMessage(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回(返回信息)
|
||||
*
|
||||
* @param message 返回信息
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> success(String message) {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.SUCCESS.getCode(), true, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(无参)
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail() {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.ERROR.getCode(), false, HttpStatusEnum.ERROR.getMessage(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(枚举)
|
||||
*
|
||||
* @param httpResponseEnum 枚举
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail(HttpStatusEnum httpResponseEnum) {
|
||||
|
||||
|
||||
return response(httpResponseEnum.getCode(), false, httpResponseEnum.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(状态码+返回信息)
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param message 返回信息
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail(Integer code, String message) {
|
||||
|
||||
|
||||
return response(code, false, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(返回信息+数据)
|
||||
*
|
||||
* @param message 返回信息
|
||||
* @param data 数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail(String message, T data) {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.ERROR.getCode(), false, message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(状态码+返回信息+数据)
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param message 返回消息
|
||||
* @param data 数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail(Integer code, String message, T data) {
|
||||
|
||||
|
||||
return response(code, false, message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(数据)
|
||||
*
|
||||
* @param data 数据
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail(T data) {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.ERROR.getCode(), false, HttpStatusEnum.ERROR.getMessage(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回(返回信息)
|
||||
*
|
||||
* @param message 返回信息
|
||||
* @param <T> 泛型
|
||||
* @return {@link ResponseResult<T>}
|
||||
*/
|
||||
public static <T> ResponseResult<T> fail(String message) {
|
||||
|
||||
|
||||
return response(HttpStatusEnum.ERROR.getCode(), false, message, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.zsc.edu.gateway.modules.notice.mapper;
|
||||
|
||||
import com.zsc.edu.gateway.common.mapstruct.BaseMapper;
|
||||
import com.zsc.edu.gateway.modules.notice.dto.UserMessageDto;
|
||||
import com.zsc.edu.gateway.modules.notice.entity.Message;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface MessageMapper extends BaseMapper<UserMessageDto, Message> {
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.zsc.edu.gateway.modules.notice.query;
|
||||
|
||||
import com.zsc.edu.gateway.modules.notice.entity.MessageType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AdminMessageQuery {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
public Long userId;
|
||||
|
||||
/**
|
||||
* 标题,模糊查询
|
||||
*/
|
||||
public String title;
|
||||
|
||||
/**
|
||||
* 消息创建时间区间起始
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
public LocalDateTime createAtBegin;
|
||||
|
||||
/**
|
||||
* 消息创建时间区间终止
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
public LocalDateTime createAtEnd;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.zsc.edu.gateway.modules.notice.vo;
|
||||
|
||||
import com.zsc.edu.gateway.modules.notice.entity.MessageType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
*/
|
||||
@Data
|
||||
public class AdminMessageVo {
|
||||
/**
|
||||
* 用户消息id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 接受用户数
|
||||
*/
|
||||
private Long userCount;
|
||||
/**
|
||||
* 已读用户数
|
||||
*/
|
||||
private Long readCount;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
public MessageType type = MessageType.other;
|
||||
/**
|
||||
* 是否系统消息
|
||||
*/
|
||||
public Boolean system;
|
||||
/**
|
||||
* 是否邮件
|
||||
*/
|
||||
public Boolean email;
|
||||
/**
|
||||
* 是否短信
|
||||
*/
|
||||
public Boolean sms;
|
||||
/**
|
||||
* 是否html
|
||||
*/
|
||||
public Boolean html;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
public String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
public String content;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
Loading…
Reference in New Issue
Block a user