feat: 实现团队负责人历史审批接口
This commit is contained in:
parent
5c77f66b0a
commit
caf903114e
@ -1,14 +1,15 @@
|
||||
package github.benjamin.equipreservebackend.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.dto.LeaderApprovalDTO;
|
||||
import github.benjamin.equipreservebackend.entity.Approval;
|
||||
import github.benjamin.equipreservebackend.response.ResponseResult;
|
||||
import github.benjamin.equipreservebackend.service.ApprovalService;
|
||||
import github.benjamin.equipreservebackend.vo.LeaderApprovalVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/approval")
|
||||
@ -24,4 +25,15 @@ public class ApprovalController {
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('LEADER')")
|
||||
@GetMapping("/leader/{id}")
|
||||
public ResponseResult<IPage<LeaderApprovalVO>> getLeaderApproval(@PathVariable("id") Long id,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String applicantName,
|
||||
@RequestParam(required = false) String deviceName) {
|
||||
Page<Approval> pageRequest = new Page<>(page, size);
|
||||
return ResponseResult.success(approvalService.getLeaderApproval(pageRequest, id, applicantName, deviceName));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,19 @@
|
||||
package github.benjamin.equipreservebackend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.entity.Approval;
|
||||
import github.benjamin.equipreservebackend.vo.LeaderApprovalVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ApprovalMapper extends BaseMapper<Approval> {
|
||||
|
||||
IPage<LeaderApprovalVO> getLeaderApproval(Page<?> page,
|
||||
@Param("approverId") Long approverId,
|
||||
@Param("applicantName") String applicantName,
|
||||
@Param("deviceName") String deviceName);
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
package github.benjamin.equipreservebackend.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.dto.LeaderApprovalDTO;
|
||||
import github.benjamin.equipreservebackend.entity.Approval;
|
||||
import github.benjamin.equipreservebackend.vo.LeaderApprovalVO;
|
||||
|
||||
public interface ApprovalService {
|
||||
void addApproval(LeaderApprovalDTO dto);
|
||||
|
||||
IPage<LeaderApprovalVO> getLeaderApproval(Page<Approval> pageRequest, Long userId, String applicantName, String deviceName);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package github.benjamin.equipreservebackend.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import github.benjamin.equipreservebackend.constant.ApprovalStep;
|
||||
import github.benjamin.equipreservebackend.constant.ReservationStatus;
|
||||
import github.benjamin.equipreservebackend.dto.LeaderApprovalDTO;
|
||||
@ -9,6 +12,7 @@ import github.benjamin.equipreservebackend.entity.Reservation;
|
||||
import github.benjamin.equipreservebackend.mapper.ApprovalMapper;
|
||||
import github.benjamin.equipreservebackend.mapper.ReservationMapper;
|
||||
import github.benjamin.equipreservebackend.service.ApprovalService;
|
||||
import github.benjamin.equipreservebackend.vo.LeaderApprovalVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -33,4 +37,9 @@ public class ApprovalServiceImpl implements ApprovalService {
|
||||
.eq(Reservation::getId, dto.getReservationId())
|
||||
.set(Reservation::getStatus, dto.getIsApprove() ? ReservationStatus.PENDING_DEVICE_ADMIN : ReservationStatus.REJECTED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<LeaderApprovalVO> getLeaderApproval(Page<Approval> pageRequest, Long userId, String applicantName, String deviceName) {
|
||||
return approvalMapper.getLeaderApproval(pageRequest, userId, applicantName, deviceName);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package github.benjamin.equipreservebackend.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class LeaderApprovalVO {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long approvalId;
|
||||
private String applicantName;
|
||||
private String applicantTeam;
|
||||
private String applicantContact;
|
||||
private String deviceName;
|
||||
private LocalDate startTime;
|
||||
private LocalDate endTime;
|
||||
private Integer decision;
|
||||
|
||||
}
|
@ -13,3 +13,7 @@ jwt:
|
||||
equip-reserve:
|
||||
device-days: 7
|
||||
allowed-origins: http://localhost:5173
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
22
src/main/resources/mapper/ApprovalMapper.xml
Normal file
22
src/main/resources/mapper/ApprovalMapper.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="github.benjamin.equipreservebackend.mapper.ApprovalMapper">
|
||||
|
||||
<select id="getLeaderApproval" resultType="github.benjamin.equipreservebackend.vo.LeaderApprovalVO">
|
||||
SELECT a.id as approvalId, r.applicant_name, r.applicant_team, r.applicant_contact, d.name as deviceName, r.start_time, r.end_time, a.decision
|
||||
FROM approvals a
|
||||
LEFT JOIN reservations r ON a.reservation_id = r.id
|
||||
LEFT JOIN devices d ON r.device_id = d.id
|
||||
WHERE a.approver_id = #{approverId}
|
||||
<if test="applicantName != null and applicantName != ''">
|
||||
AND r.applicant_name LIKE CONCAT('%', #{applicantName}, '%')
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
AND d.name LIKE CONCAT('%', #{deviceName}, '%')
|
||||
</if>
|
||||
ORDER BY a.timestamp DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user