jinpengyong
2023-10-18 cc120d54e26f64753e99b349599875cf6911a0af
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 cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Map;
 
import com.moral.api.service.UserService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
 
@Slf4j
@Api(tags = {"小程序用户管理"})
@RestController
@RequestMapping("/UserSmallRoutine")
public class UserSmallRoutineController {
 
    @Autowired
    private UserService userService;
 
    @ApiOperation(value = "登陆信息", notes = "登陆信息")
    @PostMapping("login")
    public ResultMessage login(@RequestBody Map<String, Object> parameters) {
        if (!(parameters.containsKey("account") && parameters.containsKey("password"))) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> result = userService.loginSmallRoutine(parameters);
        if (!result.containsKey("token")) {
            return ResultMessage.fail((int) result.get("code"), (String) result.get("msg"));
        }
        return ResultMessage.ok(result);
    }
 
 
}