为了便于二次开发依赖framework项目

1.BaseController迁移到framework com.ruoyi.web.base中
2.admin中的properties 放到root pom中
pull/34/head
CharlesSong 2018-11-13 16:48:44 +08:00
parent 737c2d8515
commit 26b4f598e2
27 changed files with 183 additions and 184 deletions

View File

@ -24,6 +24,7 @@
<bitwalker.version>1.19</bitwalker.version> <bitwalker.version>1.19</bitwalker.version>
<kaptcha.version>2.3.2</kaptcha.version> <kaptcha.version>2.3.2</kaptcha.version>
<swagger.version>2.7.0</swagger.version> <swagger.version>2.7.0</swagger.version>
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>

View File

@ -14,11 +14,7 @@
<description> <description>
web服务入口 web服务入口
</description> </description>
<properties>
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
<swagger.version>2.7.0</swagger.version>
</properties>
<dependencies> <dependencies>
@ -28,13 +24,6 @@
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 --> <optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency> </dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
</dependency>
<!-- swagger2--> <!-- swagger2-->
<dependency> <dependency>

View File

@ -4,7 +4,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* druid * druid

View File

@ -18,7 +18,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.quartz.domain.SysJob; import com.ruoyi.quartz.domain.SysJob;
import com.ruoyi.quartz.service.ISysJobService; import com.ruoyi.quartz.service.ISysJobService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -15,7 +15,7 @@ import com.ruoyi.common.utils.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.domain.SysJobLog;
import com.ruoyi.quartz.service.ISysJobLogService; import com.ruoyi.quartz.service.ISysJobLogService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -15,7 +15,7 @@ import com.ruoyi.common.utils.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysLogininfor; import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService; import com.ruoyi.system.service.ISysLogininforService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* 访 * 访

View File

@ -17,7 +17,7 @@ import com.ruoyi.common.utils.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysOperLog; import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService; import com.ruoyi.system.service.ISysOperLogService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -19,7 +19,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysUserOnline; import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.impl.SysUserOnlineServiceImpl; import com.ruoyi.system.service.impl.SysUserOnlineServiceImpl;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* 线 * 线

View File

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.google.code.kaptcha.Constants; import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer; import com.google.code.kaptcha.Producer;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -18,7 +18,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -19,7 +19,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysDept; import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole; import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -18,7 +18,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysDictData; import com.ruoyi.system.domain.SysDictData;
import com.ruoyi.system.service.ISysDictDataService; import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -18,7 +18,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysDictType; import com.ruoyi.system.domain.SysDictType;
import com.ruoyi.system.service.ISysDictTypeService; import com.ruoyi.system.service.ISysDictTypeService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -9,7 +9,7 @@ import com.ruoyi.common.config.Global;
import com.ruoyi.system.domain.SysMenu; import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.domain.SysUser; import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysMenuService; import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.base.AjaxResult; import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.util.ServletUtils; import com.ruoyi.framework.util.ServletUtils;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -18,7 +18,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysMenu; import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.domain.SysRole; import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.service.ISysMenuService; import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -17,7 +17,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService; import com.ruoyi.system.service.ISysNoticeService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -18,7 +18,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -23,7 +23,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser; import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysDictDataService; import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -19,7 +19,7 @@ import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.SysRole; import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -23,7 +23,7 @@ import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -4,7 +4,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* build * build

View File

@ -18,7 +18,7 @@ import com.ruoyi.common.support.Convert;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.generator.domain.TableInfo; import com.ruoyi.generator.domain.TableInfo;
import com.ruoyi.generator.service.IGenService; import com.ruoyi.generator.service.IGenService;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* *

View File

@ -4,7 +4,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
/** /**
* swagger * swagger

View File

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.base.AjaxResult; import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.web.core.base.BaseController; import com.ruoyi.framework.web.base.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;

View File

@ -111,6 +111,14 @@
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -1,149 +1,150 @@
package com.ruoyi.web.core.base; package com.ruoyi.framework.web.base;
import java.util.Date; import com.github.pagehelper.PageHelper;
import java.util.List; import com.github.pagehelper.PageInfo;
import java.beans.PropertyEditorSupport; import com.ruoyi.common.base.AjaxResult;
import org.springframework.web.bind.WebDataBinder; import com.ruoyi.common.utils.DateUtils;
import org.springframework.web.bind.annotation.InitBinder; import com.ruoyi.common.utils.StringUtils;
import com.github.pagehelper.PageHelper; import com.ruoyi.framework.util.ShiroUtils;
import com.github.pagehelper.PageInfo; import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.common.base.AjaxResult; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.framework.web.page.TableSupport;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.SysUser;
import com.ruoyi.framework.util.ShiroUtils; import org.springframework.web.bind.WebDataBinder;
import com.ruoyi.framework.web.page.PageDomain; import org.springframework.web.bind.annotation.InitBinder;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.page.TableSupport; import java.beans.PropertyEditorSupport;
import com.ruoyi.system.domain.SysUser; import java.util.Date;
import java.util.List;
/**
* web /**
* * web
* @author ruoyi *
*/ * @author ruoyi
public class BaseController */
{ public class BaseController
/** {
* Date /**
*/ * Date
@InitBinder */
public void initBinder(WebDataBinder binder) @InitBinder
{ public void initBinder(WebDataBinder binder)
// Date 类型转换 {
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() // Date 类型转换
{ binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
@Override {
public void setAsText(String text) @Override
{ public void setAsText(String text)
setValue(DateUtils.parseDate(text)); {
} setValue(DateUtils.parseDate(text));
}); }
} });
}
/**
* /**
*/ *
protected void startPage() */
{ protected void startPage()
PageDomain pageDomain = TableSupport.buildPageRequest(); {
Integer pageNum = pageDomain.getPageNum(); PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageSize = pageDomain.getPageSize(); Integer pageNum = pageDomain.getPageNum();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) Integer pageSize = pageDomain.getPageSize();
{ if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
String orderBy = pageDomain.getOrderBy(); {
PageHelper.startPage(pageNum, pageSize, orderBy); String orderBy = pageDomain.getOrderBy();
} PageHelper.startPage(pageNum, pageSize, orderBy);
} }
}
/**
* /**
*/ *
@SuppressWarnings({ "rawtypes", "unchecked" }) */
protected TableDataInfo getDataTable(List<?> list) @SuppressWarnings({ "rawtypes", "unchecked" })
{ protected TableDataInfo getDataTable(List<?> list)
TableDataInfo rspData = new TableDataInfo(); {
rspData.setCode(0); TableDataInfo rspData = new TableDataInfo();
rspData.setRows(list); rspData.setCode(0);
rspData.setTotal(new PageInfo(list).getTotal()); rspData.setRows(list);
return rspData; rspData.setTotal(new PageInfo(list).getTotal());
} return rspData;
}
/**
* /**
* *
* @param rows *
* @return * @param rows
*/ * @return
protected AjaxResult toAjax(int rows) */
{ protected AjaxResult toAjax(int rows)
return rows > 0 ? success() : error(); {
} return rows > 0 ? success() : error();
}
/**
* /**
*/ *
public AjaxResult success() */
{ public AjaxResult success()
return AjaxResult.success(); {
} return AjaxResult.success();
}
/**
* /**
*/ *
public AjaxResult error() */
{ public AjaxResult error()
return AjaxResult.error(); {
} return AjaxResult.error();
}
/**
* /**
*/ *
public AjaxResult success(String message) */
{ public AjaxResult success(String message)
return AjaxResult.success(message); {
} return AjaxResult.success(message);
}
/**
* /**
*/ *
public AjaxResult error(String message) */
{ public AjaxResult error(String message)
return AjaxResult.error(message); {
} return AjaxResult.error(message);
}
/**
* /**
*/ *
public AjaxResult error(int code, String message) */
{ public AjaxResult error(int code, String message)
return AjaxResult.error(code, message); {
} return AjaxResult.error(code, message);
}
/**
* /**
*/ *
public String redirect(String url) */
{ public String redirect(String url)
return StringUtils.format("redirect:{}", url); {
} return StringUtils.format("redirect:{}", url);
}
public SysUser getUser()
{ public SysUser getUser()
return ShiroUtils.getUser(); {
} return ShiroUtils.getUser();
}
public void setUser(SysUser user)
{ public void setUser(SysUser user)
ShiroUtils.setUser(user); {
} ShiroUtils.setUser(user);
}
public Long getUserId()
{ public Long getUserId()
return getUser().getUserId(); {
} return getUser().getUserId();
}
public String getLoginName()
{ public String getLoginName()
return getUser().getLoginName(); {
} return getUser().getLoginName();
} }
}