xuhy
2023-08-11 7a8c46e7acecf0a0275e36f27623ed44db7451fc
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
package com.stylefeng.guns.modular.api;
 
 
import com.stylefeng.guns.modular.system.service.IDispatchService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.LoginWarpper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * 调度控制器
 */
@Api
@RestController
@RequestMapping("")
public class DispatchController {
 
    @Autowired
    private IDispatchService dispatchService;
 
 
    /**
     * 账号密码登录
     * @param account
     * @param password
     * @return
     */
    @ResponseBody
    @PostMapping("/base/dispatch/dispatchLogin")
    @ApiOperation(value = "账号密码登录", tags = {"调度端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "登录账号", name = "account", required = true, dataType = "String"),
            @ApiImplicitParam(value = "登录密码", name = "password", required = true, dataType = "String")
    })
    public ResultUtil<LoginWarpper> dispatchLogin(String account, String password){
        try {
            return dispatchService.dispatchLogin(account, password);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 修改推单配置
     * @param pushOrder
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/api/dispatch/editPushOrder", method = RequestMethod.POST)
    @ApiOperation(value = "修改推单配置", tags = {"调度端-设置"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "推单配置(1=接收,2=不接收)", name = "pushOrder", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil editPushOrder(Integer pushOrder, HttpServletRequest request){
        try {
            Integer uid = dispatchService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return dispatchService.editPushOrder(pushOrder, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}