1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Add affair management

This commit is contained in:
assina045
2023-05-06 03:54:36 +08:00
parent 5a1d44bf66
commit c944c20f2d
12 changed files with 678 additions and 3 deletions

View File

@@ -1,7 +1,12 @@
package com.cfive.pinnacle.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cfive.pinnacle.entity.Affair;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.IAffairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
@@ -11,8 +16,57 @@ import org.springframework.web.bind.annotation.RestController;
* @author FatttSnake
* @since 2023-04-30
*/
@CrossOrigin
@RestController
@RequestMapping("/affair")
public class AffairController {
@Autowired
IAffairService affairService;
@PostMapping("/add")
public ResponseResult addAffair(@RequestBody Affair affair){
return ResponseResult.build(ResponseCode.DATABASE_SAVE_OK,"success",affairService.save(affair));
}
@GetMapping("/NotApproved")
public ResponseResult select_NotApproved(){
LambdaQueryWrapper<Affair> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Affair::getStatus, 0);
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", affairService.list(wrapper));
}
@GetMapping("/Approved")
public ResponseResult select_Approved(){
LambdaQueryWrapper<Affair> wrapper2 =new LambdaQueryWrapper<>();
wrapper2.ne(Affair::getStatus,0);
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK,"success",affairService.list(wrapper2)) ;
}
@PutMapping("/yes")
public ResponseResult updateAffair_yes(@RequestBody Affair affair){
System.out.println(affair);
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK,"success",affairService.updateAffair_Yes(affair));
//审批同意
}
@PutMapping("/no")
public ResponseResult updateAffair_No(@RequestBody Affair affair){
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK,"success",affairService.updateAffair_No(affair));
//审批驳回
}
@DeleteMapping("/{id}")
public ResponseResult deleteAffair_Apprioved(@PathVariable Long id){
System.out.println("affair");
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK,"success",affairService.removeById(id));
//删除已审批事务
}
}

View File

@@ -10,6 +10,7 @@ import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -72,6 +73,7 @@ public class Affair implements Serializable {
* 创建时间
*/
@TableField("create_time")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",timezone = "UTC")
private LocalDateTime createTime;
/**

View File

@@ -2,7 +2,9 @@ package com.cfive.pinnacle.mapper;
import com.cfive.pinnacle.entity.Affair;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* <p>
@@ -15,4 +17,31 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AffairMapper extends BaseMapper<Affair> {
@Insert("insert into t_affair(title,type_id,content,applicant_id,inspector_id,create_time) values(#{title},#{typeId},#{content},#{applicantId},#{inspectorId},#{createTime})")
int insertAffair(Affair affair);
//添加事务
//不添加事务的状态(affairsStatus),当事务进行添加时,添加的状态默认为'未审批'
@Delete("delete from t_affair where id=#{id}")
int deleteAffairs(Affair affair);
//根据id撤回新建的事务在新建事务时会再进行一次确定
// (是否撤回,当用户撤回新建的事务时根据新建的事务的id删除该条事务在数据库中的信息)
@Update("update t_affair set status=1 where id=#{id}")
int updateAffairs_Yes(Affair affair);
//管理员权限--->修改事务的状态(AffairsStatus)--->达到审批的效果
//同意
@Update("update t_affair set Status=2 where id=#{id}" )
int updateAffairs_NO(Affair affair);
//不同意
@Select("SELECT * from t_affair where status=0 ")
@ResultType(Affair.class)
List<Affair> selectAffairs_NotApproved();
}

View File

@@ -13,4 +13,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IAffairService extends IService<Affair> {
int insertAffair(Affair affair);
int updateAffair_Yes(Affair affair);
int updateAffair_No(Affair affair);
int deleteAffair_ApprovedByID(Affair affair);
}

View File

@@ -4,6 +4,7 @@ import com.cfive.pinnacle.entity.Affair;
import com.cfive.pinnacle.mapper.AffairMapper;
import com.cfive.pinnacle.service.IAffairService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@@ -17,4 +18,26 @@ import org.springframework.stereotype.Service;
@Service
public class AffairServiceImpl extends ServiceImpl<AffairMapper, Affair> implements IAffairService {
@Autowired
private AffairMapper affairMapper;
@Override
public int insertAffair(Affair affair) {
return affairMapper.insertAffair(affair);
}
public int updateAffair_Yes(Affair affair) {
return affairMapper.updateAffairs_Yes(affair);
}
public int updateAffair_No(Affair affair) {
return affairMapper.updateAffairs_NO(affair);
}
@Override
public int deleteAffair_ApprovedByID(Affair affair) {
return affairMapper.deleteAffairs(affair);
}
}