WcsLoginController.java 1.67 KB
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");
    }
}