WcsLoginController.java
1.67 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
package com.huaheng.api.wcs.controller;
import com.alibaba.fastjson.JSONException;
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.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import javax.annotation.Resource;
import java.util.Map;
/**
* Created by Enzo Cotter on 2020/1/1.
*/
@RequestMapping("/API/WMS/v2")
@Controller
public class WcsLoginController extends BaseController {
@Resource
private IUserService userService;
@PostMapping("/login")
@ApiOperation("用户登陆")
@ResponseBody
public AjaxResult login(@RequestBody @ApiParam(value="code和password的Map集合") Map<String, String> param) {
if (param.get("username") == null) {
throw new JSONException("username(用户名)不能为空");
}
if (param.get("password") == null) {
throw new JSONException("password(密码)不能为空");
}
AjaxResult ajaxResult = userService.login(param.get("username"), param.get("password"), param.get("warehouseCode"), true);
return ajaxResult;
}
@PostMapping("/heartbeat")
@ApiOperation("心跳接口,用于延长cookie有效期")
@ResponseBody
public AjaxResult heartbeat()
{
return AjaxResult.success("success");
}
}