Merge branch 'dev-hzm' into dev
# Conflicts: # agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/user/service/ISysUserService.java # agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/user/service/impl/SysUserServiceImpl.java
This commit is contained in:
commit
f0633dfcea
@ -28,4 +28,12 @@ public enum NoticeTypeEnum implements DictionaryEnum<Integer> {
|
||||
private final String desc;
|
||||
private final String cssTag;
|
||||
|
||||
public static Integer getDescByValue(Integer value) {
|
||||
for (NoticeTypeEnum item : values()) {
|
||||
if (item.value.equals(value)) {
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,4 +25,13 @@ public enum StatusEnum implements DictionaryEnum<Integer> {
|
||||
private final String desc;
|
||||
private final String cssTag;
|
||||
|
||||
public static Integer getDescByValue(Integer value) {
|
||||
for (StatusEnum item : StatusEnum.values()) {
|
||||
if (item.value.equals(value)) {
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class SysNoticeController {
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@GetMapping
|
||||
@GetMapping("/list")
|
||||
public PageR<NoticeVO> list(NoticeQuery query) {
|
||||
PageR<NoticeVO> page = sysNoticeService.getNoticeList(query);
|
||||
return page;
|
||||
@ -57,7 +57,7 @@ public class SysNoticeController {
|
||||
/**
|
||||
* 新增通知公告
|
||||
*/
|
||||
@PostMapping
|
||||
@PostMapping("/create")
|
||||
public R<Void> add(@RequestBody NoticeAddDTO addDTO) {
|
||||
sysNoticeService.addNotice(addDTO);
|
||||
return R.ok();
|
||||
@ -66,8 +66,8 @@ public class SysNoticeController {
|
||||
/**
|
||||
* 修改通知公告
|
||||
*/
|
||||
@PutMapping("/{noticeId}")
|
||||
public R<Void> edit(@PathVariable Long noticeId, @RequestBody NoticeUpdateDTO updateDTO) {
|
||||
@PostMapping("/update/{noticeId}")
|
||||
public R<Void> edit(@PathVariable("noticeId") Long noticeId, @RequestBody NoticeUpdateDTO updateDTO) {
|
||||
updateDTO.setNoticeId(noticeId);
|
||||
sysNoticeService.updateNotice(updateDTO);
|
||||
return R.ok();
|
||||
@ -76,8 +76,8 @@ public class SysNoticeController {
|
||||
/**
|
||||
* 删除通知公告
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R<Void> remove(@RequestParam List<Integer> noticeIds) {
|
||||
@PostMapping("/del")
|
||||
public R<Void> remove(@RequestBody List<Integer> noticeIds) {
|
||||
sysNoticeService.deleteNotice(noticeIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -15,16 +15,26 @@ import com.agileboot.system.notice.dto.NoticeVO;
|
||||
import com.agileboot.system.notice.entity.SysNotice;
|
||||
import com.agileboot.system.notice.mapper.SysNoticeMapper;
|
||||
import com.agileboot.system.notice.service.ISysNoticeService;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageR<NoticeVO> getNoticeList(NoticeQuery query) {
|
||||
QueryWrapper<SysNotice> queryWrapper = new QueryWrapper<SysNotice>()
|
||||
@ -33,6 +43,14 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||
.eq("n.deleted", 0)
|
||||
.like(StrUtil.isNotEmpty(query.getCreatorName()), "u.username", query.getCreatorName());
|
||||
Page<SysNotice> page = this.baseMapper.getNoticeList(query.toPage(), queryWrapper);
|
||||
|
||||
Set<Long> userIds = page.getRecords().stream().map(SysNotice::getCreateBy).collect(Collectors.toSet());
|
||||
Map<Long, String> idNameMap = userService.geIdNameByIds(userIds);
|
||||
page.getRecords().forEach(sysNotice -> {
|
||||
Long creatorId = sysNotice.getCreateBy();
|
||||
String creatorName = idNameMap.get(creatorId);
|
||||
sysNotice.setSearchValue(creatorName);
|
||||
});
|
||||
IPage<NoticeVO> convert = page.convert(NoticeVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class SysPostController {
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@PutMapping
|
||||
@PostMapping("/update")
|
||||
public R<Void> edit(@RequestBody UpdatePostDTO updateCommand) {
|
||||
sysPostService.updatePost(updateCommand);
|
||||
return R.ok();
|
||||
@ -81,9 +81,10 @@ public class SysPostController {
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R<Void> remove(@RequestParam @NotNull @NotEmpty List<Long> ids) {
|
||||
@PostMapping("/del")
|
||||
public R<Void> remove(@RequestBody @NotNull @NotEmpty List<Long> ids) {
|
||||
sysPostService.deletePost(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,8 +11,7 @@ import com.agileboot.system.post.dto.UpdatePostDTO;
|
||||
import com.agileboot.system.post.entity.SysPost;
|
||||
import com.agileboot.system.post.mapper.SysPostMapper;
|
||||
import com.agileboot.system.post.service.ISysPostService;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.agileboot.system.user.mapper.SysUserMapper;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -28,13 +27,20 @@ import java.util.stream.Collectors;
|
||||
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService {
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public PostVO getPostInfo(Long postId) {
|
||||
// sysUserMapper.getPostInfo();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageR<PostVO> getPostList(PostQuery query) {
|
||||
Page<SysPost> page = super.page(query.toPage(), query.toQueryWrapper());
|
||||
@ -90,11 +96,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|
||||
@Override
|
||||
public void deletePost(List<Long> ids) {
|
||||
// 检测职位是否分配给用户
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = Wrappers.lambdaQuery(SysUser.class)
|
||||
.in(SysUser::getPostId, ids);
|
||||
if (sysUserMapper.exists(queryWrapper)) {
|
||||
throw new BizException(ErrorCode.Business.POST_ALREADY_ASSIGNED_TO_USER_CAN_NOT_BE_DELETED);
|
||||
}
|
||||
sysUserService.checkAnyPostIsAssignedToUser(ids);
|
||||
super.removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ISysUserService {
|
||||
@ -40,4 +41,8 @@ public interface ISysUserService {
|
||||
void deleteBatchRoleId(List<Long> userIds);
|
||||
|
||||
boolean checkDeptAssignedToUsers(Long deptId);
|
||||
|
||||
void checkAnyPostIsAssignedToUser(List<Long> ids);
|
||||
|
||||
Map<Long, String> geIdNameByIds(Set<Long> userIds);
|
||||
}
|
||||
|
||||
@ -24,7 +24,9 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
||||
@ -198,4 +200,28 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
.eq(SysUser::getDeptId, deptId);
|
||||
return super.exists(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测职位是否分配给用户
|
||||
*/
|
||||
@Override
|
||||
public void checkAnyPostIsAssignedToUser(List<Long> ids) {
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = Wrappers.lambdaQuery(SysUser.class)
|
||||
.in(SysUser::getPostId, ids);
|
||||
if (super.exists(queryWrapper)) {
|
||||
throw new BizException(ErrorCode.Business.POST_ALREADY_ASSIGNED_TO_USER_CAN_NOT_BE_DELETED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> geIdNameByIds(Set<Long> userIds) {
|
||||
if (userIds.isEmpty()) {
|
||||
return Map.of();
|
||||
}
|
||||
return super.list(Wrappers.lambdaQuery(SysUser.class)
|
||||
.select(SysUser::getUserId, SysUser::getUsername)
|
||||
.in(SysUser::getUserId, userIds))
|
||||
.stream()
|
||||
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getUsername));
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public class NoticeAddDTO {
|
||||
@Size(max = 50, message = "公告标题不能超过50个字符")
|
||||
protected String noticeTitle;
|
||||
|
||||
protected String noticeType;
|
||||
protected Integer noticeType;
|
||||
|
||||
/**
|
||||
* 想要支持富文本的话, 避免Xss过滤的话, 请加上@JsonDeserialize(using = StringDeserializer.class) 注解
|
||||
@ -26,6 +26,6 @@ public class NoticeAddDTO {
|
||||
@JsonDeserialize(using = StringDeserializer.class)
|
||||
protected String noticeContent;
|
||||
|
||||
protected String status;
|
||||
protected Integer status;
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ public class NoticeVO {
|
||||
this.noticeContent = entity.getNoticeContent();
|
||||
this.status = entity.getStatus();
|
||||
this.createTime = entity.getCreateTime();
|
||||
this.creatorName = entity.getSearchValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
package com.agileboot.system.post.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.system.post.entity.SysPost;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@ -14,9 +19,15 @@ public class PostQuery extends PageQuery<SysPost> {
|
||||
private String postCode;
|
||||
private String postName;
|
||||
private Integer status;
|
||||
private LocalDate beginTime;
|
||||
private LocalDate endTime;
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper<SysPost> toQueryWrapper() {
|
||||
return null;
|
||||
return Wrappers.lambdaQuery(SysPost.class)
|
||||
.like(StrUtil.isNotBlank(postCode), SysPost::getPostCode, postCode)
|
||||
.like(StrUtil.isNotBlank(postName), SysPost::getPostName, postName)
|
||||
.eq(Objects.nonNull(status), SysPost::getStatus, status)
|
||||
.between(Objects.nonNull(beginTime) && Objects.nonNull(endTime), SysPost::getCreateTime, beginTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user