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());
|
}
|
}
|
|
}
|