✨作者主页:IT研究室✨
个人简介:曾从事计算机专业培训教学,擅长Java、Python、微信小程序、Golang、安卓Android等。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。
☑文末获取源码☑
精彩专栏推荐⬇⬇⬇
Java项目
Python项目
安卓项目
微信小程序项目
@RestController
@RequestMapping("/abandons")
public class AbandonController {
@Autowired
private AbandonMapper abandonMapper;
@Autowired
private AbandonService abandonService;
@Autowired
private UserMapper userMapper;
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private ApprovalMapper approvalMapper;
//用get请求查询数据库信息
@GetMapping
public List findAll(){
return abandonMapper.findAll();//查询所有数据
}
//用post请求对数据库数据进行增加和修改
@PostMapping
public Integer save(@RequestBody Abandon abandon){
abandon.setApplierId(userMapper.selectId(abandon.getApplierName()));
abandon.setDeviceId(deviceMapper.selectByNumber(abandon.getDeviceNumber()));
return abandonService.save(abandon);//往数据库插入或更新数据
}
//按照审批状态分页查询
@GetMapping("/page")
public Map findStatus(@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam String isApprove){
pageNum = (pageNum - 1) * pageSize;
Integer total = abandonMapper.selectTotal(isApprove);
List data = abandonMapper.selectPage(pageNum,pageSize,isApprove);
for(Abandon abandon : data){
abandon.setDeviceNumber(deviceMapper.selectById(abandon.getDeviceId()));
abandon.setApplierName(userMapper.selectName(abandon.getApplierId()));
}
Map res = new HashMap<>();
res.put("data",data);
res.put("total",total);
return res;
}
//用post请求对数据库数据进行增加和修改
@PostMapping("/{id}")
public int updateApprove(@PathVariable Integer id){
Integer approvalId = approvalMapper.findLatest();
abandonMapper.updateApproval(id,approvalId);
return abandonMapper.updateApprove(id);//往数据库插入或更新数据
}
@GetMapping("/{id}")
public List selectById(@PathVariable Integer id){
List abandons = abandonMapper.selectById(id);
for(Abandon abandon : abandons){
abandon.setDeviceNumber(deviceMapper.selectById(abandon.getDeviceId()));
}
return abandons;
}
}
大家可以帮忙点赞、收藏、关注、评论啦~
源码获取:私信我