Browse Source

add function

hlf 2 years ago
parent
commit
3a44b946b7
24 changed files with 671 additions and 59 deletions
  1. 4 1
      build.gradle.kts
  2. 44 0
      src/main/java/com/gyee/table/controller/LoginController.java
  3. 7 0
      src/main/java/com/gyee/table/entity/ComponentModificationRecord.java
  4. 10 1
      src/main/java/com/gyee/table/entity/Configurationinfo.java
  5. 7 0
      src/main/java/com/gyee/table/entity/Line.java
  6. 7 0
      src/main/java/com/gyee/table/entity/Project.java
  7. 8 1
      src/main/java/com/gyee/table/entity/User.java
  8. 7 0
      src/main/java/com/gyee/table/entity/Windpowerstation.java
  9. 7 0
      src/main/java/com/gyee/table/entity/Windturbine.java
  10. 19 0
      src/main/java/com/gyee/table/jwt/auth/AllowAllCredentialsMatcher.java
  11. 45 0
      src/main/java/com/gyee/table/jwt/auth/JwtToken.java
  12. 136 0
      src/main/java/com/gyee/table/jwt/filter/JwtFilter.java
  13. 67 0
      src/main/java/com/gyee/table/jwt/utils/JwtUtils.java
  14. 17 0
      src/main/java/com/gyee/table/mapper/SysUserMapper.java
  15. 0 14
      src/main/java/com/gyee/table/mapper/UserMapper.java
  16. 16 0
      src/main/java/com/gyee/table/service/ISysUserService.java
  17. 0 15
      src/main/java/com/gyee/table/service/IUserService.java
  18. 30 0
      src/main/java/com/gyee/table/service/impl/SysUserServiceImpl.java
  19. 0 19
      src/main/java/com/gyee/table/service/impl/UserServiceImpl.java
  20. 21 0
      src/main/java/com/gyee/table/utils/StringUtil.java
  21. 197 0
      src/main/java/com/gyee/table/vo/AjaxResult.java
  22. 10 3
      src/main/resources/mappers/Configurationinfo.xml
  23. 12 0
      src/main/resources/mappers/SysUserMapper.xml
  24. 0 5
      src/main/resources/mappers/UserMapper.xml

+ 4 - 1
build.gradle.kts

