mirror of https://gitee.com/stylefeng/roses
【8.0.5】【notice】新增通知
parent
db233bff8a
commit
2985ceaef1
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* 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.sys.api.enums.notice;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.base.ReadableEnum;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知发布状态
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2024-01-12 16:38
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum NoticePublishStatusEnum implements ReadableEnum<NoticePublishStatusEnum> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已发布
|
||||||
|
*/
|
||||||
|
ALREADY(1, "已发布"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未发布
|
||||||
|
*/
|
||||||
|
NOT_PUBLISH(2, "未发布");
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
NoticePublishStatusEnum(Integer code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKey() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getName() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NoticePublishStatusEnum parseToEnum(String originValue) {
|
||||||
|
if (ObjectUtil.isEmpty(originValue)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (NoticePublishStatusEnum value : NoticePublishStatusEnum.values()) {
|
||||||
|
if (value.code.equals(Convert.toInt(originValue))) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,10 @@
|
||||||
package cn.stylefeng.roses.kernel.sys.modular.notice.entity;
|
package cn.stylefeng.roses.kernel.sys.modular.notice.entity;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseBusinessEntity;
|
||||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import cn.stylefeng.roses.kernel.sys.modular.notice.pojo.NoticeUserScope;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@ -18,10 +17,10 @@ import java.util.Map;
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2024/01/12 16:06
|
* @since 2024/01/12 16:06
|
||||||
*/
|
*/
|
||||||
@TableName("sys_notice")
|
@TableName(value = "sys_notice", autoResultMap = true)
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class SysNotice extends BaseEntity {
|
public class SysNotice extends BaseBusinessEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
|
@ -75,9 +74,9 @@ public class SysNotice extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 通知范围,存用户id集合
|
* 通知范围,存用户id集合
|
||||||
*/
|
*/
|
||||||
@TableField("notice_user_scope")
|
@TableField(value = "notice_user_scope", typeHandler = JacksonTypeHandler.class)
|
||||||
@ChineseDescription("通知范围,存用户id集合")
|
@ChineseDescription("通知范围,存用户id集合")
|
||||||
private Map<String, Object> noticeUserScope;
|
private NoticeUserScope noticeUserScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否发布:1-已发布,2-未发布
|
* 是否发布:1-已发布,2-未发布
|
||||||
|
@ -86,31 +85,17 @@ public class SysNotice extends BaseEntity {
|
||||||
@ChineseDescription("是否发布:1-已发布,2-未发布")
|
@ChineseDescription("是否发布:1-已发布,2-未发布")
|
||||||
private Integer publishStatus;
|
private Integer publishStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 乐观锁
|
|
||||||
*/
|
|
||||||
@TableField("version_flag")
|
|
||||||
@ChineseDescription("乐观锁")
|
|
||||||
private Long versionFlag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拓展字段
|
* 拓展字段
|
||||||
*/
|
*/
|
||||||
@TableField("expand_field")
|
@TableField(value = "expand_field", typeHandler = JacksonTypeHandler.class)
|
||||||
@ChineseDescription("拓展字段")
|
@ChineseDescription("拓展字段")
|
||||||
private Map<String, Object> expandField;
|
private Map<String, Object> expandField;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:Y-被删除,N-未删除
|
|
||||||
*/
|
|
||||||
@TableField("del_flag")
|
|
||||||
@ChineseDescription("是否删除:Y-被删除,N-未删除")
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户号
|
* 租户号
|
||||||
*/
|
*/
|
||||||
@TableField("tenant_id")
|
@TableField(value = "tenant_id", fill = FieldFill.INSERT)
|
||||||
@ChineseDescription("租户号")
|
@ChineseDescription("租户号")
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,12 @@ public enum SysNoticeExceptionEnum implements AbstractExceptionEnum {
|
||||||
/**
|
/**
|
||||||
* 查询结果不存在
|
* 查询结果不存在
|
||||||
*/
|
*/
|
||||||
SYS_NOTICE_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
SYS_NOTICE_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知范围不能为空
|
||||||
|
*/
|
||||||
|
SYS_NOTICE_SCOPE_EMPTY(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "通知范围不能为空");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误编码
|
* 错误编码
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.notice.pojo;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知的通知人员范围
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2024-01-12 16:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class NoticeUserScope {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送给指定的机构
|
||||||
|
*/
|
||||||
|
@ChineseDescription("发送给指定的机构")
|
||||||
|
private List<SimpleDict> pointOrgList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送给指定的用户
|
||||||
|
*/
|
||||||
|
@ChineseDescription("发送给指定的用户")
|
||||||
|
private List<SimpleDict> pointUserList;
|
||||||
|
|
||||||
|
}
|
|
@ -2,13 +2,13 @@ package cn.stylefeng.roses.kernel.sys.modular.notice.pojo.request;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.notice.pojo.NoticeUserScope;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知管理封装类
|
* 通知管理封装类
|
||||||
|
@ -23,7 +23,7 @@ public class SysNoticeRequest extends BaseRequest {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class})
|
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class, updateStatus.class})
|
||||||
@ChineseDescription("主键")
|
@ChineseDescription("主键")
|
||||||
private Long noticeId;
|
private Long noticeId;
|
||||||
|
|
||||||
|
@ -34,22 +34,17 @@ public class SysNoticeRequest extends BaseRequest {
|
||||||
@ChineseDescription("通知标题")
|
@ChineseDescription("通知标题")
|
||||||
private String noticeTitle;
|
private String noticeTitle;
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知摘要
|
|
||||||
*/
|
|
||||||
@ChineseDescription("通知摘要")
|
|
||||||
private String noticeSummary;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知内容
|
* 通知内容
|
||||||
*/
|
*/
|
||||||
@ChineseDescription("通知内容")
|
@ChineseDescription("通知内容")
|
||||||
|
@NotBlank(message = "通知内容不能为空", groups = {add.class, edit.class})
|
||||||
private String noticeContent;
|
private String noticeContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优先级,来自字典:high-高优先级,middle-中,low-低
|
* 优先级,来自字典:high-高优先级,middle-中,low-低
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "优先级,来自字典:high-高优先级,middle-中,low-低不能为空", groups = {add.class, edit.class})
|
@NotBlank(message = "优先级不能为空", groups = {add.class, edit.class})
|
||||||
@ChineseDescription("优先级,来自字典:high-高优先级,middle-中,low-低")
|
@ChineseDescription("优先级,来自字典:high-高优先级,middle-中,low-低")
|
||||||
private String priorityLevel;
|
private String priorityLevel;
|
||||||
|
|
||||||
|
@ -57,52 +52,21 @@ public class SysNoticeRequest extends BaseRequest {
|
||||||
* 开始时间
|
* 开始时间
|
||||||
*/
|
*/
|
||||||
@ChineseDescription("开始时间")
|
@ChineseDescription("开始时间")
|
||||||
private String noticeBeginTime;
|
private String noticeBeginTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束时间
|
* 结束时间
|
||||||
*/
|
*/
|
||||||
@ChineseDescription("结束时间")
|
@ChineseDescription("结束时间")
|
||||||
private String noticeEndTime;
|
private String noticeEndTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知范围,存用户id集合
|
|
||||||
*/
|
|
||||||
@ChineseDescription("通知范围,存用户id集合")
|
|
||||||
private Map<String, Object> noticeUserScope;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否发布:1-已发布,2-未发布
|
* 是否发布:1-已发布,2-未发布
|
||||||
*/
|
*/
|
||||||
@ChineseDescription("是否发布:1-已发布,2-未发布")
|
@ChineseDescription("是否发布:1-已发布,2-未发布")
|
||||||
|
@NotNull(message = "发布状态不能为空", groups = updateStatus.class)
|
||||||
private Integer publishStatus;
|
private Integer publishStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 乐观锁
|
|
||||||
*/
|
|
||||||
@ChineseDescription("乐观锁")
|
|
||||||
private Long versionFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拓展字段
|
|
||||||
*/
|
|
||||||
@ChineseDescription("拓展字段")
|
|
||||||
private Map<String, Object> expandField;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:Y-被删除,N-未删除
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "是否删除:Y-被删除,N-未删除不能为空", groups = {add.class, edit.class})
|
|
||||||
@ChineseDescription("是否删除:Y-被删除,N-未删除")
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户号
|
|
||||||
*/
|
|
||||||
@ChineseDescription("租户号")
|
|
||||||
private Long tenantId;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除用的id集合
|
* 批量删除用的id集合
|
||||||
*/
|
*/
|
||||||
|
@ -110,4 +74,10 @@ public class SysNoticeRequest extends BaseRequest {
|
||||||
@ChineseDescription("批量删除用的id集合")
|
@ChineseDescription("批量删除用的id集合")
|
||||||
private List<Long> batchDeleteIdList;
|
private List<Long> batchDeleteIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知人员和部门的范围
|
||||||
|
*/
|
||||||
|
@ChineseDescription("通知人员和部门的范围")
|
||||||
|
private NoticeUserScope noticeUserScope;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.enums.notice.NoticePublishStatusEnum;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.notice.entity.SysNotice;
|
import cn.stylefeng.roses.kernel.sys.modular.notice.entity.SysNotice;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.notice.enums.SysNoticeExceptionEnum;
|
import cn.stylefeng.roses.kernel.sys.modular.notice.enums.SysNoticeExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.notice.mapper.SysNoticeMapper;
|
import cn.stylefeng.roses.kernel.sys.modular.notice.mapper.SysNoticeMapper;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.notice.pojo.NoticeUserScope;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.notice.pojo.request.SysNoticeRequest;
|
import cn.stylefeng.roses.kernel.sys.modular.notice.pojo.request.SysNoticeRequest;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.notice.service.SysNoticeService;
|
import cn.stylefeng.roses.kernel.sys.modular.notice.service.SysNoticeService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
@ -29,10 +31,28 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements SysNoticeService {
|
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements SysNoticeService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void add(SysNoticeRequest sysNoticeRequest) {
|
public void add(SysNoticeRequest sysNoticeRequest) {
|
||||||
|
|
||||||
|
// 1. 判断通知人员范围不能为空
|
||||||
|
NoticeUserScope noticeUserScope = sysNoticeRequest.getNoticeUserScope();
|
||||||
|
if (noticeUserScope == null) {
|
||||||
|
throw new ServiceException(SysNoticeExceptionEnum.SYS_NOTICE_SCOPE_EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 通知的人员和部门不能同时为空
|
||||||
|
if (ObjectUtil.isEmpty(noticeUserScope.getPointOrgList()) && ObjectUtil.isEmpty(noticeUserScope.getPointUserList())) {
|
||||||
|
throw new ServiceException(SysNoticeExceptionEnum.SYS_NOTICE_SCOPE_EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 存储基础信息
|
||||||
SysNotice sysNotice = new SysNotice();
|
SysNotice sysNotice = new SysNotice();
|
||||||
BeanUtil.copyProperties(sysNoticeRequest, sysNotice);
|
BeanUtil.copyProperties(sysNoticeRequest, sysNotice);
|
||||||
|
|
||||||
|
// 新增的时候,默认设置状态为未发布
|
||||||
|
sysNotice.setPublishStatus(NoticePublishStatusEnum.NOT_PUBLISH.getCode());
|
||||||
|
|
||||||
this.save(sysNotice);
|
this.save(sysNotice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue