LoginApi.java
3.56 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
79
80
81
82
83
84
85
86
87
88
package com.huaheng.api.general.Controller;
import com.alibaba.fastjson.JSONException;
import com.huaheng.common.utils.DataUtils;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.system.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/api")
@Api(tags = {"Login"}, description = "登陆接口")
public class LoginApi extends BaseController {
@Autowired
private IUserService userService;
@PostMapping("/login")
@ApiOperation("登陆接口")
public AjaxResult login(@RequestBody @ApiParam(value="登陆的Map集合") Map<String, String> param)
{
if (param.get("username") == null)
throw new JSONException("username(用户名)不能为空");
if (param.get("password") == null)
throw new JSONException("password(密码)不能为空");
if (param.get("warehouseId") == null)
throw new JSONException("warehouseId(仓库ID)不能为空");
if (param.get("warehouseCode") == null)
throw new JSONException("warehouseCode(仓库编码)不能为空");
String username = param.get("username");
String password = param.get("password");
Integer warehouseId = DataUtils.getInteger(param.get("warehouseId"));
String warehouseCode = param.get("warehouseCode");
AjaxResult ajaxResult = userService.login(username, password, warehouseId, warehouseCode, false);
return ajaxResult;
}
@PostMapping("/heartbeat")
@ApiOperation("心跳接口,用于延长cookie有效期")
public AjaxResult heartbeat()
{
return AjaxResult.success("success");
}
// @PostMapping("entrance")
// AjaxResult entrance(HttpServletRequest request, @RequestBody Map<String, String> params) {
//// // 当参数数据过大时,无论是通过注解@RequestParam 还是通过request.getParameter()都无法获取参数,只能通过读取输入流获取
//// if (params == null) {
//// params = new HashMap<>();
//// String requestData = "";
////// requestData = readInputStream(request);
//// String[] requestArray = requestData.split("&");
//// for (String item : requestArray) {
//// String[] arr = item.split("="); // 用split拆分字符串会把空字符串剔除
//// if (arr.length > 1) {
//// String key = arr[0];
//// String value = "";
////// String value = arr.length > 1 ? URLDecoder.decode(arr[1], CHARSET_NAME) : "";
//// params.put(key, value);
//// }
//// }
//// }
//// TtxSession sess = getSession(request)
//// ResponseMessage rsp = inbound(sess, params)
// String method = params.get("method");
// String requestData = params.get("data");
// AjaxResult ajaxResult = entrance(method, requestData);
// return ajaxResult;
// }
//
// AjaxResult entrance(String method, String requestData) {
// AjaxResult ajaxResult;
// if (method == "") {
// AvgTaskModel avgTaskModel = JSON.parseObject(requestData, AvgTaskModel.class);
// ajaxResult = TaskConfirm(avgTaskModel);
// }
// return AjaxResult.success("");
// }
}