LoginController.java
2.47 KB
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
77
78
package cn.com.glsx.merchants.controller;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.merchants.request.example.*;
import cn.com.glsx.merchants.response.ProductResponse;
import cn.com.glsx.merchants.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.FileCopyUtils;
import cn.com.glsx.merchants.response.LoginResponse;
import cn.com.glsx.merchants.response.ExampleResponse;
import cn.com.glsx.merchants.response.UploadFileResponse;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import com.rop.session.SimpleSession;
/**
* @author zhouhaibao
* @version 1.0
* @description: 用户登录接口
* @date 2021/7/13 10:00
*/
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("用户登录")
@Slf4j
public class LoginController {
@Autowired
private LoginService loginService;
/**
* 登录示例
*
* @param request
* @return
*/
@ServiceMethod(method = "merchants.api.example.login", needInSession = NeedInSessionType.NO)
@ApiOperation("登录")
public RopResponse<LoginResponse> login(LoginRequest request) {
try {
LoginResponse response = loginService.login(request);
// 创建会话
return RopResponse.success(response);
} catch (RpcServiceException e) {
log.info("=======LoginController__invoke__findMerProMenuTreeRemote__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
}
}
/**
* 登出示例
*
* @param request
* @return
*/
@ServiceMethod(method = "merchants.api.example.logout", needInSession = NeedInSessionType.YES)
@ApiOperation("登出")
public RopResponse<Boolean> logout(AbstractRopRequest request) {
loginService.logout(request);
// 删除会话
return RopResponse.success(true);
}
}