mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-11 06:57:12 +08:00
merge dev into dev
feat:通知公告新增用户选择范围 仪表盘公告列表增加数据权限 Created-by: kiki1373639299 Author-id: 86659 MR-id: 188392 Commit-by: KAI Merged-by: Charles_7c E2E-issues: Description: <!-- 非常感谢您的 PR!在提交之前,请务必确保您 PR 的代码经过了完整测试,并且通过了代码规范检查。 --> <!-- 在 [] 中输入 x 来勾选) --> ## PR 类型 <!-- 您的 PR 引入了哪种类型的变更? --> <!-- 只支持选择一种类型,如果有多种类型,可以在更新日志中增加 “类型” 列。 --> - [X] 新 feature - [ ] Bug 修复 - [ ] 功能增强 - [ ] 文档变更 - [ ] 代码样式变更 - [ ] 重构 - [ ] 性能改进 - [ ] 单元测试 - [ ] CI/CD - [ ] 其他 ## PR 目的 <!-- 描述一下您的 PR 解决了什么问题。如果可以,请链接到相关 issues。 --> ## 解决方案 <!-- 详细描述您是如何解决的问题 --> ## PR 测试 <!-- 如果可以,请为您的 PR 添加或更新单元测试。 --> <!-- 请描述一下您是如何测试 PR 的。例如:创建/更新单元测试或添加相关的截图。 --> ## Changelog | 模块 | Changelog | Related issues | |-----|-----------| -------------- | | system | notice相关对象新增字段,UserQuery 新增userIds作为查询条件 | | | webapi | 新增用户列表查询,新增通知范围查询条件,sys_notice 增量sql | | <!-- 如果有多种类型的变更,可以在变更日志表中增加 “类型” 列,该列的值与上方 “PR 类型” 相同。 --> <!-- Related issues 格式为 Closes #<issue号>,或者 Fixes #<issue号>,或者 Resolves #<issue号>。 --> ## 其他信息 <!-- 请描述一下还有哪些注意事项。例如:如果引入了一个不向下兼容的变更,请描述其影响。 --> ## 提交前确认 - [ ] PR 代码经过了完整测试,并且通过了代码规范检查 - [ ] 已经完整填写 Changelog,并链接到了相关 issues - [ ] PR 代码将要提交到 dev 分支 See merge request: continew/continew-admin!1
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.continew.admin.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import top.continew.admin.system.model.entity.NoticeDO;
|
||||
import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp;
|
||||
import top.continew.starter.data.mp.base.BaseMapper;
|
||||
@@ -35,5 +36,5 @@ public interface NoticeMapper extends BaseMapper<NoticeDO> {
|
||||
*
|
||||
* @return 仪表盘公告列表
|
||||
*/
|
||||
List<DashboardNoticeResp> selectDashboardList();
|
||||
List<DashboardNoticeResp> selectDashboardList(@Param("userId") Long userId);
|
||||
}
|
@@ -16,12 +16,15 @@
|
||||
|
||||
package top.continew.admin.system.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import top.continew.starter.extension.crud.model.entity.BaseDO;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告实体
|
||||
@@ -30,7 +33,7 @@ import java.time.LocalDateTime;
|
||||
* @since 2023/8/20 10:55
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_notice")
|
||||
@TableName(value = "sys_notice",autoResultMap = true)
|
||||
public class NoticeDO extends BaseDO {
|
||||
|
||||
@Serial
|
||||
@@ -60,4 +63,15 @@ public class NoticeDO extends BaseDO {
|
||||
* 终止时间
|
||||
*/
|
||||
private LocalDateTime terminateTime;
|
||||
|
||||
/**
|
||||
* 通知范围
|
||||
*/
|
||||
private Integer noticeScope;
|
||||
|
||||
/**
|
||||
* 通知用户
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> noticeUsers;
|
||||
}
|
@@ -66,4 +66,10 @@ public class UserQuery implements Serializable {
|
||||
*/
|
||||
@Schema(description = "部门 ID", example = "1")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户 IDS
|
||||
*/
|
||||
@Schema(description = "用户 ID数组",example = "[1,2,3]")
|
||||
private List<Long> userIds;
|
||||
}
|
||||
|
@@ -19,12 +19,14 @@ package top.continew.admin.system.model.req;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Future;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import top.continew.starter.extension.crud.model.req.BaseReq;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建或修改公告信息
|
||||
@@ -74,4 +76,17 @@ public class NoticeReq extends BaseReq {
|
||||
@Schema(description = "终止时间", example = "2023-08-08 23:59:59", type = "string")
|
||||
@Future(message = "终止时间必须是未来时间")
|
||||
private LocalDateTime terminateTime;
|
||||
|
||||
/**
|
||||
* 通知范围
|
||||
*/
|
||||
@Schema(description = "通知范围(1.所有人 2.指定用户)",example = "1")
|
||||
@NotNull(message = "通知范围不能为空")
|
||||
private Integer noticeScope;
|
||||
|
||||
/**
|
||||
* 指定用户
|
||||
*/
|
||||
@Schema(description = "指定用户",example = "[1,2,3]")
|
||||
private List<String> noticeUsers;
|
||||
}
|
@@ -24,6 +24,7 @@ import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告详情信息
|
||||
@@ -73,4 +74,16 @@ public class NoticeDetailResp extends BaseDetailResp {
|
||||
@Schema(description = "终止时间", example = "2023-08-08 23:59:59", type = "string")
|
||||
@ExcelProperty(value = "终止时间")
|
||||
private LocalDateTime terminateTime;
|
||||
|
||||
/**
|
||||
* 通知范围
|
||||
*/
|
||||
@Schema(description = "通知范围(1.所有人 2.指定用户)",example = "1")
|
||||
private Integer noticeScope;
|
||||
|
||||
/**
|
||||
* 指定用户
|
||||
*/
|
||||
@Schema(description = "指定用户",example = "[1,2,3]")
|
||||
private List<String> noticeUsers;
|
||||
}
|
@@ -23,6 +23,7 @@ import top.continew.starter.extension.crud.model.resp.BaseResp;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告信息
|
||||
@@ -70,4 +71,17 @@ public class NoticeResp extends BaseResp {
|
||||
public NoticeStatusEnum getStatus() {
|
||||
return NoticeStatusEnum.getStatus(effectiveTime, terminateTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通知范围
|
||||
*/
|
||||
@Schema(description = "通知范围(1.所有人 2.指定用户)",example = "1")
|
||||
private Integer noticeScope;
|
||||
|
||||
/**
|
||||
* 指定用户
|
||||
*/
|
||||
@Schema(description = "指定用户",example = "[1,2,3]")
|
||||
private List<String> noticeUsers;
|
||||
}
|
@@ -18,6 +18,7 @@ package top.continew.admin.system.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.continew.admin.common.context.UserContextHolder;
|
||||
import top.continew.admin.system.mapper.NoticeMapper;
|
||||
import top.continew.admin.system.model.entity.NoticeDO;
|
||||
import top.continew.admin.system.model.query.NoticeQuery;
|
||||
@@ -42,6 +43,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, NoticeDO, N
|
||||
|
||||
@Override
|
||||
public List<DashboardNoticeResp> listDashboard() {
|
||||
return baseMapper.selectDashboardList();
|
||||
Long userId = UserContextHolder.isAdmin()? null: UserContextHolder.getUserId();
|
||||
return baseMapper.selectDashboardList(userId);
|
||||
}
|
||||
}
|
@@ -126,6 +126,13 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
return pageResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserResp> list(UserQuery query, SortQuery sortQuery) {
|
||||
QueryWrapper<UserDO> queryWrapper = this.buildQueryWrapper(query);
|
||||
List<UserDetailResp> entityList = baseMapper.selectUserList(queryWrapper);
|
||||
return BeanUtil.copyToList(entityList, UserResp.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long add(UserDO user) {
|
||||
user.setStatus(DisEnableStatusEnum.ENABLE);
|
||||
@@ -488,6 +495,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
DisEnableStatusEnum status = query.getStatus();
|
||||
List<Date> createTimeList = query.getCreateTime();
|
||||
Long deptId = query.getDeptId();
|
||||
List<Long> userIdList = query.getUserIds();
|
||||
return new QueryWrapper<UserDO>().and(StrUtil.isNotBlank(description), q -> q.like("t1.username", description)
|
||||
.or()
|
||||
.like("t1.nickname", description)
|
||||
@@ -503,7 +511,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
.collect(Collectors.toList());
|
||||
deptIdList.add(deptId);
|
||||
q.in("t1.dept_id", deptIdList);
|
||||
});
|
||||
}).in(CollUtil.isNotEmpty(userIdList),"t1.id", userIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -5,11 +5,27 @@
|
||||
<select id="selectDashboardList"
|
||||
resultType="top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp">
|
||||
SELECT
|
||||
id, title, type
|
||||
FROM sys_notice
|
||||
WHERE (effective_time IS NULL OR NOW() > effective_time)
|
||||
AND (terminate_time IS NULL OR terminate_time > NOW())
|
||||
ORDER BY sort ASC, effective_time DESC
|
||||
LIMIT 5
|
||||
id,
|
||||
title,
|
||||
type
|
||||
FROM
|
||||
sys_notice
|
||||
WHERE
|
||||
( effective_time IS NULL OR NOW() > effective_time )
|
||||
AND (
|
||||
terminate_time IS NULL
|
||||
OR terminate_time > NOW())
|
||||
<if test="userId != null">
|
||||
AND ( notice_scope = 1
|
||||
OR (
|
||||
notice_scope = 2 AND
|
||||
<!--转化为字符串类型,因为存储的也是字符串类型-->
|
||||
JSON_EXTRACT(notice_users, "$[0]") = CAST(#{userId} AS CHAR)
|
||||
))
|
||||
</if>
|
||||
ORDER BY
|
||||
sort ASC,
|
||||
effective_time DESC
|
||||
LIMIT 5;
|
||||
</select>
|
||||
</mapper>
|
@@ -43,10 +43,12 @@ import top.continew.starter.core.util.validate.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.controller.BaseController;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
|
||||
import top.continew.starter.extension.crud.util.ValidateGroup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户管理 API
|
||||
@@ -63,6 +65,11 @@ public class UserController extends BaseController<UserService, UserResp, UserDe
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@Override
|
||||
public List<UserResp> list(UserQuery query, SortQuery sortQuery) {
|
||||
return super.list(query, sortQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseIdResp<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody UserReq req) {
|
||||
String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword()));
|
||||
|
@@ -5,6 +5,8 @@ databaseChangeLog:
|
||||
file: db/changelog/mysql/continew-admin_column.sql
|
||||
- include:
|
||||
file: db/changelog/mysql/continew-admin_data.sql
|
||||
- include:
|
||||
file: db/changelog/mysql/continew-admin_change_v3.4.0.sql
|
||||
# PostgreSQL
|
||||
# - include:
|
||||
# file: db/changelog/postgresql/continew-admin_table.sql
|
||||
|
@@ -0,0 +1,6 @@
|
||||
-- 消息通知表 新增通知范围 和 通知用户两个字段
|
||||
START TRANSACTION;
|
||||
ALTER TABLE sys_notice
|
||||
ADD COLUMN notice_scope INT NOT NULL COMMENT '通知范围' AFTER terminate_time,
|
||||
ADD COLUMN notice_users JSON DEFAULT NULL COMMENT '通知用户' AFTER notice_scope;
|
||||
COMMIT;
|
Reference in New Issue
Block a user