yangys
2024-02-02 b82c71a3e3a97a78bd18ff598d27f3062600d22a
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
package com.qianwen.mdc.controller.plant;
 
import javax.servlet.http.HttpServletRequest;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.qianwen.mdc.common.OpResult;
import com.qianwen.mdc.dto.IdsDTO;
import com.qianwen.mdc.dto.plant.PlantDTO;
import com.qianwen.mdc.service.plant.PlantService;
import com.qianwen.mdc.vallidate.AddGroup;
import com.qianwen.mdc.vallidate.UpdateGroup;
 
/**
 * @author y_ys79
 * 厂房控制器
 */
@Validated
@RestController
@CrossOrigin
@RequestMapping(value = "/plant", method = RequestMethod.POST)
public class PlantEditController {
    @Autowired
    private PlantService plantService;
 
    public static final Logger logger = LoggerFactory.getLogger(PlantEditController.class);
    
 
    /**
     * 新增地图
     * @param token
     * @param machineDTO
     * @param request
     * @return
     */
    @PostMapping(value = "/save")
    public OpResult<Void> save(@Validated(value = {AddGroup.class}) @RequestBody PlantDTO plantDTO,HttpServletRequest request) {
        
        try {
            plantService.save(plantDTO);
        }catch(Exception ex) {
            logger.error("新增厂房异常",ex);
            return OpResult.fail(ex.getMessage());
        }
 
        return OpResult.success();
    }
 
    /**
     * 修改厂房信息
     * @param plantDTO
     * @param request
     * @return
     */
    @PostMapping(value = "/modify")
    public OpResult<Void> modify(@Validated(value = {UpdateGroup.class}) @RequestBody PlantDTO plantDTO,HttpServletRequest request) {
        
        try {
            plantService.modify(plantDTO);
        }catch(Exception ex) {
            logger.error("修改厂房异常",ex);
            return OpResult.fail(ex.getMessage());
        }
 
        return OpResult.success();
    }
    
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public OpResult<Void> delete(@RequestHeader(value = "mdc-token", defaultValue = "") String token,
            @RequestBody IdsDTO dto, HttpServletRequest request) {
        //accountTokenService.checkToken(token);
 
         try {
             plantService.delete(dto.getIds());
            return OpResult.success();
        }catch(Exception e) {
            logger.error("删除维护记录失败",e);
            return OpResult.fail(e.getMessage());
        }
    }
    
    
}