Commit 60eafb6b authored by zhangc's avatar zhangc

Merge branch 'dm_dev' of gitlab.ioubuy.cn:yaobenzhang/dm_project into dm_dev

parents e3e30701 c107cecd
......@@ -61,6 +61,70 @@ public class Result<T> implements Serializable {
return this;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public Result(boolean success, String message, Integer code) {
this.success = success;
this.message = message;
this.code = code;
}
public Result(boolean success, String message, Integer code, T result) {
this.success = success;
this.message = message;
this.code = code;
this.result = result;
}
public Result(boolean success, String message, Integer code, T result, long timestamp) {
this.success = success;
this.message = message;
this.code = code;
this.result = result;
this.timestamp = timestamp;
}
public static Result<Object> ok() {
Result<Object> r = new Result<Object>();
......
package com.jz.common.utils;
/**
* @ClassName: 返回状态码
* @Author: Carl
* @Date: 2020/12/1
* @Version:
*/
public class StatusCode {
public static final int OK = 30000; // 成功
public static final int ERROR = 30001; // 失败
public static final int LOGINERROR = 30002; // 用户名或密码错误
public static final int ACCESSERROR = 30003; // 权限不足
}
......@@ -9,7 +9,6 @@
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
......@@ -19,7 +18,6 @@
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
......
package com.jz.manage.moduls.controller.sys;
import com.jz.common.entity.sys.SysUser;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.manage.moduls.controller.BaseController;
import com.jz.manage.moduls.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginController extends BaseController {
@RequestMapping("/sys")
public class LoginController extends BaseController {
@Autowired
private SysUserService sysUserService;
/**
* 登录功能
* @param account 账号
* @param password 密码
* @return
*/
@GetMapping(value = "login")
public Result<SysUser> login(String account, String password) {
// 获取用户的信息
SysUser sysUser = sysUserService.selectByUsername(account);
if (sysUser == null) {
return new Result<>(false, "用户不存在!", StatusCode.LOGINERROR);
}
if (sysUser.getAccount().equals(account) && sysUser.getPassword().equals(password)) {
return new Result<>(true, "登录成功!", StatusCode.OK);
}
return new Result<>(false, "用户名或密码错误!", StatusCode.ERROR);
}
/*@ApiOperation("登录接口")
@RequestMapping(value = "/login", method = RequestMethod.POST)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment