y_ys79
2024-01-05 e5840972b6b17ec03bfc1069a9cacfe0cef189c6
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
100
101
102
103
104
105
package com.qianwen.mdc.controller;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qianwen.mdc.common.OpResult;
import com.qianwen.mdc.domain.*;
import com.qianwen.mdc.dto.MachineDTO;
import com.qianwen.mdc.mapper.*;
import com.qianwen.mdc.service.impl.MdcTokenServiceImpl;
import com.qianwen.mdc.service.machine.MachineAddService;
import com.qianwen.mdc.service.machine.MachineEditService;
import com.qianwen.mdc.utils.TimestampUtil;
 
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
 
/**
 * @author y_ys79
 * 机床设备新增控制器
 */
@RestController
@CrossOrigin
@RequestMapping(value = "/machine", method = RequestMethod.POST)
public class MachineEditController {
    @Autowired
    private MachineEditService editService;
    @Autowired
    private AccountTokenMapper mdcTokenMapper;
    
 
    public static final Logger logger = LoggerFactory.getLogger(MachineEditController.class);
    
 
    
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public OpResult<Void> modify(@RequestHeader(value = "mdc-token", defaultValue = "") String token,
            MachineDTO machineDTO,HttpServletRequest request) {
       
        try {
            editService.modify(machineDTO);
        }catch(Exception ex) {
            logger.error("修改机床失败",ex);
            return OpResult.fail(ex.getMessage());
        }
 
        return OpResult.success();
    }
 
    /**
     * 删除设备
     * @param token
     * @param id
     * @param request
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public OpResult<Void> delete(@RequestHeader(value = "mdc-token", defaultValue = "") String token,
            Integer id) {
        
        try {
            editService.delete(id);
        }catch(Exception ex) {
            return OpResult.fail(ex.getMessage());
        }
 
        return OpResult.success();
    }
    
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public OpResult<Void> remove(@RequestHeader(value = "mdc-token", defaultValue = "") String token,
            Integer id) {
       
        try {
            editService.remove(id);
        }catch(Exception ex) {
            return OpResult.fail(ex.getMessage());
        }
 
        return OpResult.success();
    }
    
    @RequestMapping(value = "/concern", method = RequestMethod.POST)
    public OpResult<Void> switchConcern(@RequestHeader(value = "mdc-token", defaultValue = "") String token,
            Integer id,int concern) {
       
        try {
            editService.switchConcern(id,concern);
        }catch(Exception ex) {
            return OpResult.fail(ex.getMessage());
        }
 
        return OpResult.success();
    }
 
}