admin
2024-06-24 5d3b3b74afd2ac4cf21697fc38367b2f88170e9f
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
package com.taoke.autopay.controller.client;
 
import com.taoke.autopay.entity.ClientInfo;
import com.taoke.autopay.exception.LoginException;
import com.taoke.autopay.service.ClientInfoService;
import com.taoke.autopay.utils.JsonUtil;
import com.taoke.autopay.vo.AcceptData;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
 
/**
 * @author hxh
 * @title: UserController
 * @description: TODO
 * @date 2024/6/14 18:38
 */
@Controller
@RequestMapping("api/user")
public class UserController {
 
    @Resource
    private ClientInfoService clientInfoService;
 
 
    @ResponseBody
    @RequestMapping("login")
    public String login(AcceptData acceptData,String account,String pwd){
        try {
            ClientInfo info = clientInfoService.login(account, pwd);
            info.setPwd(null);
            return JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(info));
        } catch (LoginException e) {
           return JsonUtil.loadFalseResult(1,e.getMessage());
        }
    }
 
 
    @ResponseBody
    @RequestMapping("logout")
    public String logout(AcceptData acceptData,Long uid){
        try {
            clientInfoService.logout(uid);
            return JsonUtil.loadTrueResult(new JSONObject());
        } catch (Exception e) {
            e.printStackTrace();
            return JsonUtil.loadFalseResult(1,e.getMessage());
        }
    }
 
}