Pre Merge pull request !275 from Zail/master

This commit is contained in:
Zail 2021-03-18 09:11:44 +08:00 committed by Gitee
commit a0208a1c15
54 changed files with 2617 additions and 3131 deletions

View File

@ -9,11 +9,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
*
* @author ruoyi
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
public static void main(String[] args)
{
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class RuoYiApplication {
public static void main(String[] args) {
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +

View File

@ -8,11 +8,9 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
*
* @author ruoyi
*/
public class RuoYiServletInitializer extends SpringBootServletInitializer
{
public class RuoYiServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RuoYiApplication.class);
}
}

View File

@ -1,7 +1,12 @@
package com.ruoyi.web.controller.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -11,13 +16,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 通用请求处理
@ -25,8 +26,7 @@ import com.ruoyi.common.utils.file.FileUtils;
* @author ruoyi
*/
@Controller
public class CommonController
{
public class CommonController {
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
@ -39,12 +39,9 @@ public class CommonController
* @param delete 是否删除
*/
@GetMapping("common/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
try
{
if (!FileUtils.checkAllowDownload(fileName))
{
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
try {
if (!FileUtils.checkAllowDownload(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
@ -53,13 +50,11 @@ public class CommonController
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
if (delete) {
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
catch (Exception e) {
log.error("下载文件失败", e);
}
}
@ -69,10 +64,8 @@ public class CommonController
*/
@PostMapping("/common/upload")
@ResponseBody
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
{
public AjaxResult uploadFile(MultipartFile file) throws Exception {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
@ -83,8 +76,7 @@ public class CommonController
ajax.put("url", url);
return ajax;
}
catch (Exception e)
{
catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ -94,12 +86,9 @@ public class CommonController
*/
@GetMapping("/common/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
try
{
if (!FileUtils.checkAllowDownload(resource))
{
throws Exception {
try {
if (!FileUtils.checkAllowDownload(resource)) {
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径
@ -112,8 +101,7 @@ public class CommonController
FileUtils.setAttachmentResponseHeader(response, downloadName);
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}
catch (Exception e)
{
catch (Exception e) {
log.error("下载文件失败", e);
}
}

View File

@ -11,16 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/demo/modal")
public class DemoDialogController
{
public class DemoDialogController {
private String prefix = "demo/modal";
/**
* 模态窗口
*/
@GetMapping("/dialog")
public String dialog()
{
public String dialog() {
return prefix + "/dialog";
}
@ -28,8 +26,7 @@ public class DemoDialogController
* 弹层组件
*/
@GetMapping("/layer")
public String layer()
{
public String layer() {
return prefix + "/layer";
}
@ -37,8 +34,7 @@ public class DemoDialogController
* 表单
*/
@GetMapping("/form")
public String form()
{
public String form() {
return prefix + "/form";
}
@ -46,8 +42,7 @@ public class DemoDialogController
* 表格
*/
@GetMapping("/table")
public String table()
{
public String table() {
return prefix + "/table";
}
@ -55,8 +50,7 @@ public class DemoDialogController
* 表格check
*/
@GetMapping("/check")
public String check()
{
public String check() {
return prefix + "/table/check";
}
@ -64,8 +58,7 @@ public class DemoDialogController
* 表格radio
*/
@GetMapping("/radio")
public String radio()
{
public String radio() {
return prefix + "/table/radio";
}
@ -73,8 +66,7 @@ public class DemoDialogController
* 表格回传父窗体
*/
@GetMapping("/parent")
public String parent()
{
public String parent() {
return prefix + "/table/parent";
}
}

File diff suppressed because one or more lines are too long

View File

@ -11,16 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/demo/icon")
public class DemoIconController
{
public class DemoIconController {
private String prefix = "demo/icon";
/**
* FontAwesome图标
*/
@GetMapping("/fontawesome")
public String fontAwesome()
{
public String fontAwesome() {
return prefix + "/fontawesome";
}
@ -28,8 +26,7 @@ public class DemoIconController
* Glyphicons图标
*/
@GetMapping("/glyphicons")
public String glyphicons()
{
public String glyphicons() {
return prefix + "/glyphicons";
}
}

View File

@ -1,17 +1,5 @@
package com.ruoyi.web.controller.demo.controller;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
@ -23,6 +11,15 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.demo.domain.CustomerModel;
import com.ruoyi.web.controller.demo.domain.UserOperateModel;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 操作控制
@ -31,11 +28,11 @@ import com.ruoyi.web.controller.demo.domain.UserOperateModel;
*/
@Controller
@RequestMapping("/demo/operate")
public class DemoOperateController extends BaseController
{
public class DemoOperateController extends BaseController {
private String prefix = "demo/operate";
private final static Map<Integer, UserOperateModel> users = new LinkedHashMap<Integer, UserOperateModel>();
{
users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
@ -69,8 +66,7 @@ public class DemoOperateController extends BaseController
* 表格
*/
@GetMapping("/table")
public String table()
{
public String table() {
return prefix + "/table";
}
@ -78,8 +74,7 @@ public class DemoOperateController extends BaseController
* 其他
*/
@GetMapping("/other")
public String other()
{
public String other() {
return prefix + "/other";
}
@ -88,44 +83,35 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(UserOperateModel userModel)
{
public TableDataInfo list(UserOperateModel userModel) {
TableDataInfo rspData = new TableDataInfo();
List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values());
// 查询条件过滤
if (StringUtils.isNotEmpty(userModel.getSearchValue()))
{
if (StringUtils.isNotEmpty(userModel.getSearchValue())) {
userList.clear();
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
{
if (entry.getValue().getUserName().equals(userModel.getSearchValue()))
{
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) {
if (entry.getValue().getUserName().equals(userModel.getSearchValue())) {
userList.add(entry.getValue());
}
}
}
else if (StringUtils.isNotEmpty(userModel.getUserName()))
{
else if (StringUtils.isNotEmpty(userModel.getUserName())) {
userList.clear();
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
{
if (entry.getValue().getUserName().equals(userModel.getUserName()))
{
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) {
if (entry.getValue().getUserName().equals(userModel.getUserName())) {
userList.add(entry.getValue());
}
}
}
PageDomain pageDomain = TableSupport.buildPageRequest();
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
{
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
rspData.setRows(userList);
rspData.setTotal(userList.size());
return rspData;
}
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
Integer pageSize = pageDomain.getPageNum() * 10;
if (pageSize > userList.size())
{
if (pageSize > userList.size()) {
pageSize = userList.size();
}
rspData.setRows(userList.subList(pageNum, pageSize));
@ -137,8 +123,7 @@ public class DemoOperateController extends BaseController
* 新增用户
*/
@GetMapping("/add")
public String add(ModelMap mmap)
{
public String add(ModelMap mmap) {
return prefix + "/add";
}
@ -147,8 +132,7 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(UserOperateModel user)
{
public AjaxResult addSave(UserOperateModel user) {
Integer userId = users.size() + 1;
user.setUserId(userId);
return AjaxResult.success(users.put(userId, user));
@ -159,8 +143,7 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/customer/add")
@ResponseBody
public AjaxResult addSave(CustomerModel customerModel)
{
public AjaxResult addSave(CustomerModel customerModel) {
System.out.println(customerModel.toString());
return AjaxResult.success();
}
@ -169,8 +152,7 @@ public class DemoOperateController extends BaseController
* 修改用户
*/
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Integer userId, ModelMap mmap)
{
public String edit(@PathVariable("userId") Integer userId, ModelMap mmap) {
mmap.put("user", users.get(userId));
return prefix + "/edit";
}
@ -180,8 +162,7 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(UserOperateModel user)
{
public AjaxResult editSave(UserOperateModel user) {
return AjaxResult.success(users.put(user.getUserId(), user));
}
@ -190,8 +171,7 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/export")
@ResponseBody
public AjaxResult export(UserOperateModel user)
{
public AjaxResult export(UserOperateModel user) {
List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values());
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
return util.exportExcel(list, "用户数据");
@ -202,8 +182,7 @@ public class DemoOperateController extends BaseController
*/
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate()
{
public AjaxResult importTemplate() {
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
return util.importTemplateExcel("用户数据");
}
@ -213,8 +192,7 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
List<UserOperateModel> userList = util.importExcel(file.getInputStream());
String message = importUser(userList, updateSupport);
@ -226,11 +204,9 @@ public class DemoOperateController extends BaseController
*/
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
Integer[] userIds = Convert.toIntArray(ids);
for (Integer userId : userIds)
{
for (Integer userId : userIds) {
users.remove(userId);
}
return AjaxResult.success();
@ -240,16 +216,14 @@ public class DemoOperateController extends BaseController
* 查看详细
*/
@GetMapping("/detail/{userId}")
public String detail(@PathVariable("userId") Integer userId, ModelMap mmap)
{
public String detail(@PathVariable("userId") Integer userId, ModelMap mmap) {
mmap.put("user", users.get(userId));
return prefix + "/detail";
}
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
public AjaxResult clean() {
users.clear();
return success();
}
@ -261,64 +235,52 @@ public class DemoOperateController extends BaseController
* @param isUpdateSupport 是否更新支持如果已存在则进行更新数据
* @return 结果
*/
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport)
{
if (StringUtils.isNull(userList) || userList.size() == 0)
{
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport) {
if (StringUtils.isNull(userList) || userList.size() == 0) {
throw new BusinessException("导入用户数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (UserOperateModel user : userList)
{
try
{
for (UserOperateModel user : userList) {
try {
// 验证是否存在这个用户
boolean userFlag = false;
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
{
if (entry.getValue().getUserName().equals(user.getUserName()))
{
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) {
if (entry.getValue().getUserName().equals(user.getUserName())) {
userFlag = true;
break;
}
}
if (!userFlag)
{
if (!userFlag) {
Integer userId = users.size() + 1;
user.setUserId(userId);
users.put(userId, user);
successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功");
}
else if (isUpdateSupport)
{
else if (isUpdateSupport) {
users.put(user.getUserId(), user);
successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功");
}
else
{
else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在");
}
}
catch (Exception e)
{
catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0)
{
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new BusinessException(failureMsg.toString());
}
else
{
else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();

View File

@ -11,16 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/demo/report")
public class DemoReportController
{
public class DemoReportController {
private String prefix = "demo/report";
/**
* 百度ECharts
*/
@GetMapping("/echarts")
public String echarts()
{
public String echarts() {
return prefix + "/echarts";
}
@ -28,8 +26,7 @@ public class DemoReportController
* 图表插件
*/
@GetMapping("/peity")
public String peity()
{
public String peity() {
return prefix + "/peity";
}
@ -37,8 +34,7 @@ public class DemoReportController
* 线状图插件
*/
@GetMapping("/sparkline")
public String sparkline()
{
public String sparkline() {
return prefix + "/sparkline";
}
@ -46,8 +42,7 @@ public class DemoReportController
* 图表组合
*/
@GetMapping("/metrics")
public String metrics()
{
public String metrics() {
return prefix + "/metrics";
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.demo.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -19,6 +8,14 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
/**
* 表格相关
@ -27,11 +24,11 @@ import com.ruoyi.common.utils.StringUtils;
*/
@Controller
@RequestMapping("/demo/table")
public class DemoTableController extends BaseController
{
public class DemoTableController extends BaseController {
private String prefix = "demo/table";
private final static List<UserTableModel> users = new ArrayList<UserTableModel>();
{
users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
@ -62,6 +59,7 @@ public class DemoTableController extends BaseController
}
private final static List<UserTableColumn> columns = new ArrayList<UserTableColumn>();
{
columns.add(new UserTableColumn("用户ID", "userId"));
columns.add(new UserTableColumn("用户编号", "userCode"));
@ -75,8 +73,7 @@ public class DemoTableController extends BaseController
* 搜索相关
*/
@GetMapping("/search")
public String search()
{
public String search() {
return prefix + "/search";
}
@ -84,8 +81,7 @@ public class DemoTableController extends BaseController
* 数据汇总
*/
@GetMapping("/footer")
public String footer()
{
public String footer() {
return prefix + "/footer";
}
@ -93,8 +89,7 @@ public class DemoTableController extends BaseController
* 组合表头
*/
@GetMapping("/groupHeader")
public String groupHeader()
{
public String groupHeader() {
return prefix + "/groupHeader";
}
@ -102,8 +97,7 @@ public class DemoTableController extends BaseController
* 表格导出
*/
@GetMapping("/export")
public String export()
{
public String export() {
return prefix + "/export";
}
@ -111,8 +105,7 @@ public class DemoTableController extends BaseController
* 翻页记住选择
*/
@GetMapping("/remember")
public String remember()
{
public String remember() {
return prefix + "/remember";
}
@ -120,8 +113,7 @@ public class DemoTableController extends BaseController
* 跳转至指定页
*/
@GetMapping("/pageGo")
public String pageGo()
{
public String pageGo() {
return prefix + "/pageGo";
}
@ -129,8 +121,7 @@ public class DemoTableController extends BaseController
* 自定义查询参数
*/
@GetMapping("/params")
public String params()
{
public String params() {
return prefix + "/params";
}
@ -138,8 +129,7 @@ public class DemoTableController extends BaseController
* 多表格
*/
@GetMapping("/multi")
public String multi()
{
public String multi() {
return prefix + "/multi";
}
@ -147,8 +137,7 @@ public class DemoTableController extends BaseController
* 点击按钮加载表格
*/
@GetMapping("/button")
public String button()
{
public String button() {
return prefix + "/button";
}
@ -156,8 +145,7 @@ public class DemoTableController extends BaseController
* 直接加载表格数据
*/
@GetMapping("/data")
public String data(ModelMap mmap)
{
public String data(ModelMap mmap) {
mmap.put("users", users);
return prefix + "/data";
}
@ -166,8 +154,7 @@ public class DemoTableController extends BaseController
* 表格冻结列
*/
@GetMapping("/fixedColumns")
public String fixedColumns()
{
public String fixedColumns() {
return prefix + "/fixedColumns";
}
@ -175,8 +162,7 @@ public class DemoTableController extends BaseController
* 自定义触发事件
*/
@GetMapping("/event")
public String event()
{
public String event() {
return prefix + "/event";
}
@ -184,8 +170,7 @@ public class DemoTableController extends BaseController
* 表格细节视图
*/
@GetMapping("/detail")
public String detail()
{
public String detail() {
return prefix + "/detail";
}
@ -193,8 +178,7 @@ public class DemoTableController extends BaseController
* 表格父子视图
*/
@GetMapping("/child")
public String child()
{
public String child() {
return prefix + "/child";
}
@ -202,8 +186,7 @@ public class DemoTableController extends BaseController
* 表格图片预览
*/
@GetMapping("/image")
public String image()
{
public String image() {
return prefix + "/image";
}
@ -211,8 +194,7 @@ public class DemoTableController extends BaseController
* 动态增删改查
*/
@GetMapping("/curd")
public String curd()
{
public String curd() {
return prefix + "/curd";
}
@ -220,8 +202,7 @@ public class DemoTableController extends BaseController
* 表格拖拽操作
*/
@GetMapping("/reorder")
public String reorder()
{
public String reorder() {
return prefix + "/reorder";
}
@ -229,8 +210,7 @@ public class DemoTableController extends BaseController
* 表格列宽拖动
*/
@GetMapping("/resizable")
public String resizable()
{
public String resizable() {
return prefix + "/resizable";
}
@ -238,8 +218,7 @@ public class DemoTableController extends BaseController
* 表格行内编辑操作
*/
@GetMapping("/editable")
public String editable()
{
public String editable() {
return prefix + "/editable";
}
@ -247,8 +226,7 @@ public class DemoTableController extends BaseController
* 主子表提交
*/
@GetMapping("/subdata")
public String subdata()
{
public String subdata() {
return prefix + "/subdata";
}
@ -256,8 +234,7 @@ public class DemoTableController extends BaseController
* 表格自动刷新
*/
@GetMapping("/refresh")
public String refresh()
{
public String refresh() {
return prefix + "/refresh";
}
@ -265,8 +242,7 @@ public class DemoTableController extends BaseController
* 表格打印配置
*/
@GetMapping("/print")
public String print()
{
public String print() {
return prefix + "/print";
}
@ -274,8 +250,7 @@ public class DemoTableController extends BaseController
* 表格标题格式化
*/
@GetMapping("/headerStyle")
public String headerStyle()
{
public String headerStyle() {
return prefix + "/headerStyle";
}
@ -283,8 +258,7 @@ public class DemoTableController extends BaseController
* 表格动态列
*/
@GetMapping("/dynamicColumns")
public String dynamicColumns()
{
public String dynamicColumns() {
return prefix + "/dynamicColumns";
}
@ -292,8 +266,7 @@ public class DemoTableController extends BaseController
* 表格其他操作
*/
@GetMapping("/other")
public String other()
{
public String other() {
return prefix + "/other";
}
@ -302,12 +275,10 @@ public class DemoTableController extends BaseController
*/
@PostMapping("/ajaxColumns")
@ResponseBody
public AjaxResult ajaxColumns(UserTableColumn userColumn)
{
public AjaxResult ajaxColumns(UserTableColumn userColumn) {
List<UserTableColumn> columnList = new ArrayList<UserTableColumn>(Arrays.asList(new UserTableColumn[columns.size()]));
Collections.copy(columnList, columns);
if (userColumn != null && "userBalance".equals(userColumn.getField()))
{
if (userColumn != null && "userBalance".equals(userColumn.getField())) {
columnList.add(new UserTableColumn("用户余额", "userBalance"));
}
return AjaxResult.success(columnList);
@ -318,34 +289,28 @@ public class DemoTableController extends BaseController
*/
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(UserTableModel userModel)
{
public TableDataInfo list(UserTableModel userModel) {
TableDataInfo rspData = new TableDataInfo();
List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()]));
Collections.copy(userList, users);
// 查询条件过滤
if (StringUtils.isNotEmpty(userModel.getUserName()))
{
if (StringUtils.isNotEmpty(userModel.getUserName())) {
userList.clear();
for (UserTableModel user : users)
{
if (user.getUserName().equals(userModel.getUserName()))
{
for (UserTableModel user : users) {
if (user.getUserName().equals(userModel.getUserName())) {
userList.add(user);
}
}
}
PageDomain pageDomain = TableSupport.buildPageRequest();
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
{
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
rspData.setRows(userList);
rspData.setTotal(userList.size());
return rspData;
}
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
Integer pageSize = pageDomain.getPageNum() * 10;
if (pageSize > userList.size())
{
if (pageSize > userList.size()) {
pageSize = userList.size();
}
rspData.setRows(userList.subList(pageNum, pageSize));
@ -354,83 +319,95 @@ public class DemoTableController extends BaseController
}
}
class UserTableColumn
{
/** 表头 */
class UserTableColumn {
/**
* 表头
*/
private String title;
/** 字段 */
/**
* 字段
*/
private String field;
public UserTableColumn()
{
public UserTableColumn() {
}
public UserTableColumn(String title, String field)
{
public UserTableColumn(String title, String field) {
this.title = title;
this.field = field;
}
public String getTitle()
{
public String getTitle() {
return title;
}
public void setTitle(String title)
{
public void setTitle(String title) {
this.title = title;
}
public String getField()
{
public String getField() {
return field;
}
public void setField(String field)
{
public void setField(String field) {
this.field = field;
}
}
class UserTableModel
{
/** 用户ID */
class UserTableModel {
/**
* 用户ID
*/
private int userId;
/** 用户编号 */
/**
* 用户编号
*/
private String userCode;
/** 用户姓名 */
/**
* 用户姓名
*/
private String userName;
/** 用户性别 */
/**
* 用户性别
*/
private String userSex;
/** 用户手机 */
/**
* 用户手机
*/
private String userPhone;
/** 用户邮箱 */
/**
* 用户邮箱
*/
private String userEmail;
/** 用户余额 */
/**
* 用户余额
*/
private double userBalance;
/** 用户状态0正常 1停用 */
/**
* 用户状态0正常 1停用
*/
private String status;
/** 创建时间 */
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
public UserTableModel()
{
public UserTableModel() {
}
public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone,
String userEmail, double userBalance, String status)
{
String userEmail, double userBalance, String status) {
this.userId = userId;
this.userCode = userCode;
this.userName = userName;
@ -442,93 +419,75 @@ class UserTableModel
this.createTime = DateUtils.getNowDate();
}
public int getUserId()
{
public int getUserId() {
return userId;
}
public void setUserId(int userId)
{
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserCode()
{
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode)
{
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getUserName()
{
public String getUserName() {
return userName;
}
public void setUserName(String userName)
{
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserSex()
{
public String getUserSex() {
return userSex;
}
public void setUserSex(String userSex)
{
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserPhone()
{
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone)
{
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
public String getUserEmail()
{
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail)
{
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public double getUserBalance()
{
public double getUserBalance() {
return userBalance;
}
public void setUserBalance(double userBalance)
{
public void setUserBalance(double userBalance) {
this.userBalance = userBalance;
}
public String getStatus()
{
public String getStatus() {
return status;
}
public void setStatus(String status)
{
public void setStatus(String status) {
this.status = status;
}
public Date getCreateTime()
{
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime)
{
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -1,16 +1,16 @@
package com.ruoyi.web.controller.demo.domain;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* 客户测试信息
*
* @author ruoyi
*/
public class CustomerModel
{
public class CustomerModel {
/**
* 客户姓名
*/
@ -41,70 +41,58 @@ public class CustomerModel
*/
private List<GoodsModel> goods;
public String getName()
{
public String getName() {
return name;
}
public void setName(String name)
{
public void setName(String name) {
this.name = name;
}
public String getPhonenumber()
{
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber)
{
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getSex()
{
public String getSex() {
return sex;
}
public void setSex(String sex)
{
public void setSex(String sex) {
this.sex = sex;
}
public String getBirthday()
{
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday)
{
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getRemark()
{
public String getRemark() {
return remark;
}
public void setRemark(String remark)
{
public void setRemark(String remark) {
this.remark = remark;
}
public List<GoodsModel> getGoods()
{
public List<GoodsModel> getGoods() {
return goods;
}
public void setGoods(List<GoodsModel> goods)
{
public void setGoods(List<GoodsModel> goods) {
this.goods = goods;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("name", getName())
.append("phonenumber", getPhonenumber())
.append("sex", getSex())

View File

@ -1,16 +1,16 @@
package com.ruoyi.web.controller.demo.domain;
import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 商品测试信息
*
* @author ruoyi
*/
public class GoodsModel
{
public class GoodsModel {
/**
* 商品名称
*/
@ -36,59 +36,49 @@ public class GoodsModel
*/
private String type;
public String getName()
{
public String getName() {
return name;
}
public void setName(String name)
{
public void setName(String name) {
this.name = name;
}
public Integer getWeight()
{
public Integer getWeight() {
return weight;
}
public void setWeight(Integer weight)
{
public void setWeight(Integer weight) {
this.weight = weight;
}
public Double getPrice()
{
public Double getPrice() {
return price;
}
public void setPrice(Double price)
{
public void setPrice(Double price) {
this.price = price;
}
public Date getDate()
{
public Date getDate() {
return date;
}
public void setDate(Date date)
{
public void setDate(Date date) {
this.date = date;
}
public String getType()
{
public String getType() {
return type;
}
public void setType(String type)
{
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("name", getName())
.append("weight", getWeight())
.append("price", getPrice())

View File

@ -1,13 +1,13 @@
package com.ruoyi.web.controller.demo.domain;
import java.util.Date;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.DateUtils;
public class UserOperateModel extends BaseEntity
{
import java.util.Date;
public class UserOperateModel extends BaseEntity {
private static final long serialVersionUID = 1L;
private int userId;
@ -36,14 +36,12 @@ public class UserOperateModel extends BaseEntity
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date createTime;
public UserOperateModel()
{
public UserOperateModel() {
}
public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone,
String userEmail, double userBalance, String status)
{
String userEmail, double userBalance, String status) {
this.userId = userId;
this.userCode = userCode;
this.userName = userName;
@ -55,95 +53,77 @@ public class UserOperateModel extends BaseEntity
this.createTime = DateUtils.getNowDate();
}
public int getUserId()
{
public int getUserId() {
return userId;
}
public void setUserId(int userId)
{
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserCode()
{
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode)
{
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getUserName()
{
public String getUserName() {
return userName;
}
public void setUserName(String userName)
{
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserSex()
{
public String getUserSex() {
return userSex;
}
public void setUserSex(String userSex)
{
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserPhone()
{
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone)
{
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
public String getUserEmail()
{
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail)
{
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public double getUserBalance()
{
public double getUserBalance() {
return userBalance;
}
public void setUserBalance(double userBalance)
{
public void setUserBalance(double userBalance) {
this.userBalance = userBalance;
}
public String getStatus()
{
public String getStatus() {
return status;
}
public void setStatus(String status)
{
public void setStatus(String status) {
this.status = status;
}
@Override
public Date getCreateTime()
{
public Date getCreateTime() {
return createTime;
}
@Override
public void setCreateTime(Date createTime)
{
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -1,5 +1,8 @@
package com.ruoyi.web.controller.monitor;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -7,9 +10,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.CacheService;
/**
* 缓存监控
@ -18,38 +18,33 @@ import com.ruoyi.framework.web.service.CacheService;
*/
@Controller
@RequestMapping("/monitor/cache")
public class CacheController extends BaseController
{
public class CacheController extends BaseController {
private String prefix = "monitor/cache";
@Autowired
private CacheService cacheService;
@GetMapping()
public String cache(ModelMap mmap)
{
public String cache(ModelMap mmap) {
mmap.put("cacheNames", cacheService.getCacheNames());
return prefix + "/cache";
}
@PostMapping("/getNames")
public String getCacheNames(String fragment, ModelMap mmap)
{
public String getCacheNames(String fragment, ModelMap mmap) {
mmap.put("cacheNames", cacheService.getCacheNames());
return prefix + "/cache::" + fragment;
}
@PostMapping("/getKeys")
public String getCacheKeys(String fragment, String cacheName, ModelMap mmap)
{
public String getCacheKeys(String fragment, String cacheName, ModelMap mmap) {
mmap.put("cacheName", cacheName);
mmap.put("cacheKyes", cacheService.getCacheKeys(cacheName));
return prefix + "/cache::" + fragment;
}
@PostMapping("/getValue")
public String getCacheValue(String fragment, String cacheName, String cacheKey, ModelMap mmap)
{
public String getCacheValue(String fragment, String cacheName, String cacheKey, ModelMap mmap) {
mmap.put("cacheName", cacheName);
mmap.put("cacheKey", cacheKey);
mmap.put("cacheValue", cacheService.getCacheValue(cacheName, cacheKey));
@ -58,24 +53,21 @@ public class CacheController extends BaseController
@PostMapping("/clearCacheName")
@ResponseBody
public AjaxResult clearCacheName(String cacheName, ModelMap mmap)
{
public AjaxResult clearCacheName(String cacheName, ModelMap mmap) {
cacheService.clearCacheName(cacheName);
return AjaxResult.success();
}
@PostMapping("/clearCacheKey")
@ResponseBody
public AjaxResult clearCacheKey(String cacheName, String cacheKey, ModelMap mmap)
{
public AjaxResult clearCacheKey(String cacheName, String cacheKey, ModelMap mmap) {
cacheService.clearCacheKey(cacheName, cacheKey);
return AjaxResult.success();
}
@GetMapping("/clearAll")
@ResponseBody
public AjaxResult clearAll(ModelMap mmap)
{
public AjaxResult clearAll(ModelMap mmap) {
cacheService.clearAll();
return AjaxResult.success();
}

View File

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.monitor;
import com.ruoyi.common.core.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.controller.BaseController;
/**
* druid 监控
@ -13,14 +13,12 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/monitor/data")
public class DruidController extends BaseController
{
public class DruidController extends BaseController {
private String prefix = "/druid";
@RequiresPermissions("monitor:data:view")
@GetMapping()
public String index()
{
public String index() {
return redirect(prefix + "/index");
}
}

View File

@ -1,12 +1,12 @@
package com.ruoyi.web.controller.monitor;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.web.domain.Server;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.web.domain.Server;
/**
* 服务器监控
@ -15,14 +15,12 @@ import com.ruoyi.framework.web.domain.Server;
*/
@Controller
@RequestMapping("/monitor/server")
public class ServerController extends BaseController
{
public class ServerController extends BaseController {
private String prefix = "monitor/server";
@RequiresPermissions("monitor:server:view")
@GetMapping()
public String server(ModelMap mmap) throws Exception
{
public String server(ModelMap mmap) throws Exception {
Server server = new Server();
server.copyTo();
mmap.put("server", server);

View File

@ -1,7 +1,14 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -9,14 +16,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
import java.util.List;
/**
* 系统访问记录
@ -25,8 +26,7 @@ import com.ruoyi.system.service.ISysLogininforService;
*/
@Controller
@RequestMapping("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
public class SysLogininforController extends BaseController {
private String prefix = "monitor/logininfor";
@Autowired
@ -37,16 +37,14 @@ public class SysLogininforController extends BaseController
@RequiresPermissions("monitor:logininfor:view")
@GetMapping()
public String logininfor()
{
public String logininfor() {
return prefix + "/logininfor";
}
@RequiresPermissions("monitor:logininfor:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysLogininfor logininfor)
{
public TableDataInfo list(SysLogininfor logininfor) {
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
@ -56,8 +54,7 @@ public class SysLogininforController extends BaseController
@RequiresPermissions("monitor:logininfor:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysLogininfor logininfor)
{
public AjaxResult export(SysLogininfor logininfor) {
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
return util.exportExcel(list, "登录日志");
@ -67,8 +64,7 @@ public class SysLogininforController extends BaseController
@Log(title = "登录日志", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(logininforService.deleteLogininforByIds(ids));
}
@ -76,8 +72,7 @@ public class SysLogininforController extends BaseController
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
public AjaxResult clean() {
logininforService.cleanLogininfor();
return success();
}
@ -86,8 +81,7 @@ public class SysLogininforController extends BaseController
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@PostMapping("/unlock")
@ResponseBody
public AjaxResult unlock(String loginName)
{
public AjaxResult unlock(String loginName) {
passwordService.clearLoginRecordCache(loginName);
return success();
}

View File

@ -1,15 +1,5 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -18,6 +8,13 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 操作日志记录
@ -26,8 +23,7 @@ import com.ruoyi.system.service.ISysOperLogService;
*/
@Controller
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
public class SysOperlogController extends BaseController {
private String prefix = "monitor/operlog";
@Autowired
@ -35,16 +31,14 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:view")
@GetMapping()
public String operlog()
{
public String operlog() {
return prefix + "/operlog";
}
@RequiresPermissions("monitor:operlog:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysOperLog operLog)
{
public TableDataInfo list(SysOperLog operLog) {
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
@ -54,8 +48,7 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysOperLog operLog)
{
public AjaxResult export(SysOperLog operLog) {
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
return util.exportExcel(list, "操作日志");
@ -64,15 +57,13 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(operLogService.deleteOperLogByIds(ids));
}
@RequiresPermissions("monitor:operlog:detail")
@GetMapping("/detail/{operId}")
public String detail(@PathVariable("operId") Long operId, ModelMap mmap)
{
public String detail(@PathVariable("operId") Long operId, ModelMap mmap) {
mmap.put("operLog", operLogService.selectOperLogById(operId));
return prefix + "/detail";
}
@ -81,8 +72,7 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
public AjaxResult clean() {
operLogService.cleanOperLog();
return success();
}

View File

@ -1,14 +1,5 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -21,6 +12,16 @@ import com.ruoyi.framework.shiro.session.OnlineSession;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 在线用户监控
@ -29,8 +30,7 @@ import com.ruoyi.system.service.ISysUserOnlineService;
*/
@Controller
@RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController
{
public class SysUserOnlineController extends BaseController {
private String prefix = "monitor/online";
@Autowired
@ -41,41 +41,34 @@ public class SysUserOnlineController extends BaseController
@RequiresPermissions("monitor:online:view")
@GetMapping()
public String online()
{
public String online() {
return prefix + "/online";
}
@RequiresPermissions("monitor:online:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysUserOnline userOnline)
{
public TableDataInfo list(SysUserOnline userOnline) {
startPage();
List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
return getDataTable(list);
}
@RequiresPermissions(value = { "monitor:online:batchForceLogout", "monitor:online:forceLogout" }, logical = Logical.OR)
@RequiresPermissions(value = {"monitor:online:batchForceLogout", "monitor:online:forceLogout"}, logical = Logical.OR)
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/batchForceLogout")
@ResponseBody
public AjaxResult batchForceLogout(String ids)
{
for (String sessionId : Convert.toStrArray(ids))
{
public AjaxResult batchForceLogout(String ids) {
for (String sessionId : Convert.toStrArray(ids)) {
SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null)
{
if (online == null) {
return error("用户已下线");
}
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
if (onlineSession == null)
{
if (onlineSession == null) {
return error("用户已下线");
}
if (sessionId.equals(ShiroUtils.getSessionId()))
{
if (sessionId.equals(ShiroUtils.getSessionId())) {
return error("当前登录用户无法强退");
}
onlineSessionDAO.delete(onlineSession);

View File

@ -1,20 +1,21 @@
package com.ruoyi.web.controller.system;
import java.awt.image.BufferedImage;
import java.io.IOException;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.ruoyi.common.core.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
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.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.ruoyi.common.core.controller.BaseController;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* 图片验证码支持算术形式
@ -23,8 +24,8 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/captcha")
public class SysCaptchaController extends BaseController
{
public class SysCaptchaController extends BaseController {
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@ -35,11 +36,9 @@ public class SysCaptchaController extends BaseController
* 验证码生成
*/
@GetMapping(value = "/captchaImage")
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response)
{
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) {
ServletOutputStream out = null;
try
{
try {
HttpSession session = request.getSession();
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
@ -51,15 +50,13 @@ public class SysCaptchaController extends BaseController
String capStr = null;
String code = null;
BufferedImage bi = null;
if ("math".equals(type))
{
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))
{
else if ("char".equals(type)) {
capStr = code = captchaProducer.createText();
bi = captchaProducer.createImage(capStr);
}
@ -67,23 +64,17 @@ public class SysCaptchaController extends BaseController
out = response.getOutputStream();
ImageIO.write(bi, "jpg", out);
out.flush();
}
catch (Exception e)
{
catch (Exception e) {
e.printStackTrace();
}
finally
{
try
{
if (out != null)
{
finally {
try {
if (out != null) {
out.close();
}
}
catch (IOException e)
{
catch (IOException e) {
e.printStackTrace();
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -21,6 +10,14 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 参数配置 信息操作处理
@ -29,8 +26,7 @@ import com.ruoyi.system.service.ISysConfigService;
*/
@Controller
@RequestMapping("/system/config")
public class SysConfigController extends BaseController
{
public class SysConfigController extends BaseController {
private String prefix = "system/config";
@Autowired
@ -38,8 +34,7 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:view")
@GetMapping()
public String config()
{
public String config() {
return prefix + "/config";
}
@ -49,8 +44,7 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysConfig config)
{
public TableDataInfo list(SysConfig config) {
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
@ -60,8 +54,7 @@ public class SysConfigController extends BaseController
@RequiresPermissions("system:config:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysConfig config)
{
public AjaxResult export(SysConfig config) {
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
return util.exportExcel(list, "参数数据");
@ -71,8 +64,7 @@ public class SysConfigController extends BaseController
* 新增参数配置
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -83,10 +75,8 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysConfig config)
{
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
public AjaxResult addSave(@Validated SysConfig config) {
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(ShiroUtils.getLoginName());
@ -97,8 +87,7 @@ public class SysConfigController extends BaseController
* 修改参数配置
*/
@GetMapping("/edit/{configId}")
public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
{
public String edit(@PathVariable("configId") Long configId, ModelMap mmap) {
mmap.put("config", configService.selectConfigById(configId));
return prefix + "/edit";
}
@ -110,10 +99,8 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysConfig config)
{
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
public AjaxResult editSave(@Validated SysConfig config) {
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(ShiroUtils.getLoginName());
@ -127,8 +114,7 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(configService.deleteConfigByIds(ids));
}
@ -139,8 +125,7 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@GetMapping("/clearCache")
@ResponseBody
public AjaxResult clearCache()
{
public AjaxResult clearCache() {
configService.clearCache();
return success();
}
@ -150,8 +135,7 @@ public class SysConfigController extends BaseController
*/
@PostMapping("/checkConfigKeyUnique")
@ResponseBody
public String checkConfigKeyUnique(SysConfig config)
{
public String checkConfigKeyUnique(SysConfig config) {
return configService.checkConfigKeyUnique(config);
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -22,6 +11,14 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 部门信息
@ -30,8 +27,7 @@ import com.ruoyi.system.service.ISysDeptService;
*/
@Controller
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
public class SysDeptController extends BaseController {
private String prefix = "system/dept";
@Autowired
@ -39,16 +35,14 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:view")
@GetMapping()
public String dept()
{
public String dept() {
return prefix + "/dept";
}
@RequiresPermissions("system:dept:list")
@PostMapping("/list")
@ResponseBody
public List<SysDept> list(SysDept dept)
{
public List<SysDept> list(SysDept dept) {
List<SysDept> deptList = deptService.selectDeptList(dept);
return deptList;
}
@ -57,8 +51,7 @@ public class SysDeptController extends BaseController
* 新增部门
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add";
}
@ -70,10 +63,8 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
public AjaxResult addSave(@Validated SysDept dept) {
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(ShiroUtils.getLoginName());
@ -84,11 +75,9 @@ public class SysDeptController extends BaseController
* 修改
*/
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) {
SysDept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
if (StringUtils.isNotNull(dept) && 100L == deptId) {
dept.setParentName("");
}
mmap.put("dept", dept);
@ -102,19 +91,15 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
public AjaxResult editSave(@Validated SysDept dept) {
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(dept.getDeptId()))
{
else if (dept.getParentId().equals(dept.getDeptId())) {
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
{
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
return AjaxResult.error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(ShiroUtils.getLoginName());
@ -128,14 +113,11 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{deptId}")
@ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId)
{
if (deptService.selectDeptCount(deptId) > 0)
{
public AjaxResult remove(@PathVariable("deptId") Long deptId) {
if (deptService.selectDeptCount(deptId) > 0) {
return AjaxResult.warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
if (deptService.checkDeptExistUser(deptId)) {
return AjaxResult.warn("部门存在用户,不允许删除");
}
return toAjax(deptService.deleteDeptById(deptId));
@ -146,8 +128,7 @@ public class SysDeptController extends BaseController
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
public String checkDeptNameUnique(SysDept dept)
{
public String checkDeptNameUnique(SysDept dept) {
return deptService.checkDeptNameUnique(dept);
}
@ -157,10 +138,9 @@ public class SysDeptController extends BaseController
* @param deptId 部门ID
* @param excludeId 排除ID
*/
@GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
@GetMapping(value = {"/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}"})
public String selectDeptTree(@PathVariable("deptId") Long deptId,
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
{
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap) {
mmap.put("dept", deptService.selectDeptById(deptId));
mmap.put("excludeId", excludeId);
return prefix + "/tree";
@ -171,8 +151,7 @@ public class SysDeptController extends BaseController
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
public List<Ztree> treeData() {
List<Ztree> ztrees = deptService.selectDeptTree(new SysDept());
return ztrees;
}
@ -182,8 +161,7 @@ public class SysDeptController extends BaseController
*/
@GetMapping("/treeData/{excludeId}")
@ResponseBody
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
{
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId) {
SysDept dept = new SysDept();
dept.setDeptId(excludeId);
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
@ -195,8 +173,7 @@ public class SysDeptController extends BaseController
*/
@GetMapping("/roleDeptTreeData")
@ResponseBody
public List<Ztree> deptTreeData(SysRole role)
{
public List<Ztree> deptTreeData(SysRole role) {
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
return ztrees;
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -20,6 +9,14 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 数据字典信息
@ -28,8 +25,7 @@ import com.ruoyi.system.service.ISysDictDataService;
*/
@Controller
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController
{
public class SysDictDataController extends BaseController {
private String prefix = "system/dict/data";
@Autowired
@ -37,16 +33,14 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:view")
@GetMapping()
public String dictData()
{
public String dictData() {
return prefix + "/data";
}
@PostMapping("/list")
@RequiresPermissions("system:dict:list")
@ResponseBody
public TableDataInfo list(SysDictData dictData)
{
public TableDataInfo list(SysDictData dictData) {
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
@ -56,8 +50,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysDictData dictData)
{
public AjaxResult export(SysDictData dictData) {
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
return util.exportExcel(list, "字典数据");
@ -67,8 +60,7 @@ public class SysDictDataController extends BaseController
* 新增字典类型
*/
@GetMapping("/add/{dictType}")
public String add(@PathVariable("dictType") String dictType, ModelMap mmap)
{
public String add(@PathVariable("dictType") String dictType, ModelMap mmap) {
mmap.put("dictType", dictType);
return prefix + "/add";
}
@ -80,8 +72,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDictData dict)
{
public AjaxResult addSave(@Validated SysDictData dict) {
dict.setCreateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.insertDictData(dict));
}
@ -90,8 +81,7 @@ public class SysDictDataController extends BaseController
* 修改字典类型
*/
@GetMapping("/edit/{dictCode}")
public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap)
{
public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap) {
mmap.put("dict", dictDataService.selectDictDataById(dictCode));
return prefix + "/edit";
}
@ -103,8 +93,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDictData dict)
{
public AjaxResult editSave(@Validated SysDictData dict) {
dict.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.updateDictData(dict));
}
@ -113,8 +102,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(dictDataService.deleteDictDataByIds(ids));
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -22,6 +11,14 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 数据字典信息
@ -30,8 +27,7 @@ import com.ruoyi.system.service.ISysDictTypeService;
*/
@Controller
@RequestMapping("/system/dict")
public class SysDictTypeController extends BaseController
{
public class SysDictTypeController extends BaseController {
private String prefix = "system/dict/type";
@Autowired
@ -39,16 +35,14 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:view")
@GetMapping()
public String dictType()
{
public String dictType() {
return prefix + "/type";
}
@PostMapping("/list")
@RequiresPermissions("system:dict:list")
@ResponseBody
public TableDataInfo list(SysDictType dictType)
{
public TableDataInfo list(SysDictType dictType) {
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
@ -58,8 +52,7 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysDictType dictType)
{
public AjaxResult export(SysDictType dictType) {
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
@ -70,8 +63,7 @@ public class SysDictTypeController extends BaseController
* 新增字典类型
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -82,10 +74,8 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDictType dict)
{
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
public AjaxResult addSave(@Validated SysDictType dict) {
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(ShiroUtils.getLoginName());
@ -96,8 +86,7 @@ public class SysDictTypeController extends BaseController
* 修改字典类型
*/
@GetMapping("/edit/{dictId}")
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
{
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap) {
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
return prefix + "/edit";
}
@ -109,10 +98,8 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDictType dict)
{
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
public AjaxResult editSave(@Validated SysDictType dict) {
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setUpdateBy(ShiroUtils.getLoginName());
@ -123,8 +110,7 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(dictTypeService.deleteDictTypeByIds(ids));
}
@ -135,8 +121,7 @@ public class SysDictTypeController extends BaseController
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@GetMapping("/clearCache")
@ResponseBody
public AjaxResult clearCache()
{
public AjaxResult clearCache() {
dictTypeService.clearCache();
return success();
}
@ -146,8 +131,7 @@ public class SysDictTypeController extends BaseController
*/
@RequiresPermissions("system:dict:list")
@GetMapping("/detail/{dictId}")
public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap)
{
public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap) {
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
mmap.put("dictList", dictTypeService.selectDictTypeAll());
return "system/dict/data/data";
@ -158,8 +142,7 @@ public class SysDictTypeController extends BaseController
*/
@PostMapping("/checkDictTypeUnique")
@ResponseBody
public String checkDictTypeUnique(SysDictType dictType)
{
public String checkDictTypeUnique(SysDictType dictType) {
return dictTypeService.checkDictTypeUnique(dictType);
}
@ -168,8 +151,7 @@ public class SysDictTypeController extends BaseController
*/
@GetMapping("/selectDictTree/{columnId}/{dictType}")
public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
ModelMap mmap)
{
ModelMap mmap) {
mmap.put("columnId", columnId);
mmap.put("dict", dictTypeService.selectDictTypeByType(dictType));
return prefix + "/tree";
@ -180,8 +162,7 @@ public class SysDictTypeController extends BaseController
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
public List<Ztree> treeData() {
List<Ztree> ztrees = dictTypeService.selectDictTree(new SysDictType());
return ztrees;
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.Date;
import java.util.List;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -18,14 +7,22 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.CookieUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.*;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
/**
* 首页 业务处理
@ -33,8 +30,8 @@ import com.ruoyi.system.service.ISysMenuService;
* @author ruoyi
*/
@Controller
public class SysIndexController extends BaseController
{
public class SysIndexController extends BaseController {
@Autowired
private ISysMenuService menuService;
@ -46,8 +43,7 @@ public class SysIndexController extends BaseController
// 系统首页
@GetMapping("/index")
public String index(ModelMap mmap)
{
public String index(ModelMap mmap) {
// 取身份信息
SysUser user = ShiroUtils.getSysUser();
// 根据用户id取出菜单
@ -69,10 +65,8 @@ public class SysIndexController extends BaseController
// 优先Cookie配置导航菜单
Cookie[] cookies = ServletUtils.getRequest().getCookies();
for (Cookie cookie : cookies)
{
if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName()))
{
for (Cookie cookie : cookies) {
if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName())) {
indexStyle = cookie.getValue();
break;
}
@ -83,8 +77,7 @@ public class SysIndexController extends BaseController
// 锁定屏幕
@GetMapping("/lockscreen")
public String lockscreen(ModelMap mmap)
{
public String lockscreen(ModelMap mmap) {
mmap.put("user", ShiroUtils.getSysUser());
ServletUtils.getSession().setAttribute(ShiroConstants.LOCK_SCREEN, true);
return "lock";
@ -93,15 +86,12 @@ public class SysIndexController extends BaseController
// 解锁屏幕
@PostMapping("/unlockscreen")
@ResponseBody
public AjaxResult unlockscreen(String password)
{
public AjaxResult unlockscreen(String password) {
SysUser user = ShiroUtils.getSysUser();
if (StringUtils.isNull(user))
{
if (StringUtils.isNull(user)) {
return AjaxResult.error("服务器超时,请重新登陆");
}
if (passwordService.matches(user, password))
{
if (passwordService.matches(user, password)) {
ServletUtils.getSession().removeAttribute(ShiroConstants.LOCK_SCREEN);
return AjaxResult.success();
}
@ -110,41 +100,35 @@ public class SysIndexController extends BaseController
// 切换主题
@GetMapping("/system/switchSkin")
public String switchSkin()
{
public String switchSkin() {
return "skin";
}
// 切换菜单
@GetMapping("/system/menuStyle/{style}")
public void menuStyle(@PathVariable String style, HttpServletResponse response)
{
public void menuStyle(@PathVariable String style) {
HttpServletResponse response = ServletUtils.getResponse();
CookieUtils.setCookie(response, "nav-style", style);
}
// 系统介绍
@GetMapping("/system/main")
public String main(ModelMap mmap)
{
public String main(ModelMap mmap) {
mmap.put("version", RuoYiConfig.getVersion());
return "main";
}
// 检查初始密码是否提醒修改
public boolean initPasswordIsModify(Date pwdUpdateDate)
{
public boolean initPasswordIsModify(Date pwdUpdateDate) {
Integer initPasswordModify = Convert.toInt(configService.selectConfigByKey("sys.account.initPasswordModify"));
return initPasswordModify != null && initPasswordModify == 1 && pwdUpdateDate == null;
}
// 检查密码是否过期
public boolean passwordIsExpiration(Date pwdUpdateDate)
{
public boolean passwordIsExpiration(Date pwdUpdateDate) {
Integer passwordValidateDays = Convert.toInt(configService.selectConfigByKey("sys.account.passwordValidateDays"));
if (passwordValidateDays != null && passwordValidateDays > 0)
{
if (StringUtils.isNull(pwdUpdateDate))
{
if (passwordValidateDays != null && passwordValidateDays > 0) {
if (StringUtils.isNull(pwdUpdateDate)) {
// 如果从未修改过初始密码直接提醒过期
return true;
}

View File

@ -1,7 +1,9 @@
package com.ruoyi.web.controller.system;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
@ -10,10 +12,9 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 登录验证
@ -21,14 +22,13 @@ import com.ruoyi.common.utils.StringUtils;
* @author ruoyi
*/
@Controller
public class SysLoginController extends BaseController
{
public class SysLoginController extends BaseController {
@GetMapping("/login")
public String login(HttpServletRequest request, HttpServletResponse response)
{
public String login(HttpServletRequest request, HttpServletResponse response) {
// 如果是Ajax请求返回Json字符串
if (ServletUtils.isAjaxRequest(request))
{
if (ServletUtils.isAjaxRequest(request)) {
return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
}
@ -37,20 +37,19 @@ public class SysLoginController extends BaseController
@PostMapping("/login")
@ResponseBody
public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe)
{
public AjaxResult ajaxLogin(String username,
String password,
Boolean rememberMe) {
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
Subject subject = SecurityUtils.getSubject();
try
{
try {
subject.login(token);
return success();
}
catch (AuthenticationException e)
{
catch (AuthenticationException e) {
String msg = "用户或密码错误";
if (StringUtils.isNotEmpty(e.getMessage()))
{
if (StringUtils.isNotEmpty(e.getMessage())) {
msg = e.getMessage();
}
return error(msg);
@ -58,8 +57,7 @@ public class SysLoginController extends BaseController
}
@GetMapping("/unauth")
public String unauth()
{
public String unauth() {
return "error/unauth";
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -22,6 +11,14 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.service.ISysMenuService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 菜单信息
@ -30,8 +27,7 @@ import com.ruoyi.system.service.ISysMenuService;
*/
@Controller
@RequestMapping("/system/menu")
public class SysMenuController extends BaseController
{
public class SysMenuController extends BaseController {
private String prefix = "system/menu";
@Autowired
@ -39,16 +35,14 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:view")
@GetMapping()
public String menu()
{
public String menu() {
return prefix + "/menu";
}
@RequiresPermissions("system:menu:list")
@PostMapping("/list")
@ResponseBody
public List<SysMenu> list(SysMenu menu)
{
public List<SysMenu> list(SysMenu menu) {
Long userId = ShiroUtils.getUserId();
List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
return menuList;
@ -61,14 +55,11 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}")
@ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.selectCountMenuByParentId(menuId) > 0)
{
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
if (menuService.selectCountMenuByParentId(menuId) > 0) {
return AjaxResult.warn("存在子菜单,不允许删除");
}
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
{
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0) {
return AjaxResult.warn("菜单已分配,不允许删除");
}
AuthorizationUtils.clearAllCachedAuthorizationInfo();
@ -79,15 +70,12 @@ public class SysMenuController extends BaseController
* 新增
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
SysMenu menu = null;
if (0L != parentId)
{
if (0L != parentId) {
menu = menuService.selectMenuById(parentId);
}
else
{
else {
menu = new SysMenu();
menu.setMenuId(0L);
menu.setMenuName("主目录");
@ -103,10 +91,8 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysMenu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
public AjaxResult addSave(@Validated SysMenu menu) {
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
menu.setCreateBy(ShiroUtils.getLoginName());
@ -118,8 +104,7 @@ public class SysMenuController extends BaseController
* 修改菜单
*/
@GetMapping("/edit/{menuId}")
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
{
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap) {
mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/edit";
}
@ -131,10 +116,8 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysMenu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
public AjaxResult editSave(@Validated SysMenu menu) {
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
menu.setUpdateBy(ShiroUtils.getLoginName());
@ -146,8 +129,7 @@ public class SysMenuController extends BaseController
* 选择菜单图标
*/
@GetMapping("/icon")
public String icon()
{
public String icon() {
return prefix + "/icon";
}
@ -156,8 +138,7 @@ public class SysMenuController extends BaseController
*/
@PostMapping("/checkMenuNameUnique")
@ResponseBody
public String checkMenuNameUnique(SysMenu menu)
{
public String checkMenuNameUnique(SysMenu menu) {
return menuService.checkMenuNameUnique(menu);
}
@ -166,8 +147,7 @@ public class SysMenuController extends BaseController
*/
@GetMapping("/roleMenuTreeData")
@ResponseBody
public List<Ztree> roleMenuTreeData(SysRole role)
{
public List<Ztree> roleMenuTreeData(SysRole role) {
Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
return ztrees;
@ -178,8 +158,7 @@ public class SysMenuController extends BaseController
*/
@GetMapping("/menuTreeData")
@ResponseBody
public List<Ztree> menuTreeData()
{
public List<Ztree> menuTreeData() {
Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.menuTreeData(userId);
return ztrees;
@ -189,8 +168,7 @@ public class SysMenuController extends BaseController
* 选择菜单树
*/
@GetMapping("/selectMenuTree/{menuId}")
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap)
{
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap) {
mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/tree";
}

View File

@ -1,15 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -18,6 +8,13 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 公告 信息操作处理
@ -26,8 +23,7 @@ import com.ruoyi.system.service.ISysNoticeService;
*/
@Controller
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController
{
public class SysNoticeController extends BaseController {
private String prefix = "system/notice";
@Autowired
@ -35,8 +31,7 @@ public class SysNoticeController extends BaseController
@RequiresPermissions("system:notice:view")
@GetMapping()
public String notice()
{
public String notice() {
return prefix + "/notice";
}
@ -46,8 +41,7 @@ public class SysNoticeController extends BaseController
@RequiresPermissions("system:notice:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysNotice notice)
{
public TableDataInfo list(SysNotice notice) {
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
@ -57,8 +51,7 @@ public class SysNoticeController extends BaseController
* 新增公告
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -69,8 +62,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysNotice notice)
{
public AjaxResult addSave(SysNotice notice) {
notice.setCreateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.insertNotice(notice));
}
@ -79,8 +71,7 @@ public class SysNoticeController extends BaseController
* 修改公告
*/
@GetMapping("/edit/{noticeId}")
public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
{
public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap) {
mmap.put("notice", noticeService.selectNoticeById(noticeId));
return prefix + "/edit";
}
@ -92,8 +83,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysNotice notice)
{
public AjaxResult editSave(SysNotice notice) {
notice.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.updateNotice(notice));
}
@ -105,8 +95,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(noticeService.deleteNoticeByIds(ids));
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -21,6 +10,14 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 岗位信息操作处理
@ -29,8 +26,7 @@ import com.ruoyi.system.service.ISysPostService;
*/
@Controller
@RequestMapping("/system/post")
public class SysPostController extends BaseController
{
public class SysPostController extends BaseController {
private String prefix = "system/post";
@Autowired
@ -38,16 +34,14 @@ public class SysPostController extends BaseController
@RequiresPermissions("system:post:view")
@GetMapping()
public String operlog()
{
public String operlog() {
return prefix + "/post";
}
@RequiresPermissions("system:post:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysPost post)
{
public TableDataInfo list(SysPost post) {
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
@ -57,8 +51,7 @@ public class SysPostController extends BaseController
@RequiresPermissions("system:post:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysPost post)
{
public AjaxResult export(SysPost post) {
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
return util.exportExcel(list, "岗位数据");
@ -68,14 +61,11 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
public AjaxResult remove(String ids) {
try {
return toAjax(postService.deletePostByIds(ids));
}
catch (Exception e)
{
catch (Exception e) {
return error(e.getMessage());
}
}
@ -84,8 +74,7 @@ public class SysPostController extends BaseController
* 新增岗位
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -96,14 +85,11 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysPost post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
public AjaxResult addSave(@Validated SysPost post) {
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(ShiroUtils.getLoginName());
@ -114,8 +100,7 @@ public class SysPostController extends BaseController
* 修改岗位
*/
@GetMapping("/edit/{postId}")
public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
{
public String edit(@PathVariable("postId") Long postId, ModelMap mmap) {
mmap.put("post", postService.selectPostById(postId));
return prefix + "/edit";
}
@ -127,14 +112,11 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysPost post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
public AjaxResult editSave(@Validated SysPost post) {
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(ShiroUtils.getLoginName());
@ -146,8 +128,7 @@ public class SysPostController extends BaseController
*/
@PostMapping("/checkPostNameUnique")
@ResponseBody
public String checkPostNameUnique(SysPost post)
{
public String checkPostNameUnique(SysPost post) {
return postService.checkPostNameUnique(post);
}
@ -156,8 +137,7 @@ public class SysPostController extends BaseController
*/
@PostMapping("/checkPostCodeUnique")
@ResponseBody
public String checkPostCodeUnique(SysPost post)
{
public String checkPostCodeUnique(SysPost post) {
return postService.checkPostCodeUnique(post);
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
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.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
@ -22,6 +11,13 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* 个人信息 业务处理
@ -30,8 +26,7 @@ import com.ruoyi.system.service.ISysUserService;
*/
@Controller
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController
{
public class SysProfileController extends BaseController {
private static final Logger log = LoggerFactory.getLogger(SysProfileController.class);
private String prefix = "system/user/profile";
@ -46,8 +41,7 @@ public class SysProfileController extends BaseController
* 个人信息
*/
@GetMapping()
public String profile(ModelMap mmap)
{
public String profile(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", user);
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
@ -57,19 +51,16 @@ public class SysProfileController extends BaseController
@GetMapping("/checkPassword")
@ResponseBody
public boolean checkPassword(String password)
{
public boolean checkPassword(String password) {
SysUser user = ShiroUtils.getSysUser();
if (passwordService.matches(user, password))
{
if (passwordService.matches(user, password)) {
return true;
}
return false;
}
@GetMapping("/resetPwd")
public String resetPwd(ModelMap mmap)
{
public String resetPwd(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/resetPwd";
@ -78,22 +69,18 @@ public class SysProfileController extends BaseController
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwd(String oldPassword, String newPassword)
{
public AjaxResult resetPwd(String oldPassword, String newPassword) {
SysUser user = ShiroUtils.getSysUser();
if (!passwordService.matches(user, oldPassword))
{
if (!passwordService.matches(user, oldPassword)) {
return error("修改密码失败,旧密码错误");
}
if (passwordService.matches(user, newPassword))
{
if (passwordService.matches(user, newPassword)) {
return error("新密码不能与旧密码相同");
}
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
user.setPwdUpdateDate(DateUtils.getNowDate());
if (userService.resetUserPwd(user) > 0)
{
if (userService.resetUserPwd(user) > 0) {
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
return success();
}
@ -104,8 +91,7 @@ public class SysProfileController extends BaseController
* 修改用户
*/
@GetMapping("/edit")
public String edit(ModelMap mmap)
{
public String edit(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/edit";
@ -115,8 +101,7 @@ public class SysProfileController extends BaseController
* 修改头像
*/
@GetMapping("/avatar")
public String avatar(ModelMap mmap)
{
public String avatar(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/avatar";
@ -128,15 +113,13 @@ public class SysProfileController extends BaseController
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/update")
@ResponseBody
public AjaxResult update(SysUser user)
{
public AjaxResult update(SysUser user) {
SysUser currentUser = ShiroUtils.getSysUser();
currentUser.setUserName(user.getUserName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (userService.updateUserInfo(currentUser) > 0)
{
if (userService.updateUserInfo(currentUser) > 0) {
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
@ -149,25 +132,20 @@ public class SysProfileController extends BaseController
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateAvatar")
@ResponseBody
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
{
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file) {
SysUser currentUser = ShiroUtils.getSysUser();
try
{
if (!file.isEmpty())
{
try {
if (!file.isEmpty()) {
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
currentUser.setAvatar(avatar);
if (userService.updateUserInfo(currentUser) > 0)
{
if (userService.updateUserInfo(currentUser) > 0) {
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
}
return error();
}
catch (Exception e)
{
catch (Exception e) {
log.error("修改头像失败!", e);
return error(e.getMessage());
}

View File

@ -1,16 +1,16 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.framework.shiro.service.SysRegisterService;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.framework.shiro.service.SysRegisterService;
import com.ruoyi.system.service.ISysConfigService;
/**
* 注册验证
@ -18,8 +18,7 @@ import com.ruoyi.system.service.ISysConfigService;
* @author ruoyi
*/
@Controller
public class SysRegisterController extends BaseController
{
public class SysRegisterController extends BaseController {
@Autowired
private SysRegisterService registerService;
@ -27,17 +26,14 @@ public class SysRegisterController extends BaseController
private ISysConfigService configService;
@GetMapping("/register")
public String register()
{
public String register() {
return "register";
}
@PostMapping("/register")
@ResponseBody
public AjaxResult ajaxRegister(SysUser user)
{
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
public AjaxResult ajaxRegister(SysUser user) {
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
return error("当前系统没有开启注册功能!");
}
String msg = registerService.register(user);

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -25,6 +14,14 @@ import com.ruoyi.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 角色信息
@ -33,8 +30,7 @@ import com.ruoyi.system.service.ISysUserService;
*/
@Controller
@RequestMapping("/system/role")
public class SysRoleController extends BaseController
{
public class SysRoleController extends BaseController {
private String prefix = "system/role";
@Autowired
@ -45,16 +41,14 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:view")
@GetMapping()
public String role()
{
public String role() {
return prefix + "/role";
}
@RequiresPermissions("system:role:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysRole role)
{
public TableDataInfo list(SysRole role) {
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
@ -64,8 +58,7 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysRole role)
{
public AjaxResult export(SysRole role) {
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
return util.exportExcel(list, "角色数据");
@ -75,8 +68,7 @@ public class SysRoleController extends BaseController
* 新增角色
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -87,14 +79,11 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysRole role)
{
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
public AjaxResult addSave(@Validated SysRole role) {
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setCreateBy(ShiroUtils.getLoginName());
@ -107,8 +96,7 @@ public class SysRoleController extends BaseController
* 修改角色
*/
@GetMapping("/edit/{roleId}")
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/edit";
}
@ -120,15 +108,12 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysRole role)
{
public AjaxResult editSave(@Validated SysRole role) {
roleService.checkRoleAllowed(role);
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setUpdateBy(ShiroUtils.getLoginName());
@ -140,8 +125,7 @@ public class SysRoleController extends BaseController
* 角色分配数据权限
*/
@GetMapping("/authDataScope/{roleId}")
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/dataScope";
}
@ -153,12 +137,10 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/authDataScope")
@ResponseBody
public AjaxResult authDataScopeSave(SysRole role)
{
public AjaxResult authDataScopeSave(SysRole role) {
roleService.checkRoleAllowed(role);
role.setUpdateBy(ShiroUtils.getLoginName());
if (roleService.authDataScope(role) > 0)
{
if (roleService.authDataScope(role) > 0) {
ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
return success();
}
@ -169,8 +151,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(roleService.deleteRoleByIds(ids));
}
@ -179,8 +160,7 @@ public class SysRoleController extends BaseController
*/
@PostMapping("/checkRoleNameUnique")
@ResponseBody
public String checkRoleNameUnique(SysRole role)
{
public String checkRoleNameUnique(SysRole role) {
return roleService.checkRoleNameUnique(role);
}
@ -189,8 +169,7 @@ public class SysRoleController extends BaseController
*/
@PostMapping("/checkRoleKeyUnique")
@ResponseBody
public String checkRoleKeyUnique(SysRole role)
{
public String checkRoleKeyUnique(SysRole role) {
return roleService.checkRoleKeyUnique(role);
}
@ -198,8 +177,7 @@ public class SysRoleController extends BaseController
* 选择菜单树
*/
@GetMapping("/selectMenuTree")
public String selectMenuTree()
{
public String selectMenuTree() {
return prefix + "/tree";
}
@ -210,8 +188,7 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
public AjaxResult changeStatus(SysRole role) {
roleService.checkRoleAllowed(role);
return toAjax(roleService.changeStatus(role));
}
@ -221,8 +198,7 @@ public class SysRoleController extends BaseController
*/
@RequiresPermissions("system:role:edit")
@GetMapping("/authUser/{roleId}")
public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/authUser";
}
@ -233,8 +209,7 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:list")
@PostMapping("/authUser/allocatedList")
@ResponseBody
public TableDataInfo allocatedList(SysUser user)
{
public TableDataInfo allocatedList(SysUser user) {
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
@ -246,8 +221,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancel")
@ResponseBody
public AjaxResult cancelAuthUser(SysUserRole userRole)
{
public AjaxResult cancelAuthUser(SysUserRole userRole) {
return toAjax(roleService.deleteAuthUser(userRole));
}
@ -257,8 +231,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancelAll")
@ResponseBody
public AjaxResult cancelAuthUserAll(Long roleId, String userIds)
{
public AjaxResult cancelAuthUserAll(Long roleId, String userIds) {
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
@ -266,8 +239,7 @@ public class SysRoleController extends BaseController
* 选择用户
*/
@GetMapping("/authUser/selectUser/{roleId}")
public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/selectUser";
}
@ -278,8 +250,7 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:list")
@PostMapping("/authUser/unallocatedList")
@ResponseBody
public TableDataInfo unallocatedList(SysUser user)
{
public TableDataInfo unallocatedList(SysUser user) {
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
@ -291,8 +262,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/selectAll")
@ResponseBody
public AjaxResult selectAuthUserAll(Long roleId, String userIds)
{
public AjaxResult selectAuthUserAll(Long roleId, String userIds) {
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
}

View File

@ -1,18 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -28,6 +15,16 @@ import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户信息
@ -36,8 +33,7 @@ import com.ruoyi.system.service.ISysUserService;
*/
@Controller
@RequestMapping("/system/user")
public class SysUserController extends BaseController
{
public class SysUserController extends BaseController {
private String prefix = "system/user";
@Autowired
@ -54,16 +50,14 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:view")
@GetMapping()
public String user()
{
public String user() {
return prefix + "/user";
}
@RequiresPermissions("system:user:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysUser user)
{
public TableDataInfo list(SysUser user) {
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
@ -73,8 +67,7 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysUser user)
{
public AjaxResult export(SysUser user) {
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.exportExcel(list, "用户数据");
@ -84,8 +77,7 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = ShiroUtils.getSysUser().getLoginName();
@ -96,8 +88,7 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:view")
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate()
{
public AjaxResult importTemplate() {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.importTemplateExcel("用户数据");
}
@ -106,8 +97,7 @@ public class SysUserController extends BaseController
* 新增用户
*/
@GetMapping("/add")
public String add(ModelMap mmap)
{
public String add(ModelMap mmap) {
mmap.put("roles", roleService.selectRoleAll().stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
mmap.put("posts", postService.selectPostAll());
return prefix + "/add";
@ -120,20 +110,16 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysUser user)
{
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
{
public AjaxResult addSave(@Validated SysUser user) {
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))) {
return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
&& UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
user.setSalt(ShiroUtils.randomSalt());
@ -146,8 +132,7 @@ public class SysUserController extends BaseController
* 修改用户
*/
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
{
public String edit(@PathVariable("userId") Long userId, ModelMap mmap) {
List<SysRole> roles = roleService.selectRolesByUserId(userId);
mmap.put("user", userService.selectUserById(userId));
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
@ -162,17 +147,14 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysUser user)
{
public AjaxResult editSave(@Validated SysUser user) {
userService.checkUserAllowed(user);
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
&& UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(ShiroUtils.getLoginName());
@ -181,8 +163,7 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:resetPwd")
@GetMapping("/resetPwd/{userId}")
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
{
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap) {
mmap.put("user", userService.selectUserById(userId));
return prefix + "/resetPwd";
}
@ -191,15 +172,12 @@ public class SysUserController extends BaseController
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwdSave(SysUser user)
{
public AjaxResult resetPwdSave(SysUser user) {
userService.checkUserAllowed(user);
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
if (userService.resetUserPwd(user) > 0)
{
if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue())
{
if (userService.resetUserPwd(user) > 0) {
if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue()) {
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
}
return success();
@ -211,8 +189,7 @@ public class SysUserController extends BaseController
* 进入授权角色页
*/
@GetMapping("/authRole/{userId}")
public String authRole(@PathVariable("userId") Long userId, ModelMap mmap)
{
public String authRole(@PathVariable("userId") Long userId, ModelMap mmap) {
SysUser user = userService.selectUserById(userId);
// 获取用户所属的角色列表
List<SysRole> roles = roleService.selectRolesByUserId(userId);
@ -228,8 +205,7 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PostMapping("/authRole/insertAuthRole")
@ResponseBody
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
userService.insertUserAuth(userId, roleIds);
return success();
}
@ -238,8 +214,7 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(userService.deleteUserByIds(ids));
}
@ -248,8 +223,7 @@ public class SysUserController extends BaseController
*/
@PostMapping("/checkLoginNameUnique")
@ResponseBody
public String checkLoginNameUnique(SysUser user)
{
public String checkLoginNameUnique(SysUser user) {
return userService.checkLoginNameUnique(user.getLoginName());
}
@ -258,8 +232,7 @@ public class SysUserController extends BaseController
*/
@PostMapping("/checkPhoneUnique")
@ResponseBody
public String checkPhoneUnique(SysUser user)
{
public String checkPhoneUnique(SysUser user) {
return userService.checkPhoneUnique(user);
}
@ -268,8 +241,7 @@ public class SysUserController extends BaseController
*/
@PostMapping("/checkEmailUnique")
@ResponseBody
public String checkEmailUnique(SysUser user)
{
public String checkEmailUnique(SysUser user) {
return userService.checkEmailUnique(user);
}
@ -280,8 +252,7 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysUser user)
{
public AjaxResult changeStatus(SysUser user) {
userService.checkUserAllowed(user);
return toAjax(userService.changeStatus(user));
}

View File

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.tool;
import com.ruoyi.common.core.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.controller.BaseController;
/**
* build 表单构建
@ -13,14 +13,12 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/tool/build")
public class BuildController extends BaseController
{
public class BuildController extends BaseController {
private String prefix = "tool/build";
@RequiresPermissions("tool:build:view")
@GetMapping()
public String build()
{
public String build() {
return prefix + "/build";
}
}

View File

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.tool;
import com.ruoyi.common.core.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.controller.BaseController;
/**
* swagger 接口
@ -13,12 +13,10 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/tool/swagger")
public class SwaggerController extends BaseController
{
public class SwaggerController extends BaseController {
@RequiresPermissions("tool:swagger:view")
@GetMapping()
public String index()
{
public String index() {
return redirect("/swagger-ui.html");
}
}

View File

@ -1,24 +1,15 @@
package com.ruoyi.web.controller.tool;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
/**
* swagger 用户测试方法
@ -28,9 +19,9 @@ import io.swagger.annotations.ApiOperation;
@Api("用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController
{
public class TestController extends BaseController {
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
@ -38,8 +29,7 @@ public class TestController extends BaseController
@ApiOperation("获取用户列表")
@GetMapping("/list")
public AjaxResult userList()
{
public AjaxResult userList() {
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return AjaxResult.success(userList);
}
@ -47,14 +37,11 @@ public class TestController extends BaseController
@ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@GetMapping("/{userId}")
public AjaxResult getUser(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
public AjaxResult getUser(@PathVariable Integer userId) {
if (!users.isEmpty() && users.containsKey(userId)) {
return AjaxResult.success(users.get(userId));
}
else
{
else {
return error("用户不存在");
}
}
@ -62,10 +49,8 @@ public class TestController extends BaseController
@ApiOperation("新增用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PostMapping("/save")
public AjaxResult save(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
public AjaxResult save(UserEntity user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
return error("用户ID不能为空");
}
return AjaxResult.success(users.put(user.getUserId(), user));
@ -74,14 +59,11 @@ public class TestController extends BaseController
@ApiOperation("更新用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PutMapping("/update")
public AjaxResult update(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
public AjaxResult update(UserEntity user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
return error("用户ID不能为空");
}
if (users.isEmpty() || !users.containsKey(user.getUserId()))
{
if (users.isEmpty() || !users.containsKey(user.getUserId())) {
return error("用户不存在");
}
users.remove(user.getUserId());
@ -91,23 +73,19 @@ public class TestController extends BaseController
@ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@DeleteMapping("/{userId}")
public AjaxResult delete(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
public AjaxResult delete(@PathVariable Integer userId) {
if (!users.isEmpty() && users.containsKey(userId)) {
users.remove(userId);
return success();
}
else
{
else {
return error("用户不存在");
}
}
}
@ApiModel("用户实体")
class UserEntity
{
class UserEntity {
@ApiModelProperty("用户ID")
private Integer userId;
@ -120,56 +98,46 @@ class UserEntity
@ApiModelProperty("用户手机")
private String mobile;
public UserEntity()
{
public UserEntity() {
}
public UserEntity(Integer userId, String username, String password, String mobile)
{
public UserEntity(Integer userId, String username, String password, String mobile) {
this.userId = userId;
this.username = username;
this.password = password;
this.mobile = mobile;
}
public Integer getUserId()
{
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId)
{
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUsername()
{
public String getUsername() {
return username;
}
public void setUsername(String username)
{
public void setUsername(String username) {
this.username = username;
}
public String getPassword()
{
public String getPassword() {
return password;
}
public void setPassword(String password)
{
public void setPassword(String password) {
this.password = password;
}
public String getMobile()
{
public String getMobile() {
return mobile;
}
public void setMobile(String mobile)
{
public void setMobile(String mobile) {
this.mobile = mobile;
}
}

View File

@ -1,10 +1,10 @@
package com.ruoyi.web.core.config;
import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@ -21,9 +21,11 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
/** 是否开启swagger */
public class SwaggerConfig {
/**
* 是否开启swagger
*/
@Value("${swagger.enabled}")
private boolean enabled;
@ -31,8 +33,7 @@ public class SwaggerConfig
* 创建API
*/
@Bean
public Docket createRestApi()
{
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
// 是否启用Swagger
.enable(enabled)
@ -52,8 +53,7 @@ public class SwaggerConfig
/**
* 添加摘要信息
*/
private ApiInfo apiInfo()
{
private ApiInfo apiInfo() {
// 用ApiInfoBuilder进行定制
return new ApiInfoBuilder()
// 设置标题

View File

@ -8,7 +8,7 @@ spring:
master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: password
password: root!@#
# 从库数据源
slave:
# 从数据源开关/默认关闭

View File

@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口默认为80
port: 80
port: 8090
servlet:
# 应用的访问路径
context-path: /
@ -98,7 +98,7 @@ shiro:
# 验证码开关
captchaEnabled: true
# 验证码类型 math 数组计算 char 字符
captchaType: math
captchaType: char
cookie:
# 设置Cookie的域名 默认空,即当前访问的域名
domain:

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 引入spring-boot的logging配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<!-- 日志存放路径 -->
<property name="log.path" value="/Users/zail/Workspace/logs"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 错误日志输出 -->
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>

View File

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>

View File

@ -9,7 +9,7 @@
<link th:href="@{/css/style.css}" rel="stylesheet"/>
</head>
<body class="gray-bg">
<div class="middle-box text-center animated fadeInDown">
<div class="middle-box text-center animated fadeInDown">
<h1>403</h1>
<h3 class="font-bold">您没有访问权限!</h3>
@ -17,12 +17,14 @@
对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面
<a href="javascript:index()" class="btn btn-outline btn-primary btn-xs">返回主页</a>
</div>
</div>
<script th:inline="javascript">
</div>
<script th:inline="javascript">
var ctx = [[@{/}]];
function index() {
window.top.location = ctx + "index";
}
</script>
</script>
</body>
</html>

View File

@ -36,35 +36,54 @@
<a class="menuItem noactive" title="个人中心" th:href="@{/system/user/profile}">
<div class="hide" th:text="个人中心"></div>
<div class="pull-left image">
<img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}" th:onerror="this.src='img/profile.jpg'" class="img-circle" alt="User Image">
<img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}"
th:onerror="this.src='img/profile.jpg'" class="img-circle" alt="User Image">
</div>
</a>
<div class="pull-left info">
<p>[[${user.loginName}]]</p>
<p th:text="${user.loginName}"></p>
<a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
<a th:href="@{logout}" style="padding-left:5px;"><i class="fa fa-sign-out text-danger"></i> 注销</a>
<a th:href="@{logout}" style="padding-left:5px;">
<i class="fa fa-sign-out text-danger"></i>
注销
</a>
</div>
</div>
</li>
<li>
<a class="menuItem" th:href="@{/system/main}"><i class="fa fa-home"></i> <span class="nav-label">首页</span> </a>
<a class="menuItem" th:href="@{/system/main}"><i class="fa fa-home"></i> <span
class="nav-label">首页</span> </a>
</li>
<li th:each="menu : ${menus}">
<a th:class="@{${!#strings.isEmpty(menu.url) && menu.url != '#'} ? ${menu.target}}" th:href="@{${#strings.isEmpty(menu.url)} ? |#| : ${menu.url}}" th:data-refresh="${menu.isRefresh == '0'}">
<a th:class="@{${!#strings.isEmpty(menu.url) && menu.url != '#'} ? ${menu.target}}"
th:href="@{${#strings.isEmpty(menu.url)} ? |#| : ${menu.url}}"
th:data-refresh="${menu.isRefresh == '0'}">
<i class="fa fa-bar-chart-o" th:class="${menu.icon}"></i>
<span class="nav-label" th:text="${menu.menuName}">一级菜单</span>
<span th:class="${#strings.isEmpty(menu.url) || menu.url == '#'} ? |fa arrow|"></span>
</a>
<ul class="nav nav-second-level collapse">
<li th:each="cmenu : ${menu.children}">
<a th:if="${#lists.isEmpty(cmenu.children)}" th:class="${#strings.isEmpty(cmenu.target)} ? |menuItem| : ${cmenu.target}" th:utext="${cmenu.menuName}" th:href="@{${cmenu.url}}" th:data-refresh="${cmenu.isRefresh == '0'}">二级菜单</a>
<a th:if="${not #lists.isEmpty(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span class="fa arrow"></span></a>
<a th:if="${#lists.isEmpty(cmenu.children)}"
th:class="${#strings.isEmpty(cmenu.target)} ? |menuItem| : ${cmenu.target}"
th:utext="${cmenu.menuName}" th:href="@{${cmenu.url}}"
th:data-refresh="${cmenu.isRefresh == '0'}">二级菜单</a>
<a th:if="${not #lists.isEmpty(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span
class="fa arrow"></span></a>
<ul th:if="${not #lists.isEmpty(cmenu.children)}" class="nav nav-third-level">
<li th:each="emenu : ${cmenu.children}">
<a th:if="${#lists.isEmpty(emenu.children)}" th:class="${#strings.isEmpty(emenu.target)} ? |menuItem| : ${emenu.target}" th:text="${emenu.menuName}" th:href="@{${emenu.url}}" th:data-refresh="${emenu.isRefresh == '0'}">三级菜单</a>
<a th:if="${not #lists.isEmpty(emenu.children)}" href="#">[[${emenu.menuName}]]<span class="fa arrow"></span></a>
<a th:if="${#lists.isEmpty(emenu.children)}"
th:class="${#strings.isEmpty(emenu.target)} ? |menuItem| : ${emenu.target}"
th:text="${emenu.menuName}" th:href="@{${emenu.url}}"
th:data-refresh="${emenu.isRefresh == '0'}">三级菜单</a>
<a th:if="${not #lists.isEmpty(emenu.children)}" href="#">[[${emenu.menuName}]]<span
class="fa arrow"></span></a>
<ul th:if="${not #lists.isEmpty(emenu.children)}" class="nav nav-four-level">
<li th:each="fmenu : ${emenu.children}"><a th:if="${#lists.isEmpty(fmenu.children)}" th:class="${#strings.isEmpty(fmenu.target)} ? |menuItem| : ${fmenu.target}" th:text="${fmenu.menuName}" th:href="@{${fmenu.url}}" th:data-refresh="${fmenu.isRefresh == '0'}">四级菜单</a></li>
<li th:each="fmenu : ${emenu.children}"><a
th:if="${#lists.isEmpty(fmenu.children)}"
th:class="${#strings.isEmpty(fmenu.target)} ? |menuItem| : ${fmenu.target}"
th:text="${fmenu.menuName}" th:href="@{${fmenu.url}}"
th:data-refresh="${fmenu.isRefresh == '0'}">四级菜单</a></li>
</ul>
</li>
</ul>
@ -72,9 +91,10 @@
</ul>
</li>
<li th:if="${demoEnabled}">
<a href="#"><i class="fa fa-desktop"></i><span class="nav-label">实例演示</span><span class="fa arrow"></span></a>
<a href="#"><i class="fa fa-desktop"></i><span class="nav-label">实例演示</span><span
class="fa arrow"></span></a>
<ul class="nav nav-second-level collapse">
<li> <a>表单<span class="fa arrow"></span></a>
<li><a>表单<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="menuItem" th:href="@{/demo/form/button}">按钮</a></li>
<li><a class="menuItem" th:href="@{/demo/form/grid}">栅格</a></li>
@ -98,7 +118,7 @@
<li><a class="menuItem" th:href="@{/demo/form/localrefresh}">Ajax局部刷新</a></li>
</ul>
</li>
<li> <a>表格<span class="fa arrow"></span></a>
<li><a>表格<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="menuItem" th:href="@{/demo/table/search}">查询条件</a></li>
<li><a class="menuItem" th:href="@{/demo/table/footer}">数据汇总</a></li>
@ -127,20 +147,20 @@
<li><a class="menuItem" th:href="@{/demo/table/other}">表格其他操作</a></li>
</ul>
</li>
<li> <a>弹框<span class="fa arrow"></span></a>
<li><a>弹框<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="menuItem" th:href="@{/demo/modal/dialog}">模态窗口</a></li>
<li><a class="menuItem" th:href="@{/demo/modal/layer}">弹层组件</a></li>
<li><a class="menuItem" th:href="@{/demo/modal/table}">弹层表格</a></li>
</ul>
</li>
<li> <a>操作<span class="fa arrow"></span></a>
<li><a>操作<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="menuItem" th:href="@{/demo/operate/table}">表格</a></li>
<li><a class="menuItem" th:href="@{/demo/operate/other}">其他</a></li>
</ul>
</li>
<li> <a>报表<span class="fa arrow"></span></a>
<li><a>报表<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="menuItem" th:href="@{/demo/report/echarts}">百度ECharts</a></li>
<li><a class="menuItem" th:href="@{/demo/report/peity}">peity</a></li>
@ -148,7 +168,7 @@
<li><a class="menuItem" th:href="@{/demo/report/metrics}">图表组合</a></li>
</ul>
</li>
<li> <a>图标<span class="fa arrow"></span></a>
<li><a>图标<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="menuItem" th:href="@{/demo/icon/fontawesome}">Font Awesome</a></li>
<li><a class="menuItem" th:href="@{/demo/icon/glyphicons}">Glyphicons</a></li>
@ -188,12 +208,17 @@
</a>
</div>
<ul class="nav navbar-top-links navbar-right welcome-message">
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="开发文档" href="http://doc.ruoyi.vip/ruoyi" target="_blank"><i class="fa fa-question-circle"></i> 文档</a></li>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="锁定屏幕" href="#" id="lockScreen"><i class="fa fa-lock"></i> 锁屏</a></li>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="全屏显示" href="#" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏</a></li>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="开发文档"
href="http://doc.ruoyi.vip/ruoyi" target="_blank"><i class="fa fa-question-circle"></i>
文档</a></li>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="锁定屏幕" href="#"
id="lockScreen"><i class="fa fa-lock"></i> 锁屏</a></li>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="全屏显示" href="#"
id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏</a></li>
<li class="dropdown user-menu">
<a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
<img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}" th:onerror="this.src='img/profile.jpg'" class="user-image">
<img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}"
th:onerror="this.src='img/profile.jpg'" class="user-image">
<span class="hidden-xs">[[${#strings.defaultString(user.userName, '-')}]]</span>
</a>
<ul class="dropdown-menu">
@ -240,13 +265,14 @@
<a id="ax_close_max" class="ax_close_max" href="#" title="关闭全屏"> <i class="fa fa-times-circle-o"></i> </a>
<div class="row mainContent" id="content-main" th:style="${#bools.isFalse(ignoreFooter)} ? |height: calc(100% - 91px)|">
<div class="row mainContent" id="content-main"
th:style="${#bools.isFalse(ignoreFooter)} ? |height: calc(100% - 91px)|">
<iframe class="RuoYi_iframe" name="iframe0" width="100%" height="100%" th:data-id="@{/system/main}"
th:src="@{/system/main}" frameborder="0" seamless></iframe>
</div>
<div th:if="${ignoreFooter}" class="footer">
<div class="pull-right">© [[${copyrightYear}]] RuoYi Copyright </div>
<div class="pull-right">© [[${copyrightYear}]] RuoYi Copyright</div>
</div>
</div>
<!--右侧部分结束-->
@ -264,86 +290,91 @@
<script th:src="@{/ruoyi/index.js?v=20201208}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<script th:inline="javascript">
window.history.forward(1);
var ctx = [[@{/}]];
var lockscreen = [[${session.lockscreen}]];
if(lockscreen){window.top.location=ctx+"lockscreen";}
// 皮肤缓存
var skin = storage.get("skin");
// history表示去掉地址的#)否则地址以"#"形式展示
var mode = "history";
// 历史访问路径缓存
var historyPath = storage.get("historyPath");
// 是否页签与菜单联动
var isLinkage = true;
window.history.forward(1);
var ctx = [[@{/}]];
var lockscreen = [[${session.lockscreen}]];
if (lockscreen) {
window.top.location = ctx + "lockscreen";
}
// 皮肤缓存
var skin = storage.get("skin");
// history表示去掉地址的#)否则地址以"#"形式展示
var mode = "history";
// 历史访问路径缓存
var historyPath = storage.get("historyPath");
// 是否页签与菜单联动
var isLinkage = true;
// 本地主题优先,未设置取系统配置
if($.common.isNotEmpty(skin)){
// 本地主题优先,未设置取系统配置
if ($.common.isNotEmpty(skin)) {
$("body").addClass(skin.split('|')[0]);
$("body").addClass(skin.split('|')[1]);
} else {
}
else {
$("body").addClass([[${sideTheme}]]);
$("body").addClass([[${skinName}]]);
}
}
/* 用户管理-重置密码 */
function resetPwd() {
/* 用户管理-重置密码 */
function resetPwd() {
var url = ctx + 'system/user/profile/resetPwd';
$.modal.open("重置密码", url, '770', '380');
}
}
/* 切换主题 */
function switchSkin() {
/* 切换主题 */
function switchSkin() {
layer.open({
type : 2,
shadeClose : true,
title : "切换主题",
area : ["530px", "386px"],
content : [ctx + "system/switchSkin", 'no']
type: 2,
shadeClose: true,
title: "切换主题",
area: ["530px", "386px"],
content: [ctx + "system/switchSkin", 'no']
})
}
}
/* 切换菜单 */
function toggleMenu() {
$.modal.confirm("确认要切换成横向菜单吗?", function() {
$.get(ctx + 'system/menuStyle/topnav', function(result) {
/* 切换菜单 */
function toggleMenu() {
$.modal.confirm("确认要切换成横向菜单吗?", function () {
$.get(ctx + 'system/menuStyle/topnav', function (result) {
window.location.reload();
});
})
}
}
/** 刷新时访问路径页签 */
function applyPath(url) {
/** 刷新时访问路径页签 */
function applyPath(url) {
$('a[href$="' + decodeURI(url) + '"]').click();
if (!$('a[href$="' + url + '"]').hasClass("noactive")) {
$('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li").addClass("active").end().parents("ul").addClass("in");
}
}
}
$(function() {
if($.common.equals("history", mode) && window.performance.navigation.type == 1) {
$(function () {
if ($.common.equals("history", mode) && window.performance.navigation.type == 1) {
var url = storage.get('publicPath');
if ($.common.isNotEmpty(url)) {
applyPath(url);
}
} else {
}
else {
var hash = location.hash;
if ($.common.isNotEmpty(hash)) {
var url = hash.substring(1, hash.length);
applyPath(url);
} else {
if($.common.equals("history", mode)) {
}
else {
if ($.common.equals("history", mode)) {
storage.set('publicPath', "");
}
}
}
/* 初始密码提示 */
if([[${isDefaultModifyPwd}]]) {
if ([[${isDefaultModifyPwd}]]) {
layer.confirm("您的密码还是初始密码,请修改密码!", {
icon: 0,
title: "安全提示",
btn: ['确认' , '取消'],
btn: ['确认', '取消'],
offset: ['30%']
}, function (index) {
resetPwd();
@ -352,11 +383,11 @@ $(function() {
}
/* 过期密码提示 */
if([[${isPasswordExpired}]]) {
if ([[${isPasswordExpired}]]) {
layer.confirm("您的密码已过期,请尽快修改密码!", {
icon: 0,
title: "安全提示",
btn: ['确认' , '取消'],
btn: ['确认', '取消'],
offset: ['30%']
}, function (index) {
resetPwd();
@ -364,7 +395,7 @@ $(function() {
});
}
$("[data-toggle='tooltip']").tooltip();
});
});
</script>
</body>
</html>

View File

@ -3,12 +3,91 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--360浏览器优先以webkit内核解析-->
<!-- 360浏览器优先以webkit内核解析 -->
<title>锁定屏幕</title>
<link th:href="@{favicon.ico}" rel="shortcut icon"/>
<link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
<style>.lockscreen{background:#d2d6de;height:auto;}.lockscreen .lockscreen-name{text-align:center;font-weight:600;margin-top:50px;margin-bottom:30px;}.lockscreen-wrapper{max-width:400px;margin:10% auto;z-index:800;position:relative;}.lockscreen .lockscreen-name{text-align:center;font-weight:600;margin-top:50px;margin-bottom:30px;}.lockscreen-item{border-radius:4px;padding:0;background:#fff;position:relative;margin:10px auto 30px auto;width:290px}.lockscreen-image{border-radius:50%;position:absolute;left:-10px;top:-25px;background:#fff;padding:5px;z-index:10}.lockscreen-image>img{border-radius:50%;width:70px;height:70px}.lockscreen-credentials{margin-left:70px}.lockscreen-credentials .form-control{border:0}.lockscreen-credentials .btn{background-color:#fff;border:0;padding:0 10px}.lockscreen-footer{margin-top:150px}.lockscreen-time{width:100%;color:#fff;font-size:60px;display:inline-block;text-align:center;font-family:'Open Sans',sans-serif;font-weight:300;}</style>
<style>
.lockscreen {
background: #d2d6de;
height: auto;
}
.lockscreen .lockscreen-name {
text-align: center;
font-weight: 600;
margin-top: 50px;
margin-bottom: 30px;
}
.lockscreen-wrapper {
max-width: 400px;
margin: 10% auto;
z-index: 800;
position: relative;
}
.lockscreen .lockscreen-name {
text-align: center;
font-weight: 600;
margin-top: 50px;
margin-bottom: 30px;
}
.lockscreen-item {
border-radius: 4px;
padding: 0;
background: #fff;
position: relative;
margin: 10px auto 30px auto;
width: 290px
}
.lockscreen-image {
border-radius: 50%;
position: absolute;
left: -10px;
top: -25px;
background: #fff;
padding: 5px;
z-index: 10
}
.lockscreen-image > img {
border-radius: 50%;
width: 70px;
height: 70px
}
.lockscreen-credentials {
margin-left: 70px
}
.lockscreen-credentials .form-control {
border: 0
}
.lockscreen-credentials .btn {
background-color: #fff;
border: 0;
padding: 0 10px
}
.lockscreen-footer {
margin-top: 150px
}
.lockscreen-time {
width: 100%;
color: #fff;
font-size: 60px;
display: inline-block;
text-align: center;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
}
</style>
</head>
<body class="lockscreen">
<div class="lockscreen-wrapper">
@ -17,13 +96,15 @@
<div class="lockscreen-item">
<div class="lockscreen-image">
<img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}" th:onerror="this.src='img/profile.jpg'" class="img-circle" alt="User Image">
<img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}"
th:onerror="this.src='img/profile.jpg'" class="img-circle" alt="User Image">
</div>
<form class="lockscreen-credentials" method="post" action="#" onsubmit="return false;">
<div class="input-group">
<input type="password" name="password" autocomplete="off" class="form-control" placeholder="密码">
<div class="input-group-btn">
<button type="button" class="btn" onclick="unlock()"><i class="fa fa-arrow-right text-muted"></i></button>
<button type="button" class="btn" onclick="unlock()"><i class="fa fa-arrow-right text-muted"></i>
</button>
</div>
</div>
</form>
@ -42,15 +123,15 @@
</body>
<script th:inline="javascript">
var ctx = [[@{/}]];
Date.prototype.format = function(fmt) {
Date.prototype.format = function (fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) {
@ -65,16 +146,16 @@
return fmt;
}
$(function() {
$(function () {
$('.lockscreen-time').text((new Date()).format('hh:mm:ss'));
setInterval(function() {
setInterval(function () {
$('.lockscreen-time').text((new Date()).format('hh:mm:ss'));
}, 500);
init();
animate();
});
$(document).keydown(function(event) {
$(document).keydown(function (event) {
if (event.keyCode == 13) {
unlock();
}
@ -93,14 +174,15 @@
url: ctx + "unlockscreen",
type: "post",
dataType: "json",
data: { password: password },
beforeSend: function() {
data: {password: password},
beforeSend: function () {
index = layer.load(2, {shade: false});
},
success: function(result) {
success: function (result) {
if (result.code == web_status.SUCCESS) {
location.href = ctx + 'index';
} else {
}
else {
$.modal.msg(result.msg);
$("input[name='password']").val("");
}
@ -108,28 +190,29 @@
}
};
$.ajax(config);
};
}
var container;
var camera, scene, projector, renderer;
var PI2 = Math.PI * 2;
var programFill = function(context) {
var programFill = function (context) {
context.beginPath();
context.arc(0, 0, 1, 0, PI2, true);
context.closePath();
context.fill();
};
var programStroke = function(context) {
var programStroke = function (context) {
context.lineWidth = 0.05;
context.beginPath();
context.arc(0, 0, 1, 0, PI2, true);
context.closePath();
context.stroke();
};
}
var mouse = {x: 0, y: 0}, INTERSECTED;
var mouse = { x: 0, y: 0 }, INTERSECTED;
function init() {
container = document.createElement('div');
container.id = 'bgc';
@ -143,7 +226,10 @@
scene = new THREE.Scene();
for (var i = 0; i < 100; i++) {
var particle = new THREE.Particle(new THREE.ParticleCanvasMaterial({ color: Math.random() * 0x808080 + 0x808080, program: programStroke }));
var particle = new THREE.Particle(new THREE.ParticleCanvasMaterial({
color: Math.random() * 0x808080 + 0x808080,
program: programStroke
}));
particle.position.x = Math.random() * 800 - 400;
particle.position.y = Math.random() * 800 - 400;
particle.position.z = Math.random() * 800 - 400;
@ -156,24 +242,24 @@
container.appendChild(renderer.domElement);
document.addEventListener('mousemove', onDocumentMouseMove, false);
window.addEventListener('resize', onWindowResize, false);
};
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight - 10);
};
}
function onDocumentMouseMove(event) {
event.preventDefault();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
};
}
function animate() {
requestAnimationFrame(animate);
render();
};
}
var radius = 600;
var theta = 0;
@ -198,7 +284,8 @@
INTERSECTED = intersects[0].object;
INTERSECTED.material.program = programFill;
}
} else {
}
else {
if (INTERSECTED) INTERSECTED.material.program = programStroke;
INTERSECTED = null;
}

View File

@ -15,13 +15,20 @@
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/>
<style type="text/css">label.error { position:inherit; }</style>
<style type="text/css">
label.error {
position: inherit;
}
</style>
<script>
if(window.top!==window.self){alert('未登录或登录超时。请重新登录');window.top.location=window.location};
if (window.top !== window.self) {
alert('未登录或登录超时。请重新登录');
window.top.location = window.location
}
</script>
</head>
<body class="signin">
<div class="signinpanel">
<div class="signinpanel">
<div class="row">
<div class="col-sm-7">
<div class="signin-info">
@ -44,11 +51,15 @@
<form id="signupForm" autocomplete="off">
<h4 class="no-margins">登录:</h4>
<p class="m-t-md">你若不离不弃,我必生死相依</p>
<input type="text" name="username" class="form-control uname" placeholder="用户名" value="admin" />
<input type="password" name="password" class="form-control pword" placeholder="密码" value="admin123" />
<input type="text" name="username" class="form-control uname" placeholder="用户名" value="admin"/>
<input type="password" name="password" class="form-control pword" placeholder="密码" value="admin123"/>
<div class="row m-t" th:if="${captchaEnabled==true}">
<div class="col-xs-6">
<input type="text" name="validateCode" class="form-control code" placeholder="验证码" maxlength="5" />
<input type="text"
name="validateCode"
class="form-control code"
placeholder="验证码"
maxlength="5"/>
</div>
<div class="col-xs-6">
<a href="javascript:void(0);" title="点击更换验证码">
@ -68,14 +79,16 @@
Copyright © 2018-2021 ruoyi.vip All Rights Reserved. <br>
</div>
</div>
</div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]]; var captchaType = [[${captchaType}]]; </script>
<!-- 全局js -->
<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<script src="../static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<!-- 验证插件 -->
<script src="../static/ajax/libs/validate/jquery.validate.min.js" th:src="@{/ajax/libs/validate/jquery.validate.min.js}"></script>
<script src="../static/ajax/libs/validate/messages_zh.min.js" th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script>
<script src="../static/ajax/libs/validate/jquery.validate.min.js"
th:src="@{/ajax/libs/validate/jquery.validate.min.js}"></script>
<script src="../static/ajax/libs/validate/messages_zh.min.js"
th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script>
<script src="../static/ajax/libs/layer/layer.min.js" th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script src="../static/ajax/libs/blockUI/jquery.blockUI.js" th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script src="../static/ruoyi/js/ry-ui.js" th:src="@{/ruoyi/js/ry-ui.js?v=4.6.0}"></script>

View File

@ -12,15 +12,26 @@
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{/css/style.css}" rel="stylesheet"/>
<style type="text/css">
.list-unstyled{margin:10px;}
.full-opacity-hover{opacity:1;filter:alpha(opacity=1);border:1px solid #fff}
.full-opacity-hover:hover{border:1px solid #f00;}
.list-unstyled {
margin: 10px;
}
.full-opacity-hover {
opacity: 1;
filter: alpha(opacity=1);
border: 1px solid #fff
}
.full-opacity-hover:hover {
border: 1px solid #f00;
}
</style>
</head>
<body class="gray-bg">
<ul class="list-unstyled clearfix">
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-blue|theme-dark" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-blue|theme-dark"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #367fa9"></span>
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span>
<span style="width: 20%; float: left; height: 30px; background: #2f4050"></span>
@ -30,7 +41,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-green|theme-dark" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-green|theme-dark"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #008d4c"></span>
<span style="width: 80%; float: left; height: 13px; background: #00a65a"></span>
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
@ -40,7 +52,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-purple|theme-dark" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-purple|theme-dark"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #555299"></span>
<span style="width: 80%; float: left; height: 13px; background: #605ca8"></span>
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
@ -50,7 +63,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-red|theme-dark" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-red|theme-dark"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #dd4b39"></span>
<span style="width: 80%; float: left; height: 13px; background: #d73925"></span>
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
@ -60,7 +74,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-yellow|theme-dark" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-yellow|theme-dark"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #f39c12"></span>
<span style="width: 80%; float: left; height: 13px; background: #e08e0b"></span>
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
@ -70,7 +85,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-blue|theme-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-blue|theme-light"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #367fa9"></span>
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
@ -80,7 +96,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-green|theme-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-green|theme-light"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #008d4c"></span>
<span style="width: 80%; float: left; height: 13px; background: #00a65a"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
@ -90,7 +107,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-purple|theme-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-purple|theme-light"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #555299"></span>
<span style="width: 80%; float: left; height: 13px; background: #605ca8"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
@ -100,7 +118,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-red|theme-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-red|theme-light"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #dd4b39"></span>
<span style="width: 80%; float: left; height: 13px; background: #d73925"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
@ -110,7 +129,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-yellow|theme-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-yellow|theme-light"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #f39c12"></span>
<span style="width: 80%; float: left; height: 13px; background: #e08e0b"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
@ -120,7 +140,8 @@
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-blue|theme-blue" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-blue|theme-blue"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #367fa9"></span>
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span>
<span style="width: 20%; float: left; height: 30px; background: rgba(15,41,80,1)"></span>
@ -129,7 +150,8 @@
<p class="text-center">蓝浅(新)</p>
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-green|theme-blue" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<a href="javascript:" data-skin="skin-green|theme-blue"
style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 20%; float: left; height: 13px; background: #008d4c"></span>
<span style="width: 80%; float: left; height: 13px; background: #00a65a"></span>
<span style="width: 20%; float: left; height: 30px; background: rgba(15,41,80,1)"></span>
@ -142,24 +164,24 @@
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/ruoyi/js/common.js?v=4.6.0}"></script>
<script type="text/javascript">
//皮肤样式列表
var skins = ["skin-blue", "skin-green", "skin-purple", "skin-red", "skin-yellow"];
// 皮肤样式列表
var skins = ["skin-blue", "skin-green", "skin-purple", "skin-red", "skin-yellow"];
// 主题样式列表
var themes = ["theme-dark", "theme-light", "theme-blue"];
// 主题样式列表
var themes = ["theme-dark", "theme-light", "theme-blue"];
$("[data-skin]").on('click',
function(e) {
$("[data-skin]").on('click',
function (e) {
var skin = $(this).data('skin');
$.each(skins, function(i) {
$.each(skins, function (i) {
parent.$("body").removeClass(skins[i]);
});
$.each(themes, function(i) {
$.each(themes, function (i) {
parent.$("body").removeClass(themes[i]);
});
parent.$("body").addClass(skin.split('|')[0]);
parent.$("body").addClass(skin.split('|')[1]);
storage.set('skin', skin);
});
});
</script>
</html>

View File

@ -10,107 +10,104 @@ import org.springframework.stereotype.Component;
*/
@Component
@ConfigurationProperties(prefix = "ruoyi")
public class RuoYiConfig
{
/** 项目名称 */
public class RuoYiConfig {
/**
* 项目名称
*/
private static String name;
/** 版本 */
/**
* 版本
*/
private static String version;
/** 版权年份 */
/**
* 版权年份
*/
private static String copyrightYear;
/** 实例演示开关 */
/**
* 实例演示开关
*/
private static boolean demoEnabled;
/** 上传路径 */
/**
* 上传路径
*/
private static String profile;
/** 获取地址开关 */
/**
* 获取地址开关
*/
private static boolean addressEnabled;
public static String getName()
{
public static String getName() {
return name;
}
public void setName(String name)
{
public void setName(String name) {
RuoYiConfig.name = name;
}
public static String getVersion()
{
public static String getVersion() {
return version;
}
public void setVersion(String version)
{
public void setVersion(String version) {
RuoYiConfig.version = version;
}
public static String getCopyrightYear()
{
public static String getCopyrightYear() {
return copyrightYear;
}
public void setCopyrightYear(String copyrightYear)
{
public void setCopyrightYear(String copyrightYear) {
RuoYiConfig.copyrightYear = copyrightYear;
}
public static boolean isDemoEnabled()
{
public static boolean isDemoEnabled() {
return demoEnabled;
}
public void setDemoEnabled(boolean demoEnabled)
{
public void setDemoEnabled(boolean demoEnabled) {
RuoYiConfig.demoEnabled = demoEnabled;
}
public static String getProfile()
{
public static String getProfile() {
return profile;
}
public void setProfile(String profile)
{
public void setProfile(String profile) {
RuoYiConfig.profile = profile;
}
public static boolean isAddressEnabled()
{
public static boolean isAddressEnabled() {
return addressEnabled;
}
public void setAddressEnabled(boolean addressEnabled)
{
public void setAddressEnabled(boolean addressEnabled) {
RuoYiConfig.addressEnabled = addressEnabled;
}
/**
* 获取头像上传路径
*/
public static String getAvatarPath()
{
public static String getAvatarPath() {
return getProfile() + "/avatar";
}
/**
* 获取下载路径
*/
public static String getDownloadPath()
{
public static String getDownloadPath() {
return getProfile() + "/download/";
}
/**
* 获取上传路径
*/
public static String getUploadPath()
{
public static String getUploadPath() {
return getProfile() + "/upload";
}
}

View File

@ -5,8 +5,8 @@ package com.ruoyi.common.constant;
*
* @author ruoyi
*/
public class ShiroConstants
{
public class ShiroConstants {
/**
* 当前登录的用户
*/

View File

@ -1,15 +1,5 @@
package com.ruoyi.common.core.controller;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
@ -21,28 +11,36 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
/**
* web层通用数据处理
*
* @author ruoyi
*/
public class BaseController
{
public class BaseController {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 将前台传递过来的日期格式的字符串自动转化为Date类型
*/
@InitBinder
public void initBinder(WebDataBinder binder)
{
public void initBinder(WebDataBinder binder) {
// Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
{
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text)
{
public void setAsText(String text) {
setValue(DateUtils.parseDate(text));
}
});
@ -51,13 +49,11 @@ public class BaseController
/**
* 设置请求分页数据
*/
protected void startPage()
{
protected void startPage() {
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
{
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.startPage(pageNum, pageSize, orderBy);
}
@ -66,11 +62,9 @@ public class BaseController
/**
* 设置请求排序数据
*/
protected void startOrderBy()
{
protected void startOrderBy() {
PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
{
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.orderBy(orderBy);
}
@ -79,33 +73,29 @@ public class BaseController
/**
* 获取request
*/
public HttpServletRequest getRequest()
{
public HttpServletRequest getRequest() {
return ServletUtils.getRequest();
}
/**
* 获取response
*/
public HttpServletResponse getResponse()
{
public HttpServletResponse getResponse() {
return ServletUtils.getResponse();
}
/**
* 获取session
*/
public HttpSession getSession()
{
public HttpSession getSession() {
return getRequest().getSession();
}
/**
* 响应请求分页数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(List<?> list)
{
@SuppressWarnings({"rawtypes", "unchecked"})
protected TableDataInfo getDataTable(List<?> list) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(0);
rspData.setRows(list);
@ -119,8 +109,7 @@ public class BaseController
* @param rows 影响行数
* @return 操作结果
*/
protected AjaxResult toAjax(int rows)
{
protected AjaxResult toAjax(int rows) {
return rows > 0 ? success() : error();
}
@ -130,56 +119,49 @@ public class BaseController
* @param result 结果
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result)
{
protected AjaxResult toAjax(boolean result) {
return result ? success() : error();
}
/**
* 返回成功
*/
public AjaxResult success()
{
public AjaxResult success() {
return AjaxResult.success();
}
/**
* 返回失败消息
*/
public AjaxResult error()
{
public AjaxResult error() {
return AjaxResult.error();
}
/**
* 返回成功消息
*/
public AjaxResult success(String message)
{
public AjaxResult success(String message) {
return AjaxResult.success(message);
}
/**
* 返回失败消息
*/
public AjaxResult error(String message)
{
public AjaxResult error(String message) {
return AjaxResult.error(message);
}
/**
* 返回错误码消息
*/
public AjaxResult error(Type type, String message)
{
public AjaxResult error(Type type, String message) {
return new AjaxResult(type, message);
}
/**
* 页面跳转
*/
public String redirect(String url)
{
public String redirect(String url) {
return StringUtils.format("redirect:{}", url);
}
}

View File

@ -1,46 +1,56 @@
package com.ruoyi.common.core.domain;
import java.util.HashMap;
import com.ruoyi.common.utils.StringUtils;
import java.util.HashMap;
/**
* 操作消息提醒
*
* @author ruoyi
*/
public class AjaxResult extends HashMap<String, Object>
{
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/** 状态码 */
/**
* 状态码
*/
public static final String CODE_TAG = "code";
/** 返回内容 */
/**
* 返回内容
*/
public static final String MSG_TAG = "msg";
/** 数据对象 */
/**
* 数据对象
*/
public static final String DATA_TAG = "data";
/**
* 状态类型
*/
public enum Type
{
/** 成功 */
public enum Type {
/**
* 成功
*/
SUCCESS(0),
/** 警告 */
/**
* 警告
*/
WARN(301),
/** 错误 */
/**
* 错误
*/
ERROR(500);
private final int value;
Type(int value)
{
Type(int value) {
this.value = value;
}
public int value()
{
public int value() {
return this.value;
}
}
@ -48,8 +58,7 @@ public class AjaxResult extends HashMap<String, Object>
/**
* 初始化一个新创建的 AjaxResult 对象使其表示一个空消息
*/
public AjaxResult()
{
public AjaxResult() {
}
/**
@ -58,8 +67,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param type 状态类型
* @param msg 返回内容
*/
public AjaxResult(Type type, String msg)
{
public AjaxResult(Type type, String msg) {
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
}
@ -71,12 +79,10 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @param data 数据对象
*/
public AjaxResult(Type type, String msg, Object data)
{
public AjaxResult(Type type, String msg, Object data) {
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
if (StringUtils.isNotNull(data))
{
if (StringUtils.isNotNull(data)) {
super.put(DATA_TAG, data);
}
}
@ -89,8 +95,7 @@ public class AjaxResult extends HashMap<String, Object>
* @return 数据对象
*/
@Override
public AjaxResult put(String key, Object value)
{
public AjaxResult put(String key, Object value) {
super.put(key, value);
return this;
}
@ -100,8 +105,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @return 成功消息
*/
public static AjaxResult success()
{
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
@ -110,8 +114,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @return 成功消息
*/
public static AjaxResult success(Object data)
{
public static AjaxResult success(Object data) {
return AjaxResult.success("操作成功", data);
}
@ -121,8 +124,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @return 成功消息
*/
public static AjaxResult success(String msg)
{
public static AjaxResult success(String msg) {
return AjaxResult.success(msg, null);
}
@ -133,8 +135,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param data 数据对象
* @return 成功消息
*/
public static AjaxResult success(String msg, Object data)
{
public static AjaxResult success(String msg, Object data) {
return new AjaxResult(Type.SUCCESS, msg, data);
}
@ -144,8 +145,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult warn(String msg)
{
public static AjaxResult warn(String msg) {
return AjaxResult.warn(msg, null);
}
@ -156,8 +156,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult warn(String msg, Object data)
{
public static AjaxResult warn(String msg, Object data) {
return new AjaxResult(Type.WARN, msg, data);
}
@ -166,8 +165,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @return
*/
public static AjaxResult error()
{
public static AjaxResult error() {
return AjaxResult.error("操作失败");
}
@ -177,8 +175,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(String msg)
{
public static AjaxResult error(String msg) {
return AjaxResult.error(msg, null);
}
@ -189,8 +186,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult error(String msg, Object data)
{
public static AjaxResult error(String msg, Object data) {
return new AjaxResult(Type.ERROR, msg, data);
}
}

View File

@ -1,20 +1,21 @@
package com.ruoyi.common.core.text;
import com.ruoyi.common.utils.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.text.NumberFormat;
import java.util.Set;
import com.ruoyi.common.utils.StringUtils;
/**
* 类型转换器
*
* @author ruoyi
*/
public class Convert
{
public class Convert {
/**
* 转换为字符串<br>
* 如果给定的值为null或者转换失败返回默认值<br>
@ -24,14 +25,11 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static String toStr(Object value, String defaultValue)
{
if (null == value)
{
public static String toStr(Object value, String defaultValue) {
if (null == value) {
return defaultValue;
}
if (value instanceof String)
{
if (value instanceof String) {
return (String) value;
}
return value.toString();
@ -45,8 +43,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static String toStr(Object value)
{
public static String toStr(Object value) {
return toStr(value, null);
}
@ -59,14 +56,11 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Character toChar(Object value, Character defaultValue)
{
if (null == value)
{
public static Character toChar(Object value, Character defaultValue) {
if (null == value) {
return defaultValue;
}
if (value instanceof Character)
{
if (value instanceof Character) {
return (Character) value;
}
@ -82,8 +76,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Character toChar(Object value)
{
public static Character toChar(Object value) {
return toChar(value, null);
}
@ -96,31 +89,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Byte toByte(Object value, Byte defaultValue)
{
if (value == null)
{
public static Byte toByte(Object value, Byte defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Byte)
{
if (value instanceof Byte) {
return (Byte) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).byteValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Byte.parseByte(valueStr);
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -133,8 +119,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Byte toByte(Object value)
{
public static Byte toByte(Object value) {
return toByte(value, null);
}
@ -147,31 +132,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Short toShort(Object value, Short defaultValue)
{
if (value == null)
{
public static Short toShort(Object value, Short defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Short)
{
if (value instanceof Short) {
return (Short) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).shortValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Short.parseShort(valueStr.trim());
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -184,8 +162,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Short toShort(Object value)
{
public static Short toShort(Object value) {
return toShort(value, null);
}
@ -198,27 +175,21 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Number toNumber(Object value, Number defaultValue)
{
if (value == null)
{
public static Number toNumber(Object value, Number defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return (Number) value;
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return NumberFormat.getInstance().parse(valueStr);
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -231,8 +202,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Number toNumber(Object value)
{
public static Number toNumber(Object value) {
return toNumber(value, null);
}
@ -245,31 +215,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Integer toInt(Object value, Integer defaultValue)
{
if (value == null)
{
public static Integer toInt(Object value, Integer defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Integer)
{
if (value instanceof Integer) {
return (Integer) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).intValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Integer.parseInt(valueStr.trim());
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -282,8 +245,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Integer toInt(Object value)
{
public static Integer toInt(Object value) {
return toInt(value, null);
}
@ -293,8 +255,7 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static Integer[] toIntArray(String str)
{
public static Integer[] toIntArray(String str) {
return toIntArray(",", str);
}
@ -304,8 +265,7 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static Long[] toLongArray(String str)
{
public static Long[] toLongArray(String str) {
return toLongArray(",", str);
}
@ -316,16 +276,13 @@ public class Convert
* @param split 被转换的值
* @return 结果
*/
public static Integer[] toIntArray(String split, String str)
{
if (StringUtils.isEmpty(str))
{
return new Integer[] {};
public static Integer[] toIntArray(String split, String str) {
if (StringUtils.isEmpty(str)) {
return new Integer[]{};
}
String[] arr = str.split(split);
final Integer[] ints = new Integer[arr.length];
for (int i = 0; i < arr.length; i++)
{
for (int i = 0; i < arr.length; i++) {
final Integer v = toInt(arr[i], 0);
ints[i] = v;
}
@ -339,16 +296,13 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static Long[] toLongArray(String split, String str)
{
if (StringUtils.isEmpty(str))
{
return new Long[] {};
public static Long[] toLongArray(String split, String str) {
if (StringUtils.isEmpty(str)) {
return new Long[]{};
}
String[] arr = str.split(split);
final Long[] longs = new Long[arr.length];
for (int i = 0; i < arr.length; i++)
{
for (int i = 0; i < arr.length; i++) {
final Long v = toLong(arr[i], null);
longs[i] = v;
}
@ -361,8 +315,7 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static String[] toStrArray(String str)
{
public static String[] toStrArray(String str) {
return toStrArray(",", str);
}
@ -373,8 +326,7 @@ public class Convert
* @param split 被转换的值
* @return 结果
*/
public static String[] toStrArray(String split, String str)
{
public static String[] toStrArray(String split, String str) {
return str.split(split);
}
@ -387,32 +339,25 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Long toLong(Object value, Long defaultValue)
{
if (value == null)
{
public static Long toLong(Object value, Long defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Long)
{
if (value instanceof Long) {
return (Long) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).longValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
// 支持科学计数法
return new BigDecimal(valueStr.trim()).longValue();
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -425,8 +370,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Long toLong(Object value)
{
public static Long toLong(Object value) {
return toLong(value, null);
}
@ -439,32 +383,25 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Double toDouble(Object value, Double defaultValue)
{
if (value == null)
{
public static Double toDouble(Object value, Double defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Double)
{
if (value instanceof Double) {
return (Double) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).doubleValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
// 支持科学计数法
return new BigDecimal(valueStr.trim()).doubleValue();
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -477,8 +414,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Double toDouble(Object value)
{
public static Double toDouble(Object value) {
return toDouble(value, null);
}
@ -491,31 +427,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Float toFloat(Object value, Float defaultValue)
{
if (value == null)
{
public static Float toFloat(Object value, Float defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Float)
{
if (value instanceof Float) {
return (Float) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).floatValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Float.parseFloat(valueStr.trim());
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -528,8 +457,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Float toFloat(Object value)
{
public static Float toFloat(Object value) {
return toFloat(value, null);
}
@ -542,24 +470,19 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Boolean toBool(Object value, Boolean defaultValue)
{
if (value == null)
{
public static Boolean toBool(Object value, Boolean defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Boolean)
{
if (value instanceof Boolean) {
return (Boolean) value;
}
String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
valueStr = valueStr.trim().toLowerCase();
switch (valueStr)
{
switch (valueStr) {
case "true":
return true;
case "false":
@ -587,8 +510,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Boolean toBool(Object value)
{
public static Boolean toBool(Object value) {
return toBool(value, null);
}
@ -601,29 +523,23 @@ public class Convert
* @param defaultValue 默认值
* @return Enum
*/
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue)
{
if (value == null)
{
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
if (value == null) {
return defaultValue;
}
if (clazz.isAssignableFrom(value.getClass()))
{
if (clazz.isAssignableFrom(value.getClass())) {
@SuppressWarnings("unchecked")
E myE = (E) value;
return myE;
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Enum.valueOf(clazz, valueStr);
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -636,8 +552,7 @@ public class Convert
* @param value
* @return Enum
*/
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value)
{
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
return toEnum(clazz, value, null);
}
@ -650,31 +565,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static BigInteger toBigInteger(Object value, BigInteger defaultValue)
{
if (value == null)
{
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof BigInteger)
{
if (value instanceof BigInteger) {
return (BigInteger) value;
}
if (value instanceof Long)
{
if (value instanceof Long) {
return BigInteger.valueOf((Long) value);
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return new BigInteger(valueStr);
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -687,8 +595,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static BigInteger toBigInteger(Object value)
{
public static BigInteger toBigInteger(Object value) {
return toBigInteger(value, null);
}
@ -701,39 +608,30 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
{
if (value == null)
{
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof BigDecimal)
{
if (value instanceof BigDecimal) {
return (BigDecimal) value;
}
if (value instanceof Long)
{
if (value instanceof Long) {
return new BigDecimal((Long) value);
}
if (value instanceof Double)
{
if (value instanceof Double) {
return new BigDecimal((Double) value);
}
if (value instanceof Integer)
{
if (value instanceof Integer) {
return new BigDecimal((Integer) value);
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return new BigDecimal(valueStr);
}
catch (Exception e)
{
catch (Exception e) {
return defaultValue;
}
}
@ -746,8 +644,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static BigDecimal toBigDecimal(Object value)
{
public static BigDecimal toBigDecimal(Object value) {
return toBigDecimal(value, null);
}
@ -758,8 +655,7 @@ public class Convert
* @param obj 对象
* @return 字符串
*/
public static String utf8Str(Object obj)
{
public static String utf8Str(Object obj) {
return str(obj, CharsetKit.CHARSET_UTF_8);
}
@ -771,8 +667,7 @@ public class Convert
* @param charsetName 字符集
* @return 字符串
*/
public static String str(Object obj, String charsetName)
{
public static String str(Object obj, String charsetName) {
return str(obj, Charset.forName(charsetName));
}
@ -784,23 +679,18 @@ public class Convert
* @param charset 字符集
* @return 字符串
*/
public static String str(Object obj, Charset charset)
{
if (null == obj)
{
public static String str(Object obj, Charset charset) {
if (null == obj) {
return null;
}
if (obj instanceof String)
{
if (obj instanceof String) {
return (String) obj;
}
else if (obj instanceof byte[] || obj instanceof Byte[])
{
else if (obj instanceof byte[] || obj instanceof Byte[]) {
return str((Byte[]) obj, charset);
}
else if (obj instanceof ByteBuffer)
{
else if (obj instanceof ByteBuffer) {
return str((ByteBuffer) obj, charset);
}
return obj.toString();
@ -813,8 +703,7 @@ public class Convert
* @param charset 字符集
* @return 字符串
*/
public static String str(byte[] bytes, String charset)
{
public static String str(byte[] bytes, String charset) {
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
}
@ -825,15 +714,12 @@ public class Convert
* @param charset 字符集如果此字段为空则解码的结果取决于平台
* @return 解码后的字符串
*/
public static String str(byte[] data, Charset charset)
{
if (data == null)
{
public static String str(byte[] data, Charset charset) {
if (data == null) {
return null;
}
if (null == charset)
{
if (null == charset) {
return new String(data);
}
return new String(data, charset);
@ -846,10 +732,8 @@ public class Convert
* @param charset 字符集如果为空使用当前系统字符集
* @return 字符串
*/
public static String str(ByteBuffer data, String charset)
{
if (data == null)
{
public static String str(ByteBuffer data, String charset) {
if (data == null) {
return null;
}
@ -863,24 +747,22 @@ public class Convert
* @param charset 字符集如果为空使用当前系统字符集
* @return 字符串
*/
public static String str(ByteBuffer data, Charset charset)
{
if (null == charset)
{
public static String str(ByteBuffer data, Charset charset) {
if (null == charset) {
charset = Charset.defaultCharset();
}
return charset.decode(data).toString();
}
// ----------------------------------------------------------------------- 全角半角转换
/**
* 半角转全角
*
* @param input String.
* @return 全角字符串.
*/
public static String toSBC(String input)
{
public static String toSBC(String input) {
return toSBC(input, null);
}
@ -891,23 +773,18 @@ public class Convert
* @param notConvertSet 不替换的字符集合
* @return 全角字符串.
*/
public static String toSBC(String input, Set<Character> notConvertSet)
{
public static String toSBC(String input, Set<Character> notConvertSet) {
char c[] = input.toCharArray();
for (int i = 0; i < c.length; i++)
{
if (null != notConvertSet && notConvertSet.contains(c[i]))
{
for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) {
// 跳过不替换的字符
continue;
}
if (c[i] == ' ')
{
if (c[i] == ' ') {
c[i] = '\u3000';
}
else if (c[i] < '\177')
{
else if (c[i] < '\177') {
c[i] = (char) (c[i] + 65248);
}
@ -921,8 +798,7 @@ public class Convert
* @param input String.
* @return 半角字符串
*/
public static String toDBC(String input)
{
public static String toDBC(String input) {
return toDBC(input, null);
}
@ -933,23 +809,18 @@ public class Convert
* @param notConvertSet 不替换的字符集合
* @return 替换后的字符
*/
public static String toDBC(String text, Set<Character> notConvertSet)
{
public static String toDBC(String text, Set<Character> notConvertSet) {
char c[] = text.toCharArray();
for (int i = 0; i < c.length; i++)
{
if (null != notConvertSet && notConvertSet.contains(c[i]))
{
for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) {
// 跳过不替换的字符
continue;
}
if (c[i] == '\u3000')
{
if (c[i] == '\u3000') {
c[i] = ' ';
}
else if (c[i] > '\uFF00' && c[i] < '\uFF5F')
{
else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
c[i] = (char) (c[i] - 65248);
}
}
@ -964,31 +835,26 @@ public class Convert
* @param n 数字
* @return 中文大写数字
*/
public static String digitUppercase(double n)
{
String[] fraction = { "", "" };
String[] digit = { "", "", "", "", "", "", "", "", "", "" };
String[][] unit = { { "", "", "亿" }, { "", "", "", "" } };
public static String digitUppercase(double n) {
String[] fraction = {"", ""};
String[] digit = {"", "", "", "", "", "", "", "", "", ""};
String[][] unit = {{"", "", "亿"}, {"", "", "", ""}};
String head = n < 0 ? "" : "";
n = Math.abs(n);
String s = "";
for (int i = 0; i < fraction.length; i++)
{
for (int i = 0; i < fraction.length; i++) {
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
}
if (s.length() < 1)
{
if (s.length() < 1) {
s = "";
}
int integerPart = (int) Math.floor(n);
for (int i = 0; i < unit[0].length && integerPart > 0; i++)
{
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
String p = "";
for (int j = 0; j < unit[1].length && n > 0; j++)
{
for (int j = 0; j < unit[1].length && n > 0; j++) {
p = digit[integerPart % 10] + unit[1][j] + p;
integerPart = integerPart / 10;
}

View File

@ -1,84 +1,77 @@
package com.ruoyi.common.utils;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.ruoyi.common.core.text.Convert;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.ruoyi.common.core.text.Convert;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* 客户端工具类
*
* @author ruoyi
*/
public class ServletUtils
{
public class ServletUtils {
/**
* 定义移动端请求的所有可能类型
*/
private final static String[] agent = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
private final static String[] agent = {"Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser"};
/**
* 获取String参数
*/
public static String getParameter(String name)
{
public static String getParameter(String name) {
return getRequest().getParameter(name);
}
/**
* 获取String参数
*/
public static String getParameter(String name, String defaultValue)
{
public static String getParameter(String name, String defaultValue) {
return Convert.toStr(getRequest().getParameter(name), defaultValue);
}
/**
* 获取Integer参数
*/
public static Integer getParameterToInt(String name)
{
public static Integer getParameterToInt(String name) {
return Convert.toInt(getRequest().getParameter(name));
}
/**
* 获取Integer参数
*/
public static Integer getParameterToInt(String name, Integer defaultValue)
{
public static Integer getParameterToInt(String name, Integer defaultValue) {
return Convert.toInt(getRequest().getParameter(name), defaultValue);
}
/**
* 获取request
*/
public static HttpServletRequest getRequest()
{
public static HttpServletRequest getRequest() {
return getRequestAttributes().getRequest();
}
/**
* 获取response
*/
public static HttpServletResponse getResponse()
{
public static HttpServletResponse getResponse() {
return getRequestAttributes().getResponse();
}
/**
* 获取session
*/
public static HttpSession getSession()
{
public static HttpSession getSession() {
return getRequest().getSession();
}
public static ServletRequestAttributes getRequestAttributes()
{
public static ServletRequestAttributes getRequestAttributes() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes;
}
@ -90,16 +83,13 @@ public class ServletUtils
* @param string 待渲染的字符串
* @return null
*/
public static String renderString(HttpServletResponse response, String string)
{
try
{
public static String renderString(HttpServletResponse response, String string) {
try {
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().print(string);
}
catch (IOException e)
{
catch (IOException e) {
e.printStackTrace();
}
return null;
@ -110,29 +100,24 @@ public class ServletUtils
*
* @param request
*/
public static boolean isAjaxRequest(HttpServletRequest request)
{
public static boolean isAjaxRequest(HttpServletRequest request) {
String accept = request.getHeader("accept");
if (accept != null && accept.indexOf("application/json") != -1)
{
if (accept != null && accept.indexOf("application/json") != -1) {
return true;
}
String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
{
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
return true;
}
String uri = request.getRequestURI();
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml"))
{
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) {
return true;
}
String ajax = request.getParameter("__ajax");
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
{
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) {
return true;
}
return false;
@ -141,18 +126,13 @@ public class ServletUtils
/**
* 判断User-Agent 是不是来自于手机
*/
public static boolean checkAgentIsMobile(String ua)
{
public static boolean checkAgentIsMobile(String ua) {
boolean flag = false;
if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;")))
{
if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;"))) {
// 排除 苹果桌面系统
if (!ua.contains("Windows NT") && !ua.contains("Macintosh"))
{
for (String item : agent)
{
if (ua.contains(item))
{
if (!ua.contains("Windows NT") && !ua.contains("Macintosh")) {
for (String item : agent) {
if (ua.contains(item)) {
flag = true;
break;
}

View File

@ -1,50 +1,44 @@
package com.ruoyi.common.utils;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.bean.BeanUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.bean.BeanUtils;
import org.apache.shiro.subject.Subject;
/**
* shiro 工具类
*
* @author ruoyi
*/
public class ShiroUtils
{
public static Subject getSubject()
{
public class ShiroUtils {
public static Subject getSubject() {
return SecurityUtils.getSubject();
}
public static Session getSession()
{
public static Session getSession() {
return SecurityUtils.getSubject().getSession();
}
public static void logout()
{
public static void logout() {
getSubject().logout();
}
public static SysUser getSysUser()
{
public static SysUser getSysUser() {
SysUser user = null;
Object obj = getSubject().getPrincipal();
if (StringUtils.isNotNull(obj))
{
if (StringUtils.isNotNull(obj)) {
user = new SysUser();
BeanUtils.copyBeanProp(user, obj);
}
return user;
}
public static void setSysUser(SysUser user)
{
public static void setSysUser(SysUser user) {
Subject subject = getSubject();
PrincipalCollection principalCollection = subject.getPrincipals();
String realmName = principalCollection.getRealmNames().iterator().next();
@ -53,31 +47,26 @@ public class ShiroUtils
subject.runAs(newPrincipalCollection);
}
public static Long getUserId()
{
public static Long getUserId() {
return getSysUser().getUserId().longValue();
}
public static String getLoginName()
{
public static String getLoginName() {
return getSysUser().getLoginName();
}
public static String getIp()
{
public static String getIp() {
return getSubject().getSession().getHost();
}
public static String getSessionId()
{
public static String getSessionId() {
return String.valueOf(getSubject().getSession().getId());
}
/**
* 生成随机盐
*/
public static String randomSalt()
{
public static String randomSalt() {
// 一个Byte占两个字节此处生成的3字节字符串长度为6
SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator();
String hex = secureRandom.nextBytes(3).toHex();

View File

@ -1,10 +1,12 @@
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;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
import static com.google.code.kaptcha.Constants.*;
/**
@ -13,11 +15,10 @@ import static com.google.code.kaptcha.Constants.*;
* @author ruoyi
*/
@Configuration
public class CaptchaConfig
{
public class CaptchaConfig {
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean()
{
public DefaultKaptcha getKaptchaBean() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yesno
@ -44,8 +45,7 @@ public class CaptchaConfig
}
@Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath()
{
public DefaultKaptcha getKaptchaBeanMath() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yesno