Commit 784c020f by RuoYi

若依开源1.1.3发布

parent 20070163
## 平台简介 ## 平台简介
一直想做一款后台管理系统,看了很多优秀的开源项目但是发现没有合适自己的。于是利用空闲休息时间开始自己写一套后台系统。如此有了若依管理系统。她可以用于所有的Web应用程序,如网站管理后台,网站会员中心,CMS,CRM,OA。所有前端后台代码封装过后十分精简易上手,提高开发效率及质量。同时支持移动客户端访问。系统会陆续更新一些实用功能。 一直想做一款后台管理系统,看了很多优秀的开源项目但是发现没有合适的。于是利用空闲休息时间开始自己写了一套后台系统。如此有了若依。她可以用于所有的Web应用程序,如网站管理后台,网站会员中心,CMS,CRM,OA。所有前端后台代码封装过后十分精简易上手,出错概率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。
寓意:你若不离不弃,我必生死相依 寓意:你若不离不弃,我必生死相依
...@@ -22,28 +22,19 @@ ...@@ -22,28 +22,19 @@
## 系统演示 [www.ruoyi.club](http://www.ruoyi.club) ## 系统演示 [www.ruoyi.club](http://www.ruoyi.club)
![登录界面](https://static.oschina.net/uploads/space/2018/0425/110329_Ftsu_1438828.png) ![登录界面](https://static.oschina.net/uploads/space/2018/0513/145506_0712_1438828.png)
![首页](https://static.oschina.net/uploads/space/2018/0426/215626_fkrN_1438828.png) ![系统首页](https://static.oschina.net/uploads/space/2018/0513/145514_LKRy_1438828.png)
![用户管理](https://static.oschina.net/uploads/space/2018/0424/233815_kb8P_1438828.png) ![用户管理](https://static.oschina.net/uploads/space/2018/0513/145523_7Cuh_1438828.png)
![用户修改](https://static.oschina.net/uploads/space/2018/0424/233819_spnr_1438828.png) ![用户修改](https://static.oschina.net/uploads/space/2018/0513/145530_vE5H_1438828.png)
![部门选择](https://static.oschina.net/uploads/space/2018/0424/233826_J5NV_1438828.png) ![头像修改](https://static.oschina.net/uploads/space/2018/0513/145931_iibt_1438828.png)
![部门修改](https://static.oschina.net/uploads/space/2018/0424/234035_gkfz_1438828.png) ![菜单管理](https://static.oschina.net/uploads/space/2018/0513/145608_ex4U_1438828.png)
![菜单选择](https://static.oschina.net/uploads/space/2018/0424/233929_xcaM_1438828.png)
![菜单修改](https://static.oschina.net/uploads/space/2018/0311/235921_7txy_1438828.png)
![在线构建](https://static.oschina.net/uploads/space/2018/0424/233957_fRat_1438828.png)
![代码生成](https://static.oschina.net/uploads/space/2018/0424/233952_QXsG_1438828.png)
![操作日志](https://static.oschina.net/uploads/space/2018/0424/234055_8omc_1438828.png)
![角色管理](https://static.oschina.net/uploads/space/2018/0513/150005_gV8b_1438828.png)
## 若依交流群 ## 若依交流群
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>RuoYi</artifactId> <artifactId>RuoYi</artifactId>
<version>1.1.2</version> <version>1.1.3</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>RuoYi</name> <name>RuoYi</name>
...@@ -124,6 +124,13 @@ ...@@ -124,6 +124,13 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.5</version> <version>2.5</version>
</dependency> </dependency>
<!--文件上传工具类 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
<!--Shiro核心框架 --> <!--Shiro核心框架 -->
<dependency> <dependency>
...@@ -192,6 +199,19 @@ ...@@ -192,6 +199,19 @@
<artifactId>velocity</artifactId> <artifactId>velocity</artifactId>
<version>${velocity.version}</version> <version>${velocity.version}</version>
</dependency> </dependency>
<!--验证码 -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
<exclusions>
<exclusion>
<artifactId>javax.servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
......
...@@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*/ */
@SpringBootApplication @SpringBootApplication
@EnableTransactionManagement @EnableTransactionManagement
@MapperScan("com.ruoyi.project.*.*.dao") @MapperScan("com.ruoyi.project.*.*.mapper")
public class RuoYiApplication public class RuoYiApplication
{ {
public static void main(String[] args) public static void main(String[] args)
......
...@@ -38,4 +38,24 @@ public class CommonConstant ...@@ -38,4 +38,24 @@ public class CommonConstant
*/ */
public static String AUTO_REOMVE_PRE = "true"; public static String AUTO_REOMVE_PRE = "true";
/**
* 当前记录起始索引
*/
public static String PAGENUM = "pageNum";
/**
* 每页显示记录数
*/
public static String PAGESIZE = "pageSize";
/**
* 排序列
*/
public static String ORDERBYCOLUMN = "orderByColumn";
/**
* 排序的方向 "desc" 或者 "asc".
*/
public static String ISASC = "isAsc";
} }
...@@ -39,8 +39,8 @@ public class CommonMap ...@@ -39,8 +39,8 @@ public class CommonMap
javaTypeMap.put("text", "String"); javaTypeMap.put("text", "String");
javaTypeMap.put("mediumtext", "String"); javaTypeMap.put("mediumtext", "String");
javaTypeMap.put("longtext", "String"); javaTypeMap.put("longtext", "String");
javaTypeMap.put("date", "String"); javaTypeMap.put("date", "Date");
javaTypeMap.put("datetime", "String"); javaTypeMap.put("datetime", "Date");
javaTypeMap.put("timestamp", "String"); javaTypeMap.put("timestamp", "Date");
} }
} }
...@@ -37,4 +37,29 @@ public interface ShiroConstants ...@@ -37,4 +37,29 @@ public interface ShiroConstants
*/ */
public String ONLINE_SESSION = "online_session"; public String ONLINE_SESSION = "online_session";
/**
* 验证码key
*/
public static final String CURRENT_CAPTCHA = "captcha";
/**
* 验证码开关
*/
public static final String CURRENT_EBABLED = "captchaEbabled";
/**
* 验证码开关
*/
public static final String CURRENT_TYPE = "captchaType";
/**
* 验证码
*/
public static final String CURRENT_VALIDATECODE = "validateCode";
/**
* 验证码错误
*/
public static final String CAPTCHA_ERROR = "captchaError";
} }
package com.ruoyi.common.exception.base;
/**
* Dao异常
*
* @author ruoyi
*/
public class DaoException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 错误消息
*/
private String defaultMessage;
public DaoException(String defaultMessage)
{
this.defaultMessage = defaultMessage;
}
public String getDefaultMessage()
{
return defaultMessage;
}
@Override
public String toString()
{
return this.getClass() + "{" + "message='" + getMessage() + '\'' + '}';
}
}
package com.ruoyi.common.exception.file;
import org.apache.commons.fileupload.FileUploadException;
/**
* 文件名超长 误异常类
*
* @author ruoyi
*/
public class FileNameLengthLimitExceededException extends FileUploadException
{
private static final long serialVersionUID = 1L;
private int length;
private int maxLength;
private String filename;
public FileNameLengthLimitExceededException(String filename, int length, int maxLength)
{
super("file name : [" + filename + "], length : [" + length + "], max length : [" + maxLength + "]");
this.length = length;
this.maxLength = maxLength;
this.filename = filename;
}
public String getFilename()
{
return filename;
}
public int getLength()
{
return length;
}
public int getMaxLength()
{
return maxLength;
}
}
package com.ruoyi.common.exception.file;
import java.util.Arrays;
import org.apache.commons.fileupload.FileUploadException;
/**
* 文件上传 误异常类
*
* @author ruoyi
*/
public class InvalidExtensionException extends FileUploadException
{
private static final long serialVersionUID = 1L;
private String[] allowedExtension;
private String extension;
private String filename;
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
{
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : ["
+ Arrays.toString(allowedExtension) + "]");
this.allowedExtension = allowedExtension;
this.extension = extension;
this.filename = filename;
}
public String[] getAllowedExtension()
{
return allowedExtension;
}
public String getExtension()
{
return extension;
}
public String getFilename()
{
return filename;
}
public static class InvalidImageExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
public static class InvalidFlashExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
public static class InvalidMediaExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
}
package com.ruoyi.common.exception.user;
/**
* 验证码错误异常类
*
* @author ruoyi
*/
public class CaptchaException extends UserException
{
private static final long serialVersionUID = 1L;
public CaptchaException()
{
super("user.jcaptcha.error", null);
}
}
...@@ -4,6 +4,8 @@ import java.text.ParseException; ...@@ -4,6 +4,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
/** /**
* 时间工具类 * 时间工具类
* *
...@@ -11,9 +13,15 @@ import java.util.Date; ...@@ -11,9 +13,15 @@ import java.util.Date;
*/ */
public class DateUtils public class DateUtils
{ {
public static final String DEFAULT_YYYYMMDD = "yyyyMMddHHmmss"; public static String YYYY = "yyyy";
public static String YYYY_MM = "yyyy-MM";
public static String YYYY_MM_DD = "yyyy-MM-dd";
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static final String DEFAULT_YYYY_MM_DD = "yyyy-MM-dd HH:mm:ss"; public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
/** /**
* 获取当前日期, 默认格式为yyyy-MM-dd * 获取当前日期, 默认格式为yyyy-MM-dd
...@@ -22,30 +30,30 @@ public class DateUtils ...@@ -22,30 +30,30 @@ public class DateUtils
*/ */
public static String getDate() public static String getDate()
{ {
return dateTimeNow("yyyy-MM-dd"); return dateTimeNow(YYYY_MM_DD);
} }
public static final String dateTimeStr() public static final String getTime()
{ {
return dateTimeNow(DEFAULT_YYYY_MM_DD); return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
} }
public static final String dateTimeNow() public static final String dateTimeNow()
{ {
return dateTimeNow(DEFAULT_YYYYMMDD); return dateTimeNow(YYYYMMDDHHMMSS);
} }
public static final String dateTimeNow(final String format) public static final String dateTimeNow(final String format)
{ {
return dateTime(format, new Date()); return parseDateToStr(format, new Date());
} }
public static final String dateTime(final Date date) public static final String dateTime(final Date date)
{ {
return dateTime(DEFAULT_YYYYMMDD, date); return parseDateToStr(YYYY_MM_DD, date);
} }
public static final String dateTime(final String format, final Date date) public static final String parseDateToStr(final String format, final Date date)
{ {
return new SimpleDateFormat(format).format(date); return new SimpleDateFormat(format).format(date);
} }
...@@ -62,4 +70,22 @@ public class DateUtils ...@@ -62,4 +70,22 @@ public class DateUtils
} }
} }
/**
* 日期路径 即年/月/日 如2018/08/08
*/
public static final String datePath()
{
Date now = new Date();
return DateFormatUtils.format(now, "yyyy/MM/dd");
}
/**
* 日期路径 即年/月/日 如20180808
*/
public static final String dateTime()
{
Date now = new Date();
return DateFormatUtils.format(now, "yyyyMMdd");
}
} }
package com.ruoyi.common.utils;
import java.io.File;
import java.io.IOException;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.tomcat.util.http.fileupload.FileUploadBase.FileSizeLimitExceededException;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
import com.ruoyi.framework.config.RuoYiConfig;
/**
* 文件上传工具类
*
* @author ruoyi
*/
public class FileUploadUtils
{
// 默认大小 50M
public static final long DEFAULT_MAX_SIZE = 52428800;
// 默认上传的地址
private static String defaultBaseDir = RuoYiConfig.getProfile();
// 默认的文件名最大长度
public static final int DEFAULT_FILE_NAME_LENGTH = 200;
// 默认文件类型jpg
public static final String IMAGE_JPG_EXTENSION = ".jpg";
private static int counter = 0;
public static void setDefaultBaseDir(String defaultBaseDir)
{
FileUploadUtils.defaultBaseDir = defaultBaseDir;
}
public static String getDefaultBaseDir()
{
return defaultBaseDir;
}
/**
* 以默认配置进行文件上传
*
* @param file 上传的文件
* @return 文件名称
* @throws Exception
*/
public static final String upload(MultipartFile file) throws IOException
{
try
{
return upload(getDefaultBaseDir(), file, FileUploadUtils.IMAGE_JPG_EXTENSION);
}
catch (Exception e)
{
throw new IOException(e);
}
}
/**
* 根据文件路径上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @return 文件名称
* @throws IOException
*/
public static final String upload(String baseDir, MultipartFile file) throws IOException
{
try
{
return upload(baseDir, file, FileUploadUtils.IMAGE_JPG_EXTENSION);
}
catch (Exception e)
{
throw new IOException(e);
}
}
/**
* 文件上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @param needDatePathAndRandomName 是否需要日期目录和随机文件名前缀
* @param extension 上传文件类型
* @return 返回上传成功的文件名
* @throws FileSizeLimitExceededException 如果超出最大大小
* @throws FileNameLengthLimitExceededException 文件名太长
* @throws IOException 比如读写文件出错时
*/
public static final String upload(String baseDir, MultipartFile file, String extension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException
{
int fileNamelength = file.getOriginalFilename().length();
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
{
throw new FileNameLengthLimitExceededException(file.getOriginalFilename(), fileNamelength,
FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
}
assertAllowed(file);
String fileName = encodingFilename(file.getOriginalFilename(), extension);
File desc = getAbsoluteFile(baseDir, baseDir + fileName);
file.transferTo(desc);
return fileName;
}
private static final File getAbsoluteFile(String uploadDir, String filename) throws IOException
{
File desc = new File(File.separator + filename);
if (!desc.getParentFile().exists())
{
desc.getParentFile().mkdirs();
}
if (!desc.exists())
{
desc.createNewFile();
}
return desc;
}
/**
* 编码文件名
*/
private static final String encodingFilename(String filename, String extension)
{
filename = filename.replace("_", " ");
filename = new Md5Hash(filename + System.nanoTime() + counter++).toHex().toString() + extension;
return filename;
}
/**
* 文件大小校验
*
* @param file 上传的文件
* @return
* @throws FileSizeLimitExceededException 如果超出最大大小
*/
public static final void assertAllowed(MultipartFile file) throws FileSizeLimitExceededException
{
long size = file.getSize();
if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
{
throw new FileSizeLimitExceededException("not allowed upload upload", size, DEFAULT_MAX_SIZE);
}
}
}
package com.ruoyi.common.utils; package com.ruoyi.common.utils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -12,11 +15,65 @@ import org.springframework.web.context.request.ServletRequestAttributes; ...@@ -12,11 +15,65 @@ import org.springframework.web.context.request.ServletRequestAttributes;
public class ServletUtils public class ServletUtils
{ {
/** /**
* 获取request对象 * 获取getStrAttribute
*/ */
public static HttpServletRequest getHttpServletRequest() public static String getStrAttribute(String name)
{ {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); return StringUtils.valueAsStr(getRequestAttributes().getRequest().getAttribute(name));
}
/**
* 获取getIntAttribute
*/
public static int getIntAttribute(String name)
{
return StringUtils.valueAsInt(getRequestAttributes().getRequest().getAttribute(name));
}
/**
* 获取getStrParameter
*/
public static String getStrParameter(String name)
{
return StringUtils.valueAsStr(getRequestAttributes().getRequest().getParameter(name));
}
/**
* 获取getIntParameter
*/
public static Integer getIntParameter(String name)
{
return StringUtils.valueAsInt(getRequestAttributes().getRequest().getParameter(name));
}
public static ServletRequestAttributes getRequestAttributes()
{
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes;
}
/**
* 获取request
*/
public static HttpServletRequest getRequest()
{
return getRequestAttributes().getRequest();
}
/**
* 获取response
*/
public static HttpServletResponse getResponse()
{
return getRequestAttributes().getResponse();
}
/**
* 获取session
*/
public static HttpSession getSession()
{
return getRequest().getSession();
} }
/** /**
...@@ -51,4 +108,5 @@ public class ServletUtils ...@@ -51,4 +108,5 @@ public class ServletUtils
return false; return false;
} }
} }
...@@ -298,4 +298,54 @@ public class StringUtils ...@@ -298,4 +298,54 @@ public class StringUtils
} }
return result.toString(); return result.toString();
} }
/**
* 字符串数据处理
*/
public static String valueAsStr(Object value)
{
if (value instanceof String)
{
return (String) value;
}
else if (value != null)
{
return value.toString();
}
else
{
return null;
}
}
/**
* 整型数据处理
*/
public static Integer valueAsInt(Object value)
{
if (value instanceof Integer)
{
return (Integer) value;
}
else if (value instanceof Number)
{
return ((Number) value).intValue();
}
else if (value instanceof String)
{
if ("NaN".equals(value))
{
return null;
}
return Integer.valueOf((String) value);
}
else if (value instanceof Boolean)
{
return ((Boolean) value) ? 1 : 0;
}
else
{
return null;
}
}
} }
\ No newline at end of file
...@@ -2,13 +2,11 @@ package com.ruoyi.common.utils; ...@@ -2,13 +2,11 @@ package com.ruoyi.common.utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.CommonConstant; import com.ruoyi.common.constant.CommonConstant;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.project.monitor.logininfor.domain.Logininfor; import com.ruoyi.project.monitor.logininfor.domain.Logininfor;
import com.ruoyi.project.monitor.logininfor.service.LogininforServiceImpl; import com.ruoyi.project.monitor.logininfor.service.LogininforServiceImpl;
import eu.bitwalker.useragentutils.UserAgent; import eu.bitwalker.useragentutils.UserAgent;
/** /**
...@@ -53,7 +51,7 @@ public class SystemLogUtils ...@@ -53,7 +51,7 @@ public class SystemLogUtils
public static void saveOpLog(String username, String message, String status) public static void saveOpLog(String username, String message, String status)
{ {
UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getHttpServletRequest().getHeader("User-Agent")); UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
// 获取客户端操作系统 // 获取客户端操作系统
String os = userAgent.getOperatingSystem().getName(); String os = userAgent.getOperatingSystem().getName();
// 获取客户端浏览器 // 获取客户端浏览器
......
package com.ruoyi.common.utils.security; package com.ruoyi.common.utils.security;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection; import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection; import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.system.user.domain.User;
/** /**
...@@ -19,6 +19,11 @@ public class ShiroUtils ...@@ -19,6 +19,11 @@ public class ShiroUtils
{ {
return SecurityUtils.getSubject(); return SecurityUtils.getSubject();
} }
public static Session getSession()
{
return SecurityUtils.getSubject().getSession();
}
public static void logout() public static void logout()
{ {
......
...@@ -87,7 +87,7 @@ public class LogAspect ...@@ -87,7 +87,7 @@ public class LogAspect
// 请求的地址 // 请求的地址
String ip = ShiroUtils.getIp(); String ip = ShiroUtils.getIp();
operLog.setOperIp(ip); operLog.setOperIp(ip);
operLog.setOperUrl(ServletUtils.getHttpServletRequest().getRequestURI()); operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
if (currentUser != null) if (currentUser != null)
{ {
operLog.setLoginName(currentUser.getLoginName()); operLog.setLoginName(currentUser.getLoginName());
...@@ -148,7 +148,7 @@ public class LogAspect ...@@ -148,7 +148,7 @@ public class LogAspect
*/ */
private static void setRequestValue(OperLog operLog) private static void setRequestValue(OperLog operLog)
{ {
Map<String, String[]> map = ServletUtils.getHttpServletRequest().getParameterMap(); Map<String, String[]> map = ServletUtils.getRequest().getParameterMap();
String params = JSONObject.toJSONString(map); String params = JSONObject.toJSONString(map);
operLog.setOperParam(StringUtils.substring(params, 0, 255)); operLog.setOperParam(StringUtils.substring(params, 0, 255));
} }
......
package com.ruoyi.framework.config;
import java.util.Properties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
/**
* 验证码配置
*
* @author ruoyi
*/
@Configuration
public class CaptchaConfig
{
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean()
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
properties.setProperty("kaptcha.border", "yes");
properties.setProperty("kaptcha.border.color", "105,179,90");
properties.setProperty("kaptcha.textproducer.font.color", "blue");
properties.setProperty("kaptcha.image.width", "160");
properties.setProperty("kaptcha.image.height", "60");
properties.setProperty("kaptcha.textproducer.font.size", "28");
properties.setProperty("kaptcha.session.key", "kaptchaCode");
properties.setProperty("kaptcha.textproducer.char.spac", "35");
properties.setProperty("kaptcha.textproducer.char.length", "5");
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
properties.setProperty("kaptcha.noise.color", "white");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
@Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath()
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
properties.setProperty("kaptcha.border", "yes");
properties.setProperty("kaptcha.border.color", "105,179,90");
properties.setProperty("kaptcha.textproducer.font.color", "blue");
properties.setProperty("kaptcha.image.width", "160");
properties.setProperty("kaptcha.image.height", "60");
properties.setProperty("kaptcha.textproducer.font.size", "38");
properties.setProperty("kaptcha.session.key", "kaptchaCodeMath");
properties.setProperty("kaptcha.textproducer.impl", "com.ruoyi.framework.config.KaptchaTextCreator");
properties.setProperty("kaptcha.textproducer.char.spac", "5");
properties.setProperty("kaptcha.textproducer.char.length", "6");
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
properties.setProperty("kaptcha.noise.color", "white");
properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}
package com.ruoyi.framework.config;
import java.util.Random;
import com.google.code.kaptcha.text.impl.DefaultTextCreator;
/**
* 验证码文本生成器
*
* @author ruoyi
*/
public class KaptchaTextCreator extends DefaultTextCreator
{
private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(",");
@Override
public String getText()
{
Integer result = 0;
Random random = new Random();
int x = random.nextInt(10);
int y = random.nextInt(10);
StringBuilder suChinese = new StringBuilder();
int randomoperands = (int) Math.round(Math.random() * 2);
if (randomoperands == 0)
{
result = x * y;
suChinese.append(CNUMBERS[x]);
suChinese.append("*");
suChinese.append(CNUMBERS[y]);
}
else if (randomoperands == 1)
{
if (!(x == 0) && y % x == 0)
{
result = y / x;
suChinese.append(CNUMBERS[y]);
suChinese.append("/");
suChinese.append(CNUMBERS[x]);
}
else
{
result = x + y;
suChinese.append(CNUMBERS[x]);
suChinese.append("+");
suChinese.append(CNUMBERS[y]);
}
}
else if (randomoperands == 2)
{
if (x >= y)
{
result = x - y;
suChinese.append(CNUMBERS[x]);
suChinese.append("-");
suChinese.append(CNUMBERS[y]);
}
else
{
result = y - x;
suChinese.append(CNUMBERS[y]);
suChinese.append("-");
suChinese.append(CNUMBERS[x]);
}
}
else
{
result = x + y;
suChinese.append(CNUMBERS[x]);
suChinese.append("+");
suChinese.append(CNUMBERS[y]);
}
suChinese.append("=?@" + result);
return suChinese.toString();
}
}
...@@ -3,6 +3,7 @@ package com.ruoyi.framework.config; ...@@ -3,6 +3,7 @@ package com.ruoyi.framework.config;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
...@@ -12,7 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter ...@@ -12,7 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
public class BaseConfig extends WebMvcConfigurerAdapter public class ResourcesConfig extends WebMvcConfigurerAdapter
{ {
/** /**
...@@ -31,4 +32,10 @@ public class BaseConfig extends WebMvcConfigurerAdapter ...@@ -31,4 +32,10 @@ public class BaseConfig extends WebMvcConfigurerAdapter
registry.setOrder(Ordered.HIGHEST_PRECEDENCE); registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
super.addViewControllers(registry); super.addViewControllers(registry);
} }
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/profile/**").addResourceLocations("file:" + RuoYiConfig.getProfile());
}
} }
\ No newline at end of file
...@@ -18,6 +18,8 @@ public class RuoYiConfig ...@@ -18,6 +18,8 @@ public class RuoYiConfig
private String version; private String version;
/** 版权年份 */ /** 版权年份 */
private String copyrightYear; private String copyrightYear;
/** 上传路径 */
private static String profile;
public String getName() public String getName()
{ {
...@@ -49,4 +51,14 @@ public class RuoYiConfig ...@@ -49,4 +51,14 @@ public class RuoYiConfig
this.copyrightYear = copyrightYear; this.copyrightYear = copyrightYear;
} }
public static String getProfile()
{
return profile;
}
public static void setProfile(String profile)
{
RuoYiConfig.profile = profile;
}
} }
...@@ -2,25 +2,33 @@ package com.ruoyi.framework.config; ...@@ -2,25 +2,33 @@ package com.ruoyi.framework.config;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.Filter; import javax.servlet.Filter;
import org.apache.shiro.cache.ehcache.EhCacheManager; import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.CookieRememberMeManager;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.servlet.SimpleCookie;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.ruoyi.framework.shiro.realm.UserRealm; import com.ruoyi.framework.shiro.realm.UserRealm;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO; import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.framework.shiro.session.OnlineSessionFactory; import com.ruoyi.framework.shiro.session.OnlineSessionFactory;
import com.ruoyi.framework.shiro.web.filter.LogoutFilter; import com.ruoyi.framework.shiro.web.filter.LogoutFilter;
import com.ruoyi.framework.shiro.web.filter.captcha.CaptchaValidateFilter;
import com.ruoyi.framework.shiro.web.filter.online.OnlineSessionFilter; import com.ruoyi.framework.shiro.web.filter.online.OnlineSessionFilter;
import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter; import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter;
import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager; import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler; import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect; import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
/** /**
...@@ -41,6 +49,30 @@ public class ShiroConfig ...@@ -41,6 +49,30 @@ public class ShiroConfig
@Value("${shiro.session.validationInterval}") @Value("${shiro.session.validationInterval}")
private int validationInterval; private int validationInterval;
// 验证码开关
@Value("${shiro.user.captchaEbabled}")
private boolean captchaEbabled;
// 验证码类型
@Value("${shiro.user.captchaType}")
private String captchaType;
// 设置Cookie的域名
@Value("${shiro.cookie.domain}")
private String domain;
// 设置cookie的有效访问路径
@Value("${shiro.cookie.path}")
private String path;
// 设置HttpOnly属性
@Value("${shiro.cookie.httpOnly}")
private boolean httpOnly;
// 设置Cookie的过期时间,秒为单位
@Value("${shiro.cookie.maxAge}")
private int maxAge;
// 登录地址 // 登录地址
@Value("${shiro.user.loginUrl}") @Value("${shiro.user.loginUrl}")
private String loginUrl; private String loginUrl;
...@@ -160,6 +192,8 @@ public class ShiroConfig ...@@ -160,6 +192,8 @@ public class ShiroConfig
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 设置realm. // 设置realm.
securityManager.setRealm(userRealm); securityManager.setRealm(userRealm);
// 记住我
securityManager.setRememberMeManager(rememberMeManager());
// 注入缓存管理器; // 注入缓存管理器;
securityManager.setCacheManager(getEhCacheManager()); securityManager.setCacheManager(getEhCacheManager());
// session管理器 // session管理器
...@@ -199,26 +233,28 @@ public class ShiroConfig ...@@ -199,26 +233,28 @@ public class ShiroConfig
filterChainDefinitionMap.put("/docs/**", "anon"); filterChainDefinitionMap.put("/docs/**", "anon");
filterChainDefinitionMap.put("/fonts/**", "anon"); filterChainDefinitionMap.put("/fonts/**", "anon");
filterChainDefinitionMap.put("/img/**", "anon"); filterChainDefinitionMap.put("/img/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/ajax/**", "anon"); filterChainDefinitionMap.put("/ajax/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/ruoyi/**", "anon"); filterChainDefinitionMap.put("/ruoyi/**", "anon");
filterChainDefinitionMap.put("/druid/**", "anon"); filterChainDefinitionMap.put("/druid/**", "anon");
// 不需要拦截的访问 filterChainDefinitionMap.put("/captcha/captchaImage**", "anon");
filterChainDefinitionMap.put("/login", "anon");
// 退出 logout地址,shiro去清除session // 退出 logout地址,shiro去清除session
filterChainDefinitionMap.put("/logout", "logout"); filterChainDefinitionMap.put("/logout", "logout");
// 不需要拦截的访问
filterChainDefinitionMap.put("/login", "anon,captchaValidate");
// 系统权限列表 // 系统权限列表
// filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll()); // filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll());
Map<String, Filter> filters = new LinkedHashMap<>(); Map<String, Filter> filters = new LinkedHashMap<>();
filters.put("onlineSession", onlineSessionFilter()); filters.put("onlineSession", onlineSessionFilter());
filters.put("syncOnlineSession", syncOnlineSessionFilter()); filters.put("syncOnlineSession", syncOnlineSessionFilter());
filters.put("captchaValidate", captchaValidateFilter());
// 注销成功,则跳转到指定页面 // 注销成功,则跳转到指定页面
filters.put("logout", logoutFilter()); filters.put("logout", logoutFilter());
shiroFilterFactoryBean.setFilters(filters); shiroFilterFactoryBean.setFilters(filters);
// 所有请求需要认证 // 所有请求需要认证
filterChainDefinitionMap.put("/**", "authc"); filterChainDefinitionMap.put("/**", "user");
// 系统请求记录当前会话 // 系统请求记录当前会话
filterChainDefinitionMap.put("/main", "onlineSession,syncOnlineSession"); filterChainDefinitionMap.put("/main", "onlineSession,syncOnlineSession");
filterChainDefinitionMap.put("/system/**", "onlineSession,syncOnlineSession"); filterChainDefinitionMap.put("/system/**", "onlineSession,syncOnlineSession");
...@@ -250,6 +286,42 @@ public class ShiroConfig ...@@ -250,6 +286,42 @@ public class ShiroConfig
} }
/** /**
* 自定义验证码过滤器
*/
@Bean
public CaptchaValidateFilter captchaValidateFilter()
{
CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter();
captchaValidateFilter.setCaptchaEbabled(captchaEbabled);
captchaValidateFilter.setCaptchaType(captchaType);
return captchaValidateFilter;
}
/**
* cookie 属性设置
*/
public SimpleCookie rememberMeCookie()
{
SimpleCookie cookie = new SimpleCookie("rememberMe");
cookie.setDomain(domain);
cookie.setPath(path);
cookie.setHttpOnly(httpOnly);
cookie.setMaxAge(maxAge * 24 * 60 * 60);
return cookie;
}
/**
* 记住我
*/
public CookieRememberMeManager rememberMeManager()
{
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCookie(rememberMeCookie());
cookieRememberMeManager.setCipherKey(Base64.decode("fCq+/xW488hMTCD+cmJ3aQ=="));
return cookieRememberMeManager;
}
/**
* 开启Shiro代理 * 开启Shiro代理
*/ */
@Bean @Bean
......
package com.ruoyi.framework.mybatis;
import java.lang.reflect.Field;
/**
* 拦截需要分页SQL 反射工具
*
* @author ruoyi
*/
public class ReflectHelper
{
/**
* 获取obj对象fieldName的Field
*
* @param obj
* @param fieldName
* @return
*/
public static Field getFieldByFieldName(Object obj, String fieldName)
{
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass())
{
try
{
return superClass.getDeclaredField(fieldName);
}
catch (NoSuchFieldException e)
{
}
}
return null;
}
/**
* 获取obj对象fieldName的属性值
*
* @param obj
* @param fieldName
* @return
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static Object getValueByFieldName(Object obj, String fieldName)
throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
{
Field field = getFieldByFieldName(obj, fieldName);
Object value = null;
if (field != null)
{
if (field.isAccessible())
{
value = field.get(obj);
}
else
{
field.setAccessible(true);
value = field.get(obj);
field.setAccessible(false);
}
}
return value;
}
/**
* 设置obj对象fieldName的属性值
*
* @param obj
* @param fieldName
* @param value
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static void setValueByFieldName(Object obj, String fieldName, Object value)
throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
{
Field field = obj.getClass().getDeclaredField(fieldName);
if (field.isAccessible())
{
field.set(obj, value);
}
else
{
field.setAccessible(true);
field.set(obj, value);
field.setAccessible(false);
}
}
}
...@@ -16,6 +16,7 @@ import org.apache.shiro.subject.PrincipalCollection; ...@@ -16,6 +16,7 @@ import org.apache.shiro.subject.PrincipalCollection;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.RoleBlockedException; import com.ruoyi.common.exception.user.RoleBlockedException;
import com.ruoyi.common.exception.user.UserBlockedException; import com.ruoyi.common.exception.user.UserBlockedException;
import com.ruoyi.common.exception.user.UserNotExistsException; import com.ruoyi.common.exception.user.UserNotExistsException;
...@@ -79,6 +80,10 @@ public class UserRealm extends AuthorizingRealm ...@@ -79,6 +80,10 @@ public class UserRealm extends AuthorizingRealm
{ {
user = loginService.login(username, password); user = loginService.login(username, password);
} }
catch (CaptchaException e)
{
throw new AuthenticationException(e.getMessage(), e);
}
catch (UserNotExistsException e) catch (UserNotExistsException e)
{ {
throw new UnknownAccountException(e.getMessage(), e); throw new UnknownAccountException(e.getMessage(), e);
......
...@@ -4,11 +4,14 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -4,11 +4,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.ruoyi.common.constant.CommonConstant; import com.ruoyi.common.constant.CommonConstant;
import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.UserBlockedException; import com.ruoyi.common.exception.user.UserBlockedException;
import com.ruoyi.common.exception.user.UserNotExistsException; import com.ruoyi.common.exception.user.UserNotExistsException;
import com.ruoyi.common.exception.user.UserPasswordNotMatchException; import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.SystemLogUtils; import com.ruoyi.common.utils.SystemLogUtils;
import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.service.IUserService; import com.ruoyi.project.system.user.service.IUserService;
...@@ -32,6 +35,12 @@ public class LoginService ...@@ -32,6 +35,12 @@ public class LoginService
*/ */
public User login(String username, String password) public User login(String username, String password)
{ {
// 验证码校验
if (!StringUtils.isEmpty(ServletUtils.getStrAttribute(ShiroConstants.CURRENT_CAPTCHA)))
{
SystemLogUtils.log(username, CommonConstant.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
throw new CaptchaException();
}
// 用户名或密码为空 错误 // 用户名或密码为空 错误
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password))
{ {
......
...@@ -85,7 +85,17 @@ public class PasswordService ...@@ -85,7 +85,17 @@ public class PasswordService
public static void main(String[] args) public static void main(String[] args)
{ {
System.out.println(new PasswordService().encryptPassword("admin", "admin123", "111111")); //System.out.println(new PasswordService().encryptPassword("admin", "admin123", "111111"));
System.out.println(new PasswordService().encryptPassword("ry", "admin123", "222222")); //System.out.println(new PasswordService().encryptPassword("ry", "admin123", "222222"));
System.out.println(new PasswordService().encryptPassword("ly", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ce", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("zs", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ls", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ww", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("zl", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("sq", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("zb", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("wj", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ys", "admin123", "123456"));
} }
} }
...@@ -11,7 +11,6 @@ import com.ruoyi.common.utils.IpUtils; ...@@ -11,7 +11,6 @@ import com.ruoyi.common.utils.IpUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.monitor.online.domain.OnlineSession; import com.ruoyi.project.monitor.online.domain.OnlineSession;
import com.ruoyi.project.monitor.online.domain.UserOnline; import com.ruoyi.project.monitor.online.domain.UserOnline;
import eu.bitwalker.useragentutils.UserAgent; import eu.bitwalker.useragentutils.UserAgent;
/** /**
...@@ -42,8 +41,7 @@ public class OnlineSessionFactory implements SessionFactory ...@@ -42,8 +41,7 @@ public class OnlineSessionFactory implements SessionFactory
HttpServletRequest request = (HttpServletRequest) sessionContext.getServletRequest(); HttpServletRequest request = (HttpServletRequest) sessionContext.getServletRequest();
if (request != null) if (request != null)
{ {
UserAgent userAgent = UserAgent UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
.parseUserAgentString(ServletUtils.getHttpServletRequest().getHeader("User-Agent"));
// 获取客户端操作系统 // 获取客户端操作系统
String os = userAgent.getOperatingSystem().getName(); String os = userAgent.getOperatingSystem().getName();
// 获取客户端浏览器 // 获取客户端浏览器
......
package com.ruoyi.framework.shiro.web.filter.captcha;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.web.filter.AccessControlFilter;
import com.google.code.kaptcha.Constants;
import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
/**
* 验证码过滤器
*
* @author ruoyi
*/
public class CaptchaValidateFilter extends AccessControlFilter
{
/**
* 是否开启验证码
*/
private boolean captchaEbabled = true;
/**
* 验证码类型
*/
private String captchaType = "math";
public void setCaptchaEbabled(boolean captchaEbabled)
{
this.captchaEbabled = captchaEbabled;
}
public void setCaptchaType(String captchaType)
{
this.captchaType = captchaType;
}
@Override
public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception
{
request.setAttribute(ShiroConstants.CURRENT_EBABLED, captchaEbabled);
request.setAttribute(ShiroConstants.CURRENT_TYPE, captchaType);
return super.onPreHandle(request, response, mappedValue);
}
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
throws Exception
{
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
// 验证码禁用 或不是表单提交 允许访问
if (captchaEbabled == false || !"post".equals(httpServletRequest.getMethod().toLowerCase()))
{
return true;
}
return validateResponse(httpServletRequest, httpServletRequest.getParameter(ShiroConstants.CURRENT_VALIDATECODE));
}
public boolean validateResponse(HttpServletRequest request, String validateCode)
{
Object obj = ShiroUtils.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
String code = String.valueOf(obj != null ? obj : "");
if (StringUtils.isEmpty(validateCode) || !validateCode.equalsIgnoreCase(code))
{
return false;
}
return true;
}
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception
{
request.setAttribute(ShiroConstants.CURRENT_CAPTCHA, ShiroConstants.CAPTCHA_ERROR);
return true;
}
}
...@@ -6,9 +6,8 @@ import com.github.pagehelper.PageInfo; ...@@ -6,9 +6,8 @@ import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.framework.web.page.PageUtilEntity;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.support.TableSupport; import com.ruoyi.framework.web.page.TableSupport;
import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.system.user.domain.User;
/** /**
...@@ -19,25 +18,16 @@ import com.ruoyi.project.system.user.domain.User; ...@@ -19,25 +18,16 @@ import com.ruoyi.project.system.user.domain.User;
public class BaseController public class BaseController
{ {
/** /**
* 获取请求分页数据
*/
public PageUtilEntity getPageUtilEntity()
{
PageUtilEntity pageUtilEntity = TableSupport.buildPageRequest();
return pageUtilEntity;
}
/**
* 设置请求分页数据 * 设置请求分页数据
*/ */
protected void setPageInfo(Object obj) protected void startPage()
{ {
PageDomain page = (PageDomain) obj; PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(page.getPageNum()) && StringUtils.isNotEmpty(page.getPageSize())) Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
{ {
int pageNum = Integer.valueOf(page.getPageNum()); String orderBy = pageDomain.getOrderBy();
int pageSize = Integer.valueOf(page.getPageSize());
String orderBy = page.getOrderBy();
PageHelper.startPage(pageNum, pageSize, orderBy); PageHelper.startPage(pageNum, pageSize, orderBy);
} }
} }
...@@ -58,7 +48,7 @@ public class BaseController ...@@ -58,7 +48,7 @@ public class BaseController
{ {
return ShiroUtils.getUser(); return ShiroUtils.getUser();
} }
public void setUser(User user) public void setUser(User user)
{ {
ShiroUtils.setUser(user); ShiroUtils.setUser(user);
......
package com.ruoyi.framework.web.dao;
import java.util.List;
import javax.annotation.Resource;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import com.ruoyi.framework.web.page.PageUtilEntity;
import com.ruoyi.framework.web.page.TableDataInfo;
/**
* 数据DAO层通用数据处理
*
* @author ruoyi
*/
public class DynamicObjectBaseDao
{
@Resource(name = "sqlSessionTemplate")
private SqlSessionTemplate sqlSessionTemplate;
/**
* 保存对象
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int save(String str, Object obj)
{
return sqlSessionTemplate.insert(str, obj);
}
/**
* 批量更新
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int batchSave(String str, List<?> objs)
{
return sqlSessionTemplate.insert(str, objs);
}
/**
* 修改对象
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int update(String str, Object obj)
{
return sqlSessionTemplate.update(str, obj);
}
/**
* 批量更新
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public void batchUpdate(String str, List<?> objs) throws Exception
{
SqlSessionFactory sqlSessionFactory = sqlSessionTemplate.getSqlSessionFactory();
// 批量执行器
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
try
{
if (objs != null)
{
for (int i = 0, size = objs.size(); i < size; i++)
{
sqlSession.update(str, objs.get(i));
}
sqlSession.flushStatements();
sqlSession.commit();
sqlSession.clearCache();
}
}
finally
{
sqlSession.close();
}
}
/**
* 批量删除 根据对象
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int batchDelete(String str, List<?> objs) throws Exception
{
return sqlSessionTemplate.delete(str, objs);
}
/**
* 批量删除 根据数组
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int batchDelete(String str, Long[] objs)
{
return sqlSessionTemplate.delete(str, objs);
}
/**
* 删除对象
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int delete(String str, Object obj)
{
return sqlSessionTemplate.delete(str, obj);
}
/**
* 查找单条对象
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public <T> T findForObject(String str, Object obj)
{
return sqlSessionTemplate.selectOne(str, obj);
}
/**
* 查找总数
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int count(String str, Object obj)
{
return sqlSessionTemplate.selectOne(str, obj);
}
/**
* 查找对象 - 无条件
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public <E> List<E> findForList(String str)
{
return sqlSessionTemplate.selectList(str);
}
/**
* 查找对象 - 有条件
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public <E> List<E> findForList(String str, Object obj)
{
return sqlSessionTemplate.selectList(str, obj);
}
/**
* 自定义分页方法
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public TableDataInfo findForList(String str, PageUtilEntity pageUtilEntity)
{
List<?> pageList = sqlSessionTemplate.selectList(str, pageUtilEntity);
TableDataInfo tableDataInfo = new TableDataInfo(pageList, pageUtilEntity.getTotalResult());
return tableDataInfo;
}
public Object findForMap(String str, Object obj, String key, String value) throws Exception
{
return sqlSessionTemplate.selectMap(str, obj, key);
}
}
package com.ruoyi.framework.web.domain;
import java.io.Serializable;
import java.util.Date;
import com.ruoyi.common.utils.DateUtils;
/**
* Entity基类
*
* @author ruoyi
*/
public class BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
/** 搜索值 */
private String searchValue;
/** 创建者 */
private String createBy;
/** 创建时间 */
private Date createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private Date updateTime;
/** 备注 */
private String remark;
public String getSearchValue()
{
return searchValue;
}
public void setSearchValue(String searchValue)
{
this.searchValue = searchValue;
}
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTimeStr()
{
return createTime != null ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, createTime) : "";
}
public String getCreateDateTimeStr()
{
return createTime != null ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, createTime) : "";
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getUpdateTimeStr()
{
return updateTime != null ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, updateTime) : "";
}
public String getUpdateDateTimeStr()
{
return updateTime != null ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, updateTime) : "";
}
public void setUpdateTime(Date updateTime)
{
this.updateTime = updateTime;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
}
package com.ruoyi.framework.web.domain; package com.ruoyi.framework.web.domain;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
* 操作消息提醒 * 操作消息提醒
...@@ -13,12 +12,10 @@ public class Message extends HashMap<String, Object> ...@@ -13,12 +12,10 @@ public class Message extends HashMap<String, Object>
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 初始化一个新创建的 Message 对象,默认成功。 * 初始化一个新创建的 Message 对象
*/ */
public Message() public Message()
{ {
put("code", 0);
put("msg", "操作成功");
} }
/** /**
...@@ -63,34 +60,22 @@ public class Message extends HashMap<String, Object> ...@@ -63,34 +60,22 @@ public class Message extends HashMap<String, Object>
* @param msg 内容 * @param msg 内容
* @return 成功消息 * @return 成功消息
*/ */
public static Message ok(String msg) public static Message success(String msg)
{ {
Message json = new Message(); Message json = new Message();
json.put("msg", msg); json.put("msg", msg);
json.put("code", 0);
return json; return json;
} }
/**
* 返回成功消息
*
* @param map 内容
* @return 成功消息
*/
public static Message ok(Map<String, Object> map)
{
Message json = new Message();
json.putAll(map);
return json;
}
/** /**
* 返回成功消息 * 返回成功消息
* *
* @return 成功消息 * @return 成功消息
*/ */
public static Message ok() public static Message success()
{ {
return new Message(); return Message.success("操作成功");
} }
/** /**
......
package com.ruoyi.framework.web.page;
import com.ruoyi.common.utils.StringUtils;
/**
* 分页数据
*
* @author ruoyi
*/
public class PageDomain
{
/** 当前记录起始索引 */
private String pageNum;
/** 每页显示记录数 */
private String pageSize;
/** 排序列 */
private String orderByColumn;
/** 排序的方向 "desc" 或者 "asc". */
private String isAsc;
/** 搜索值 */
private String searchValue;
public String getOrderBy()
{
if (StringUtils.isEmpty(orderByColumn))
{
return "";
}
return orderByColumn + " " + isAsc;
}
public String getPageNum()
{
return pageNum;
}
public void setPageNum(String pageNum)
{
this.pageNum = pageNum;
}
public String getPageSize()
{
return pageSize;
}
public void setPageSize(String pageSize)
{
this.pageSize = pageSize;
}
public String getOrderByColumn()
{
return orderByColumn;
}
public void setOrderByColumn(String orderByColumn)
{
this.orderByColumn = orderByColumn;
}
public String getIsAsc()
{
return isAsc;
}
public void setIsAsc(String isAsc)
{
this.isAsc = isAsc;
}
public String getSearchValue()
{
return searchValue;
}
public void setSearchValue(String searchValue)
{
this.searchValue = searchValue;
}
}
package com.ruoyi.framework.web.page;
import java.util.Map;
/**
* 表格请求参数封装
*
* @author ruoyi
*/
public class PageUtilEntity
{
/** 当前记录起始索引 */
private int page;
/** 每页显示记录数 */
private int size;
/** 排序列 */
private String orderByColumn;
/** 排序的方向 "desc" 或者 "asc". */
private String isAsc;
/** true:需要分页的地方,传入的参数就是Page实体;false:需要分页的地方,传入的参数所代表的实体拥有Page属性 */
private boolean entityOrField;
/** 总记录数 */
private int totalResult;
/** 搜索值 */
private String searchValue;
/** 请求参数 */
protected Map<String, Object> reqMap;
public int getPage()
{
return page;
}
public void setPage(int page)
{
this.page = page;
}
public int getSize()
{
return size;
}
public void setSize(int size)
{
this.size = size;
}
public String getOrderByColumn()
{
return orderByColumn;
}
public void setOrderByColumn(String orderByColumn)
{
this.orderByColumn = orderByColumn;
}
public String getIsAsc()
{
return isAsc;
}
public void setIsAsc(String isAsc)
{
this.isAsc = isAsc;
}
public boolean isEntityOrField()
{
return entityOrField;
}
public void setEntityOrField(boolean entityOrField)
{
this.entityOrField = entityOrField;
}
public int getTotalResult()
{
return totalResult;
}
public void setTotalResult(int totalResult)
{
this.totalResult = totalResult;
}
public String getSearchValue()
{
return searchValue;
}
public void setSearchValue(String searchValue)
{
this.searchValue = searchValue;
}
public Map<String, Object> getReqMap()
{
return reqMap;
}
public void setReqMap(Map<String, Object> reqMap)
{
this.reqMap = reqMap;
}
}
package com.ruoyi.framework.web.support; package com.ruoyi.framework.web.page;
import javax.servlet.http.HttpServletRequest; import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.constant.CommonConstant;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.MapDataUtil; /**
import com.ruoyi.framework.web.page.PageUtilEntity; * 表格数据处理
*
/** * @author ruoyi
* 表格数据处理 */
* public class TableSupport
* @author ruoyi {
*/ /**
public class TableSupport * 封装分页对象
{ */
/** public static PageDomain getPageDomain()
* 封装分页对象 {
*/ PageDomain pageDomain = new PageDomain();
public static PageUtilEntity getPageUtilEntity() pageDomain.setPageNum(ServletUtils.getIntParameter(CommonConstant.PAGENUM));
{ pageDomain.setPageSize(ServletUtils.getIntParameter(CommonConstant.PAGESIZE));
HttpServletRequest request = ServletUtils.getHttpServletRequest(); pageDomain.setOrderByColumn(ServletUtils.getStrParameter(CommonConstant.ORDERBYCOLUMN));
PageUtilEntity pageUtilEntity = new PageUtilEntity(); pageDomain.setIsAsc(ServletUtils.getStrParameter(CommonConstant.ISASC));
pageUtilEntity.setPage(Integer.valueOf(request.getParameter("offset"))); return pageDomain;
pageUtilEntity.setSize(Integer.valueOf(request.getParameter("limit"))); }
pageUtilEntity.setOrderByColumn(request.getParameter("sort"));
pageUtilEntity.setIsAsc(request.getParameter("order")); public static PageDomain buildPageRequest()
pageUtilEntity.setSearchValue(request.getParameter("search")); {
pageUtilEntity.setReqMap(MapDataUtil.convertDataMap(request)); return getPageDomain();
return pageUtilEntity; }
}
}
public static PageUtilEntity buildPageRequest()
{
return getPageUtilEntity();
}
}
...@@ -44,7 +44,7 @@ public class JobController extends BaseController ...@@ -44,7 +44,7 @@ public class JobController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(Job job) public TableDataInfo list(Job job)
{ {
setPageInfo(job); startPage();
List<Job> list = jobService.selectJobList(job); List<Job> list = jobService.selectJobList(job);
return getDataTable(list); return getDataTable(list);
} }
...@@ -65,7 +65,7 @@ public class JobController extends BaseController ...@@ -65,7 +65,7 @@ public class JobController extends BaseController
} }
if (jobService.deleteJob(job) > 0) if (jobService.deleteJob(job) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -79,7 +79,7 @@ public class JobController extends BaseController ...@@ -79,7 +79,7 @@ public class JobController extends BaseController
try try
{ {
jobService.batchDeleteJob(ids); jobService.batchDeleteJob(ids);
return Message.ok(); return Message.success();
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -99,7 +99,7 @@ public class JobController extends BaseController ...@@ -99,7 +99,7 @@ public class JobController extends BaseController
{ {
if (jobService.changeStatus(job) > 0) if (jobService.changeStatus(job) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -139,7 +139,7 @@ public class JobController extends BaseController ...@@ -139,7 +139,7 @@ public class JobController extends BaseController
{ {
if (jobService.saveJobCron(job) > 0) if (jobService.saveJobCron(job) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
...@@ -43,7 +43,7 @@ public class JobLogController extends BaseController ...@@ -43,7 +43,7 @@ public class JobLogController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(JobLog jobLog) public TableDataInfo list(JobLog jobLog)
{ {
setPageInfo(jobLog); startPage();
List<JobLog> list = jobLogService.selectJobLogList(jobLog); List<JobLog> list = jobLogService.selectJobLogList(jobLog);
return getDataTable(list); return getDataTable(list);
} }
...@@ -64,7 +64,7 @@ public class JobLogController extends BaseController ...@@ -64,7 +64,7 @@ public class JobLogController extends BaseController
} }
if (jobLogService.deleteJobLogById(jobLogId) > 0) if (jobLogService.deleteJobLogById(jobLogId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -78,7 +78,7 @@ public class JobLogController extends BaseController ...@@ -78,7 +78,7 @@ public class JobLogController extends BaseController
try try
{ {
jobLogService.batchDeleteJoblog(ids); jobLogService.batchDeleteJoblog(ids);
return Message.ok(); return Message.success();
} }
catch (Exception e) catch (Exception e)
{ {
......
package com.ruoyi.project.monitor.job.domain; package com.ruoyi.project.monitor.job.domain;
import java.io.Serializable; import java.io.Serializable;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 定时任务调度信息 sys_job * 定时任务调度信息 sys_job
* *
* @author ruoyi * @author ruoyi
*/ */
public class Job extends PageDomain implements Serializable public class Job extends BaseEntity implements Serializable
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -26,16 +26,6 @@ public class Job extends PageDomain implements Serializable ...@@ -26,16 +26,6 @@ public class Job extends PageDomain implements Serializable
private String cronExpression; private String cronExpression;
/** 状态(0正常 1暂停) */ /** 状态(0正常 1暂停) */
private int status; private int status;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新时间 */
private String updateTime;
/** 更新者 */
private String updateBy;
/** 备注 */
private String remark;
public Long getJobId() public Long getJobId()
{ {
...@@ -107,63 +97,11 @@ public class Job extends PageDomain implements Serializable ...@@ -107,63 +97,11 @@ public class Job extends PageDomain implements Serializable
this.status = status; this.status = status;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
@Override @Override
public String toString() public String toString()
{ {
return "Job [jobId=" + jobId + ", jobName=" + jobName + ", jobGroup=" + jobGroup + ", methodName=" + methodName return "Job [jobId=" + jobId + ", jobName=" + jobName + ", jobGroup=" + jobGroup + ", methodName=" + methodName
+ ", params=" + params + ", cronExpression=" + cronExpression + ", status=" + status + ", createBy=" + ", params=" + params + ", cronExpression=" + cronExpression + ", status=" + status + "]";
+ createBy + ", createTime=" + createTime + ", updateTime=" + updateTime + ", updateBy=" + updateBy
+ ", remark=" + remark + "]";
} }
} }
package com.ruoyi.project.monitor.job.domain; package com.ruoyi.project.monitor.job.domain;
import java.util.Date; import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.framework.web.page.PageDomain;
/** /**
* 定时任务调度日志信息 sys_job_log * 定时任务调度日志信息 sys_job_log
* *
* @author ruoyi * @author ruoyi
*/ */
public class JobLog extends PageDomain public class JobLog extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** ID */ /** ID */
private Long jobLogId; private Long jobLogId;
/** 任务名称 */ /** 任务名称 */
...@@ -26,8 +26,6 @@ public class JobLog extends PageDomain ...@@ -26,8 +26,6 @@ public class JobLog extends PageDomain
private int isException; private int isException;
/** 异常信息 */ /** 异常信息 */
private String exceptionInfo; private String exceptionInfo;
/** 创建时间 */
private Date createTime;
public Long getJobLogId() public Long getJobLogId()
{ {
...@@ -109,22 +107,12 @@ public class JobLog extends PageDomain ...@@ -109,22 +107,12 @@ public class JobLog extends PageDomain
this.exceptionInfo = exceptionInfo; this.exceptionInfo = exceptionInfo;
} }
public Date getCreateTime()
{
return createTime;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
@Override @Override
public String toString() public String toString()
{ {
return "JobLog [jobLogId=" + jobLogId + ", jobName=" + jobName + ", jobGroup=" + jobGroup + ", methodName=" return "JobLog [jobLogId=" + jobLogId + ", jobName=" + jobName + ", jobGroup=" + jobGroup + ", methodName="
+ methodName + ", params=" + params + ", jobMessage=" + jobMessage + ", isException=" + isException + methodName + ", params=" + params + ", jobMessage=" + jobMessage + ", isException=" + isException
+ ", exceptionInfo=" + exceptionInfo + ", createTime=" + createTime + "]"; + ", exceptionInfo=" + exceptionInfo + "]";
} }
} }
package com.ruoyi.project.monitor.job.dao; package com.ruoyi.project.monitor.job.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.monitor.job.domain.JobLog; import com.ruoyi.project.monitor.job.domain.JobLog;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.job.domain.JobLog; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.job.domain.JobLog;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IJobLogDao public interface JobLogMapper
{ {
/** /**
......
package com.ruoyi.project.monitor.job.dao; package com.ruoyi.project.monitor.job.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.monitor.job.domain.Job; import com.ruoyi.project.monitor.job.domain.Job;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.job.domain.Job; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.job.domain.Job;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IJobDao public interface JobMapper
{ {
/** /**
......
...@@ -3,8 +3,8 @@ package com.ruoyi.project.monitor.job.service; ...@@ -3,8 +3,8 @@ package com.ruoyi.project.monitor.job.service;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.project.monitor.job.dao.IJobLogDao;
import com.ruoyi.project.monitor.job.domain.JobLog; import com.ruoyi.project.monitor.job.domain.JobLog;
import com.ruoyi.project.monitor.job.mapper.JobLogMapper;
/** /**
* 定时任务调度日志信息 服务层 * 定时任务调度日志信息 服务层
...@@ -16,7 +16,7 @@ public class JobLogServiceImpl implements IJobLogService ...@@ -16,7 +16,7 @@ public class JobLogServiceImpl implements IJobLogService
{ {
@Autowired @Autowired
private IJobLogDao jobLogDao; private JobLogMapper jobLogMapper;
/** /**
* 获取quartz调度器日志的计划任务 * 获取quartz调度器日志的计划任务
...@@ -27,7 +27,7 @@ public class JobLogServiceImpl implements IJobLogService ...@@ -27,7 +27,7 @@ public class JobLogServiceImpl implements IJobLogService
@Override @Override
public List<JobLog> selectJobLogList(JobLog jobLog) public List<JobLog> selectJobLogList(JobLog jobLog)
{ {
return jobLogDao.selectJobLogList(jobLog); return jobLogMapper.selectJobLogList(jobLog);
} }
/** /**
...@@ -39,7 +39,7 @@ public class JobLogServiceImpl implements IJobLogService ...@@ -39,7 +39,7 @@ public class JobLogServiceImpl implements IJobLogService
@Override @Override
public JobLog selectJobLogById(Long jobLogId) public JobLog selectJobLogById(Long jobLogId)
{ {
return jobLogDao.selectJobLogById(jobLogId); return jobLogMapper.selectJobLogById(jobLogId);
} }
/** /**
...@@ -50,7 +50,7 @@ public class JobLogServiceImpl implements IJobLogService ...@@ -50,7 +50,7 @@ public class JobLogServiceImpl implements IJobLogService
@Override @Override
public void addJobLog(JobLog jobLog) public void addJobLog(JobLog jobLog)
{ {
jobLogDao.insertJobLog(jobLog); jobLogMapper.insertJobLog(jobLog);
} }
/** /**
...@@ -62,7 +62,7 @@ public class JobLogServiceImpl implements IJobLogService ...@@ -62,7 +62,7 @@ public class JobLogServiceImpl implements IJobLogService
@Override @Override
public int batchDeleteJoblog(Long[] ids) public int batchDeleteJoblog(Long[] ids)
{ {
return jobLogDao.batchDeleteJobLog(ids); return jobLogMapper.batchDeleteJobLog(ids);
} }
/** /**
...@@ -73,7 +73,7 @@ public class JobLogServiceImpl implements IJobLogService ...@@ -73,7 +73,7 @@ public class JobLogServiceImpl implements IJobLogService
@Override @Override
public int deleteJobLogById(Long jobId) public int deleteJobLogById(Long jobId)
{ {
return jobLogDao.deleteJobLogById(jobId); return jobLogMapper.deleteJobLogById(jobId);
} }
} }
...@@ -9,8 +9,8 @@ import org.springframework.stereotype.Service; ...@@ -9,8 +9,8 @@ import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.constant.ScheduleConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.monitor.job.dao.IJobDao;
import com.ruoyi.project.monitor.job.domain.Job; import com.ruoyi.project.monitor.job.domain.Job;
import com.ruoyi.project.monitor.job.mapper.JobMapper;
import com.ruoyi.project.monitor.job.util.ScheduleUtils; import com.ruoyi.project.monitor.job.util.ScheduleUtils;
/** /**
...@@ -25,7 +25,7 @@ public class JobServiceImpl implements IJobService ...@@ -25,7 +25,7 @@ public class JobServiceImpl implements IJobService
private Scheduler scheduler; private Scheduler scheduler;
@Autowired @Autowired
private IJobDao jobDao; private JobMapper jobMapper;
/** /**
* 项目启动时,初始化定时器 * 项目启动时,初始化定时器
...@@ -33,7 +33,7 @@ public class JobServiceImpl implements IJobService ...@@ -33,7 +33,7 @@ public class JobServiceImpl implements IJobService
@PostConstruct @PostConstruct
public void init() public void init()
{ {
List<Job> jobList = jobDao.selectJobAll(); List<Job> jobList = jobMapper.selectJobAll();
for (Job job : jobList) for (Job job : jobList)
{ {
CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, job.getJobId()); CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, job.getJobId());
...@@ -58,7 +58,7 @@ public class JobServiceImpl implements IJobService ...@@ -58,7 +58,7 @@ public class JobServiceImpl implements IJobService
@Override @Override
public List<Job> selectJobList(Job job) public List<Job> selectJobList(Job job)
{ {
return jobDao.selectJobList(job); return jobMapper.selectJobList(job);
} }
/** /**
...@@ -70,7 +70,7 @@ public class JobServiceImpl implements IJobService ...@@ -70,7 +70,7 @@ public class JobServiceImpl implements IJobService
@Override @Override
public Job selectJobById(Long jobId) public Job selectJobById(Long jobId)
{ {
return jobDao.selectJobById(jobId); return jobMapper.selectJobById(jobId);
} }
/** /**
...@@ -83,7 +83,7 @@ public class JobServiceImpl implements IJobService ...@@ -83,7 +83,7 @@ public class JobServiceImpl implements IJobService
{ {
job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
job.setUpdateBy(ShiroUtils.getLoginName()); job.setUpdateBy(ShiroUtils.getLoginName());
int rows = jobDao.updateJob(job); int rows = jobMapper.updateJob(job);
if (rows > 0) if (rows > 0)
{ {
ScheduleUtils.pauseJob(scheduler, job.getJobId()); ScheduleUtils.pauseJob(scheduler, job.getJobId());
...@@ -101,7 +101,7 @@ public class JobServiceImpl implements IJobService ...@@ -101,7 +101,7 @@ public class JobServiceImpl implements IJobService
{ {
job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
job.setUpdateBy(ShiroUtils.getLoginName()); job.setUpdateBy(ShiroUtils.getLoginName());
int rows = jobDao.updateJob(job); int rows = jobMapper.updateJob(job);
if (rows > 0) if (rows > 0)
{ {
ScheduleUtils.resumeJob(scheduler, job.getJobId()); ScheduleUtils.resumeJob(scheduler, job.getJobId());
...@@ -117,7 +117,7 @@ public class JobServiceImpl implements IJobService ...@@ -117,7 +117,7 @@ public class JobServiceImpl implements IJobService
@Override @Override
public int deleteJob(Job job) public int deleteJob(Job job)
{ {
int rows = jobDao.deleteJobById(job); int rows = jobMapper.deleteJobById(job);
if (rows > 0) if (rows > 0)
{ {
ScheduleUtils.deleteScheduleJob(scheduler, job.getJobId()); ScheduleUtils.deleteScheduleJob(scheduler, job.getJobId());
...@@ -136,7 +136,7 @@ public class JobServiceImpl implements IJobService ...@@ -136,7 +136,7 @@ public class JobServiceImpl implements IJobService
{ {
for (Long jobId : ids) for (Long jobId : ids)
{ {
Job job = jobDao.selectJobById(jobId); Job job = jobMapper.selectJobById(jobId);
deleteJob(job); deleteJob(job);
} }
} }
...@@ -170,7 +170,7 @@ public class JobServiceImpl implements IJobService ...@@ -170,7 +170,7 @@ public class JobServiceImpl implements IJobService
@Override @Override
public int triggerJob(Job job) public int triggerJob(Job job)
{ {
int rows = jobDao.updateJob(job); int rows = jobMapper.updateJob(job);
if (rows > 0) if (rows > 0)
{ {
ScheduleUtils.run(scheduler, job); ScheduleUtils.run(scheduler, job);
...@@ -188,7 +188,7 @@ public class JobServiceImpl implements IJobService ...@@ -188,7 +188,7 @@ public class JobServiceImpl implements IJobService
{ {
job.setCreateBy(ShiroUtils.getLoginName()); job.setCreateBy(ShiroUtils.getLoginName());
job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
int rows = jobDao.insertJob(job); int rows = jobMapper.insertJob(job);
if (rows > 0) if (rows > 0)
{ {
ScheduleUtils.createScheduleJob(scheduler, job); ScheduleUtils.createScheduleJob(scheduler, job);
...@@ -204,7 +204,7 @@ public class JobServiceImpl implements IJobService ...@@ -204,7 +204,7 @@ public class JobServiceImpl implements IJobService
@Override @Override
public int updateJobCron(Job job) public int updateJobCron(Job job)
{ {
int rows = jobDao.updateJob(job); int rows = jobMapper.updateJob(job);
if (rows > 0) if (rows > 0)
{ {
ScheduleUtils.updateScheduleJob(scheduler, job); ScheduleUtils.updateScheduleJob(scheduler, job);
......
...@@ -42,7 +42,7 @@ public class LogininforController extends BaseController ...@@ -42,7 +42,7 @@ public class LogininforController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(Logininfor logininfor) public TableDataInfo list(Logininfor logininfor)
{ {
setPageInfo(logininfor); startPage();
List<Logininfor> list = logininforService.selectLogininforList(logininfor); List<Logininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list); return getDataTable(list);
} }
...@@ -56,7 +56,7 @@ public class LogininforController extends BaseController ...@@ -56,7 +56,7 @@ public class LogininforController extends BaseController
int rows = logininforService.batchDeleteLogininfor(ids); int rows = logininforService.batchDeleteLogininfor(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.monitor.logininfor.domain; package com.ruoyi.project.monitor.logininfor.domain;
import java.util.Date; import java.util.Date;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 系统访问日志情况信息 sys_logininfor * 系统访问日志情况信息 sys_logininfor
* *
* @author ruoyi * @author ruoyi
*/ */
public class Logininfor extends PageDomain public class Logininfor extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** ID */ /** ID */
private Integer infoId; private Integer infoId;
/** 用户账号 */ /** 用户账号 */
......
package com.ruoyi.project.monitor.logininfor.dao; package com.ruoyi.project.monitor.logininfor.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.monitor.logininfor.domain.Logininfor; import com.ruoyi.project.monitor.logininfor.domain.Logininfor;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.logininfor.domain.Logininfor; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.logininfor.domain.Logininfor;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface ILogininforDao public interface LogininforMapper
{ {
/** /**
* 新增系统登录日志 * 新增系统登录日志
......
...@@ -3,8 +3,8 @@ package com.ruoyi.project.monitor.logininfor.service; ...@@ -3,8 +3,8 @@ package com.ruoyi.project.monitor.logininfor.service;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.project.monitor.logininfor.dao.ILogininforDao;
import com.ruoyi.project.monitor.logininfor.domain.Logininfor; import com.ruoyi.project.monitor.logininfor.domain.Logininfor;
import com.ruoyi.project.monitor.logininfor.mapper.LogininforMapper;
/** /**
* 系统访问日志情况信息 服务层处理 * 系统访问日志情况信息 服务层处理
...@@ -16,7 +16,7 @@ public class LogininforServiceImpl implements ILogininforService ...@@ -16,7 +16,7 @@ public class LogininforServiceImpl implements ILogininforService
{ {
@Autowired @Autowired
private ILogininforDao logininforDao; private LogininforMapper logininforMapper;
/** /**
* 新增系统登录日志 * 新增系统登录日志
...@@ -26,7 +26,7 @@ public class LogininforServiceImpl implements ILogininforService ...@@ -26,7 +26,7 @@ public class LogininforServiceImpl implements ILogininforService
@Override @Override
public void insertLogininfor(Logininfor logininfor) public void insertLogininfor(Logininfor logininfor)
{ {
logininforDao.insertLogininfor(logininfor); logininforMapper.insertLogininfor(logininfor);
} }
/** /**
...@@ -38,7 +38,7 @@ public class LogininforServiceImpl implements ILogininforService ...@@ -38,7 +38,7 @@ public class LogininforServiceImpl implements ILogininforService
@Override @Override
public List<Logininfor> selectLogininforList(Logininfor logininfor) public List<Logininfor> selectLogininforList(Logininfor logininfor)
{ {
return logininforDao.selectLogininforList(logininfor); return logininforMapper.selectLogininforList(logininfor);
} }
/** /**
...@@ -50,6 +50,6 @@ public class LogininforServiceImpl implements ILogininforService ...@@ -50,6 +50,6 @@ public class LogininforServiceImpl implements ILogininforService
@Override @Override
public int batchDeleteLogininfor(Long[] ids) public int batchDeleteLogininfor(Long[] ids)
{ {
return logininforDao.batchDeleteLogininfor(ids); return logininforMapper.batchDeleteLogininfor(ids);
} }
} }
...@@ -48,7 +48,7 @@ public class UserOnlineController extends BaseController ...@@ -48,7 +48,7 @@ public class UserOnlineController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(UserOnline userOnline) public TableDataInfo list(UserOnline userOnline)
{ {
setPageInfo(userOnline); startPage();
List<UserOnline> list = userOnlineService.selectUserOnlineList(userOnline); List<UserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
return getDataTable(list); return getDataTable(list);
} }
...@@ -75,7 +75,7 @@ public class UserOnlineController extends BaseController ...@@ -75,7 +75,7 @@ public class UserOnlineController extends BaseController
online.setStatus(OnlineSession.OnlineStatus.off_line); online.setStatus(OnlineSession.OnlineStatus.off_line);
userOnlineService.saveOnline(online); userOnlineService.saveOnline(online);
} }
return Message.ok(); return Message.success();
} }
@RequiresPermissions("monitor:online:forceLogout") @RequiresPermissions("monitor:online:forceLogout")
...@@ -97,7 +97,7 @@ public class UserOnlineController extends BaseController ...@@ -97,7 +97,7 @@ public class UserOnlineController extends BaseController
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
online.setStatus(OnlineSession.OnlineStatus.off_line); online.setStatus(OnlineSession.OnlineStatus.off_line);
userOnlineService.saveOnline(online); userOnlineService.saveOnline(online);
return Message.ok(); return Message.success();
} }
} }
package com.ruoyi.project.monitor.online.domain; package com.ruoyi.project.monitor.online.domain;
import java.util.Date; import java.util.Date;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.project.monitor.online.domain.OnlineSession.OnlineStatus; import com.ruoyi.project.monitor.online.domain.OnlineSession.OnlineStatus;
/** /**
...@@ -9,8 +9,9 @@ import com.ruoyi.project.monitor.online.domain.OnlineSession.OnlineStatus; ...@@ -9,8 +9,9 @@ import com.ruoyi.project.monitor.online.domain.OnlineSession.OnlineStatus;
* *
* @author ruoyi * @author ruoyi
*/ */
public class UserOnline extends PageDomain public class UserOnline extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 用户会话id */ /** 用户会话id */
private String sessionId; private String sessionId;
......
package com.ruoyi.project.monitor.online.dao; package com.ruoyi.project.monitor.online.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.monitor.online.domain.UserOnline; import com.ruoyi.project.monitor.online.domain.UserOnline;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.online.domain.UserOnline; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.online.domain.UserOnline;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IUserOnlineDao public interface UserOnlineMapper
{ {
/** /**
* 通过会话序号查询信息 * 通过会话序号查询信息
......
...@@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO; import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.project.monitor.online.dao.IUserOnlineDao;
import com.ruoyi.project.monitor.online.domain.UserOnline; import com.ruoyi.project.monitor.online.domain.UserOnline;
import com.ruoyi.project.monitor.online.mapper.UserOnlineMapper;
/** /**
* 在线用户 服务层处理 * 在线用户 服务层处理
...@@ -19,7 +19,7 @@ import com.ruoyi.project.monitor.online.domain.UserOnline; ...@@ -19,7 +19,7 @@ import com.ruoyi.project.monitor.online.domain.UserOnline;
public class UserOnlineServiceImpl implements IUserOnlineService public class UserOnlineServiceImpl implements IUserOnlineService
{ {
@Autowired @Autowired
private IUserOnlineDao userOnlineDao; private UserOnlineMapper userOnlineDao;
@Autowired @Autowired
private OnlineSessionDAO onlineSessionDAO; private OnlineSessionDAO onlineSessionDAO;
...@@ -118,7 +118,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService ...@@ -118,7 +118,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService
@Override @Override
public List<UserOnline> selectOnlineByExpired(Date expiredDate) public List<UserOnline> selectOnlineByExpired(Date expiredDate)
{ {
String lastAccessTime = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", expiredDate); String lastAccessTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate);
return userOnlineDao.selectOnlineByExpired(lastAccessTime); return userOnlineDao.selectOnlineByExpired(lastAccessTime);
} }
} }
...@@ -43,7 +43,7 @@ public class OperlogController extends BaseController ...@@ -43,7 +43,7 @@ public class OperlogController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(OperLog operLog) public TableDataInfo list(OperLog operLog)
{ {
setPageInfo(operLog); startPage();
List<OperLog> list = operLogService.selectOperLogList(operLog); List<OperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list); return getDataTable(list);
} }
...@@ -56,7 +56,7 @@ public class OperlogController extends BaseController ...@@ -56,7 +56,7 @@ public class OperlogController extends BaseController
int rows = operLogService.batchDeleteOperLog(ids); int rows = operLogService.batchDeleteOperLog(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.monitor.operlog.domain; package com.ruoyi.project.monitor.operlog.domain;
import java.util.Date; import java.util.Date;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 操作日志记录 oper_log * 操作日志记录 oper_log
* *
* @author ruoyi * @author ruoyi
*/ */
public class OperLog extends PageDomain public class OperLog extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 日志主键 */ /** 日志主键 */
private Integer operId; private Integer operId;
/** 模块标题 */ /** 模块标题 */
......
package com.ruoyi.project.monitor.operlog.dao; package com.ruoyi.project.monitor.operlog.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.monitor.operlog.domain.OperLog; import com.ruoyi.project.monitor.operlog.domain.OperLog;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.operlog.domain.OperLog; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.monitor.operlog.domain.OperLog;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IOperLogDao public interface OperLogMapper
{ {
/** /**
* 新增操作日志 * 新增操作日志
......
...@@ -3,8 +3,8 @@ package com.ruoyi.project.monitor.operlog.service; ...@@ -3,8 +3,8 @@ package com.ruoyi.project.monitor.operlog.service;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.project.monitor.operlog.dao.IOperLogDao;
import com.ruoyi.project.monitor.operlog.domain.OperLog; import com.ruoyi.project.monitor.operlog.domain.OperLog;
import com.ruoyi.project.monitor.operlog.mapper.OperLogMapper;
/** /**
* 操作日志 服务层处理 * 操作日志 服务层处理
...@@ -15,7 +15,7 @@ import com.ruoyi.project.monitor.operlog.domain.OperLog; ...@@ -15,7 +15,7 @@ import com.ruoyi.project.monitor.operlog.domain.OperLog;
public class OperLogServiceImpl implements IOperLogService public class OperLogServiceImpl implements IOperLogService
{ {
@Autowired @Autowired
private IOperLogDao operLogDao; private OperLogMapper operLogMapper;
/** /**
* 新增操作日志 * 新增操作日志
...@@ -25,7 +25,7 @@ public class OperLogServiceImpl implements IOperLogService ...@@ -25,7 +25,7 @@ public class OperLogServiceImpl implements IOperLogService
@Override @Override
public void insertOperlog(OperLog operLog) public void insertOperlog(OperLog operLog)
{ {
operLogDao.insertOperlog(operLog); operLogMapper.insertOperlog(operLog);
} }
/** /**
...@@ -37,7 +37,7 @@ public class OperLogServiceImpl implements IOperLogService ...@@ -37,7 +37,7 @@ public class OperLogServiceImpl implements IOperLogService
@Override @Override
public List<OperLog> selectOperLogList(OperLog operLog) public List<OperLog> selectOperLogList(OperLog operLog)
{ {
return operLogDao.selectOperLogList(operLog); return operLogMapper.selectOperLogList(operLog);
} }
/** /**
...@@ -49,7 +49,7 @@ public class OperLogServiceImpl implements IOperLogService ...@@ -49,7 +49,7 @@ public class OperLogServiceImpl implements IOperLogService
@Override @Override
public int batchDeleteOperLog(Long[] ids) public int batchDeleteOperLog(Long[] ids)
{ {
return operLogDao.batchDeleteOperLog(ids); return operLogMapper.batchDeleteOperLog(ids);
} }
/** /**
...@@ -61,6 +61,6 @@ public class OperLogServiceImpl implements IOperLogService ...@@ -61,6 +61,6 @@ public class OperLogServiceImpl implements IOperLogService
@Override @Override
public OperLog selectOperLogById(Long operId) public OperLog selectOperLogById(Long operId)
{ {
return operLogDao.selectOperLogById(operId); return operLogMapper.selectOperLogById(operId);
} }
} }
...@@ -84,7 +84,7 @@ public class DeptController extends BaseController ...@@ -84,7 +84,7 @@ public class DeptController extends BaseController
{ {
if (deptService.saveDept(dept) > 0) if (deptService.saveDept(dept) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -108,7 +108,7 @@ public class DeptController extends BaseController ...@@ -108,7 +108,7 @@ public class DeptController extends BaseController
} }
if (deptService.deleteDeptById(deptId) > 0) if (deptService.deleteDeptById(deptId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.system.dept.domain; package com.ruoyi.project.system.dept.domain;
import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 部门对象 sys_dept * 部门对象 sys_dept
* *
* @author ruoyi * @author ruoyi
*/ */
public class Dept public class Dept extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 部门ID */ /** 部门ID */
private Long deptId; private Long deptId;
/** 父部门ID */ /** 父部门ID */
...@@ -25,14 +28,6 @@ public class Dept ...@@ -25,14 +28,6 @@ public class Dept
private int status; private int status;
/** 父部门名称 */ /** 父部门名称 */
private String parentName; private String parentName;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private String updateTime;
public Long getDeptId() public Long getDeptId()
{ {
...@@ -124,53 +119,12 @@ public class Dept ...@@ -124,53 +119,12 @@ public class Dept
this.parentName = parentName; this.parentName = parentName;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
@Override @Override
public String toString() public String toString()
{ {
return "Dept [deptId=" + deptId + ", parentId=" + parentId + ", deptName=" + deptName + ", orderNum=" + orderNum return "Dept [deptId=" + deptId + ", parentId=" + parentId + ", deptName=" + deptName + ", orderNum=" + orderNum
+ ", leader=" + leader + ", phone=" + phone + ", email=" + email + ", status=" + status + ", leader=" + leader + ", phone=" + phone + ", email=" + email + ", status=" + status
+ ", parentName=" + parentName + ", createBy=" + createBy + ", createTime=" + createTime + ", updateBy=" + ", parentName=" + parentName + "]";
+ updateBy + ", updateTime=" + updateTime + "]";
} }
} }
package com.ruoyi.project.system.dept.dao; package com.ruoyi.project.system.dept.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.dept.domain.Dept; import com.ruoyi.project.system.dept.domain.Dept;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.dept.domain.Dept; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.dept.domain.Dept;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IDeptDao public interface DeptMapper
{ {
/** /**
* 查询部门人数 * 查询部门人数
......
...@@ -6,12 +6,11 @@ import java.util.List; ...@@ -6,12 +6,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.dept.dao.IDeptDao;
import com.ruoyi.project.system.dept.domain.Dept; import com.ruoyi.project.system.dept.domain.Dept;
import com.ruoyi.project.system.dept.mapper.DeptMapper;
/** /**
* 部门管理 服务实现 * 部门管理 服务实现
...@@ -22,7 +21,7 @@ import com.ruoyi.project.system.dept.domain.Dept; ...@@ -22,7 +21,7 @@ import com.ruoyi.project.system.dept.domain.Dept;
public class DeptServiceImpl implements IDeptService public class DeptServiceImpl implements IDeptService
{ {
@Autowired @Autowired
private IDeptDao deptDao; private DeptMapper deptMapper;
/** /**
* 查询部门管理集合 * 查询部门管理集合
...@@ -32,7 +31,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -32,7 +31,7 @@ public class DeptServiceImpl implements IDeptService
@Override @Override
public List<Dept> selectDeptAll() public List<Dept> selectDeptAll()
{ {
return deptDao.selectDeptAll(); return deptMapper.selectDeptAll();
} }
/** /**
...@@ -44,7 +43,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -44,7 +43,7 @@ public class DeptServiceImpl implements IDeptService
public List<Map<String, Object>> selectDeptTree() public List<Map<String, Object>> selectDeptTree()
{ {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<Dept> deptList = deptDao.selectDeptAll(); List<Dept> deptList = deptMapper.selectDeptAll();
for (Dept dept : deptList) for (Dept dept : deptList)
{ {
...@@ -71,7 +70,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -71,7 +70,7 @@ public class DeptServiceImpl implements IDeptService
{ {
Dept dept = new Dept(); Dept dept = new Dept();
dept.setParentId(parentId); dept.setParentId(parentId);
return deptDao.selectDeptCount(dept); return deptMapper.selectDeptCount(dept);
} }
/** /**
...@@ -83,7 +82,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -83,7 +82,7 @@ public class DeptServiceImpl implements IDeptService
@Override @Override
public boolean checkDeptExistUser(Long deptId) public boolean checkDeptExistUser(Long deptId)
{ {
int result = deptDao.checkDeptExistUser(deptId); int result = deptMapper.checkDeptExistUser(deptId);
return result > 0 ? true : false; return result > 0 ? true : false;
} }
...@@ -96,7 +95,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -96,7 +95,7 @@ public class DeptServiceImpl implements IDeptService
@Override @Override
public int deleteDeptById(Long deptId) public int deleteDeptById(Long deptId)
{ {
return deptDao.deleteDeptById(deptId); return deptMapper.deleteDeptById(deptId);
} }
/** /**
...@@ -111,12 +110,12 @@ public class DeptServiceImpl implements IDeptService ...@@ -111,12 +110,12 @@ public class DeptServiceImpl implements IDeptService
if (StringUtils.isNotNull(dept.getDeptId())) if (StringUtils.isNotNull(dept.getDeptId()))
{ {
dept.setUpdateBy(ShiroUtils.getLoginName()); dept.setUpdateBy(ShiroUtils.getLoginName());
return deptDao.updateDept(dept); return deptMapper.updateDept(dept);
} }
else else
{ {
dept.setCreateBy(ShiroUtils.getLoginName()); dept.setCreateBy(ShiroUtils.getLoginName());
return deptDao.insertDept(dept); return deptMapper.insertDept(dept);
} }
} }
...@@ -129,7 +128,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -129,7 +128,7 @@ public class DeptServiceImpl implements IDeptService
@Override @Override
public Dept selectDeptById(Long deptId) public Dept selectDeptById(Long deptId)
{ {
return deptDao.selectDeptById(deptId); return deptMapper.selectDeptById(deptId);
} }
/** /**
...@@ -142,7 +141,7 @@ public class DeptServiceImpl implements IDeptService ...@@ -142,7 +141,7 @@ public class DeptServiceImpl implements IDeptService
public String checkDeptNameUnique(Dept dept) public String checkDeptNameUnique(Dept dept)
{ {
Long deptId = dept.getDeptId(); Long deptId = dept.getDeptId();
Dept info = deptDao.checkDeptNameUnique(dept.getDeptName()); Dept info = deptMapper.checkDeptNameUnique(dept.getDeptName());
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getDeptId()) if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getDeptId())
&& info.getDeptId().longValue() != deptId.longValue()) && info.getDeptId().longValue() != deptId.longValue())
{ {
......
...@@ -44,7 +44,7 @@ public class DictDataController extends BaseController ...@@ -44,7 +44,7 @@ public class DictDataController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(DictData dictData) public TableDataInfo list(DictData dictData)
{ {
setPageInfo(dictData); startPage();
List<DictData> list = dictDataService.selectDictDataList(dictData); List<DictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list); return getDataTable(list);
} }
...@@ -85,7 +85,7 @@ public class DictDataController extends BaseController ...@@ -85,7 +85,7 @@ public class DictDataController extends BaseController
{ {
if (dictDataService.saveDictData(dict) > 0) if (dictDataService.saveDictData(dict) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -106,7 +106,7 @@ public class DictDataController extends BaseController ...@@ -106,7 +106,7 @@ public class DictDataController extends BaseController
} }
if (dictDataService.deleteDictDataById(dictCode) > 0) if (dictDataService.deleteDictDataById(dictCode) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -120,7 +120,7 @@ public class DictDataController extends BaseController ...@@ -120,7 +120,7 @@ public class DictDataController extends BaseController
int rows = dictDataService.batchDeleteDictData(ids); int rows = dictDataService.batchDeleteDictData(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.system.dict.controller; package com.ruoyi.project.system.dict.controller;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.Message; import com.ruoyi.framework.web.domain.Message;
...@@ -46,7 +44,7 @@ public class DictTypeController extends BaseController ...@@ -46,7 +44,7 @@ public class DictTypeController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(DictType dictType) public TableDataInfo list(DictType dictType)
{ {
setPageInfo(dictType); startPage();
List<DictType> list = dictTypeService.selectDictTypeList(dictType); List<DictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list); return getDataTable(list);
} }
...@@ -86,7 +84,7 @@ public class DictTypeController extends BaseController ...@@ -86,7 +84,7 @@ public class DictTypeController extends BaseController
{ {
if (dictTypeService.saveDictType(dict) > 0) if (dictTypeService.saveDictType(dict) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -107,7 +105,7 @@ public class DictTypeController extends BaseController ...@@ -107,7 +105,7 @@ public class DictTypeController extends BaseController
} }
if (dictTypeService.deleteDictTypeById(dictId) > 0) if (dictTypeService.deleteDictTypeById(dictId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -121,7 +119,7 @@ public class DictTypeController extends BaseController ...@@ -121,7 +119,7 @@ public class DictTypeController extends BaseController
int rows = dictTypeService.batchDeleteDictType(ids); int rows = dictTypeService.batchDeleteDictType(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.system.dict.domain; package com.ruoyi.project.system.dict.domain;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 字典数据表 sys_dict_data * 字典数据表 sys_dict_data
* *
* @author ruoyi * @author ruoyi
*/ */
public class DictData extends PageDomain public class DictData extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 字典编码 */ /** 字典编码 */
private Long dictCode; private Long dictCode;
/** 字典排序 */ /** 字典排序 */
...@@ -21,16 +22,6 @@ public class DictData extends PageDomain ...@@ -21,16 +22,6 @@ public class DictData extends PageDomain
private String dictType; private String dictType;
/** 状态(0正常 1禁用) */ /** 状态(0正常 1禁用) */
private int status; private int status;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private String updateTime;
/** 备注 */
private String remark;
public Long getDictCode() public Long getDictCode()
{ {
...@@ -92,63 +83,11 @@ public class DictData extends PageDomain ...@@ -92,63 +83,11 @@ public class DictData extends PageDomain
this.status = status; this.status = status;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
@Override @Override
public String toString() public String toString()
{ {
return "DictData [dictCode=" + dictCode + ", dictSort=" + dictSort + ", dictLabel=" + dictLabel + ", dictValue=" return "DictData [dictCode=" + dictCode + ", dictSort=" + dictSort + ", dictLabel=" + dictLabel + ", dictValue="
+ dictValue + ", dictType=" + dictType + ", status=" + status + ", createBy=" + createBy + dictValue + ", dictType=" + dictType + ", status=" + status + "]";
+ ", createTime=" + createTime + ", updateBy=" + updateBy + ", updateTime=" + updateTime + ", remark="
+ remark + "]";
} }
} }
package com.ruoyi.project.system.dict.domain; package com.ruoyi.project.system.dict.domain;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 字典类型对象 sys_dict_type * 字典类型对象 sys_dict_type
* *
* @author ruoyi * @author ruoyi
*/ */
public class DictType extends PageDomain public class DictType extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 字典主键 */ /** 字典主键 */
private Long dictId; private Long dictId;
/** 字典名称 */ /** 字典名称 */
...@@ -17,16 +18,6 @@ public class DictType extends PageDomain ...@@ -17,16 +18,6 @@ public class DictType extends PageDomain
private String dictType; private String dictType;
/** 状态(0正常 1禁用) */ /** 状态(0正常 1禁用) */
private int status; private int status;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private String updateTime;
/** 备注 */
private String remark;
public Long getDictId() public Long getDictId()
{ {
...@@ -68,62 +59,10 @@ public class DictType extends PageDomain ...@@ -68,62 +59,10 @@ public class DictType extends PageDomain
this.status = status; this.status = status;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
@Override @Override
public String toString() public String toString()
{ {
return "DictType [dictId=" + dictId + ", dictName=" + dictName + ", dictType=" + dictType + ", status=" + status return "DictType [dictId=" + dictId + ", dictName=" + dictName + ", dictType=" + dictType + ", status=" + status + "]";
+ ", createBy=" + createBy + ", createTime=" + createTime + ", updateBy=" + updateBy + ", updateTime="
+ updateTime + ", remark=" + remark + "]";
} }
} }
package com.ruoyi.project.system.dict.dao; package com.ruoyi.project.system.dict.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.dict.domain.DictData; import com.ruoyi.project.system.dict.domain.DictData;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.dict.domain.DictData; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.dict.domain.DictData;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IDictDataDao public interface DictDataMapper
{ {
/** /**
......
package com.ruoyi.project.system.dict.dao; package com.ruoyi.project.system.dict.mapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.ruoyi.project.system.dict.domain.DictType; import com.ruoyi.project.system.dict.domain.DictType;
/** /**
...@@ -12,7 +10,7 @@ import com.ruoyi.project.system.dict.domain.DictType; ...@@ -12,7 +10,7 @@ import com.ruoyi.project.system.dict.domain.DictType;
* @author ruoyi * @author ruoyi
*/ */
@Mapper @Mapper
public interface IDictTypeDao public interface DictTypeMapper
{ {
/** /**
* 根据条件分页查询字典类型 * 根据条件分页查询字典类型
......
...@@ -5,8 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -5,8 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.dict.dao.IDictDataDao;
import com.ruoyi.project.system.dict.domain.DictData; import com.ruoyi.project.system.dict.domain.DictData;
import com.ruoyi.project.system.dict.mapper.DictDataMapper;
/** /**
* 字典 业务层处理 * 字典 业务层处理
...@@ -17,7 +17,7 @@ import com.ruoyi.project.system.dict.domain.DictData; ...@@ -17,7 +17,7 @@ import com.ruoyi.project.system.dict.domain.DictData;
public class DictDataServiceImpl implements IDictDataService public class DictDataServiceImpl implements IDictDataService
{ {
@Autowired @Autowired
private IDictDataDao dictDao; private DictDataMapper dictDataMapper;
/** /**
* 根据条件分页查询字典数据 * 根据条件分页查询字典数据
...@@ -28,7 +28,7 @@ public class DictDataServiceImpl implements IDictDataService ...@@ -28,7 +28,7 @@ public class DictDataServiceImpl implements IDictDataService
@Override @Override
public List<DictData> selectDictDataList(DictData dictData) public List<DictData> selectDictDataList(DictData dictData)
{ {
return dictDao.selectDictDataList(dictData); return dictDataMapper.selectDictDataList(dictData);
} }
/** /**
...@@ -40,7 +40,7 @@ public class DictDataServiceImpl implements IDictDataService ...@@ -40,7 +40,7 @@ public class DictDataServiceImpl implements IDictDataService
@Override @Override
public DictData selectDictDataById(Long dictCode) public DictData selectDictDataById(Long dictCode)
{ {
return dictDao.selectDictDataById(dictCode); return dictDataMapper.selectDictDataById(dictCode);
} }
/** /**
...@@ -52,7 +52,7 @@ public class DictDataServiceImpl implements IDictDataService ...@@ -52,7 +52,7 @@ public class DictDataServiceImpl implements IDictDataService
@Override @Override
public int deleteDictDataById(Long dictCode) public int deleteDictDataById(Long dictCode)
{ {
return dictDao.deleteDictDataById(dictCode); return dictDataMapper.deleteDictDataById(dictCode);
} }
/** /**
...@@ -64,7 +64,7 @@ public class DictDataServiceImpl implements IDictDataService ...@@ -64,7 +64,7 @@ public class DictDataServiceImpl implements IDictDataService
@Override @Override
public int batchDeleteDictData(Long[] ids) public int batchDeleteDictData(Long[] ids)
{ {
return dictDao.batchDeleteDictData(ids); return dictDataMapper.batchDeleteDictData(ids);
} }
/** /**
...@@ -80,12 +80,12 @@ public class DictDataServiceImpl implements IDictDataService ...@@ -80,12 +80,12 @@ public class DictDataServiceImpl implements IDictDataService
if (StringUtils.isNotNull(dictCode)) if (StringUtils.isNotNull(dictCode))
{ {
dictData.setUpdateBy(ShiroUtils.getLoginName()); dictData.setUpdateBy(ShiroUtils.getLoginName());
return dictDao.updateDictData(dictData); return dictDataMapper.updateDictData(dictData);
} }
else else
{ {
dictData.setCreateBy(ShiroUtils.getLoginName()); dictData.setCreateBy(ShiroUtils.getLoginName());
return dictDao.insertDictData(dictData); return dictDataMapper.insertDictData(dictData);
} }
} }
......
...@@ -6,8 +6,8 @@ import org.springframework.stereotype.Service; ...@@ -6,8 +6,8 @@ import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.dict.dao.IDictTypeDao;
import com.ruoyi.project.system.dict.domain.DictType; import com.ruoyi.project.system.dict.domain.DictType;
import com.ruoyi.project.system.dict.mapper.DictTypeMapper;
/** /**
* 字典 业务层处理 * 字典 业务层处理
...@@ -18,7 +18,7 @@ import com.ruoyi.project.system.dict.domain.DictType; ...@@ -18,7 +18,7 @@ import com.ruoyi.project.system.dict.domain.DictType;
public class DictTypeServiceImpl implements IDictTypeService public class DictTypeServiceImpl implements IDictTypeService
{ {
@Autowired @Autowired
private IDictTypeDao dictTypeDao; private DictTypeMapper dictTypeMapper;
/** /**
* 根据条件分页查询字典类型 * 根据条件分页查询字典类型
...@@ -29,7 +29,7 @@ public class DictTypeServiceImpl implements IDictTypeService ...@@ -29,7 +29,7 @@ public class DictTypeServiceImpl implements IDictTypeService
@Override @Override
public List<DictType> selectDictTypeList(DictType dictType) public List<DictType> selectDictTypeList(DictType dictType)
{ {
return dictTypeDao.selectDictTypeList(dictType); return dictTypeMapper.selectDictTypeList(dictType);
} }
/** /**
...@@ -41,7 +41,7 @@ public class DictTypeServiceImpl implements IDictTypeService ...@@ -41,7 +41,7 @@ public class DictTypeServiceImpl implements IDictTypeService
@Override @Override
public DictType selectDictTypeById(Long dictId) public DictType selectDictTypeById(Long dictId)
{ {
return dictTypeDao.selectDictTypeById(dictId); return dictTypeMapper.selectDictTypeById(dictId);
} }
/** /**
...@@ -53,7 +53,7 @@ public class DictTypeServiceImpl implements IDictTypeService ...@@ -53,7 +53,7 @@ public class DictTypeServiceImpl implements IDictTypeService
@Override @Override
public int deleteDictTypeById(Long dictId) public int deleteDictTypeById(Long dictId)
{ {
return dictTypeDao.deleteDictTypeById(dictId); return dictTypeMapper.deleteDictTypeById(dictId);
} }
/** /**
...@@ -65,7 +65,7 @@ public class DictTypeServiceImpl implements IDictTypeService ...@@ -65,7 +65,7 @@ public class DictTypeServiceImpl implements IDictTypeService
@Override @Override
public int batchDeleteDictType(Long[] ids) public int batchDeleteDictType(Long[] ids)
{ {
return dictTypeDao.batchDeleteDictType(ids); return dictTypeMapper.batchDeleteDictType(ids);
} }
/** /**
...@@ -81,12 +81,12 @@ public class DictTypeServiceImpl implements IDictTypeService ...@@ -81,12 +81,12 @@ public class DictTypeServiceImpl implements IDictTypeService
if (StringUtils.isNotNull(dictId)) if (StringUtils.isNotNull(dictId))
{ {
dictType.setUpdateBy(ShiroUtils.getLoginName()); dictType.setUpdateBy(ShiroUtils.getLoginName());
return dictTypeDao.updateDictType(dictType); return dictTypeMapper.updateDictType(dictType);
} }
else else
{ {
dictType.setCreateBy(ShiroUtils.getLoginName()); dictType.setCreateBy(ShiroUtils.getLoginName());
return dictTypeDao.insertDictType(dictType); return dictTypeMapper.insertDictType(dictType);
} }
} }
...@@ -104,7 +104,7 @@ public class DictTypeServiceImpl implements IDictTypeService ...@@ -104,7 +104,7 @@ public class DictTypeServiceImpl implements IDictTypeService
dict.setDictId(-1L); dict.setDictId(-1L);
} }
Long dictId = dict.getDictId(); Long dictId = dict.getDictId();
DictType dictType = dictTypeDao.checkDictTypeUnique(dict.getDictType()); DictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
if (StringUtils.isNotNull(dictType) && dictType.getDictId() != dictId) if (StringUtils.isNotNull(dictType) && dictType.getDictId() != dictId)
{ {
return UserConstants.NAME_NOT_UNIQUE; return UserConstants.NAME_NOT_UNIQUE;
......
...@@ -68,7 +68,7 @@ public class MenuController extends BaseController ...@@ -68,7 +68,7 @@ public class MenuController extends BaseController
} }
if (menuService.deleteMenuById(menuId) > 0) if (menuService.deleteMenuById(menuId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -120,7 +120,7 @@ public class MenuController extends BaseController ...@@ -120,7 +120,7 @@ public class MenuController extends BaseController
{ {
if (menuService.saveMenu(menu) > 0) if (menuService.saveMenu(menu) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
...@@ -2,14 +2,16 @@ package com.ruoyi.project.system.menu.domain; ...@@ -2,14 +2,16 @@ package com.ruoyi.project.system.menu.domain;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 角色对象 sys_menu * 角色对象 sys_menu
* *
* @author ruoyi * @author ruoyi
*/ */
public class Menu public class Menu extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 菜单ID */ /** 菜单ID */
private Long menuId; private Long menuId;
/** 菜单名称 */ /** 菜单名称 */
...@@ -30,16 +32,6 @@ public class Menu ...@@ -30,16 +32,6 @@ public class Menu
private String perms; private String perms;
/** 菜单图标 */ /** 菜单图标 */
private String icon; private String icon;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新时间 */
private String updateTime;
/** 更新者 */
private String updateBy;
/** 备注 */
private String remark;
/** 子菜单 */ /** 子菜单 */
private List<Menu> children = new ArrayList<Menu>(); private List<Menu> children = new ArrayList<Menu>();
...@@ -143,56 +135,6 @@ public class Menu ...@@ -143,56 +135,6 @@ public class Menu
this.icon = icon; this.icon = icon;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
public List<Menu> getChildren() public List<Menu> getChildren()
{ {
return children; return children;
...@@ -208,9 +150,7 @@ public class Menu ...@@ -208,9 +150,7 @@ public class Menu
{ {
return "Menu [menuId=" + menuId + ", menuName=" + menuName + ", parentName=" + parentName + ", parentId=" return "Menu [menuId=" + menuId + ", menuName=" + menuName + ", parentName=" + parentName + ", parentId="
+ parentId + ", orderNum=" + orderNum + ", url=" + url + ", menuType=" + menuType + ", visible=" + parentId + ", orderNum=" + orderNum + ", url=" + url + ", menuType=" + menuType + ", visible="
+ visible + ", perms=" + perms + ", icon=" + icon + ", createBy=" + createBy + ", createTime=" + visible + ", perms=" + perms + ", icon=" + icon + ", children=" + children + "]";
+ createTime + ", updateTime=" + updateTime + ", updateBy=" + updateBy + ", remark=" + remark
+ ", children=" + children + "]";
} }
} }
package com.ruoyi.project.system.menu.dao; package com.ruoyi.project.system.menu.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.menu.domain.Menu; import com.ruoyi.project.system.menu.domain.Menu;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.menu.domain.Menu; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.menu.domain.Menu;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IMenuDao public interface MenuMapper
{ {
/** /**
......
...@@ -9,18 +9,16 @@ import java.util.LinkedHashMap; ...@@ -9,18 +9,16 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.TreeUtils; import com.ruoyi.common.utils.TreeUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.menu.dao.IMenuDao;
import com.ruoyi.project.system.menu.domain.Menu; import com.ruoyi.project.system.menu.domain.Menu;
import com.ruoyi.project.system.role.dao.IRoleMenuDao; import com.ruoyi.project.system.menu.mapper.MenuMapper;
import com.ruoyi.project.system.role.domain.Role; import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.mapper.RoleMenuMapper;
/** /**
* 菜单 业务层处理 * 菜单 业务层处理
...@@ -33,10 +31,10 @@ public class MenuServiceImpl implements IMenuService ...@@ -33,10 +31,10 @@ public class MenuServiceImpl implements IMenuService
public static final String PREMISSION_STRING = "perms[\"{0}\"]"; public static final String PREMISSION_STRING = "perms[\"{0}\"]";
@Autowired @Autowired
private IMenuDao menuDao; private MenuMapper menuMapper;
@Autowired @Autowired
private IRoleMenuDao roleMenuDao; private RoleMenuMapper roleMenuMapper;
/** /**
* 根据用户ID查询菜单 * 根据用户ID查询菜单
...@@ -47,7 +45,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -47,7 +45,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public List<Menu> selectMenusByUserId(Long userId) public List<Menu> selectMenusByUserId(Long userId)
{ {
List<Menu> menus = menuDao.selectMenusByUserId(userId); List<Menu> menus = menuMapper.selectMenusByUserId(userId);
return TreeUtils.getChildPerms(menus, 0); return TreeUtils.getChildPerms(menus, 0);
} }
...@@ -59,7 +57,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -59,7 +57,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public List<Menu> selectMenuAll() public List<Menu> selectMenuAll()
{ {
return menuDao.selectMenuAll(); return menuMapper.selectMenuAll();
} }
/** /**
...@@ -71,7 +69,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -71,7 +69,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public Set<String> selectPermsByUserId(Long userId) public Set<String> selectPermsByUserId(Long userId)
{ {
List<String> perms = menuDao.selectPermsByUserId(userId); List<String> perms = menuMapper.selectPermsByUserId(userId);
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
for (String perm : perms) for (String perm : perms)
{ {
...@@ -94,10 +92,10 @@ public class MenuServiceImpl implements IMenuService ...@@ -94,10 +92,10 @@ public class MenuServiceImpl implements IMenuService
{ {
Long roleId = role.getRoleId(); Long roleId = role.getRoleId();
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<Menu> menuList = menuDao.selectMenuAll(); List<Menu> menuList = menuMapper.selectMenuAll();
if (StringUtils.isNotNull(roleId)) if (StringUtils.isNotNull(roleId))
{ {
List<String> roleMenuList = menuDao.selectMenuTree(roleId); List<String> roleMenuList = menuMapper.selectMenuTree(roleId);
trees = getTrees(menuList, true, roleMenuList, true); trees = getTrees(menuList, true, roleMenuList, true);
} }
else else
...@@ -117,7 +115,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -117,7 +115,7 @@ public class MenuServiceImpl implements IMenuService
public List<Map<String, Object>> menuTreeData() public List<Map<String, Object>> menuTreeData()
{ {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<Menu> menuList = menuDao.selectMenuAll(); List<Menu> menuList = menuMapper.selectMenuAll();
trees = getTrees(menuList, false, null, false); trees = getTrees(menuList, false, null, false);
return trees; return trees;
} }
...@@ -131,7 +129,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -131,7 +129,7 @@ public class MenuServiceImpl implements IMenuService
public LinkedHashMap<String, String> selectPermsAll() public LinkedHashMap<String, String> selectPermsAll()
{ {
LinkedHashMap<String, String> section = new LinkedHashMap<>(); LinkedHashMap<String, String> section = new LinkedHashMap<>();
List<Menu> permissions = menuDao.selectMenuAll(); List<Menu> permissions = menuMapper.selectMenuAll();
if (StringUtils.isNotEmpty(permissions)) if (StringUtils.isNotEmpty(permissions))
{ {
for (Menu menu : permissions) for (Menu menu : permissions)
...@@ -194,7 +192,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -194,7 +192,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public int deleteMenuById(Long menuId) public int deleteMenuById(Long menuId)
{ {
return menuDao.deleteMenuById(menuId); return menuMapper.deleteMenuById(menuId);
} }
/** /**
...@@ -206,7 +204,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -206,7 +204,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public Menu selectMenuById(Long menuId) public Menu selectMenuById(Long menuId)
{ {
return menuDao.selectMenuById(menuId); return menuMapper.selectMenuById(menuId);
} }
/** /**
...@@ -218,7 +216,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -218,7 +216,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public int selectCountMenuByParentId(Long parentId) public int selectCountMenuByParentId(Long parentId)
{ {
return menuDao.selectCountMenuByParentId(parentId); return menuMapper.selectCountMenuByParentId(parentId);
} }
/** /**
...@@ -230,7 +228,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -230,7 +228,7 @@ public class MenuServiceImpl implements IMenuService
@Override @Override
public int selectCountRoleMenuByMenuId(Long menuId) public int selectCountRoleMenuByMenuId(Long menuId)
{ {
return roleMenuDao.selectCountRoleMenuByMenuId(menuId); return roleMenuMapper.selectCountRoleMenuByMenuId(menuId);
} }
/** /**
...@@ -246,12 +244,12 @@ public class MenuServiceImpl implements IMenuService ...@@ -246,12 +244,12 @@ public class MenuServiceImpl implements IMenuService
if (StringUtils.isNotNull(menuId)) if (StringUtils.isNotNull(menuId))
{ {
menu.setUpdateBy(ShiroUtils.getLoginName()); menu.setUpdateBy(ShiroUtils.getLoginName());
return menuDao.updateMenu(menu); return menuMapper.updateMenu(menu);
} }
else else
{ {
menu.setCreateBy(ShiroUtils.getLoginName()); menu.setCreateBy(ShiroUtils.getLoginName());
return menuDao.insertMenu(menu); return menuMapper.insertMenu(menu);
} }
} }
...@@ -265,7 +263,7 @@ public class MenuServiceImpl implements IMenuService ...@@ -265,7 +263,7 @@ public class MenuServiceImpl implements IMenuService
public String checkMenuNameUnique(Menu menu) public String checkMenuNameUnique(Menu menu)
{ {
Long menuId = menu.getMenuId(); Long menuId = menu.getMenuId();
Menu info = menuDao.checkMenuNameUnique(menu.getMenuName()); Menu info = menuMapper.checkMenuNameUnique(menu.getMenuName());
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getMenuId()) if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getMenuId())
&& info.getMenuId().longValue() != menuId.longValue()) && info.getMenuId().longValue() != menuId.longValue())
{ {
......
...@@ -44,7 +44,7 @@ public class PostController extends BaseController ...@@ -44,7 +44,7 @@ public class PostController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(Post post) public TableDataInfo list(Post post)
{ {
setPageInfo(post); startPage();
List<Post> list = postService.selectPostList(post); List<Post> list = postService.selectPostList(post);
return getDataTable(list); return getDataTable(list);
} }
...@@ -69,7 +69,7 @@ public class PostController extends BaseController ...@@ -69,7 +69,7 @@ public class PostController extends BaseController
} }
if (postService.deletePostById(postId) > 0) if (postService.deletePostById(postId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -83,7 +83,7 @@ public class PostController extends BaseController ...@@ -83,7 +83,7 @@ public class PostController extends BaseController
int rows = postService.batchDeletePost(ids); int rows = postService.batchDeletePost(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -123,7 +123,7 @@ public class PostController extends BaseController ...@@ -123,7 +123,7 @@ public class PostController extends BaseController
{ {
if (postService.savePost(post) > 0) if (postService.savePost(post) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.system.post.domain; package com.ruoyi.project.system.post.domain;
import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.domain.BaseEntity;
/** /**
* 岗位对象 sys_post * 岗位对象 sys_post
* *
* @author ruoyi * @author ruoyi
*/ */
public class Post extends PageDomain public class Post extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 岗位ID */ /** 岗位ID */
private Long postId; private Long postId;
/** 岗位编码 */ /** 岗位编码 */
...@@ -21,16 +22,6 @@ public class Post extends PageDomain ...@@ -21,16 +22,6 @@ public class Post extends PageDomain
private int status; private int status;
/** 用户是否存在此岗位标识 默认不存在 */ /** 用户是否存在此岗位标识 默认不存在 */
private boolean flag = false; private boolean flag = false;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新时间 */
private String updateTime;
/** 更新者 */
private String updateBy;
/** 备注 */
private String remark;
public Long getPostId() public Long getPostId()
{ {
...@@ -92,62 +83,11 @@ public class Post extends PageDomain ...@@ -92,62 +83,11 @@ public class Post extends PageDomain
this.flag = flag; this.flag = flag;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
@Override @Override
public String toString() public String toString()
{ {
return "Post [postId=" + postId + ", postCode=" + postCode + ", postName=" + postName + ", postSort=" + postSort return "Post [postId=" + postId + ", postCode=" + postCode + ", postName=" + postName + ", postSort=" + postSort
+ ", status=" + status + ", flag=" + flag + ", createBy=" + createBy + ", createTime=" + createTime + ", status=" + status + ", flag=" + flag + "]";
+ ", updateTime=" + updateTime + ", updateBy=" + updateBy + ", remark=" + remark + "]";
} }
} }
package com.ruoyi.project.system.post.dao; package com.ruoyi.project.system.post.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.post.domain.Post; import com.ruoyi.project.system.post.domain.Post;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.post.domain.Post; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.post.domain.Post;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IPostDao public interface PostMapper
{ {
/** /**
......
package com.ruoyi.project.system.post.service; package com.ruoyi.project.system.post.service;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.post.dao.IPostDao;
import com.ruoyi.project.system.post.domain.Post; import com.ruoyi.project.system.post.domain.Post;
import com.ruoyi.project.system.user.dao.IUserPostDao; import com.ruoyi.project.system.post.mapper.PostMapper;
import com.ruoyi.project.system.user.mapper.UserPostMapper;
/** /**
* 岗位信息 服务层处理 * 岗位信息 服务层处理
...@@ -20,10 +18,10 @@ import com.ruoyi.project.system.user.dao.IUserPostDao; ...@@ -20,10 +18,10 @@ import com.ruoyi.project.system.user.dao.IUserPostDao;
public class PostServiceImpl implements IPostService public class PostServiceImpl implements IPostService
{ {
@Autowired @Autowired
private IPostDao postDao; private PostMapper postMapper;
@Autowired @Autowired
private IUserPostDao userPostDao; private UserPostMapper userPostMapper;
/** /**
* 查询岗位信息集合 * 查询岗位信息集合
...@@ -34,7 +32,7 @@ public class PostServiceImpl implements IPostService ...@@ -34,7 +32,7 @@ public class PostServiceImpl implements IPostService
@Override @Override
public List<Post> selectPostList(Post post) public List<Post> selectPostList(Post post)
{ {
return postDao.selectPostList(post); return postMapper.selectPostList(post);
} }
/** /**
...@@ -45,7 +43,7 @@ public class PostServiceImpl implements IPostService ...@@ -45,7 +43,7 @@ public class PostServiceImpl implements IPostService
@Override @Override
public List<Post> selectPostAll() public List<Post> selectPostAll()
{ {
return postDao.selectPostAll(); return postMapper.selectPostAll();
} }
/** /**
...@@ -57,8 +55,8 @@ public class PostServiceImpl implements IPostService ...@@ -57,8 +55,8 @@ public class PostServiceImpl implements IPostService
@Override @Override
public List<Post> selectPostsByUserId(Long userId) public List<Post> selectPostsByUserId(Long userId)
{ {
List<Post> userPosts = postDao.selectPostsByUserId(userId); List<Post> userPosts = postMapper.selectPostsByUserId(userId);
List<Post> posts = postDao.selectPostAll(); List<Post> posts = postMapper.selectPostAll();
for (Post post : posts) for (Post post : posts)
{ {
for (Post userRole : userPosts) for (Post userRole : userPosts)
...@@ -82,7 +80,7 @@ public class PostServiceImpl implements IPostService ...@@ -82,7 +80,7 @@ public class PostServiceImpl implements IPostService
@Override @Override
public Post selectPostById(Long postId) public Post selectPostById(Long postId)
{ {
return postDao.selectPostById(postId); return postMapper.selectPostById(postId);
} }
/** /**
...@@ -94,7 +92,7 @@ public class PostServiceImpl implements IPostService ...@@ -94,7 +92,7 @@ public class PostServiceImpl implements IPostService
@Override @Override
public int deletePostById(Long postId) public int deletePostById(Long postId)
{ {
return postDao.deletePostById(postId); return postMapper.deletePostById(postId);
} }
/** /**
...@@ -106,7 +104,7 @@ public class PostServiceImpl implements IPostService ...@@ -106,7 +104,7 @@ public class PostServiceImpl implements IPostService
@Override @Override
public int batchDeletePost(Long[] ids) public int batchDeletePost(Long[] ids)
{ {
return postDao.batchDeletePost(ids); return postMapper.batchDeletePost(ids);
} }
/** /**
...@@ -124,13 +122,13 @@ public class PostServiceImpl implements IPostService ...@@ -124,13 +122,13 @@ public class PostServiceImpl implements IPostService
{ {
post.setUpdateBy(ShiroUtils.getLoginName()); post.setUpdateBy(ShiroUtils.getLoginName());
// 修改岗位信息 // 修改岗位信息
count = postDao.updatePost(post); count = postMapper.updatePost(post);
} }
else else
{ {
post.setCreateBy(ShiroUtils.getLoginName()); post.setCreateBy(ShiroUtils.getLoginName());
// 新增岗位信息 // 新增岗位信息
count = postDao.insertPost(post); count = postMapper.insertPost(post);
} }
return count; return count;
} }
...@@ -144,7 +142,7 @@ public class PostServiceImpl implements IPostService ...@@ -144,7 +142,7 @@ public class PostServiceImpl implements IPostService
@Override @Override
public int selectCountPostById(Long postId) public int selectCountPostById(Long postId)
{ {
return userPostDao.selectCountPostById(postId); return userPostMapper.selectCountPostById(postId);
} }
} }
...@@ -46,7 +46,7 @@ public class RoleController extends BaseController ...@@ -46,7 +46,7 @@ public class RoleController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(Role role) public TableDataInfo list(Role role)
{ {
setPageInfo(role); startPage();
List<Role> list = roleService.selectRoleList(role); List<Role> list = roleService.selectRoleList(role);
return getDataTable(list); return getDataTable(list);
} }
...@@ -87,7 +87,7 @@ public class RoleController extends BaseController ...@@ -87,7 +87,7 @@ public class RoleController extends BaseController
{ {
if (roleService.saveRole(role) > 0) if (roleService.saveRole(role) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -110,7 +110,7 @@ public class RoleController extends BaseController ...@@ -110,7 +110,7 @@ public class RoleController extends BaseController
} }
if (roleService.deleteRoleById(roleId) > 0) if (roleService.deleteRoleById(roleId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -124,7 +124,7 @@ public class RoleController extends BaseController ...@@ -124,7 +124,7 @@ public class RoleController extends BaseController
int rows = roleService.batchDeleteRole(ids); int rows = roleService.batchDeleteRole(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.system.role.domain; package com.ruoyi.project.system.role.domain;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.framework.web.page.PageDomain;
/** /**
* 角色对象 sys_role * 角色对象 sys_role
* *
* @author ruoyi * @author ruoyi
*/ */
public class Role extends PageDomain public class Role extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 角色ID */ /** 角色ID */
private Long roleId; private Long roleId;
/** 角色名 */ /** 角色名 */
...@@ -21,16 +21,6 @@ public class Role extends PageDomain ...@@ -21,16 +21,6 @@ public class Role extends PageDomain
private String roleSort; private String roleSort;
/** 角色状态:0正常,1禁用 */ /** 角色状态:0正常,1禁用 */
private int status; private int status;
/** 创建者 */
private String createBy;
/** 创建时间 */
private Date createTime;
/** 更新时间 */
private Date updateTime;
/** 更新者 */
private String updateBy;
/** 备注 */
private String remark;
/** 用户是否存在此角色标识 默认不存在 */ /** 用户是否存在此角色标识 默认不存在 */
private boolean flag = false; private boolean flag = false;
/** 菜单组 */ /** 菜单组 */
...@@ -86,56 +76,6 @@ public class Role extends PageDomain ...@@ -86,56 +76,6 @@ public class Role extends PageDomain
this.status = status; this.status = status;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public Date getCreateTime()
{
return createTime;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
public Date getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(Date updateTime)
{
this.updateTime = updateTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
public boolean isFlag() public boolean isFlag()
{ {
return flag; return flag;
...@@ -160,9 +100,7 @@ public class Role extends PageDomain ...@@ -160,9 +100,7 @@ public class Role extends PageDomain
public String toString() public String toString()
{ {
return "Role [roleId=" + roleId + ", roleName=" + roleName + ", roleKey=" + roleKey + ", roleSort=" + roleSort return "Role [roleId=" + roleId + ", roleName=" + roleName + ", roleKey=" + roleKey + ", roleSort=" + roleSort
+ ", status=" + status + ", createBy=" + createBy + ", createTime=" + createTime + ", updateTime=" + ", status=" + status + ", flag=" + flag + ", menuIds=" + Arrays.toString(menuIds) + "]";
+ updateTime + ", updateBy=" + updateBy + ", remark=" + remark + ", flag=" + flag + ", menuIds="
+ Arrays.toString(menuIds) + "]";
} }
} }
package com.ruoyi.project.system.role.dao; package com.ruoyi.project.system.role.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.role.domain.Role; import com.ruoyi.project.system.role.domain.Role;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.role.domain.Role; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.role.domain.Role;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IRoleDao public interface RoleMapper
{ {
/** /**
......
package com.ruoyi.project.system.role.dao; package com.ruoyi.project.system.role.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.role.domain.RoleMenu; import com.ruoyi.project.system.role.domain.RoleMenu;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.role.domain.RoleMenu; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.role.domain.RoleMenu;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IRoleMenuDao public interface RoleMenuMapper
{ {
/** /**
......
...@@ -5,18 +5,16 @@ import java.util.Arrays; ...@@ -5,18 +5,16 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.role.dao.IRoleDao;
import com.ruoyi.project.system.role.dao.IRoleMenuDao;
import com.ruoyi.project.system.role.domain.Role; import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.domain.RoleMenu; import com.ruoyi.project.system.role.domain.RoleMenu;
import com.ruoyi.project.system.user.dao.IUserRoleDao; import com.ruoyi.project.system.role.mapper.RoleMapper;
import com.ruoyi.project.system.role.mapper.RoleMenuMapper;
import com.ruoyi.project.system.user.mapper.UserRoleMapper;
/** /**
* 角色 业务层处理 * 角色 业务层处理
...@@ -28,13 +26,13 @@ public class RoleServiceImpl implements IRoleService ...@@ -28,13 +26,13 @@ public class RoleServiceImpl implements IRoleService
{ {
@Autowired @Autowired
private IRoleDao roleDao; private RoleMapper roleMapper;
@Autowired @Autowired
private IRoleMenuDao roleMenuDao; private RoleMenuMapper roleMenuMapper;
@Autowired @Autowired
private IUserRoleDao userRoleDao; private UserRoleMapper userRoleMapper;
/** /**
* 根据条件分页查询角色数据 * 根据条件分页查询角色数据
...@@ -45,7 +43,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -45,7 +43,7 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public List<Role> selectRoleList(Role role) public List<Role> selectRoleList(Role role)
{ {
return roleDao.selectRoleList(role); return roleMapper.selectRoleList(role);
} }
/** /**
...@@ -57,7 +55,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -57,7 +55,7 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public Set<String> selectRoleKeys(Long userId) public Set<String> selectRoleKeys(Long userId)
{ {
List<Role> perms = roleDao.selectRolesByUserId(userId); List<Role> perms = roleMapper.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
for (Role perm : perms) for (Role perm : perms)
{ {
...@@ -78,8 +76,8 @@ public class RoleServiceImpl implements IRoleService ...@@ -78,8 +76,8 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public List<Role> selectRolesByUserId(Long userId) public List<Role> selectRolesByUserId(Long userId)
{ {
List<Role> userRoles = roleDao.selectRolesByUserId(userId); List<Role> userRoles = roleMapper.selectRolesByUserId(userId);
List<Role> roles = roleDao.selectRolesAll(); List<Role> roles = roleMapper.selectRolesAll();
for (Role role : roles) for (Role role : roles)
{ {
for (Role userRole : userRoles) for (Role userRole : userRoles)
...@@ -102,7 +100,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -102,7 +100,7 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public List<Role> selectRoleAll() public List<Role> selectRoleAll()
{ {
return roleDao.selectRolesAll(); return roleMapper.selectRolesAll();
} }
/** /**
...@@ -114,7 +112,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -114,7 +112,7 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public Role selectRoleById(Long roleId) public Role selectRoleById(Long roleId)
{ {
return roleDao.selectRoleById(roleId); return roleMapper.selectRoleById(roleId);
} }
/** /**
...@@ -126,8 +124,8 @@ public class RoleServiceImpl implements IRoleService ...@@ -126,8 +124,8 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public int deleteRoleById(Long roleId) public int deleteRoleById(Long roleId)
{ {
roleMenuDao.deleteRoleMenuByRoleId(roleId); roleMenuMapper.deleteRoleMenuByRoleId(roleId);
return roleDao.deleteRoleById(roleId); return roleMapper.deleteRoleById(roleId);
} }
/** /**
...@@ -139,8 +137,8 @@ public class RoleServiceImpl implements IRoleService ...@@ -139,8 +137,8 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public int batchDeleteRole(Long[] ids) public int batchDeleteRole(Long[] ids)
{ {
roleMenuDao.deleteRoleMenu(ids); roleMenuMapper.deleteRoleMenu(ids);
return roleDao.batchDeleteRole(ids); return roleMapper.batchDeleteRole(ids);
} }
/** /**
...@@ -157,15 +155,15 @@ public class RoleServiceImpl implements IRoleService ...@@ -157,15 +155,15 @@ public class RoleServiceImpl implements IRoleService
{ {
role.setUpdateBy(ShiroUtils.getLoginName()); role.setUpdateBy(ShiroUtils.getLoginName());
// 修改角色信息 // 修改角色信息
roleDao.updateRole(role); roleMapper.updateRole(role);
// 删除角色与菜单关联 // 删除角色与菜单关联
roleMenuDao.deleteRoleMenuByRoleId(roleId); roleMenuMapper.deleteRoleMenuByRoleId(roleId);
} }
else else
{ {
role.setCreateBy(ShiroUtils.getLoginName()); role.setCreateBy(ShiroUtils.getLoginName());
// 新增角色信息 // 新增角色信息
roleDao.insertRole(role); roleMapper.insertRole(role);
} }
return insertRoleMenu(role); return insertRoleMenu(role);
} }
...@@ -189,7 +187,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -189,7 +187,7 @@ public class RoleServiceImpl implements IRoleService
} }
if (list.size() > 0) if (list.size() > 0)
{ {
rows = roleMenuDao.batchRoleMenu(list); rows = roleMenuMapper.batchRoleMenu(list);
} }
return rows; return rows;
} }
...@@ -204,7 +202,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -204,7 +202,7 @@ public class RoleServiceImpl implements IRoleService
public String checkRoleNameUnique(Role role) public String checkRoleNameUnique(Role role)
{ {
Long roleId = role.getRoleId(); Long roleId = role.getRoleId();
Role info = roleDao.checkRoleNameUnique(role.getRoleName()); Role info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getRoleId()) && info.getRoleId() != roleId) if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getRoleId()) && info.getRoleId() != roleId)
{ {
return UserConstants.NAME_NOT_UNIQUE; return UserConstants.NAME_NOT_UNIQUE;
...@@ -221,7 +219,7 @@ public class RoleServiceImpl implements IRoleService ...@@ -221,7 +219,7 @@ public class RoleServiceImpl implements IRoleService
@Override @Override
public int selectCountUserRoleByRoleId(Long roleId) public int selectCountUserRoleByRoleId(Long roleId)
{ {
return userRoleDao.selectCountUserRoleByRoleId(roleId); return userRoleMapper.selectCountUserRoleByRoleId(roleId);
} }
} }
package com.ruoyi.project.system.user.controller;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.ruoyi.framework.web.domain.Message;
/**
* 图片验证码(支持算术形式)
* @author ruoyi
*/
@Controller
@RequestMapping("/captcha")
public class CaptchaController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
/**
* 验证码生成
*/
@RequestMapping(value = "/captchaImage")
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response)
{
ServletOutputStream out = null;
try
{
HttpSession session = request.getSession();
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache");
response.setContentType("image/jpeg");
String type = request.getParameter("type");
String capStr = null;
String code = null;
BufferedImage bi = null;
if ("math".equals(type))
{
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
bi = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(type))
{
capStr = code = captchaProducer.createText();
bi = captchaProducer.createImage(capStr);
}
session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code);
out = response.getOutputStream();
ImageIO.write(bi, "jpg", out);
out.flush();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (out != null)
{
out.close();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
return null;
}
/**
* @Desc 验证码验证
* @param kaptchaCode
* @param request
* @return
* @author YY<2017年10月31日>
*/
@RequestMapping("/captchaVerify")
@ResponseBody
public Message captchaVerify(String kaptchaCode, HttpServletRequest request)
{
try
{
HttpSession session = request.getSession();
Object obj = session.getAttribute(Constants.KAPTCHA_SESSION_KEY);
String code = String.valueOf(obj != null ? obj : "");
if (StringUtils.isNotBlank(kaptchaCode) && kaptchaCode.equalsIgnoreCase(code))
{
return Message.success("验证码正确");
}
}
catch (Exception e)
{
e.printStackTrace();
return Message.error("系统错误:" + e.getMessage());
}
return Message.error("验证码错误");
}
}
\ No newline at end of file
...@@ -29,14 +29,14 @@ public class LoginController extends BaseController ...@@ -29,14 +29,14 @@ public class LoginController extends BaseController
@PostMapping("/login") @PostMapping("/login")
@ResponseBody @ResponseBody
public Message ajaxLogin(String username, String password) public Message ajaxLogin(String username, String password, Boolean rememberMe)
{ {
UsernamePasswordToken token = new UsernamePasswordToken(username, password); UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
try try
{ {
subject.login(token); subject.login(token);
return Message.ok(); return Message.success();
} }
catch (AuthenticationException e) catch (AuthenticationException e)
{ {
......
package com.ruoyi.project.system.user.controller; package com.ruoyi.project.system.user.controller;
import org.apache.shiro.crypto.hash.Md5Hash; import org.apache.shiro.crypto.hash.Md5Hash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
...@@ -8,7 +10,10 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -8,7 +10,10 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.utils.FileUploadUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.Message; import com.ruoyi.framework.web.domain.Message;
...@@ -24,6 +29,8 @@ import com.ruoyi.project.system.user.service.IUserService; ...@@ -24,6 +29,8 @@ import com.ruoyi.project.system.user.service.IUserService;
@RequestMapping("/system/user/profile") @RequestMapping("/system/user/profile")
public class ProfileController extends BaseController public class ProfileController extends BaseController
{ {
private static final Logger log = LoggerFactory.getLogger(ProfileController.class);
private String prefix = "system/user/profile"; private String prefix = "system/user/profile";
@Autowired @Autowired
...@@ -84,7 +91,7 @@ public class ProfileController extends BaseController ...@@ -84,7 +91,7 @@ public class ProfileController extends BaseController
if (rows > 0) if (rows > 0)
{ {
setUser(userService.selectUserById(user.getUserId())); setUser(userService.selectUserById(user.getUserId()));
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -102,6 +109,18 @@ public class ProfileController extends BaseController ...@@ -102,6 +109,18 @@ public class ProfileController extends BaseController
} }
/** /**
* 修改头像
*/
@Log(title = "系统管理", action = "个人信息-修改头像")
@GetMapping("/avatar/{userId}")
public String avatar(@PathVariable("userId") Long userId, Model model)
{
User user = userService.selectUserById(userId);
model.addAttribute("user", user);
return prefix + "/avatar";
}
/**
* 修改用户 * 修改用户
*/ */
@Log(title = "系统管理", action = "个人信息-保存用户") @Log(title = "系统管理", action = "个人信息-保存用户")
...@@ -112,8 +131,37 @@ public class ProfileController extends BaseController ...@@ -112,8 +131,37 @@ public class ProfileController extends BaseController
if (userService.updateUser(user) > 0) if (userService.updateUser(user) > 0)
{ {
setUser(userService.selectUserById(user.getUserId())); setUser(userService.selectUserById(user.getUserId()));
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
/**
* 保存头像
*/
@Log(title = "系统管理", action = "个人信息-保存头像")
@PostMapping("/updateAvatar")
@ResponseBody
public Message updateAvatar(User user, @RequestParam("avatarfile") MultipartFile file)
{
try
{
if (!file.isEmpty())
{
String avatar = FileUploadUtils.upload(file);
user.setAvatar(avatar);
if (userService.updateUser(user) > 0)
{
setUser(userService.selectUserById(user.getUserId()));
return Message.success();
}
}
return Message.error();
}
catch (Exception e)
{
log.error("updateAvatar failed!", e);
return Message.error(e.getMessage());
}
}
} }
...@@ -56,7 +56,7 @@ public class UserController extends BaseController ...@@ -56,7 +56,7 @@ public class UserController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(User user) public TableDataInfo list(User user)
{ {
setPageInfo(user); startPage();
List<User> list = userService.selectUserList(user); List<User> list = userService.selectUserList(user);
return getDataTable(list); return getDataTable(list);
} }
...@@ -112,7 +112,7 @@ public class UserController extends BaseController ...@@ -112,7 +112,7 @@ public class UserController extends BaseController
int rows = userService.resetUserPwd(user); int rows = userService.resetUserPwd(user);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -131,7 +131,7 @@ public class UserController extends BaseController ...@@ -131,7 +131,7 @@ public class UserController extends BaseController
} }
if (userService.deleteUserById(userId) > 0) if (userService.deleteUserById(userId) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -146,7 +146,7 @@ public class UserController extends BaseController ...@@ -146,7 +146,7 @@ public class UserController extends BaseController
int rows = userService.batchDeleteUser(ids); int rows = userService.batchDeleteUser(ids);
if (rows > 0) if (rows > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
...@@ -163,7 +163,7 @@ public class UserController extends BaseController ...@@ -163,7 +163,7 @@ public class UserController extends BaseController
{ {
if (userService.saveUser(user) > 0) if (userService.saveUser(user) > 0)
{ {
return Message.ok(); return Message.success();
} }
return Message.error(); return Message.error();
} }
......
package com.ruoyi.project.system.user.domain; package com.ruoyi.project.system.user.domain;
import java.util.Arrays; import java.util.Arrays;
import org.apache.shiro.crypto.SecureRandomNumberGenerator; import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.project.system.dept.domain.Dept; import com.ruoyi.project.system.dept.domain.Dept;
/** /**
...@@ -12,8 +10,9 @@ import com.ruoyi.project.system.dept.domain.Dept; ...@@ -12,8 +10,9 @@ import com.ruoyi.project.system.dept.domain.Dept;
* *
* @author ruoyi * @author ruoyi
*/ */
public class User extends PageDomain public class User extends BaseEntity
{ {
private static final long serialVersionUID = 1L;
/** 用户ID */ /** 用户ID */
private Long userId; private Long userId;
/** 部门ID */ /** 部门ID */
...@@ -42,14 +41,6 @@ public class User extends PageDomain ...@@ -42,14 +41,6 @@ public class User extends PageDomain
private int status; private int status;
/** 拒绝登录描述 */ /** 拒绝登录描述 */
private String refuseDes; private String refuseDes;
/** 创建者 */
private String createBy;
/** 创建时间 */
private String createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private String updateTime;
/** 部门对象 */ /** 部门对象 */
private Dept dept; private Dept dept;
/** 角色组 */ /** 角色组 */
...@@ -208,46 +199,6 @@ public class User extends PageDomain ...@@ -208,46 +199,6 @@ public class User extends PageDomain
this.refuseDes = refuseDes; this.refuseDes = refuseDes;
} }
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public String getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(String updateTime)
{
this.updateTime = updateTime;
}
public Dept getDept() public Dept getDept()
{ {
return dept; return dept;
...@@ -282,11 +233,10 @@ public class User extends PageDomain ...@@ -282,11 +233,10 @@ public class User extends PageDomain
public String toString() public String toString()
{ {
return "User [userId=" + userId + ", deptId=" + deptId + ", parentId=" + parentId + ", loginName=" + loginName return "User [userId=" + userId + ", deptId=" + deptId + ", parentId=" + parentId + ", loginName=" + loginName
+ ", userName=" + userName + ", email=" + email + ", phonenumber=" + phonenumber + ", password=" + ", userName=" + userName + ", email=" + email + ", phonenumber=" + phonenumber + ", sex=" + sex
+ password + ", salt=" + salt + ", userType=" + userType + ", status=" + status + ", refuseDes=" + ", avatar=" + avatar + ", password=" + password + ", salt=" + salt + ", userType=" + userType
+ refuseDes + ", createBy=" + createBy + ", createTime=" + createTime + ", updateBy=" + updateBy + ", status=" + status + ", refuseDes=" + refuseDes + ", dept=" + dept + ", roleIds="
+ ", updateTime=" + updateTime + ", dept=" + dept + ", roleIds=" + Arrays.toString(roleIds) + Arrays.toString(roleIds) + ", postIds=" + Arrays.toString(postIds) + "]";
+ ", postIds=" + Arrays.toString(postIds) + "]";
} }
} }
package com.ruoyi.project.system.user.dao; package com.ruoyi.project.system.user.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.system.user.domain.User;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.user.domain.User; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.user.domain.User;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IUserDao public interface UserMapper
{ {
/** /**
......
package com.ruoyi.project.system.user.dao; package com.ruoyi.project.system.user.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.user.domain.UserPost; import com.ruoyi.project.system.user.domain.UserPost;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.user.domain.UserPost; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.user.domain.UserPost;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IUserPostDao public interface UserPostMapper
{ {
/** /**
......
package com.ruoyi.project.system.user.dao; package com.ruoyi.project.system.user.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.user.domain.UserRole; import com.ruoyi.project.system.user.domain.UserRole;
...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.user.domain.UserRole; ...@@ -8,7 +8,7 @@ import com.ruoyi.project.system.user.domain.UserRole;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface IUserRoleDao public interface UserRoleMapper
{ {
/** /**
......
...@@ -58,7 +58,7 @@ public interface IUserService ...@@ -58,7 +58,7 @@ public interface IUserService
* @return 结果 * @return 结果
*/ */
public int saveUser(User user); public int saveUser(User user);
/** /**
* 修改用户信息 * 修改用户信息
* *
......
...@@ -2,24 +2,22 @@ package com.ruoyi.project.system.user.service; ...@@ -2,24 +2,22 @@ package com.ruoyi.project.system.user.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils; import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.framework.shiro.service.PasswordService; import com.ruoyi.framework.shiro.service.PasswordService;
import com.ruoyi.project.system.post.dao.IPostDao;
import com.ruoyi.project.system.post.domain.Post; import com.ruoyi.project.system.post.domain.Post;
import com.ruoyi.project.system.role.dao.IRoleDao; import com.ruoyi.project.system.post.mapper.PostMapper;
import com.ruoyi.project.system.role.domain.Role; import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.user.dao.IUserDao; import com.ruoyi.project.system.role.mapper.RoleMapper;
import com.ruoyi.project.system.user.dao.IUserPostDao;
import com.ruoyi.project.system.user.dao.IUserRoleDao;
import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.domain.UserPost; import com.ruoyi.project.system.user.domain.UserPost;
import com.ruoyi.project.system.user.domain.UserRole; import com.ruoyi.project.system.user.domain.UserRole;
import com.ruoyi.project.system.user.mapper.UserMapper;
import com.ruoyi.project.system.user.mapper.UserPostMapper;
import com.ruoyi.project.system.user.mapper.UserRoleMapper;
/** /**
* 用户 业务层处理 * 用户 业务层处理
...@@ -31,19 +29,19 @@ public class UserServiceImpl implements IUserService ...@@ -31,19 +29,19 @@ public class UserServiceImpl implements IUserService
{ {
@Autowired @Autowired
private IUserDao userDao; private UserMapper userMapper;
@Autowired @Autowired
private IRoleDao roleDao; private RoleMapper roleMapper;
@Autowired @Autowired
private IPostDao postDao; private PostMapper postMapper;
@Autowired @Autowired
private IUserPostDao userPostDao; private UserPostMapper userPostMapper;
@Autowired @Autowired
private IUserRoleDao userRoleDao; private UserRoleMapper userRoleMapper;
@Autowired @Autowired
private PasswordService passwordService; private PasswordService passwordService;
...@@ -58,7 +56,7 @@ public class UserServiceImpl implements IUserService ...@@ -58,7 +56,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public List<User> selectUserList(User user) public List<User> selectUserList(User user)
{ {
return userDao.selectUserList(user); return userMapper.selectUserList(user);
} }
/** /**
...@@ -70,7 +68,7 @@ public class UserServiceImpl implements IUserService ...@@ -70,7 +68,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public User selectUserByName(String userName) public User selectUserByName(String userName)
{ {
return userDao.selectUserByName(userName); return userMapper.selectUserByName(userName);
} }
/** /**
...@@ -82,7 +80,7 @@ public class UserServiceImpl implements IUserService ...@@ -82,7 +80,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public User selectUserById(Long userId) public User selectUserById(Long userId)
{ {
return userDao.selectUserById(userId); return userMapper.selectUserById(userId);
} }
/** /**
...@@ -95,10 +93,10 @@ public class UserServiceImpl implements IUserService ...@@ -95,10 +93,10 @@ public class UserServiceImpl implements IUserService
public int deleteUserById(Long userId) public int deleteUserById(Long userId)
{ {
// 删除用户与角色关联 // 删除用户与角色关联
userRoleDao.deleteUserRoleByUserId(userId); userRoleMapper.deleteUserRoleByUserId(userId);
// 删除用户与岗位表 // 删除用户与岗位表
userPostDao.deleteUserPostByUserId(userId); userPostMapper.deleteUserPostByUserId(userId);
return userDao.deleteUserById(userId); return userMapper.deleteUserById(userId);
} }
/** /**
...@@ -110,9 +108,9 @@ public class UserServiceImpl implements IUserService ...@@ -110,9 +108,9 @@ public class UserServiceImpl implements IUserService
@Override @Override
public int batchDeleteUser(Long[] ids) public int batchDeleteUser(Long[] ids)
{ {
userRoleDao.deleteUserRole(ids); userRoleMapper.deleteUserRole(ids);
userPostDao.deleteUserPost(ids); userPostMapper.deleteUserPost(ids);
return userDao.batchDeleteUser(ids); return userMapper.batchDeleteUser(ids);
} }
/** /**
...@@ -130,13 +128,13 @@ public class UserServiceImpl implements IUserService ...@@ -130,13 +128,13 @@ public class UserServiceImpl implements IUserService
{ {
user.setUpdateBy(ShiroUtils.getLoginName()); user.setUpdateBy(ShiroUtils.getLoginName());
// 修改用户信息 // 修改用户信息
count = userDao.updateUser(user); count = userMapper.updateUser(user);
// 删除用户与角色关联 // 删除用户与角色关联
userRoleDao.deleteUserRoleByUserId(userId); userRoleMapper.deleteUserRoleByUserId(userId);
// 新增用户与角色管理 // 新增用户与角色管理
insertUserRole(user); insertUserRole(user);
// 删除用户与岗位关联 // 删除用户与岗位关联
userPostDao.deleteUserPostByUserId(userId); userPostMapper.deleteUserPostByUserId(userId);
// 新增用户与岗位管理 // 新增用户与岗位管理
insertUserPost(user); insertUserPost(user);
...@@ -147,7 +145,7 @@ public class UserServiceImpl implements IUserService ...@@ -147,7 +145,7 @@ public class UserServiceImpl implements IUserService
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setCreateBy(ShiroUtils.getLoginName()); user.setCreateBy(ShiroUtils.getLoginName());
// 新增用户信息 // 新增用户信息
count = userDao.insertUser(user); count = userMapper.insertUser(user);
// 新增用户岗位关联 // 新增用户岗位关联
insertUserPost(user); insertUserPost(user);
// 新增用户与角色管理 // 新增用户与角色管理
...@@ -165,7 +163,7 @@ public class UserServiceImpl implements IUserService ...@@ -165,7 +163,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public int updateUser(User user) public int updateUser(User user)
{ {
return userDao.updateUser(user); return userMapper.updateUser(user);
} }
/** /**
...@@ -179,7 +177,7 @@ public class UserServiceImpl implements IUserService ...@@ -179,7 +177,7 @@ public class UserServiceImpl implements IUserService
{ {
user.randomSalt(); user.randomSalt();
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
return userDao.updateUser(user); return userMapper.updateUser(user);
} }
/** /**
...@@ -200,7 +198,7 @@ public class UserServiceImpl implements IUserService ...@@ -200,7 +198,7 @@ public class UserServiceImpl implements IUserService
} }
if (list.size() > 0) if (list.size() > 0)
{ {
userRoleDao.batchUserRole(list); userRoleMapper.batchUserRole(list);
} }
} }
...@@ -222,7 +220,7 @@ public class UserServiceImpl implements IUserService ...@@ -222,7 +220,7 @@ public class UserServiceImpl implements IUserService
} }
if (list.size() > 0) if (list.size() > 0)
{ {
userPostDao.batchUserPost(list); userPostMapper.batchUserPost(list);
} }
} }
...@@ -235,7 +233,7 @@ public class UserServiceImpl implements IUserService ...@@ -235,7 +233,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public String checkUserNameUnique(String loginName) public String checkUserNameUnique(String loginName)
{ {
int count = userDao.checkUserNameUnique(loginName); int count = userMapper.checkUserNameUnique(loginName);
if (count > 0) if (count > 0)
{ {
return UserConstants.NAME_NOT_UNIQUE; return UserConstants.NAME_NOT_UNIQUE;
...@@ -252,7 +250,7 @@ public class UserServiceImpl implements IUserService ...@@ -252,7 +250,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public String selectUserRoleGroup(Long userId) public String selectUserRoleGroup(Long userId)
{ {
List<Role> list = roleDao.selectRolesByUserId(userId); List<Role> list = roleMapper.selectRolesByUserId(userId);
StringBuffer idsStr = new StringBuffer(); StringBuffer idsStr = new StringBuffer();
for (Role role : list) for (Role role : list)
{ {
...@@ -274,7 +272,7 @@ public class UserServiceImpl implements IUserService ...@@ -274,7 +272,7 @@ public class UserServiceImpl implements IUserService
@Override @Override
public String selectUserPostGroup(Long userId) public String selectUserPostGroup(Long userId)
{ {
List<Post> list = postDao.selectPostsByUserId(userId); List<Post> list = postMapper.selectPostsByUserId(userId);
StringBuffer idsStr = new StringBuffer(); StringBuffer idsStr = new StringBuffer();
for (Post post : list) for (Post post : list)
{ {
......
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