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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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.*;
import com.gkhy.safePlatform.equipment.model.dto.resp.SafeMaterialClassifyDto;
import com.gkhy.safePlatform.equipment.service.MaterialClassifyService;
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.PostMapping;
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/classify")
public class MaterialClassifyController {
    @Autowired
    private MaterialClassifyService materialClassifyService;
    /**
     * 列表
     * @return
     */
    @PostMapping(value = "/list")
    public ResultVO<List<SafeMaterialClassifyDto>> list(Authentication authentication){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return new ResultVO<>(ResultCodes.OK,materialClassifyService.list());
 
    }
    /**
     * 列表
     * @return
     */
    @PostMapping(value = "page/list")
    public SearchResultVO<List<SafeMaterialClassifyDto>> listByPage(Authentication authentication,@RequestBody PageQuery<MaterialClassifyQuery> pageQuery){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        PageUtils.checkCheck(pageQuery);
        return materialClassifyService.listByPage(currentUser,pageQuery);
 
    }
 
    /**
     * 新增
     * @return
     */
    @PostMapping(value = "save")
    public ResultVO save(Authentication authentication, @Validated @RequestBody SafeMaterialClassifyAddReq req){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return materialClassifyService.save(currentUser,req);
    }
 
    /**
     * 更新
     * @return
     */
    @PostMapping(value = "update")
    public ResultVO update(Authentication authentication, @Validated @RequestBody SafeMaterialClassifyModReq req){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        return materialClassifyService.update(currentUser,req);
    }
 
    /**
     * 逻辑删除 单条
     * @return
     */
    @PostMapping(value = "delete")
    public ResultVO delete(Authentication authentication, @RequestBody JSONObject jsonObject){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        Long id = jsonObject.getLong("id");
        return materialClassifyService.delete(currentUser,id);
    }
    /**
     * 逻辑删除-批量
     * @return
     */
//    @PostMapping(value = "batch/delete")
//    public ResultVO batchDelete(Authentication authentication, @Validated @RequestBody ParamForm paramForm){
//        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
//        return materialClassifyService.batchDelete(currentUser,paramForm);
//    }
 
    /**
     * 查询单条数据
     */
    @PostMapping(value = "queryById")
    public ResultVO<SafeMaterialClassifyDto> queryById(Authentication authentication, @RequestBody JSONObject jsonObject){
        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
        Long id = jsonObject.getLong("id");
        return new ResultVO<>(ResultCodes.OK,materialClassifyService.queryById(currentUser,id));
    }
}