【7.2.5】更新消息和通知模块的包装类

pull/37/head
fengshuonan 2022-09-07 15:08:37 +08:00
parent 0561b658fd
commit 34f186c384
8 changed files with 25 additions and 139 deletions

View File

@ -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-->

View File

@ -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();

View File

@ -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>

View File

@ -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));
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -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));
}

View File

@ -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();
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}