admin
2021-11-19 4daec329f36cc9d86911c08b8ec8e00270792189
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
package com.ks.app.controller.client.api;
 
import com.ks.app.dto.user.LoginInfoDTO;
import com.ks.app.entity.user.UserInfo;
import com.ks.app.entity.user.UserLoginRecord;
import com.ks.app.exception.user.LoginException;
import com.ks.app.service.inter.user.UserAccountService;
import com.ks.app.vo.AcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.StringUtil;
 
import javax.annotation.Resource;
 
/**
 * @author hxh
 * @title: UserController
 * @description: 用户接口
 * @date 2021/11/16 17:37
 */
@Controller
@RequestMapping("api/v1/user")
public class UserController {
 
    @Resource
    private UserAccountService userAccountService;
 
    @ResponseBody
    @RequestMapping("loginPhone")
    public String loginPhone(AcceptData acceptData, String phone, String vcode, String token) {
        LoginInfoDTO loginInfo = new LoginInfoDTO();
        loginInfo.setLoginType(UserLoginRecord.TYPE_LOGIN_PHONE);
        if (!StringUtil.isNullOrEmpty(phone)) {
            if (StringUtil.isNullOrEmpty(vcode)) {
                return JsonUtil.loadFalseResult("请上传验证码");
            }
 
            loginInfo.setPhone(phone);
            loginInfo.setVcode(vcode);
 
        } else if (StringUtil.isNullOrEmpty(token)) {
            loginInfo.setPhoneAuthInfo(token);
        } else {
            return JsonUtil.loadFalseResult("信息不完整");
        }
        loginInfo.setSystem(acceptData.getSystem());
        try {
            UserInfo userInfo = userAccountService.login(loginInfo);
            return JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(userInfo));
        } catch (LoginException e) {
            return JsonUtil.loadFalseResult(e.getMessage());
        }
 
    }
 
 
}