@@ -33,8 +33,11 @@ dependencies {
     implementation("org.apache.commons:commons-lang3:3.12.0")
     implementation("org.postgresql:postgresql:42.4.0")
     implementation("org.springframework.boot:spring-boot-starter-data-jpa")
-    //implementation("cn.hutool:hutool-all:5.8.15")
+    implementation("cn.hutool:hutool-all:5.8.15")
     implementation("com.github.pagehelper:pagehelper-spring-boot-starter:1.4.1")
+    implementation("com.auth0:java-jwt:3.4.0")
+    implementation("org.apache.shiro:shiro-core:1.7.1")
+    implementation("org.apache.shiro:shiro-spring:1.7.1")
 }
 
 tasks.withType<Test> {

+ 44 - 0
src/main/java/com/gyee/table/controller/LoginController.java

@@ -0,0 +1,44 @@
+package com.gyee.table.controller;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.gyee.table.entity.SysUser;
+import com.gyee.table.jwt.utils.JwtUtils;
+import com.gyee.table.service.ISysUserService;
+import com.gyee.table.utils.StringUtil;
+import com.gyee.table.vo.AjaxResult;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 14:55
+ * 文件说明:
+ */
+@Controller
+public class LoginController {
+
+    @Resource
+    private ISysUserService userService;
+
+    @PostMapping("/toLogin")
+    @ResponseBody
+    public AjaxResult jwtLogin(String username, String password) {
+        if (StringUtil.isEmpty(username) || StringUtil.isEmpty(password)) {
+            return AjaxResult.error("账号和密码不能为空!");
+        }
+        SysUser user = userService.selectUserByLoginName(username);
+        if (user == null) {
+            return AjaxResult.error("用户不存在/密码错误!");
+        }
+
+        if (ObjectUtil.isNull(userService.checkPassword(username, password))) {
+            return AjaxResult.error("用户不存在/密码错误!");
+        }
+
+        String token = JwtUtils.createToken(username, user.getPassword());
+        return AjaxResult.success("登录成功,请妥善保管您的token信息").put("token", token).put("id", user.getId()).put("loginName", user.getLoginName()).put("userName", user.getUserName()).put("userAuthority", user.getUserAuthority());
+    }
+}

+ 7 - 0
src/main/java/com/gyee/table/entity/ComponentModificationRecord.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/28 9:30
  * 文件说明:
  */
 @Data
+@Entity
+@Table(name="component_modification_record")
 public class ComponentModificationRecord {
 
+    @Id
     private String id;
     private String updataDate;
     private String changeUser;

+ 10 - 1
src/main/java/com/gyee/table/entity/Configurationinfo.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/20 9:56
  * 文件说明:
  */
 @Data
+@Entity
+@Table(name="configurationinfo")
 public class Configurationinfo {
 
+    @Id
     private String id;
     private String name;
     private String needBg;
@@ -24,9 +31,11 @@ public class Configurationinfo {
     private String trSvg;
     private String type;
     private String uploadDate;
-    private String user;
+    private String uploadUser;
     private String updataDate;
     private String changeUser;
     private Integer pageNum;
     private Integer pageSize;
+    private String uploadUserStr;
+    private String changeUserStr;
 }

+ 7 - 0
src/main/java/com/gyee/table/entity/Line.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/16 17:01
  * 文件说明:
  */
 @Data
+@Entity
+@Table(name="line")
 public class Line {
 
+    @Id
     private String id;
     private String code;
     private String name;

+ 7 - 0
src/main/java/com/gyee/table/entity/Project.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/16 17:03
  * 文件说明:
  */
 @Data
+@Entity
+@Table(name="project")
 public class Project {
 
+    @Id
     private String id;
     private String code;
     private String name;

+ 8 - 1
src/main/java/com/gyee/table/entity/User.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/28 9:28
  * 文件说明:
  */
 @Data
-public class User {
+@Entity
+@Table(name="sys_user")
+public class SysUser {
 
+    @Id
     private String id;
     private String loginName;
     private String password;

+ 7 - 0
src/main/java/com/gyee/table/entity/Windpowerstation.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/16 17:05
  * 文件说明:
  */
 @Data
+@Entity
+@Table(name="windpowerstation")
 public class Windpowerstation {
 
+    @Id
     private String id;
     private String code;
     private String name;

+ 7 - 0
src/main/java/com/gyee/table/entity/Windturbine.java

@@ -2,14 +2,21 @@ package com.gyee.table.entity;
 
 import lombok.Data;
 
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 /**
  * @author hlf
  * @date 2023/3/16 17:07
  * 文件说明:
  */
 @Data
+@Entity
+@Table(name="windturbine")
 public class Windturbine {
 
+    @Id
     private String id;
     private String code;
     private String windpowerstationid;

+ 19 - 0
src/main/java/com/gyee/table/jwt/auth/AllowAllCredentialsMatcher.java

@@ -0,0 +1,19 @@
+package com.gyee.table.jwt.auth;
+
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;
+
+/**
+ * 无需验证密码
+ * 
+ * @author ruoyi
+ */
+public class AllowAllCredentialsMatcher extends SimpleCredentialsMatcher
+{
+    @Override
+    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info)
+    {
+        return true;
+    }
+}

+ 45 - 0
src/main/java/com/gyee/table/jwt/auth/JwtToken.java

@@ -0,0 +1,45 @@
+package com.gyee.table.jwt.auth;
+
+import org.apache.shiro.authc.UsernamePasswordToken;
+
+/**
+ * 自定义登录Token
+ * 
+ * @author ruoyi
+ */
+public class JwtToken extends UsernamePasswordToken
+{
+    private static final long serialVersionUID = 1L;
+
+    private String token;
+
+    public JwtToken()
+    {
+    }
+
+    public JwtToken(String username, String password, boolean rememberMe)
+    {
+        super(username, password, rememberMe);
+    }
+
+    public JwtToken(String username, String password)
+    {
+        super(username, password, false);
+    }
+
+    public JwtToken(String token)
+    {
+        super("", "", false);
+        this.token = token;
+    }
+
+    public String getToken()
+    {
+        return token;
+    }
+
+    public void setToken(String token)
+    {
+        this.token = token;
+    }
+}

+ 136 - 0
src/main/java/com/gyee/table/jwt/filter/JwtFilter.java

@@ -0,0 +1,136 @@
+package com.gyee.table.jwt.filter;
+
+import com.alibaba.fastjson.JSON;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.exceptions.TokenExpiredException;
+import com.gyee.table.jwt.auth.JwtToken;
+import com.gyee.table.utils.StringUtil;
+import com.gyee.table.vo.AjaxResult;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.web.filter.AccessControlFilter;
+import org.apache.shiro.web.util.WebUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * jwt 自定义拦截器
+ *
+ * @author ruoyi
+ */
+public class JwtFilter extends AccessControlFilter
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(JwtFilter.class);
+
+    private static final String AUTHZ_HEADER = "token";
+
+    private final ThreadLocal<String> MSG_HOLDER = new ThreadLocal<>();
+
+    @Override
+    public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception
+    {
+        return super.onPreHandle(request, response, mappedValue);
+    }
+
+    @Override
+    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception
+    {
+        return this.executeLogin(request, response);
+    }
+
+    /**
+     * 执行登录方法(UserRealm判断,异常返回false)
+     */
+    protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception
+    {
+        String token = WebUtils.toHttp(request).getHeader(AUTHZ_HEADER);
+        if (StringUtil.isEmpty(token))
+        {
+            MSG_HOLDER.set("消息头不正确,header需要携带token参数");
+            return false;
+        }
+        try
+        {
+            // 断是否有权限
+            JwtToken jwtToken = new JwtToken(token);
+            this.getSubject(request, response).login(jwtToken);
+            return true;
+        }
+        catch (AuthenticationException e)
+        {
+            if (e.getCause() instanceof TokenExpiredException)
+            {
+                MSG_HOLDER.set("token已过期");
+            }
+            else if (e.getCause() instanceof JWTVerificationException)
+            {
+                MSG_HOLDER.set("用户密码错误");
+            }
+            else
+            {
+                MSG_HOLDER.set("用户信息验证失败:" + e.getMessage());
+            }
+            return false;
+        }
+    }
+
+    /**
+     * 请求前处理,处理跨域
+     */
+    @Override
+    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception
+    {
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+        httpServletResponse.setHeader("Access-control-Allow-Origin", httpServletRequest.getHeader("Origin"));
+        httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
+        httpServletResponse.setHeader("Access-Control-Allow-Headers", httpServletRequest.getHeader("Access-Control-Request-Headers"));
+        // 跨域时,option请求直接返回正常状态
+        if (httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name()))
+        {
+            httpServletResponse.setStatus(HttpStatus.OK.value());
+            return false;
+        }
+        return super.preHandle(request, response);
+    }
+
+    /**
+     * 异常处理
+     */
+    @Override
+    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception
+    {
+        this.jwtFail(request, response, 401, "对不起,您无权限进行操作!");
+        return false;
+    }
+
+    /**
+     * 认证失败,异常返回
+     */
+    protected void jwtFail(ServletRequest request, ServletResponse response, int code, String message)
+    {
+        HttpServletResponse httpResponse = WebUtils.toHttp(response);
+        String contentType = "application/json;charset=UTF-8";
+        httpResponse.setStatus(401);
+        httpResponse.setContentType(contentType);
+        try
+        {
+            String msg = StringUtil.isNotEmpty(MSG_HOLDER.get()) ? MSG_HOLDER.get() : message;
+            AjaxResult ajaxResult = new AjaxResult().put(AjaxResult.CODE_TAG, code).put(AjaxResult.MSG_TAG, msg);
+            PrintWriter printWriter = httpResponse.getWriter();
+            printWriter.append(JSON.toJSONString(ajaxResult));
+        }
+        catch (IOException e)
+        {
+            LOGGER.error("sendChallenge error,can not resolve httpServletResponse");
+        }
+    }
+}

+ 67 - 0
src/main/java/com/gyee/table/jwt/utils/JwtUtils.java

@@ -0,0 +1,67 @@
+package com.gyee.table.jwt.utils;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTDecodeException;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.exceptions.TokenExpiredException;
+import com.auth0.jwt.interfaces.DecodedJWT;
+
+import java.util.Date;
+
+/**
+ * jwt 工具类
+ * 
+ * @author ruoyi
+ */
+public class JwtUtils
+{
+    private static final long EXPIRE_TIME = 3 * 120 * 60 * 1000;
+
+    private static final String CLAIM_NAME = "username";
+
+    public static String createToken(String username, String password)
+    {
+        return createToken(username, password, EXPIRE_TIME);
+    }
+
+    public static String createToken(String username, String password, long expireTime)
+    {
+        Date date = new Date(System.currentTimeMillis() + expireTime);
+        // 加密处理密码
+        Algorithm algorithm = Algorithm.HMAC256(password);
+        return JWT.create().withClaim(CLAIM_NAME, username).withExpiresAt(date).sign(algorithm);
+    }
+
+    public static void verify(String username, String dbPwd, String token)
+    {
+        Algorithm algorithm = Algorithm.HMAC256(dbPwd);
+        JWTVerifier jwtVerifier = JWT.require(algorithm).withClaim(CLAIM_NAME, username).build();
+        try
+        {
+            jwtVerifier.verify(token);
+        }
+        catch (TokenExpiredException e)
+        {
+            throw new TokenExpiredException("token已过期");
+        }
+        catch (JWTVerificationException e)
+        {
+            throw new JWTVerificationException("token验证失败");
+        }
+    }
+
+    public static String getUserName(String token)
+    {
+        try
+        {
+            DecodedJWT jwt = JWT.decode(token);
+            return jwt.getClaim(CLAIM_NAME).asString();
+        }
+        catch (JWTDecodeException e)
+        {
+            return null;
+        }
+    }
+}

+ 17 - 0
src/main/java/com/gyee/table/mapper/SysUserMapper.java

@@ -0,0 +1,17 @@
+package com.gyee.table.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.table.entity.SysUser;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:35
+ * 文件说明:
+ */
+public interface SysUserMapper extends BaseMapper<SysUser> {
+
+    SysUser selectUserByLoginName(String loginName);
+
+    SysUser checkPassword(@Param("loginName") String loginName, @Param("password") String password);
+}

+ 0 - 14
src/main/java/com/gyee/table/mapper/UserMapper.java

@@ -1,14 +0,0 @@
-package com.gyee.table.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.table.entity.User;
-
-/**
- * @author hlf
- * @date 2023/3/28 9:35
- * 文件说明:
- */
-public interface UserMapper extends BaseMapper<User> {
-
-
-}

+ 16 - 0
src/main/java/com/gyee/table/service/ISysUserService.java

@@ -0,0 +1,16 @@
+package com.gyee.table.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.table.entity.SysUser;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:32
+ * 文件说明:
+ */
+public interface ISysUserService extends IService<SysUser> {
+
+    SysUser selectUserByLoginName(String loginName);
+
+    SysUser checkPassword(String loginName, String password);
+}

+ 0 - 15
src/main/java/com/gyee/table/service/IUserService.java

@@ -1,15 +0,0 @@
-package com.gyee.table.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.table.entity.User;
-
-/**
- * @author hlf
- * @date 2023/3/28 9:32
- * 文件说明:
- */
-public interface IUserService extends IService<User> {
-
-
-
-}

+ 30 - 0
src/main/java/com/gyee/table/service/impl/SysUserServiceImpl.java

@@ -0,0 +1,30 @@
+package com.gyee.table.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.table.entity.SysUser;
+import com.gyee.table.mapper.SysUserMapper;
+import com.gyee.table.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:32
+ * 文件说明:
+ */
+@Service
+public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
+
+    @Autowired(required = false)
+    private SysUserMapper userMapper;
+
+    @Override
+    public SysUser selectUserByLoginName(String loginName) {
+        return userMapper.selectUserByLoginName(loginName);
+    }
+
+    @Override
+    public SysUser checkPassword(String loginName, String password) {
+        return userMapper.checkPassword(loginName, password);
+    }
+}

+ 0 - 19
src/main/java/com/gyee/table/service/impl/UserServiceImpl.java

@@ -1,19 +0,0 @@
-package com.gyee.table.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.table.entity.User;
-import com.gyee.table.mapper.UserMapper;
-import com.gyee.table.service.IUserService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author hlf
- * @date 2023/3/28 9:32
- * 文件说明:
- */
-@Service
-public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
-
-
-
-}

+ 21 - 0
src/main/java/com/gyee/table/utils/StringUtil.java

@@ -43,4 +43,25 @@ public class StringUtil extends StringUtils {
 		return uuid.replaceAll("-", "");
 	}
 
+	/**
+	 * * 判断一个对象是否非空
+	 *
+	 * @param object Object
+	 * @return true:非空 false:空
+	 */
+	public static boolean isNotNull(Object object)
+	{
+		return !isNull(object);
+	}
+
+	/**
+	 * * 判断一个对象是否为空
+	 *
+	 * @param object Object
+	 * @return true:为空 false:非空
+	 */
+	public static boolean isNull(Object object)
+	{
+		return object == null;
+	}
 }

+ 197 - 0
src/main/java/com/gyee/table/vo/AjaxResult.java

@@ -0,0 +1,197 @@
+package com.gyee.table.vo;
+
+import com.gyee.table.utils.StringUtil;
+
+import java.util.HashMap;
+
+/**
+ * 操作消息提醒
+ *
+ * @author ruoyi
+ */
+public class AjaxResult extends HashMap<String, Object>
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 状态码 */
+    public static final String CODE_TAG = "code";
+
+    /** 返回内容 */
+    public static final String MSG_TAG = "msg";
+
+    /** 数据对象 */
+    public static final String DATA_TAG = "data";
+
+    /**
+     * 状态类型
+     */
+    public enum Type
+    {
+        /** 成功 */
+        SUCCESS(200),
+        /** 警告 */
+        WARN(301),
+        /** 错误 */
+        ERROR(500);
+        private final int value;
+
+        Type(int value)
+        {
+            this.value = value;
+        }
+
+        public int value()
+        {
+            return this.value;
+        }
+    }
+
+    /**
+     * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
+     */
+    public AjaxResult()
+    {
+    }
+
+    /**
+     * 初始化一个新创建的 AjaxResult 对象
+     *
+     * @param type 状态类型
+     * @param msg 返回内容
+     */
+    public AjaxResult(Type type, String msg)
+    {
+        super.put(CODE_TAG, type.value);
+        super.put(MSG_TAG, msg);
+    }
+
+    /**
+     * 初始化一个新创建的 AjaxResult 对象
+     *
+     * @param type 状态类型
+     * @param msg 返回内容
+     * @param data 数据对象
+     */
+    public AjaxResult(Type type, String msg, Object data)
+    {
+        super.put(CODE_TAG, type.value);
+        super.put(MSG_TAG, msg);
+        if (StringUtil.isNotNull(data))
+        {
+            super.put(DATA_TAG, data);
+        }
+    }
+
+    /**
+     * 方便链式调用
+     *
+     * @param key 键
+     * @param value 值
+     * @return 数据对象
+     */
+    @Override
+    public AjaxResult put(String key, Object value)
+    {
+        super.put(key, value);
+        return this;
+    }
+
+    /**
+     * 返回成功消息
+     *
+     * @return 成功消息
+     */
+    public static AjaxResult success()
+    {
+        return AjaxResult.success("操作成功");
+    }
+
+    /**
+     * 返回成功数据
+     *
+     * @return 成功消息
+     */
+    public static AjaxResult success(Object data)
+    {
+        return AjaxResult.success("操作成功", data);
+    }
+
+    /**
+     * 返回成功消息
+     *
+     * @param msg 返回内容
+     * @return 成功消息
+     */
+    public static AjaxResult success(String msg)
+    {
+        return AjaxResult.success(msg, null);
+    }
+
+    /**
+     * 返回成功消息
+     *
+     * @param msg 返回内容
+     * @param data 数据对象
+     * @return 成功消息
+     */
+    public static AjaxResult success(String msg, Object data)
+    {
+        return new AjaxResult(Type.SUCCESS, msg, data);
+    }
+
+    /**
+     * 返回警告消息
+     *
+     * @param msg 返回内容
+     * @return 警告消息
+     */
+    public static AjaxResult warn(String msg)
+    {
+        return AjaxResult.warn(msg, null);
+    }
+
+    /**
+     * 返回警告消息
+     *
+     * @param msg 返回内容
+     * @param data 数据对象
+     * @return 警告消息
+     */
+    public static AjaxResult warn(String msg, Object data)
+    {
+        return new AjaxResult(Type.WARN, msg, data);
+    }
+
+    /**
+     * 返回错误消息
+     *
+     * @return
+     */
+    public static AjaxResult error()
+    {
+        return AjaxResult.error("操作失败");
+    }
+
+    /**
+     * 返回错误消息
+     *
+     * @param msg 返回内容
+     * @return 警告消息
+     */
+    public static AjaxResult error(String msg)
+    {
+        return AjaxResult.error(msg, null);
+    }
+
+    /**
+     * 返回错误消息
+     *
+     * @param msg 返回内容
+     * @param data 数据对象
+     * @return 警告消息
+     */
+    public static AjaxResult error(String msg, Object data)
+    {
+        return new AjaxResult(Type.ERROR, msg, data);
+    }
+}

+ 10 - 3
src/main/resources/mappers/Configurationinfo.xml

@@ -17,16 +17,23 @@
         <result property="trSvg"          column="tr_svg"              />
         <result property="type"           column="type"                />
         <result property="uploadDate"     column="upload_date"         />
-        <result property="user"           column="user"                />
+        <result property="uploadUser"     column="upload_user"         />
         <result property="updataDate"     column="updata_date"         />
         <result property="changeUser"     column="change_user"         />
     </resultMap>
 
     <select id="selectConfigurationinfoList" parameterType="Configurationinfo" resultMap="ConfigurationinfoResult">
-        select * from configurationinfo
+        select
+        c.*,
+        u1.user_name as "uploadUserStr",
+        u2.user_name as "changeUserStr"
+        from
+        configurationinfo c
+        left join sys_user u1 on u1.id = c.upload_user
+        left join sys_user u2 on u2.id = c.change_user
         <where>
             <if test="name != null and name != ''">and name = #{name}</if>
-            <if test="user != null and user != ''">and user = #{user}</if>
+            <if test="uploadUser != null and uploadUser != ''">and upload_user = #{uploadUser}</if>
             <if test="changeUser != null and changeUser != ''">and changeUser = #{changeUser}</if>
             <if test="needMapDone != null">and needMapDone = #{needMapDone}</if>
         </where>

+ 12 - 0
src/main/resources/mappers/SysUserMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.gyee.table.mapper.SysUserMapper">
+
+    <select id="selectUserByLoginName" resultType="com.gyee.table.entity.SysUser">
+        select * from sys_user where login_name = #{loginName}
+    </select>
+
+    <select id="checkPassword" resultType="com.gyee.table.entity.SysUser">
+        select * from sys_user where login_name = #{loginName} and password = #{password}
+    </select>
+</mapper>

+ 0 - 5
src/main/resources/mappers/UserMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.gyee.table.mapper.UserMapper">
-
-</mapper>