mirror of https://gitee.com/stylefeng/roses
【7.2.5】更新消息和通知模块的包装类
parent
0561b658fd
commit
34f186c384
|
@ -43,6 +43,14 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--系统管理api模块-->
|
||||
<!--用来做id转化-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--web-->
|
||||
<!--LogRecordFactory快速创建http类的日志参数会用到-->
|
||||
<!--如果不要记录当前请求的http接口信息,就不用本模块,所以optional=true-->
|
||||
|
|
|
@ -28,6 +28,8 @@ import cn.stylefeng.roses.kernel.message.api.enums.MessageBusinessTypeEnum;
|
|||
import cn.stylefeng.roses.kernel.message.api.enums.MessagePriorityLevelEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat;
|
||||
import cn.stylefeng.roses.kernel.system.api.format.UserFormatProcess;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -60,6 +62,7 @@ public class MessageResponse implements Serializable {
|
|||
* 发送用户id
|
||||
*/
|
||||
@ChineseDescription("发送用户id")
|
||||
@SimpleFieldFormat(processClass = UserFormatProcess.class)
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
|
@ -122,25 +125,25 @@ public class MessageResponse implements Serializable {
|
|||
@ChineseDescription("阅读状态:0-未读,1-已读")
|
||||
private String readFlagValue;
|
||||
|
||||
public String getPriorityLevelValue(){
|
||||
public String getPriorityLevelValue() {
|
||||
AtomicReference<String> value = new AtomicReference<>("");
|
||||
Optional.ofNullable(this.priorityLevel).ifPresent(val ->{
|
||||
Optional.ofNullable(this.priorityLevel).ifPresent(val -> {
|
||||
value.set(MessagePriorityLevelEnum.getName(this.priorityLevel));
|
||||
});
|
||||
return value.get();
|
||||
}
|
||||
|
||||
public String getReadFlagValue(){
|
||||
public String getReadFlagValue() {
|
||||
AtomicReference<String> value = new AtomicReference<>("");
|
||||
Optional.ofNullable(this.readFlag).ifPresent(val ->{
|
||||
Optional.ofNullable(this.readFlag).ifPresent(val -> {
|
||||
value.set(MessageReadFlagEnum.getName(this.readFlag));
|
||||
});
|
||||
return value.get();
|
||||
}
|
||||
|
||||
public String getBusinessTypeValue(){
|
||||
public String getBusinessTypeValue() {
|
||||
AtomicReference<String> value = new AtomicReference<>("");
|
||||
Optional.ofNullable(this.businessType).ifPresent(val ->{
|
||||
Optional.ofNullable(this.businessType).ifPresent(val -> {
|
||||
value.set(MessageBusinessTypeEnum.getName(this.businessType));
|
||||
});
|
||||
return value.get();
|
||||
|
|
|
@ -32,13 +32,6 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--系统管理api模块-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
|
|
|
@ -31,14 +31,12 @@ import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
|||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageSendRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.response.MessageResponse;
|
||||
import cn.stylefeng.roses.kernel.message.modular.wrapper.MessageWrapper;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.BusinessLog;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.wrapper.api.annotation.Wrapper;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -134,7 +132,6 @@ public class SysMessageController {
|
|||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "分页查询系统消息列表", path = "/sysMessage/page")
|
||||
@Wrapper(MessageWrapper.class)
|
||||
public ResponseData<PageResult<MessageResponse>> page(MessageRequest messageRequest) {
|
||||
return new SuccessResponseData<>(messageApi.queryPageCurrentUser(messageRequest));
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.modular.wrapper;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.response.MessageResponse;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.wrapper.api.BaseWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息的包装
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/14 17:28
|
||||
*/
|
||||
public class MessageWrapper implements BaseWrapper<MessageResponse> {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> doWrap(MessageResponse beWrappedModel) {
|
||||
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
UserServiceApi userServiceApi = SpringUtil.getBean(UserServiceApi.class);
|
||||
|
||||
if (beWrappedModel.getSendUserId() != null) {
|
||||
SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(beWrappedModel.getSendUserId());
|
||||
if (sysUserDTO != null) {
|
||||
resultMap.put("sendUserName", sysUserDTO.getRealName());
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
|
@ -34,8 +34,6 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
|||
import cn.stylefeng.roses.kernel.system.api.pojo.notice.SysNoticeRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.entity.SysNotice;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.service.SysNoticeService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.wrapper.NoticeWrapper;
|
||||
import cn.stylefeng.roses.kernel.wrapper.api.annotation.Wrapper;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -113,7 +111,6 @@ public class SysNoticeController {
|
|||
* @date 2021/1/9 21:23
|
||||
*/
|
||||
@GetResource(name = "查询通知管理", path = "/sysNotice/page")
|
||||
@Wrapper(NoticeWrapper.class)
|
||||
public ResponseData<PageResult<SysNotice>> page(SysNoticeRequest sysNoticeParam) {
|
||||
return new SuccessResponseData<>(sysNoticeService.findPage(sysNoticeParam));
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ package cn.stylefeng.roses.kernel.system.modular.notice.entity;
|
|||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.dict.api.serializer.DictValueSerializer;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat;
|
||||
import cn.stylefeng.roses.kernel.system.api.format.UserFormatProcess;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
@ -119,4 +121,10 @@ public class SysNotice extends BaseEntity {
|
|||
return "priority_level|" + this.priorityLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SimpleFieldFormat(processClass = UserFormatProcess.class)
|
||||
public Long getCreateUser() {
|
||||
return super.getCreateUser();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.system.modular.notice.wrapper;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.entity.SysNotice;
|
||||
import cn.stylefeng.roses.kernel.wrapper.api.BaseWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统通知的包装
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/6/14 17:28
|
||||
*/
|
||||
public class NoticeWrapper implements BaseWrapper<SysNotice> {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> doWrap(SysNotice beWrappedModel) {
|
||||
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
UserServiceApi userServiceApi = SpringUtil.getBean(UserServiceApi.class);
|
||||
|
||||
if (beWrappedModel.getCreateUser() != null) {
|
||||
SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(beWrappedModel.getCreateUser());
|
||||
if (sysUserDTO != null) {
|
||||
resultMap.put("createUserName", sysUserDTO.getRealName());
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue