zhangfeng
2023-01-06 c128ed33c2447e8daea89d70795098748bd5b2af
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.gkhy.safePlatform.equipment.controller;
 
 
import com.alibaba.fastjson.JSONObject;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.equipment.model.dto.req.MaterialReceiveRecordsBaseReq;
import com.gkhy.safePlatform.equipment.model.dto.req.MaterialReceiveRecordsQuery;
import com.gkhy.safePlatform.equipment.model.dto.resp.MaterialReceiveRecordsBaseDto;
import com.gkhy.safePlatform.equipment.service.MaterialReceiveRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
 
@RestController
@RequestMapping("/equipment/material/record")
public class SafeMaterialReceiveRecordsController {
    @Autowired
    private MaterialReceiveRecordsService materialReceiveRecordsService;
 
    @RequestMapping("page/list")
    public SearchResultVO<List<MaterialReceiveRecordsBaseDto>> list(Authentication authentication, @RequestBody PageQuery<MaterialReceiveRecordsQuery> pageQuery){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        PageUtils.checkCheck(pageQuery);
        return materialReceiveRecordsService.listByPage(currentUser,pageQuery);
    }
    /**
     * 归还物资
     */
    @RequestMapping("revert")
    public ResultVO revertMaterial(Authentication authentication, @Validated @RequestBody MaterialReceiveRecordsBaseReq req){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        materialReceiveRecordsService.revertMaterial(currentUser,req);
        return new ResultVO(ResultCodes.OK);
    }
    /**
     * 获取单条记录
     */
    @RequestMapping("queryById")
    public ResultVO queryById(Authentication authentication, @RequestBody JSONObject jsonObject){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        Long id = jsonObject.getLong("id");
        MaterialReceiveRecordsBaseDto materialReceiveRecordsBaseDto = materialReceiveRecordsService.queryById(currentUser,id);
        return new ResultVO(ResultCodes.OK,materialReceiveRecordsBaseDto);
    }
}