mirror of
https://github.com/suyiiyii/SIMS.git
synced 2025-06-03 12:56:10 +08:00
1. 普通成员可以向管理员申请撤销某一个奖惩记录
2. 管理员可查看所有成员的申请撤销记录,同样需分页展示
This commit is contained in:
parent
5308e05c80
commit
a2659cb192
@ -1,13 +1,28 @@
|
|||||||
package top.suyiiyii.sims.controller;
|
package top.suyiiyii.sims.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.modelmapper.ModelMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import top.suyiiyii.sims.common.AuthAccess;
|
||||||
|
import top.suyiiyii.sims.common.Result;
|
||||||
|
import top.suyiiyii.sims.dto.CommonResponse;
|
||||||
|
import top.suyiiyii.sims.dto.RecordDto;
|
||||||
|
import top.suyiiyii.sims.dto.RevokeRequestDto;
|
||||||
|
import top.suyiiyii.sims.entity.RevokeRequest;
|
||||||
|
import top.suyiiyii.sims.exception.ServiceException;
|
||||||
|
import top.suyiiyii.sims.service.CategoryService;
|
||||||
|
import top.suyiiyii.sims.service.NotificationService;
|
||||||
|
import top.suyiiyii.sims.service.RecordService;
|
||||||
import top.suyiiyii.sims.service.RevokedService;
|
import top.suyiiyii.sims.service.RevokedService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author tortoise
|
* @Author tortoise
|
||||||
* @Date 2024/9/6 10:03
|
* @Date 2024/9/6 10:03
|
||||||
@ -22,9 +37,55 @@ import top.suyiiyii.sims.service.RevokedService;
|
|||||||
public class RevokedController {
|
public class RevokedController {
|
||||||
@Autowired
|
@Autowired
|
||||||
RevokedService revokedService;
|
RevokedService revokedService;
|
||||||
|
@Autowired
|
||||||
|
ModelMapper modelMapper;
|
||||||
|
@Autowired
|
||||||
|
NotificationService notificationService;
|
||||||
|
@Autowired
|
||||||
|
CategoryService categoryService;
|
||||||
|
@Autowired
|
||||||
|
RecordService recordService;
|
||||||
//TODO 普通成员向管理员申请撤销
|
//TODO 普通成员向管理员申请撤销
|
||||||
|
@AuthAccess(allowRoles = {"user"})
|
||||||
|
@Operation(summary = "成员申请撤销")
|
||||||
|
@PostMapping("/revoked")
|
||||||
|
public Result<CommonResponse> revoked(@RequestBody Request request) {
|
||||||
|
|
||||||
|
if(request.getReason().isBlank()) {
|
||||||
|
throw new ServiceException("撤销原因不能为空");
|
||||||
|
}
|
||||||
|
RevokeRequest revokeRequest = modelMapper.map(request, RevokeRequest.class);
|
||||||
|
|
||||||
|
revokedService.addRevokeRequest(revokeRequest);
|
||||||
|
//发送通知给管理员
|
||||||
|
notificationService.addNotification(revokeRequest);
|
||||||
|
return Result.success(CommonResponse.factory("申请成功"));
|
||||||
|
}
|
||||||
//TODO 管理员查看所有撤销申请
|
//TODO 管理员查看所有撤销申请
|
||||||
|
@AuthAccess(allowRoles = {"admin"})
|
||||||
|
@Operation(summary = "管理员查看所有撤销申请")
|
||||||
|
@GetMapping("/revoked")
|
||||||
|
public Result<List<RevokeRequestDto>> revoked(
|
||||||
|
@RequestParam(defaultValue = "0") int page,
|
||||||
|
@RequestParam(defaultValue = "10") int size) {
|
||||||
|
List<RevokeRequest> revokeRequests = revokedService.getAll(page, size);
|
||||||
|
List<RevokeRequestDto> revokeRequestDtos = new ArrayList<>();
|
||||||
|
for (RevokeRequest revokeRequest : revokeRequests) {
|
||||||
|
RevokeRequestDto revokeRequestDto = modelMapper.map(revokeRequest, RevokeRequestDto.class);
|
||||||
|
revokeRequestDto.setCategoryName(categoryService.getCategoryName(recordService.getCategoryIdById(revokeRequest.getRecordId())));
|
||||||
|
revokeRequestDto.setSubCategoryName(categoryService.getsubCategoryName(recordService.getCategoryIdById(revokeRequest.getRecordId())));
|
||||||
|
revokeRequestDtos.add(revokeRequestDto);
|
||||||
|
}
|
||||||
|
return Result.success(revokeRequestDtos);
|
||||||
|
}
|
||||||
//TODO 管理员可以撤销某一成员的奖励或惩罚记录,需填写撤销原因,撤销备注
|
//TODO 管理员可以撤销某一成员的奖励或惩罚记录,需填写撤销原因,撤销备注
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Request {
|
||||||
|
private Integer userId;
|
||||||
|
private Integer recordId;
|
||||||
|
private String reason;
|
||||||
|
private Long requestTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
32
src/main/java/top/suyiiyii/sims/dto/RevokeRequestDto.java
Normal file
32
src/main/java/top/suyiiyii/sims/dto/RevokeRequestDto.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package top.suyiiyii.sims.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author tortoise
|
||||||
|
* @Date 2024/9/8 21:34
|
||||||
|
* @PackageName:top.suyiiyii.sims.dto
|
||||||
|
* @ClassName: RevokeRequestDto
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RevokeRequestDto {
|
||||||
|
private Integer id;
|
||||||
|
private String categoryName;
|
||||||
|
private String subCategoryName;
|
||||||
|
private Integer userId;
|
||||||
|
private String reason;
|
||||||
|
private Long requestTime;
|
||||||
|
private String status;
|
||||||
|
//处理时间
|
||||||
|
private Long handleTime;
|
||||||
|
private String adminRemark;
|
||||||
|
|
||||||
|
}
|
@ -27,7 +27,7 @@ public class Notification {
|
|||||||
private String title;
|
private String title;
|
||||||
private String content;
|
private String content;
|
||||||
private Integer senderId;
|
private Integer senderId;
|
||||||
private LocalDateTime createdAt;
|
private Long createdAt;
|
||||||
private String status;
|
private String status;
|
||||||
private String type;
|
private String type;
|
||||||
private Integer targetUserId;
|
private Integer targetUserId;
|
||||||
|
@ -27,10 +27,10 @@ public class RevokeRequest {
|
|||||||
private Integer recordId;
|
private Integer recordId;
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
private String reason;
|
private String reason;
|
||||||
private LocalDateTime requestTime;
|
private Long requestTime;
|
||||||
private String status;
|
private String status;
|
||||||
//处理时间
|
//处理时间
|
||||||
private LocalDateTime handleTime;
|
private Long handleTime;
|
||||||
private String adminRemark;
|
private String adminRemark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class RevokedRecord {
|
|||||||
// 撤销原因
|
// 撤销原因
|
||||||
private String reason;
|
private String reason;
|
||||||
// 撤销时间
|
// 撤销时间
|
||||||
private LocalDateTime revokedTime;
|
private Long revokedTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package top.suyiiyii.sims.mapper;
|
package top.suyiiyii.sims.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import top.suyiiyii.sims.entity.RevokedRecord;
|
import top.suyiiyii.sims.entity.Notification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author tortoise
|
* @Author tortoise
|
||||||
* @Date 2024/9/6 10:04
|
* @Date 2024/9/8 20:50
|
||||||
* @PackageName:top.suyiiyii.sims.mapper
|
* @PackageName:top.suyiiyii.sims.mapper
|
||||||
* @ClassName: MpRevRecordMapper
|
* @ClassName: MpNotificationMapper
|
||||||
* @Description: TODO
|
* @Description: TODO
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
public interface MpRevRecordMapper extends BaseMapper<RevokedRecord> {
|
public interface MpNotificationMapper extends BaseMapper<Notification> {
|
||||||
}
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package top.suyiiyii.sims.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import top.suyiiyii.sims.entity.RevokeRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author tortoise
|
||||||
|
* @Date 2024/9/6 10:04
|
||||||
|
* @PackageName:top.suyiiyii.sims.mapper
|
||||||
|
* @ClassName: MpRevRequestMapper
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface MpRevRequestMapper extends BaseMapper<RevokeRequest> {
|
||||||
|
@Select("select * from revoke_request limit #{page},#{size}")
|
||||||
|
List<RevokeRequest> selectList(int page, int size);
|
||||||
|
}
|
@ -81,4 +81,6 @@ public interface RecordMapper {
|
|||||||
List<Record> getRecordsById(int page, int size, Integer sid);
|
List<Record> getRecordsById(int page, int size, Integer sid);
|
||||||
@Select("SELECT id FROM record WHERE id = #{id}")
|
@Select("SELECT id FROM record WHERE id = #{id}")
|
||||||
Integer IsRecord(Integer id);
|
Integer IsRecord(Integer id);
|
||||||
|
@Select("SELECT category_id FROM record WHERE id = #{id}")
|
||||||
|
Integer getCategoryIdById(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package top.suyiiyii.sims.service;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import top.suyiiyii.sims.entity.Notification;
|
||||||
|
import top.suyiiyii.sims.entity.RevokeRequest;
|
||||||
|
import top.suyiiyii.sims.mapper.MpNotificationMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author tortoise
|
||||||
|
* @Date 2024/9/8 20:50
|
||||||
|
* @PackageName:top.suyiiyii.sims.service
|
||||||
|
* @ClassName: NotificationService
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class NotificationService {
|
||||||
|
@Autowired
|
||||||
|
MpNotificationMapper mpNotificationMapper;
|
||||||
|
public void addNotification(RevokeRequest revokeRequest) {
|
||||||
|
Notification notification = new Notification();
|
||||||
|
notification.setSenderId(revokeRequest.getUserId());
|
||||||
|
notification.setTitle("申请撤销");
|
||||||
|
notification.setContent(revokeRequest.getReason());
|
||||||
|
notification.setType("申请");
|
||||||
|
notification.setCreatedAt(revokeRequest.getRequestTime());
|
||||||
|
notification.setStatus("未处理");
|
||||||
|
notification.setTargetUserId(-1);
|
||||||
|
mpNotificationMapper.insert(notification);
|
||||||
|
}
|
||||||
|
}
|
@ -85,4 +85,8 @@ public class RecordService {
|
|||||||
public Integer IsRecord(Integer id) {
|
public Integer IsRecord(Integer id) {
|
||||||
return recordMapper.IsRecord(id);
|
return recordMapper.IsRecord(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getCategoryIdById(Integer id) {
|
||||||
|
return recordMapper.getCategoryIdById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,10 @@ package top.suyiiyii.sims.service;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import top.suyiiyii.sims.mapper.MpRevRecordMapper;
|
import top.suyiiyii.sims.entity.RevokeRequest;
|
||||||
import top.suyiiyii.sims.mapper.RoleMapper;
|
import top.suyiiyii.sims.mapper.MpRevRequestMapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author tortoise
|
* @Author tortoise
|
||||||
@ -15,6 +17,16 @@ import top.suyiiyii.sims.mapper.RoleMapper;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class RevokedService {
|
public class RevokedService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
MpRevRecordMapper mpRevRecordMapper;
|
MpRevRequestMapper mpRevRequestMapper;
|
||||||
|
|
||||||
|
public void addRevokeRequest(RevokeRequest revokeRequest) {
|
||||||
|
revokeRequest.setStatus("待审核");
|
||||||
|
mpRevRequestMapper.insert(revokeRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
public List<RevokeRequest> getAll(int page, int size){
|
||||||
|
return mpRevRequestMapper.selectList(page,size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user