lizijie
2021-08-18 eccde23ea401394aed432865bfbbbcb89539ba20
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
package com.moral.api.controller;
 
import com.moral.api.service.SpecialDeviceHistoryService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
 
@Slf4j
@Api(tags = {"特殊设备历史"})
@RestController
@RequestMapping("/specialDeviceHistory")
public class SpecialDeviceHistoryController {
 
    @Resource
    private SpecialDeviceHistoryService specialDeviceHistoryService;
 
    @RequestMapping(value = "getSpecialDeviceHistoryByCondition",method = RequestMethod.GET)
    @ResponseBody
    public ResultMessage getSpecialDeviceHistoryByCondition(HttpServletRequest request){
        Map<String,Object> parameters = WebUtils.getParametersStartingWith(request,null);
        Map resultMap = specialDeviceHistoryService.getDataByCondition(parameters);
        if (!resultMap.containsKey("code")){
            return ResultMessage.ok(resultMap);
        }
        return ResultMessage.fail(Integer.parseInt(resultMap.get("code").toString()),resultMap.get("msg").toString());
    }
 
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ResponseBody
    public ResultMessage delete(@RequestBody Map map){
        if (map.get("id") == null){
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        specialDeviceHistoryService.delete(Integer.parseInt(map.get("id").toString()));
        return ResultMessage.ok();
    }
}