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
package com.highdatas.mdm.controller;
 
 
import com.highdatas.mdm.entity.SysDispenseConfig;
import com.highdatas.mdm.pojo.CodeMsg;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.ISysDispenseConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kimi
 * @since 2020-04-20
 */
@RestController
@RequestMapping("/dispense/config")
public class SysDispenseConfigController {
    @Autowired
    ISysDispenseConfigService dispenseConfigService;
 
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    public Result getId() {
        SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001");
        return Result.success(sysDispenseConfig);
    }
 
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result update(@RequestBody SysDispenseConfig config) {
        String id = config.getId();
        if (StringUtils.isEmpty(id)) {
            Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        boolean b = config.updateById();
        if (b) {
            return Result.success(b);
        } else {
            return Result.error(CodeMsg.DELETE_ERROR);
        }
 
    }
 
    @RequestMapping(value = "/timeout/{time}", method = RequestMethod.GET)
    public Result timeout(@PathVariable Integer time) {
        SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001");
        if (sysDispenseConfig == null) {
            Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        sysDispenseConfig.setTimeout(time).updateById();
        return Result.success(sysDispenseConfig);
    }
    @RequestMapping(value = "/resend/{cnt}", method = RequestMethod.GET)
    public Result resend(@PathVariable Integer cnt) {
        SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001");
        if (sysDispenseConfig == null) {
            Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        sysDispenseConfig.setResendCnt(cnt).updateById();
        return Result.success(sysDispenseConfig);
    }
    @RequestMapping(value = "/error", method = RequestMethod.GET)
    public Result error(@RequestParam Boolean isContinue) {
        SysDispenseConfig sysDispenseConfig = dispenseConfigService.selectById("001");
        if (sysDispenseConfig == null) {
            Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED);
        }
        sysDispenseConfig.setErrorContinue(isContinue).updateById();
        return Result.success(sysDispenseConfig);
    }
}