LoginApi.java
1.91 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
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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("warehouseCode") == null)
throw new JSONException("warehouseCode(仓库编码)不能为空");
String username = param.get("username");
String password = param.get("password");
String warehouseCode = param.get("warehouseCode");
AjaxResult ajaxResult = userService.login(username, password, warehouseCode, false);
return ajaxResult;
}
@PostMapping("/heartbeat")
@ApiOperation("心跳接口,用于延长cookie有效期")
public AjaxResult heartbeat()
{
return AjaxResult.success("success");
}
}