瞎搞呗

This commit is contained in:
Zail 2021-03-18 09:11:36 +08:00
parent 031ad2b93e
commit 0c68fc1760
53 changed files with 2519 additions and 3039 deletions

View File

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

View File

@ -5,14 +5,12 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
/** /**
* web容器中进行部署 * web容器中进行部署
* *
* @author ruoyi * @author ruoyi
*/ */
public class RuoYiServletInitializer extends SpringBootServletInitializer public class RuoYiServletInitializer extends SpringBootServletInitializer {
{
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
{
return application.sources(RuoYiApplication.class); return application.sources(RuoYiApplication.class);
} }
} }

View File

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

View File

@ -6,75 +6,67 @@ import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* 模态窗口 * 模态窗口
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/demo/modal") @RequestMapping("/demo/modal")
public class DemoDialogController public class DemoDialogController {
{
private String prefix = "demo/modal"; private String prefix = "demo/modal";
/** /**
* 模态窗口 * 模态窗口
*/ */
@GetMapping("/dialog") @GetMapping("/dialog")
public String dialog() public String dialog() {
{
return prefix + "/dialog"; return prefix + "/dialog";
} }
/** /**
* 弹层组件 * 弹层组件
*/ */
@GetMapping("/layer") @GetMapping("/layer")
public String layer() public String layer() {
{
return prefix + "/layer"; return prefix + "/layer";
} }
/** /**
* 表单 * 表单
*/ */
@GetMapping("/form") @GetMapping("/form")
public String form() public String form() {
{
return prefix + "/form"; return prefix + "/form";
} }
/** /**
* 表格 * 表格
*/ */
@GetMapping("/table") @GetMapping("/table")
public String table() public String table() {
{
return prefix + "/table"; return prefix + "/table";
} }
/** /**
* 表格check * 表格check
*/ */
@GetMapping("/check") @GetMapping("/check")
public String check() public String check() {
{
return prefix + "/table/check"; return prefix + "/table/check";
} }
/** /**
* 表格radio * 表格radio
*/ */
@GetMapping("/radio") @GetMapping("/radio")
public String radio() public String radio() {
{
return prefix + "/table/radio"; return prefix + "/table/radio";
} }
/** /**
* 表格回传父窗体 * 表格回传父窗体
*/ */
@GetMapping("/parent") @GetMapping("/parent")
public String parent() public String parent() {
{
return prefix + "/table/parent"; return prefix + "/table/parent";
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -6,30 +6,27 @@ import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* 图标相关 * 图标相关
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/demo/icon") @RequestMapping("/demo/icon")
public class DemoIconController public class DemoIconController {
{
private String prefix = "demo/icon"; private String prefix = "demo/icon";
/** /**
* FontAwesome图标 * FontAwesome图标
*/ */
@GetMapping("/fontawesome") @GetMapping("/fontawesome")
public String fontAwesome() public String fontAwesome() {
{
return prefix + "/fontawesome"; return prefix + "/fontawesome";
} }
/** /**
* Glyphicons图标 * Glyphicons图标
*/ */
@GetMapping("/glyphicons") @GetMapping("/glyphicons")
public String glyphicons() public String glyphicons() {
{
return prefix + "/glyphicons"; return prefix + "/glyphicons";
} }
} }

View File

@ -1,17 +1,5 @@
package com.ruoyi.web.controller.demo.controller; 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.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.PageDomain;
@ -23,19 +11,28 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.demo.domain.CustomerModel; import com.ruoyi.web.controller.demo.domain.CustomerModel;
import com.ruoyi.web.controller.demo.domain.UserOperateModel; 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;
/** /**
* 操作控制 * 操作控制
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/demo/operate") @RequestMapping("/demo/operate")
public class DemoOperateController extends BaseController public class DemoOperateController extends BaseController {
{
private String prefix = "demo/operate"; private String prefix = "demo/operate";
private final static Map<Integer, UserOperateModel> users = new LinkedHashMap<Integer, UserOperateModel>(); 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(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")); users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
@ -64,261 +61,226 @@ public class DemoOperateController extends BaseController
users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1")); users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
} }
/** /**
* 表格 * 表格
*/ */
@GetMapping("/table") @GetMapping("/table")
public String table() public String table() {
{
return prefix + "/table"; return prefix + "/table";
} }
/** /**
* 其他 * 其他
*/ */
@GetMapping("/other") @GetMapping("/other")
public String other() public String other() {
{
return prefix + "/other"; return prefix + "/other";
} }
/** /**
* 查询数据 * 查询数据
*/ */
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(UserOperateModel userModel) public TableDataInfo list(UserOperateModel userModel) {
{
TableDataInfo rspData = new TableDataInfo(); TableDataInfo rspData = new TableDataInfo();
List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values()); List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values());
// 查询条件过滤 // 查询条件过滤
if (StringUtils.isNotEmpty(userModel.getSearchValue())) if (StringUtils.isNotEmpty(userModel.getSearchValue())) {
{
userList.clear(); userList.clear();
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) {
{ if (entry.getValue().getUserName().equals(userModel.getSearchValue())) {
if (entry.getValue().getUserName().equals(userModel.getSearchValue()))
{
userList.add(entry.getValue()); userList.add(entry.getValue());
} }
} }
} }
else if (StringUtils.isNotEmpty(userModel.getUserName())) else if (StringUtils.isNotEmpty(userModel.getUserName())) {
{
userList.clear(); userList.clear();
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) {
{ if (entry.getValue().getUserName().equals(userModel.getUserName())) {
if (entry.getValue().getUserName().equals(userModel.getUserName()))
{
userList.add(entry.getValue()); userList.add(entry.getValue());
} }
} }
} }
PageDomain pageDomain = TableSupport.buildPageRequest(); PageDomain pageDomain = TableSupport.buildPageRequest();
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
{
rspData.setRows(userList); rspData.setRows(userList);
rspData.setTotal(userList.size()); rspData.setTotal(userList.size());
return rspData; return rspData;
} }
Integer pageNum = (pageDomain.getPageNum() - 1) * 10; Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
Integer pageSize = pageDomain.getPageNum() * 10; Integer pageSize = pageDomain.getPageNum() * 10;
if (pageSize > userList.size()) if (pageSize > userList.size()) {
{
pageSize = userList.size(); pageSize = userList.size();
} }
rspData.setRows(userList.subList(pageNum, pageSize)); rspData.setRows(userList.subList(pageNum, pageSize));
rspData.setTotal(userList.size()); rspData.setTotal(userList.size());
return rspData; return rspData;
} }
/** /**
* 新增用户 * 新增用户
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add(ModelMap mmap) public String add(ModelMap mmap) {
{
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存用户 * 新增保存用户
*/ */
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(UserOperateModel user) public AjaxResult addSave(UserOperateModel user) {
{
Integer userId = users.size() + 1; Integer userId = users.size() + 1;
user.setUserId(userId); user.setUserId(userId);
return AjaxResult.success(users.put(userId, user)); return AjaxResult.success(users.put(userId, user));
} }
/** /**
* 新增保存主子表信息 * 新增保存主子表信息
*/ */
@PostMapping("/customer/add") @PostMapping("/customer/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(CustomerModel customerModel) public AjaxResult addSave(CustomerModel customerModel) {
{
System.out.println(customerModel.toString()); System.out.println(customerModel.toString());
return AjaxResult.success(); return AjaxResult.success();
} }
/** /**
* 修改用户 * 修改用户
*/ */
@GetMapping("/edit/{userId}") @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)); mmap.put("user", users.get(userId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存用户 * 修改保存用户
*/ */
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(UserOperateModel user) public AjaxResult editSave(UserOperateModel user) {
{
return AjaxResult.success(users.put(user.getUserId(), user)); return AjaxResult.success(users.put(user.getUserId(), user));
} }
/** /**
* 导出 * 导出
*/ */
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(UserOperateModel user) public AjaxResult export(UserOperateModel user) {
{
List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values()); List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values());
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class); ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
return util.exportExcel(list, "用户数据"); return util.exportExcel(list, "用户数据");
} }
/** /**
* 下载模板 * 下载模板
*/ */
@GetMapping("/importTemplate") @GetMapping("/importTemplate")
@ResponseBody @ResponseBody
public AjaxResult importTemplate() public AjaxResult importTemplate() {
{
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class); ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
return util.importTemplateExcel("用户数据"); return util.importTemplateExcel("用户数据");
} }
/** /**
* 导入数据 * 导入数据
*/ */
@PostMapping("/importData") @PostMapping("/importData")
@ResponseBody @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); ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
List<UserOperateModel> userList = util.importExcel(file.getInputStream()); List<UserOperateModel> userList = util.importExcel(file.getInputStream());
String message = importUser(userList, updateSupport); String message = importUser(userList, updateSupport);
return AjaxResult.success(message); return AjaxResult.success(message);
} }
/** /**
* 删除用户 * 删除用户
*/ */
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
Integer[] userIds = Convert.toIntArray(ids); Integer[] userIds = Convert.toIntArray(ids);
for (Integer userId : userIds) for (Integer userId : userIds) {
{
users.remove(userId); users.remove(userId);
} }
return AjaxResult.success(); return AjaxResult.success();
} }
/** /**
* 查看详细 * 查看详细
*/ */
@GetMapping("/detail/{userId}") @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)); mmap.put("user", users.get(userId));
return prefix + "/detail"; return prefix + "/detail";
} }
@PostMapping("/clean") @PostMapping("/clean")
@ResponseBody @ResponseBody
public AjaxResult clean() public AjaxResult clean() {
{
users.clear(); users.clear();
return success(); return success();
} }
/** /**
* 导入用户数据 * 导入用户数据
* *
* @param userList 用户数据列表 * @param userList 用户数据列表
* @param isUpdateSupport 是否更新支持如果已存在则进行更新数据 * @param isUpdateSupport 是否更新支持如果已存在则进行更新数据
* @return 结果 * @return 结果
*/ */
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport) public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport) {
{ if (StringUtils.isNull(userList) || userList.size() == 0) {
if (StringUtils.isNull(userList) || userList.size() == 0)
{
throw new BusinessException("导入用户数据不能为空!"); throw new BusinessException("导入用户数据不能为空!");
} }
int successNum = 0; int successNum = 0;
int failureNum = 0; int failureNum = 0;
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
for (UserOperateModel user : userList) for (UserOperateModel user : userList) {
{ try {
try
{
// 验证是否存在这个用户 // 验证是否存在这个用户
boolean userFlag = false; boolean userFlag = false;
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) {
{ if (entry.getValue().getUserName().equals(user.getUserName())) {
if (entry.getValue().getUserName().equals(user.getUserName()))
{
userFlag = true; userFlag = true;
break; break;
} }
} }
if (!userFlag) if (!userFlag) {
{
Integer userId = users.size() + 1; Integer userId = users.size() + 1;
user.setUserId(userId); user.setUserId(userId);
users.put(userId, user); users.put(userId, user);
successNum++; successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功"); successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功");
} }
else if (isUpdateSupport) else if (isUpdateSupport) {
{
users.put(user.getUserId(), user); users.put(user.getUserId(), user);
successNum++; successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功"); successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功");
} }
else else {
{
failureNum++; failureNum++;
failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在"); failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在");
} }
} }
catch (Exception e) catch (Exception e) {
{
failureNum++; failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
failureMsg.append(msg + e.getMessage()); failureMsg.append(msg + e.getMessage());
} }
} }
if (failureNum > 0) if (failureNum > 0) {
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new BusinessException(failureMsg.toString()); throw new BusinessException(failureMsg.toString());
} }
else else {
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
} }
return successMsg.toString(); return successMsg.toString();

View File

@ -6,48 +6,43 @@ import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* 报表 * 报表
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/demo/report") @RequestMapping("/demo/report")
public class DemoReportController public class DemoReportController {
{
private String prefix = "demo/report"; private String prefix = "demo/report";
/** /**
* 百度ECharts * 百度ECharts
*/ */
@GetMapping("/echarts") @GetMapping("/echarts")
public String echarts() public String echarts() {
{
return prefix + "/echarts"; return prefix + "/echarts";
} }
/** /**
* 图表插件 * 图表插件
*/ */
@GetMapping("/peity") @GetMapping("/peity")
public String peity() public String peity() {
{
return prefix + "/peity"; return prefix + "/peity";
} }
/** /**
* 线状图插件 * 线状图插件
*/ */
@GetMapping("/sparkline") @GetMapping("/sparkline")
public String sparkline() public String sparkline() {
{
return prefix + "/sparkline"; return prefix + "/sparkline";
} }
/** /**
* 图表组合 * 图表组合
*/ */
@GetMapping("/metrics") @GetMapping("/metrics")
public String metrics() public String metrics() {
{
return prefix + "/metrics"; return prefix + "/metrics";
} }
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.demo.controller; 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.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -19,19 +8,27 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; 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.*;
/** /**
* 表格相关 * 表格相关
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/demo/table") @RequestMapping("/demo/table")
public class DemoTableController extends BaseController public class DemoTableController extends BaseController {
{
private String prefix = "demo/table"; private String prefix = "demo/table";
private final static List<UserTableModel> users = new ArrayList<UserTableModel>(); 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(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")); users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
@ -60,8 +57,9 @@ public class DemoTableController extends BaseController
users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1")); users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
} }
private final static List<UserTableColumn> columns = new ArrayList<UserTableColumn>(); private final static List<UserTableColumn> columns = new ArrayList<UserTableColumn>();
{ {
columns.add(new UserTableColumn("用户ID", "userId")); columns.add(new UserTableColumn("用户ID", "userId"));
columns.add(new UserTableColumn("用户编号", "userCode")); columns.add(new UserTableColumn("用户编号", "userCode"));
@ -70,282 +68,249 @@ public class DemoTableController extends BaseController
columns.add(new UserTableColumn("用户邮箱", "userEmail")); columns.add(new UserTableColumn("用户邮箱", "userEmail"));
columns.add(new UserTableColumn("用户状态", "status")); columns.add(new UserTableColumn("用户状态", "status"));
} }
/** /**
* 搜索相关 * 搜索相关
*/ */
@GetMapping("/search") @GetMapping("/search")
public String search() public String search() {
{
return prefix + "/search"; return prefix + "/search";
} }
/** /**
* 数据汇总 * 数据汇总
*/ */
@GetMapping("/footer") @GetMapping("/footer")
public String footer() public String footer() {
{
return prefix + "/footer"; return prefix + "/footer";
} }
/** /**
* 组合表头 * 组合表头
*/ */
@GetMapping("/groupHeader") @GetMapping("/groupHeader")
public String groupHeader() public String groupHeader() {
{
return prefix + "/groupHeader"; return prefix + "/groupHeader";
} }
/** /**
* 表格导出 * 表格导出
*/ */
@GetMapping("/export") @GetMapping("/export")
public String export() public String export() {
{
return prefix + "/export"; return prefix + "/export";
} }
/** /**
* 翻页记住选择 * 翻页记住选择
*/ */
@GetMapping("/remember") @GetMapping("/remember")
public String remember() public String remember() {
{
return prefix + "/remember"; return prefix + "/remember";
} }
/** /**
* 跳转至指定页 * 跳转至指定页
*/ */
@GetMapping("/pageGo") @GetMapping("/pageGo")
public String pageGo() public String pageGo() {
{
return prefix + "/pageGo"; return prefix + "/pageGo";
} }
/** /**
* 自定义查询参数 * 自定义查询参数
*/ */
@GetMapping("/params") @GetMapping("/params")
public String params() public String params() {
{
return prefix + "/params"; return prefix + "/params";
} }
/** /**
* 多表格 * 多表格
*/ */
@GetMapping("/multi") @GetMapping("/multi")
public String multi() public String multi() {
{
return prefix + "/multi"; return prefix + "/multi";
} }
/** /**
* 点击按钮加载表格 * 点击按钮加载表格
*/ */
@GetMapping("/button") @GetMapping("/button")
public String button() public String button() {
{
return prefix + "/button"; return prefix + "/button";
} }
/** /**
* 直接加载表格数据 * 直接加载表格数据
*/ */
@GetMapping("/data") @GetMapping("/data")
public String data(ModelMap mmap) public String data(ModelMap mmap) {
{
mmap.put("users", users); mmap.put("users", users);
return prefix + "/data"; return prefix + "/data";
} }
/** /**
* 表格冻结列 * 表格冻结列
*/ */
@GetMapping("/fixedColumns") @GetMapping("/fixedColumns")
public String fixedColumns() public String fixedColumns() {
{
return prefix + "/fixedColumns"; return prefix + "/fixedColumns";
} }
/** /**
* 自定义触发事件 * 自定义触发事件
*/ */
@GetMapping("/event") @GetMapping("/event")
public String event() public String event() {
{
return prefix + "/event"; return prefix + "/event";
} }
/** /**
* 表格细节视图 * 表格细节视图
*/ */
@GetMapping("/detail") @GetMapping("/detail")
public String detail() public String detail() {
{
return prefix + "/detail"; return prefix + "/detail";
} }
/** /**
* 表格父子视图 * 表格父子视图
*/ */
@GetMapping("/child") @GetMapping("/child")
public String child() public String child() {
{
return prefix + "/child"; return prefix + "/child";
} }
/** /**
* 表格图片预览 * 表格图片预览
*/ */
@GetMapping("/image") @GetMapping("/image")
public String image() public String image() {
{
return prefix + "/image"; return prefix + "/image";
} }
/** /**
* 动态增删改查 * 动态增删改查
*/ */
@GetMapping("/curd") @GetMapping("/curd")
public String curd() public String curd() {
{
return prefix + "/curd"; return prefix + "/curd";
} }
/** /**
* 表格拖拽操作 * 表格拖拽操作
*/ */
@GetMapping("/reorder") @GetMapping("/reorder")
public String reorder() public String reorder() {
{
return prefix + "/reorder"; return prefix + "/reorder";
} }
/** /**
* 表格列宽拖动 * 表格列宽拖动
*/ */
@GetMapping("/resizable") @GetMapping("/resizable")
public String resizable() public String resizable() {
{
return prefix + "/resizable"; return prefix + "/resizable";
} }
/** /**
* 表格行内编辑操作 * 表格行内编辑操作
*/ */
@GetMapping("/editable") @GetMapping("/editable")
public String editable() public String editable() {
{
return prefix + "/editable"; return prefix + "/editable";
} }
/** /**
* 主子表提交 * 主子表提交
*/ */
@GetMapping("/subdata") @GetMapping("/subdata")
public String subdata() public String subdata() {
{
return prefix + "/subdata"; return prefix + "/subdata";
} }
/** /**
* 表格自动刷新 * 表格自动刷新
*/ */
@GetMapping("/refresh") @GetMapping("/refresh")
public String refresh() public String refresh() {
{
return prefix + "/refresh"; return prefix + "/refresh";
} }
/** /**
* 表格打印配置 * 表格打印配置
*/ */
@GetMapping("/print") @GetMapping("/print")
public String print() public String print() {
{
return prefix + "/print"; return prefix + "/print";
} }
/** /**
* 表格标题格式化 * 表格标题格式化
*/ */
@GetMapping("/headerStyle") @GetMapping("/headerStyle")
public String headerStyle() public String headerStyle() {
{
return prefix + "/headerStyle"; return prefix + "/headerStyle";
} }
/** /**
* 表格动态列 * 表格动态列
*/ */
@GetMapping("/dynamicColumns") @GetMapping("/dynamicColumns")
public String dynamicColumns() public String dynamicColumns() {
{
return prefix + "/dynamicColumns"; return prefix + "/dynamicColumns";
} }
/** /**
* 表格其他操作 * 表格其他操作
*/ */
@GetMapping("/other") @GetMapping("/other")
public String other() public String other() {
{
return prefix + "/other"; return prefix + "/other";
} }
/** /**
* 动态获取列 * 动态获取列
*/ */
@PostMapping("/ajaxColumns") @PostMapping("/ajaxColumns")
@ResponseBody @ResponseBody
public AjaxResult ajaxColumns(UserTableColumn userColumn) public AjaxResult ajaxColumns(UserTableColumn userColumn) {
{
List<UserTableColumn> columnList = new ArrayList<UserTableColumn>(Arrays.asList(new UserTableColumn[columns.size()])); List<UserTableColumn> columnList = new ArrayList<UserTableColumn>(Arrays.asList(new UserTableColumn[columns.size()]));
Collections.copy(columnList, columns); Collections.copy(columnList, columns);
if (userColumn != null && "userBalance".equals(userColumn.getField())) if (userColumn != null && "userBalance".equals(userColumn.getField())) {
{
columnList.add(new UserTableColumn("用户余额", "userBalance")); columnList.add(new UserTableColumn("用户余额", "userBalance"));
} }
return AjaxResult.success(columnList); return AjaxResult.success(columnList);
} }
/** /**
* 查询数据 * 查询数据
*/ */
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(UserTableModel userModel) public TableDataInfo list(UserTableModel userModel) {
{
TableDataInfo rspData = new TableDataInfo(); TableDataInfo rspData = new TableDataInfo();
List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()])); List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()]));
Collections.copy(userList, users); Collections.copy(userList, users);
// 查询条件过滤 // 查询条件过滤
if (StringUtils.isNotEmpty(userModel.getUserName())) if (StringUtils.isNotEmpty(userModel.getUserName())) {
{
userList.clear(); userList.clear();
for (UserTableModel user : users) for (UserTableModel user : users) {
{ if (user.getUserName().equals(userModel.getUserName())) {
if (user.getUserName().equals(userModel.getUserName()))
{
userList.add(user); userList.add(user);
} }
} }
} }
PageDomain pageDomain = TableSupport.buildPageRequest(); PageDomain pageDomain = TableSupport.buildPageRequest();
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
{
rspData.setRows(userList); rspData.setRows(userList);
rspData.setTotal(userList.size()); rspData.setTotal(userList.size());
return rspData; return rspData;
} }
Integer pageNum = (pageDomain.getPageNum() - 1) * 10; Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
Integer pageSize = pageDomain.getPageNum() * 10; Integer pageSize = pageDomain.getPageNum() * 10;
if (pageSize > userList.size()) if (pageSize > userList.size()) {
{
pageSize = userList.size(); pageSize = userList.size();
} }
rspData.setRows(userList.subList(pageNum, pageSize)); rspData.setRows(userList.subList(pageNum, pageSize));
@ -354,83 +319,95 @@ public class DemoTableController extends BaseController
} }
} }
class UserTableColumn class UserTableColumn {
{ /**
/** 表头 */ * 表头
*/
private String title; private String title;
/** 字段 */ /**
* 字段
*/
private String field; private String field;
public UserTableColumn() public UserTableColumn() {
{
} }
public UserTableColumn(String title, String field) public UserTableColumn(String title, String field) {
{
this.title = title; this.title = title;
this.field = field; this.field = field;
} }
public String getTitle() public String getTitle() {
{
return title; return title;
} }
public void setTitle(String title) public void setTitle(String title) {
{
this.title = title; this.title = title;
} }
public String getField() public String getField() {
{
return field; return field;
} }
public void setField(String field) public void setField(String field) {
{
this.field = field; this.field = field;
} }
} }
class UserTableModel class UserTableModel {
{ /**
/** 用户ID */ * 用户ID
*/
private int userId; private int userId;
/** 用户编号 */ /**
* 用户编号
*/
private String userCode; private String userCode;
/** 用户姓名 */ /**
* 用户姓名
*/
private String userName; private String userName;
/** 用户性别 */ /**
* 用户性别
*/
private String userSex; private String userSex;
/** 用户手机 */ /**
* 用户手机
*/
private String userPhone; private String userPhone;
/** 用户邮箱 */ /**
* 用户邮箱
*/
private String userEmail; private String userEmail;
/** 用户余额 */ /**
* 用户余额
*/
private double userBalance; private double userBalance;
/** 用户状态0正常 1停用 */ /**
* 用户状态0正常 1停用
*/
private String status; private String status;
/** 创建时间 */ /**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime;
public UserTableModel() public UserTableModel() {
{
} }
public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone, 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.userId = userId;
this.userCode = userCode; this.userCode = userCode;
this.userName = userName; this.userName = userName;
@ -441,94 +418,76 @@ class UserTableModel
this.status = status; this.status = status;
this.createTime = DateUtils.getNowDate(); this.createTime = DateUtils.getNowDate();
} }
public int getUserId() public int getUserId() {
{
return userId; return userId;
} }
public void setUserId(int userId) public void setUserId(int userId) {
{
this.userId = userId; this.userId = userId;
} }
public String getUserCode() public String getUserCode() {
{
return userCode; return userCode;
} }
public void setUserCode(String userCode) public void setUserCode(String userCode) {
{
this.userCode = userCode; this.userCode = userCode;
} }
public String getUserName() public String getUserName() {
{
return userName; return userName;
} }
public void setUserName(String userName) public void setUserName(String userName) {
{
this.userName = userName; this.userName = userName;
} }
public String getUserSex() public String getUserSex() {
{
return userSex; return userSex;
} }
public void setUserSex(String userSex) public void setUserSex(String userSex) {
{
this.userSex = userSex; this.userSex = userSex;
} }
public String getUserPhone() public String getUserPhone() {
{
return userPhone; return userPhone;
} }
public void setUserPhone(String userPhone) public void setUserPhone(String userPhone) {
{
this.userPhone = userPhone; this.userPhone = userPhone;
} }
public String getUserEmail() public String getUserEmail() {
{
return userEmail; return userEmail;
} }
public void setUserEmail(String userEmail) public void setUserEmail(String userEmail) {
{
this.userEmail = userEmail; this.userEmail = userEmail;
} }
public double getUserBalance() public double getUserBalance() {
{
return userBalance; return userBalance;
} }
public void setUserBalance(double userBalance) public void setUserBalance(double userBalance) {
{
this.userBalance = userBalance; this.userBalance = userBalance;
} }
public String getStatus() public String getStatus() {
{
return status; return status;
} }
public void setStatus(String status) public void setStatus(String status) {
{
this.status = status; this.status = status;
} }
public Date getCreateTime() public Date getCreateTime() {
{
return createTime; return createTime;
} }
public void setCreateTime(Date createTime) public void setCreateTime(Date createTime) {
{
this.createTime = createTime; this.createTime = createTime;
} }
} }

View File

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

View File

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

View File

@ -1,49 +1,47 @@
package com.ruoyi.web.controller.demo.domain; package com.ruoyi.web.controller.demo.domain;
import java.util.Date;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type; import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.DateUtils; 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 static final long serialVersionUID = 1L;
private int userId; private int userId;
@Excel(name = "用户编号") @Excel(name = "用户编号")
private String userCode; private String userCode;
@Excel(name = "用户姓名") @Excel(name = "用户姓名")
private String userName; private String userName;
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String userSex; private String userSex;
@Excel(name = "用户手机") @Excel(name = "用户手机")
private String userPhone; private String userPhone;
@Excel(name = "用户邮箱") @Excel(name = "用户邮箱")
private String userEmail; private String userEmail;
@Excel(name = "用户余额") @Excel(name = "用户余额")
private double userBalance; private double userBalance;
@Excel(name = "用户状态", readConverterExp = "0=正常,1=停用") @Excel(name = "用户状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date createTime; private Date createTime;
public UserOperateModel() public UserOperateModel() {
{
} }
public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone, 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.userId = userId;
this.userCode = userCode; this.userCode = userCode;
this.userName = userName; this.userName = userName;
@ -54,96 +52,78 @@ public class UserOperateModel extends BaseEntity
this.status = status; this.status = status;
this.createTime = DateUtils.getNowDate(); this.createTime = DateUtils.getNowDate();
} }
public int getUserId() public int getUserId() {
{
return userId; return userId;
} }
public void setUserId(int userId) public void setUserId(int userId) {
{
this.userId = userId; this.userId = userId;
} }
public String getUserCode() public String getUserCode() {
{
return userCode; return userCode;
} }
public void setUserCode(String userCode) public void setUserCode(String userCode) {
{
this.userCode = userCode; this.userCode = userCode;
} }
public String getUserName() public String getUserName() {
{
return userName; return userName;
} }
public void setUserName(String userName) public void setUserName(String userName) {
{
this.userName = userName; this.userName = userName;
} }
public String getUserSex() public String getUserSex() {
{
return userSex; return userSex;
} }
public void setUserSex(String userSex) public void setUserSex(String userSex) {
{
this.userSex = userSex; this.userSex = userSex;
} }
public String getUserPhone() public String getUserPhone() {
{
return userPhone; return userPhone;
} }
public void setUserPhone(String userPhone) public void setUserPhone(String userPhone) {
{
this.userPhone = userPhone; this.userPhone = userPhone;
} }
public String getUserEmail() public String getUserEmail() {
{
return userEmail; return userEmail;
} }
public void setUserEmail(String userEmail) public void setUserEmail(String userEmail) {
{
this.userEmail = userEmail; this.userEmail = userEmail;
} }
public double getUserBalance() public double getUserBalance() {
{
return userBalance; return userBalance;
} }
public void setUserBalance(double userBalance) public void setUserBalance(double userBalance) {
{
this.userBalance = userBalance; this.userBalance = userBalance;
} }
public String getStatus() public String getStatus() {
{
return status; return status;
} }
public void setStatus(String status) public void setStatus(String status) {
{
this.status = status; this.status = status;
} }
@Override @Override
public Date getCreateTime() public Date getCreateTime() {
{
return createTime; return createTime;
} }
@Override @Override
public void setCreateTime(Date createTime) public void setCreateTime(Date createTime) {
{
this.createTime = createTime; this.createTime = createTime;
} }
} }

View File

@ -1,5 +1,8 @@
package com.ruoyi.web.controller.monitor; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
@ -7,75 +10,64 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; 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;
/** /**
* 缓存监控 * 缓存监控
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/monitor/cache") @RequestMapping("/monitor/cache")
public class CacheController extends BaseController public class CacheController extends BaseController {
{
private String prefix = "monitor/cache"; private String prefix = "monitor/cache";
@Autowired @Autowired
private CacheService cacheService; private CacheService cacheService;
@GetMapping() @GetMapping()
public String cache(ModelMap mmap) public String cache(ModelMap mmap) {
{
mmap.put("cacheNames", cacheService.getCacheNames()); mmap.put("cacheNames", cacheService.getCacheNames());
return prefix + "/cache"; return prefix + "/cache";
} }
@PostMapping("/getNames") @PostMapping("/getNames")
public String getCacheNames(String fragment, ModelMap mmap) public String getCacheNames(String fragment, ModelMap mmap) {
{
mmap.put("cacheNames", cacheService.getCacheNames()); mmap.put("cacheNames", cacheService.getCacheNames());
return prefix + "/cache::" + fragment; return prefix + "/cache::" + fragment;
} }
@PostMapping("/getKeys") @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("cacheName", cacheName);
mmap.put("cacheKyes", cacheService.getCacheKeys(cacheName)); mmap.put("cacheKyes", cacheService.getCacheKeys(cacheName));
return prefix + "/cache::" + fragment; return prefix + "/cache::" + fragment;
} }
@PostMapping("/getValue") @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("cacheName", cacheName);
mmap.put("cacheKey", cacheKey); mmap.put("cacheKey", cacheKey);
mmap.put("cacheValue", cacheService.getCacheValue(cacheName, cacheKey)); mmap.put("cacheValue", cacheService.getCacheValue(cacheName, cacheKey));
return prefix + "/cache::" + fragment; return prefix + "/cache::" + fragment;
} }
@PostMapping("/clearCacheName") @PostMapping("/clearCacheName")
@ResponseBody @ResponseBody
public AjaxResult clearCacheName(String cacheName, ModelMap mmap) public AjaxResult clearCacheName(String cacheName, ModelMap mmap) {
{
cacheService.clearCacheName(cacheName); cacheService.clearCacheName(cacheName);
return AjaxResult.success(); return AjaxResult.success();
} }
@PostMapping("/clearCacheKey") @PostMapping("/clearCacheKey")
@ResponseBody @ResponseBody
public AjaxResult clearCacheKey(String cacheName, String cacheKey, ModelMap mmap) public AjaxResult clearCacheKey(String cacheName, String cacheKey, ModelMap mmap) {
{
cacheService.clearCacheKey(cacheName, cacheKey); cacheService.clearCacheKey(cacheName, cacheKey);
return AjaxResult.success(); return AjaxResult.success();
} }
@GetMapping("/clearAll") @GetMapping("/clearAll")
@ResponseBody @ResponseBody
public AjaxResult clearAll(ModelMap mmap) public AjaxResult clearAll(ModelMap mmap) {
{
cacheService.clearAll(); cacheService.clearAll();
return AjaxResult.success(); return AjaxResult.success();
} }

View File

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

View File

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

View File

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

View File

@ -1,15 +1,5 @@
package com.ruoyi.web.controller.monitor; 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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -18,61 +8,62 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog; import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService; import com.ruoyi.system.service.ISysOperLogService;
import 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;
/** /**
* 操作日志记录 * 操作日志记录
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/monitor/operlog") @RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController public class SysOperlogController extends BaseController {
{
private String prefix = "monitor/operlog"; private String prefix = "monitor/operlog";
@Autowired @Autowired
private ISysOperLogService operLogService; private ISysOperLogService operLogService;
@RequiresPermissions("monitor:operlog:view") @RequiresPermissions("monitor:operlog:view")
@GetMapping() @GetMapping()
public String operlog() public String operlog() {
{
return prefix + "/operlog"; return prefix + "/operlog";
} }
@RequiresPermissions("monitor:operlog:list") @RequiresPermissions("monitor:operlog:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysOperLog operLog) public TableDataInfo list(SysOperLog operLog) {
{
startPage(); startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "操作日志", businessType = BusinessType.EXPORT) @Log(title = "操作日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:operlog:export") @RequiresPermissions("monitor:operlog:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysOperLog operLog) public AjaxResult export(SysOperLog operLog) {
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
return util.exportExcel(list, "操作日志"); return util.exportExcel(list, "操作日志");
} }
@RequiresPermissions("monitor:operlog:remove") @RequiresPermissions("monitor:operlog:remove")
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(operLogService.deleteOperLogByIds(ids)); return toAjax(operLogService.deleteOperLogByIds(ids));
} }
@RequiresPermissions("monitor:operlog:detail") @RequiresPermissions("monitor:operlog:detail")
@GetMapping("/detail/{operId}") @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)); mmap.put("operLog", operLogService.selectOperLogById(operId));
return prefix + "/detail"; return prefix + "/detail";
} }
@ -81,8 +72,7 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:remove") @RequiresPermissions("monitor:operlog:remove")
@PostMapping("/clean") @PostMapping("/clean")
@ResponseBody @ResponseBody
public AjaxResult clean() public AjaxResult clean() {
{
operLogService.cleanOperLog(); operLogService.cleanOperLog();
return success(); return success();
} }

View File

@ -1,14 +1,5 @@
package com.ruoyi.web.controller.monitor; 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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -21,61 +12,63 @@ import com.ruoyi.framework.shiro.session.OnlineSession;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO; import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.system.domain.SysUserOnline; import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService; 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;
/** /**
* 在线用户监控 * 在线用户监控
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/monitor/online") @RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController public class SysUserOnlineController extends BaseController {
{
private String prefix = "monitor/online"; private String prefix = "monitor/online";
@Autowired @Autowired
private ISysUserOnlineService userOnlineService; private ISysUserOnlineService userOnlineService;
@Autowired @Autowired
private OnlineSessionDAO onlineSessionDAO; private OnlineSessionDAO onlineSessionDAO;
@RequiresPermissions("monitor:online:view") @RequiresPermissions("monitor:online:view")
@GetMapping() @GetMapping()
public String online() public String online() {
{
return prefix + "/online"; return prefix + "/online";
} }
@RequiresPermissions("monitor:online:list") @RequiresPermissions("monitor:online:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysUserOnline userOnline) public TableDataInfo list(SysUserOnline userOnline) {
{
startPage(); startPage();
List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline); List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
return getDataTable(list); 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) @Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/batchForceLogout") @PostMapping("/batchForceLogout")
@ResponseBody @ResponseBody
public AjaxResult batchForceLogout(String ids) public AjaxResult batchForceLogout(String ids) {
{ for (String sessionId : Convert.toStrArray(ids)) {
for (String sessionId : Convert.toStrArray(ids))
{
SysUserOnline online = userOnlineService.selectOnlineById(sessionId); SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null) if (online == null) {
{
return error("用户已下线"); return error("用户已下线");
} }
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
if (onlineSession == null) if (onlineSession == null) {
{
return error("用户已下线"); return error("用户已下线");
} }
if (sessionId.equals(ShiroUtils.getSessionId())) if (sessionId.equals(ShiroUtils.getSessionId())) {
{
return error("当前登录用户无法强退"); return error("当前登录用户无法强退");
} }
onlineSessionDAO.delete(onlineSession); onlineSessionDAO.delete(onlineSession);

View File

@ -1,65 +1,62 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.awt.image.BufferedImage; import com.google.code.kaptcha.Constants;
import java.io.IOException; 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.annotation.Resource;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller; import java.awt.image.BufferedImage;
import org.springframework.web.bind.annotation.GetMapping; import java.io.IOException;
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;
/** /**
* 图片验证码支持算术形式 * 图片验证码支持算术形式
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/captcha") @RequestMapping("/captcha")
public class SysCaptchaController extends BaseController public class SysCaptchaController extends BaseController {
{
@Resource(name = "captchaProducer") @Resource(name = "captchaProducer")
private Producer captchaProducer; private Producer captchaProducer;
@Resource(name = "captchaProducerMath") @Resource(name = "captchaProducerMath")
private Producer captchaProducerMath; private Producer captchaProducerMath;
/** /**
* 验证码生成 * 验证码生成
*/ */
@GetMapping(value = "/captchaImage") @GetMapping(value = "/captchaImage")
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) {
{
ServletOutputStream out = null; ServletOutputStream out = null;
try try {
{
HttpSession session = request.getSession(); HttpSession session = request.getSession();
response.setDateHeader("Expires", 0); response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache"); response.setHeader("Pragma", "no-cache");
response.setContentType("image/jpeg"); response.setContentType("image/jpeg");
String type = request.getParameter("type"); String type = request.getParameter("type");
String capStr = null; String capStr = null;
String code = null; String code = null;
BufferedImage bi = null; BufferedImage bi = null;
if ("math".equals(type)) if ("math".equals(type)) {
{
String capText = captchaProducerMath.createText(); String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@")); capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1); code = capText.substring(capText.lastIndexOf("@") + 1);
bi = captchaProducerMath.createImage(capStr); bi = captchaProducerMath.createImage(capStr);
} }
else if ("char".equals(type)) else if ("char".equals(type)) {
{
capStr = code = captchaProducer.createText(); capStr = code = captchaProducer.createText();
bi = captchaProducer.createImage(capStr); bi = captchaProducer.createImage(capStr);
} }
@ -67,23 +64,17 @@ public class SysCaptchaController extends BaseController
out = response.getOutputStream(); out = response.getOutputStream();
ImageIO.write(bi, "jpg", out); ImageIO.write(bi, "jpg", out);
out.flush(); out.flush();
} }
catch (Exception e) catch (Exception e) {
{
e.printStackTrace(); e.printStackTrace();
} }
finally finally {
{ try {
try if (out != null) {
{
if (out != null)
{
out.close(); out.close();
} }
} }
catch (IOException e) catch (IOException e) {
{
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -21,61 +10,64 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import 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;
/** /**
* 参数配置 信息操作处理 * 参数配置 信息操作处理
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/config") @RequestMapping("/system/config")
public class SysConfigController extends BaseController public class SysConfigController extends BaseController {
{
private String prefix = "system/config"; private String prefix = "system/config";
@Autowired @Autowired
private ISysConfigService configService; private ISysConfigService configService;
@RequiresPermissions("system:config:view") @RequiresPermissions("system:config:view")
@GetMapping() @GetMapping()
public String config() public String config() {
{
return prefix + "/config"; return prefix + "/config";
} }
/** /**
* 查询参数配置列表 * 查询参数配置列表
*/ */
@RequiresPermissions("system:config:list") @RequiresPermissions("system:config:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysConfig config) public TableDataInfo list(SysConfig config) {
{
startPage(); startPage();
List<SysConfig> list = configService.selectConfigList(config); List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "参数管理", businessType = BusinessType.EXPORT) @Log(title = "参数管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:config:export") @RequiresPermissions("system:config:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysConfig config) public AjaxResult export(SysConfig config) {
{
List<SysConfig> list = configService.selectConfigList(config); List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
return util.exportExcel(list, "参数数据"); return util.exportExcel(list, "参数数据");
} }
/** /**
* 新增参数配置 * 新增参数配置
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存参数配置 * 新增保存参数配置
*/ */
@ -83,26 +75,23 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysConfig config) public AjaxResult addSave(@Validated SysConfig config) {
{ if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
config.setCreateBy(ShiroUtils.getLoginName()); config.setCreateBy(ShiroUtils.getLoginName());
return toAjax(configService.insertConfig(config)); return toAjax(configService.insertConfig(config));
} }
/** /**
* 修改参数配置 * 修改参数配置
*/ */
@GetMapping("/edit/{configId}") @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)); mmap.put("config", configService.selectConfigById(configId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存参数配置 * 修改保存参数配置
*/ */
@ -110,16 +99,14 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.UPDATE) @Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysConfig config) public AjaxResult editSave(@Validated SysConfig config) {
{ if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
config.setUpdateBy(ShiroUtils.getLoginName()); config.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(configService.updateConfig(config)); return toAjax(configService.updateConfig(config));
} }
/** /**
* 删除参数配置 * 删除参数配置
*/ */
@ -127,11 +114,10 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.DELETE) @Log(title = "参数管理", businessType = BusinessType.DELETE)
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(configService.deleteConfigByIds(ids)); return toAjax(configService.deleteConfigByIds(ids));
} }
/** /**
* 清空缓存 * 清空缓存
*/ */
@ -139,19 +125,17 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.CLEAN) @Log(title = "参数管理", businessType = BusinessType.CLEAN)
@GetMapping("/clearCache") @GetMapping("/clearCache")
@ResponseBody @ResponseBody
public AjaxResult clearCache() public AjaxResult clearCache() {
{
configService.clearCache(); configService.clearCache();
return success(); return success();
} }
/** /**
* 校验参数键名 * 校验参数键名
*/ */
@PostMapping("/checkConfigKeyUnique") @PostMapping("/checkConfigKeyUnique")
@ResponseBody @ResponseBody
public String checkConfigKeyUnique(SysConfig config) public String checkConfigKeyUnique(SysConfig config) {
{
return configService.checkConfigKeyUnique(config); return configService.checkConfigKeyUnique(config);
} }
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -22,47 +11,51 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService; 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;
/** /**
* 部门信息 * 部门信息
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/dept") @RequestMapping("/system/dept")
public class SysDeptController extends BaseController public class SysDeptController extends BaseController {
{
private String prefix = "system/dept"; private String prefix = "system/dept";
@Autowired @Autowired
private ISysDeptService deptService; private ISysDeptService deptService;
@RequiresPermissions("system:dept:view") @RequiresPermissions("system:dept:view")
@GetMapping() @GetMapping()
public String dept() public String dept() {
{
return prefix + "/dept"; return prefix + "/dept";
} }
@RequiresPermissions("system:dept:list") @RequiresPermissions("system:dept:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public List<SysDept> list(SysDept dept) public List<SysDept> list(SysDept dept) {
{
List<SysDept> deptList = deptService.selectDeptList(dept); List<SysDept> deptList = deptService.selectDeptList(dept);
return deptList; return deptList;
} }
/** /**
* 新增部门 * 新增部门
*/ */
@GetMapping("/add/{parentId}") @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)); mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存部门 * 新增保存部门
*/ */
@ -70,31 +63,27 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:add") @RequiresPermissions("system:dept:add")
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysDept dept) public AjaxResult addSave(@Validated SysDept dept) {
{ if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
dept.setCreateBy(ShiroUtils.getLoginName()); dept.setCreateBy(ShiroUtils.getLoginName());
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
} }
/** /**
* 修改 * 修改
*/ */
@GetMapping("/edit/{deptId}") @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); SysDept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId) if (StringUtils.isNotNull(dept) && 100L == deptId) {
{
dept.setParentName(""); dept.setParentName("");
} }
mmap.put("dept", dept); mmap.put("dept", dept);
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 保存 * 保存
*/ */
@ -102,25 +91,21 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:edit") @RequiresPermissions("system:dept:edit")
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysDept dept) public AjaxResult editSave(@Validated SysDept dept) {
{ if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
else if (dept.getParentId().equals(dept.getDeptId())) else if (dept.getParentId().equals(dept.getDeptId())) {
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} }
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
{
return AjaxResult.error("该部门包含未停用的子部门!"); return AjaxResult.error("该部门包含未停用的子部门!");
} }
dept.setUpdateBy(ShiroUtils.getLoginName()); dept.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(deptService.updateDept(dept)); return toAjax(deptService.updateDept(dept));
} }
/** /**
* 删除 * 删除
*/ */
@ -128,75 +113,67 @@ public class SysDeptController extends BaseController
@RequiresPermissions("system:dept:remove") @RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{deptId}") @GetMapping("/remove/{deptId}")
@ResponseBody @ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId) public AjaxResult remove(@PathVariable("deptId") Long deptId) {
{ if (deptService.selectDeptCount(deptId) > 0) {
if (deptService.selectDeptCount(deptId) > 0)
{
return AjaxResult.warn("存在下级部门,不允许删除"); return AjaxResult.warn("存在下级部门,不允许删除");
} }
if (deptService.checkDeptExistUser(deptId)) if (deptService.checkDeptExistUser(deptId)) {
{
return AjaxResult.warn("部门存在用户,不允许删除"); return AjaxResult.warn("部门存在用户,不允许删除");
} }
return toAjax(deptService.deleteDeptById(deptId)); return toAjax(deptService.deleteDeptById(deptId));
} }
/** /**
* 校验部门名称 * 校验部门名称
*/ */
@PostMapping("/checkDeptNameUnique") @PostMapping("/checkDeptNameUnique")
@ResponseBody @ResponseBody
public String checkDeptNameUnique(SysDept dept) public String checkDeptNameUnique(SysDept dept) {
{
return deptService.checkDeptNameUnique(dept); return deptService.checkDeptNameUnique(dept);
} }
/** /**
* 选择部门树 * 选择部门树
* *
* @param deptId 部门ID * @param deptId 部门ID
* @param excludeId 排除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, 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("dept", deptService.selectDeptById(deptId));
mmap.put("excludeId", excludeId); mmap.put("excludeId", excludeId);
return prefix + "/tree"; return prefix + "/tree";
} }
/** /**
* 加载部门列表树 * 加载部门列表树
*/ */
@GetMapping("/treeData") @GetMapping("/treeData")
@ResponseBody @ResponseBody
public List<Ztree> treeData() public List<Ztree> treeData() {
{
List<Ztree> ztrees = deptService.selectDeptTree(new SysDept()); List<Ztree> ztrees = deptService.selectDeptTree(new SysDept());
return ztrees; return ztrees;
} }
/** /**
* 加载部门列表树排除下级 * 加载部门列表树排除下级
*/ */
@GetMapping("/treeData/{excludeId}") @GetMapping("/treeData/{excludeId}")
@ResponseBody @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(); SysDept dept = new SysDept();
dept.setDeptId(excludeId); dept.setDeptId(excludeId);
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept); List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
return ztrees; return ztrees;
} }
/** /**
* 加载角色部门数据权限列表树 * 加载角色部门数据权限列表树
*/ */
@GetMapping("/roleDeptTreeData") @GetMapping("/roleDeptTreeData")
@ResponseBody @ResponseBody
public List<Ztree> deptTreeData(SysRole role) public List<Ztree> deptTreeData(SysRole role) {
{
List<Ztree> ztrees = deptService.roleDeptTreeData(role); List<Ztree> ztrees = deptService.roleDeptTreeData(role);
return ztrees; return ztrees;
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -20,59 +9,62 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictDataService; 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;
/** /**
* 数据字典信息 * 数据字典信息
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/dict/data") @RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController public class SysDictDataController extends BaseController {
{
private String prefix = "system/dict/data"; private String prefix = "system/dict/data";
@Autowired @Autowired
private ISysDictDataService dictDataService; private ISysDictDataService dictDataService;
@RequiresPermissions("system:dict:view") @RequiresPermissions("system:dict:view")
@GetMapping() @GetMapping()
public String dictData() public String dictData() {
{
return prefix + "/data"; return prefix + "/data";
} }
@PostMapping("/list") @PostMapping("/list")
@RequiresPermissions("system:dict:list") @RequiresPermissions("system:dict:list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysDictData dictData) public TableDataInfo list(SysDictData dictData) {
{
startPage(); startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "字典数据", businessType = BusinessType.EXPORT) @Log(title = "字典数据", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export") @RequiresPermissions("system:dict:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysDictData dictData) public AjaxResult export(SysDictData dictData) {
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
return util.exportExcel(list, "字典数据"); return util.exportExcel(list, "字典数据");
} }
/** /**
* 新增字典类型 * 新增字典类型
*/ */
@GetMapping("/add/{dictType}") @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); mmap.put("dictType", dictType);
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存字典类型 * 新增保存字典类型
*/ */
@ -80,22 +72,20 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:add") @RequiresPermissions("system:dict:add")
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysDictData dict) public AjaxResult addSave(@Validated SysDictData dict) {
{
dict.setCreateBy(ShiroUtils.getLoginName()); dict.setCreateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.insertDictData(dict)); return toAjax(dictDataService.insertDictData(dict));
} }
/** /**
* 修改字典类型 * 修改字典类型
*/ */
@GetMapping("/edit/{dictCode}") @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)); mmap.put("dict", dictDataService.selectDictDataById(dictCode));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存字典类型 * 修改保存字典类型
*/ */
@ -103,18 +93,16 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:edit") @RequiresPermissions("system:dict:edit")
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysDictData dict) public AjaxResult editSave(@Validated SysDictData dict) {
{
dict.setUpdateBy(ShiroUtils.getLoginName()); dict.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.updateDictData(dict)); return toAjax(dictDataService.updateDictData(dict));
} }
@Log(title = "字典数据", businessType = BusinessType.DELETE) @Log(title = "字典数据", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dict:remove") @RequiresPermissions("system:dict:remove")
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(dictDataService.deleteDictDataByIds(ids)); return toAjax(dictDataService.deleteDictDataByIds(ids));
} }
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -22,59 +11,62 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService; 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;
/** /**
* 数据字典信息 * 数据字典信息
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/dict") @RequestMapping("/system/dict")
public class SysDictTypeController extends BaseController public class SysDictTypeController extends BaseController {
{
private String prefix = "system/dict/type"; private String prefix = "system/dict/type";
@Autowired @Autowired
private ISysDictTypeService dictTypeService; private ISysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:view") @RequiresPermissions("system:dict:view")
@GetMapping() @GetMapping()
public String dictType() public String dictType() {
{
return prefix + "/type"; return prefix + "/type";
} }
@PostMapping("/list") @PostMapping("/list")
@RequiresPermissions("system:dict:list") @RequiresPermissions("system:dict:list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysDictType dictType) public TableDataInfo list(SysDictType dictType) {
{
startPage(); startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "字典类型", businessType = BusinessType.EXPORT) @Log(title = "字典类型", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export") @RequiresPermissions("system:dict:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysDictType dictType) public AjaxResult export(SysDictType dictType) {
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
return util.exportExcel(list, "字典类型"); return util.exportExcel(list, "字典类型");
} }
/** /**
* 新增字典类型 * 新增字典类型
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存字典类型 * 新增保存字典类型
*/ */
@ -82,26 +74,23 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:add") @RequiresPermissions("system:dict:add")
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysDictType dict) public AjaxResult addSave(@Validated SysDictType dict) {
{ if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
dict.setCreateBy(ShiroUtils.getLoginName()); dict.setCreateBy(ShiroUtils.getLoginName());
return toAjax(dictTypeService.insertDictType(dict)); return toAjax(dictTypeService.insertDictType(dict));
} }
/** /**
* 修改字典类型 * 修改字典类型
*/ */
@GetMapping("/edit/{dictId}") @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)); mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存字典类型 * 修改保存字典类型
*/ */
@ -109,25 +98,22 @@ public class SysDictTypeController extends BaseController
@RequiresPermissions("system:dict:edit") @RequiresPermissions("system:dict:edit")
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysDictType dict) public AjaxResult editSave(@Validated SysDictType dict) {
{ if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
dict.setUpdateBy(ShiroUtils.getLoginName()); dict.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(dictTypeService.updateDictType(dict)); return toAjax(dictTypeService.updateDictType(dict));
} }
@Log(title = "字典类型", businessType = BusinessType.DELETE) @Log(title = "字典类型", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dict:remove") @RequiresPermissions("system:dict:remove")
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(dictTypeService.deleteDictTypeByIds(ids)); return toAjax(dictTypeService.deleteDictTypeByIds(ids));
} }
/** /**
* 清空缓存 * 清空缓存
*/ */
@ -135,53 +121,48 @@ public class SysDictTypeController extends BaseController
@Log(title = "字典类型", businessType = BusinessType.CLEAN) @Log(title = "字典类型", businessType = BusinessType.CLEAN)
@GetMapping("/clearCache") @GetMapping("/clearCache")
@ResponseBody @ResponseBody
public AjaxResult clearCache() public AjaxResult clearCache() {
{
dictTypeService.clearCache(); dictTypeService.clearCache();
return success(); return success();
} }
/** /**
* 查询字典详细 * 查询字典详细
*/ */
@RequiresPermissions("system:dict:list") @RequiresPermissions("system:dict:list")
@GetMapping("/detail/{dictId}") @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("dict", dictTypeService.selectDictTypeById(dictId));
mmap.put("dictList", dictTypeService.selectDictTypeAll()); mmap.put("dictList", dictTypeService.selectDictTypeAll());
return "system/dict/data/data"; return "system/dict/data/data";
} }
/** /**
* 校验字典类型 * 校验字典类型
*/ */
@PostMapping("/checkDictTypeUnique") @PostMapping("/checkDictTypeUnique")
@ResponseBody @ResponseBody
public String checkDictTypeUnique(SysDictType dictType) public String checkDictTypeUnique(SysDictType dictType) {
{
return dictTypeService.checkDictTypeUnique(dictType); return dictTypeService.checkDictTypeUnique(dictType);
} }
/** /**
* 选择字典树 * 选择字典树
*/ */
@GetMapping("/selectDictTree/{columnId}/{dictType}") @GetMapping("/selectDictTree/{columnId}/{dictType}")
public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType, public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
ModelMap mmap) ModelMap mmap) {
{
mmap.put("columnId", columnId); mmap.put("columnId", columnId);
mmap.put("dict", dictTypeService.selectDictTypeByType(dictType)); mmap.put("dict", dictTypeService.selectDictTypeByType(dictType));
return prefix + "/tree"; return prefix + "/tree";
} }
/** /**
* 加载字典列表树 * 加载字典列表树
*/ */
@GetMapping("/treeData") @GetMapping("/treeData")
@ResponseBody @ResponseBody
public List<Ztree> treeData() public List<Ztree> treeData() {
{
List<Ztree> ztrees = dictTypeService.selectDictTree(new SysDictType()); List<Ztree> ztrees = dictTypeService.selectDictTree(new SysDictType());
return ztrees; return ztrees;
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.config.RuoYiConfig;
import com.ruoyi.common.constant.ShiroConstants; import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -18,36 +7,43 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.CookieUtils; import com.ruoyi.common.utils.*;
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.framework.shiro.service.SysPasswordService; import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysMenuService; 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;
/** /**
* 首页 业务处理 * 首页 业务处理
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
public class SysIndexController extends BaseController public class SysIndexController extends BaseController {
{
@Autowired @Autowired
private ISysMenuService menuService; private ISysMenuService menuService;
@Autowired @Autowired
private ISysConfigService configService; private ISysConfigService configService;
@Autowired @Autowired
private SysPasswordService passwordService; private SysPasswordService passwordService;
// 系统首页 // 系统首页
@GetMapping("/index") @GetMapping("/index")
public String index(ModelMap mmap) public String index(ModelMap mmap) {
{
// 取身份信息 // 取身份信息
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
// 根据用户id取出菜单 // 根据用户id取出菜单
@ -61,18 +57,16 @@ public class SysIndexController extends BaseController
mmap.put("demoEnabled", RuoYiConfig.isDemoEnabled()); mmap.put("demoEnabled", RuoYiConfig.isDemoEnabled());
mmap.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate())); mmap.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
mmap.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate())); mmap.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));
// 菜单导航显示风格 // 菜单导航显示风格
String menuStyle = configService.selectConfigByKey("sys.index.menuStyle"); String menuStyle = configService.selectConfigByKey("sys.index.menuStyle");
// 移动端默认使左侧导航菜单否则取默认配置 // 移动端默认使左侧导航菜单否则取默认配置
String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle; String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle;
// 优先Cookie配置导航菜单 // 优先Cookie配置导航菜单
Cookie[] cookies = ServletUtils.getRequest().getCookies(); Cookie[] cookies = ServletUtils.getRequest().getCookies();
for (Cookie cookie : cookies) for (Cookie cookie : cookies) {
{ if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName())) {
if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName()))
{
indexStyle = cookie.getValue(); indexStyle = cookie.getValue();
break; break;
} }
@ -80,71 +74,61 @@ public class SysIndexController extends BaseController
String webIndex = "topnav".equalsIgnoreCase(indexStyle) ? "index-topnav" : "index"; String webIndex = "topnav".equalsIgnoreCase(indexStyle) ? "index-topnav" : "index";
return webIndex; return webIndex;
} }
// 锁定屏幕 // 锁定屏幕
@GetMapping("/lockscreen") @GetMapping("/lockscreen")
public String lockscreen(ModelMap mmap) public String lockscreen(ModelMap mmap) {
{
mmap.put("user", ShiroUtils.getSysUser()); mmap.put("user", ShiroUtils.getSysUser());
ServletUtils.getSession().setAttribute(ShiroConstants.LOCK_SCREEN, true); ServletUtils.getSession().setAttribute(ShiroConstants.LOCK_SCREEN, true);
return "lock"; return "lock";
} }
// 解锁屏幕 // 解锁屏幕
@PostMapping("/unlockscreen") @PostMapping("/unlockscreen")
@ResponseBody @ResponseBody
public AjaxResult unlockscreen(String password) public AjaxResult unlockscreen(String password) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
if (StringUtils.isNull(user)) if (StringUtils.isNull(user)) {
{
return AjaxResult.error("服务器超时,请重新登陆"); return AjaxResult.error("服务器超时,请重新登陆");
} }
if (passwordService.matches(user, password)) if (passwordService.matches(user, password)) {
{
ServletUtils.getSession().removeAttribute(ShiroConstants.LOCK_SCREEN); ServletUtils.getSession().removeAttribute(ShiroConstants.LOCK_SCREEN);
return AjaxResult.success(); return AjaxResult.success();
} }
return AjaxResult.error("密码不正确,请重新输入。"); return AjaxResult.error("密码不正确,请重新输入。");
} }
// 切换主题 // 切换主题
@GetMapping("/system/switchSkin") @GetMapping("/system/switchSkin")
public String switchSkin() public String switchSkin() {
{
return "skin"; return "skin";
} }
// 切换菜单 // 切换菜单
@GetMapping("/system/menuStyle/{style}") @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); CookieUtils.setCookie(response, "nav-style", style);
} }
// 系统介绍 // 系统介绍
@GetMapping("/system/main") @GetMapping("/system/main")
public String main(ModelMap mmap) public String main(ModelMap mmap) {
{
mmap.put("version", RuoYiConfig.getVersion()); mmap.put("version", RuoYiConfig.getVersion());
return "main"; return "main";
} }
// 检查初始密码是否提醒修改 // 检查初始密码是否提醒修改
public boolean initPasswordIsModify(Date pwdUpdateDate) public boolean initPasswordIsModify(Date pwdUpdateDate) {
{
Integer initPasswordModify = Convert.toInt(configService.selectConfigByKey("sys.account.initPasswordModify")); Integer initPasswordModify = Convert.toInt(configService.selectConfigByKey("sys.account.initPasswordModify"));
return initPasswordModify != null && initPasswordModify == 1 && pwdUpdateDate == null; 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")); Integer passwordValidateDays = Convert.toInt(configService.selectConfigByKey("sys.account.passwordValidateDays"));
if (passwordValidateDays != null && passwordValidateDays > 0) if (passwordValidateDays != null && passwordValidateDays > 0) {
{ if (StringUtils.isNull(pwdUpdateDate)) {
if (StringUtils.isNull(pwdUpdateDate))
{
// 如果从未修改过初始密码直接提醒过期 // 如果从未修改过初始密码直接提醒过期
return true; return true;
} }

View File

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

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -22,38 +11,43 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.framework.shiro.util.AuthorizationUtils; import com.ruoyi.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.service.ISysMenuService; 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;
/** /**
* 菜单信息 * 菜单信息
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/menu") @RequestMapping("/system/menu")
public class SysMenuController extends BaseController public class SysMenuController extends BaseController {
{
private String prefix = "system/menu"; private String prefix = "system/menu";
@Autowired @Autowired
private ISysMenuService menuService; private ISysMenuService menuService;
@RequiresPermissions("system:menu:view") @RequiresPermissions("system:menu:view")
@GetMapping() @GetMapping()
public String menu() public String menu() {
{
return prefix + "/menu"; return prefix + "/menu";
} }
@RequiresPermissions("system:menu:list") @RequiresPermissions("system:menu:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public List<SysMenu> list(SysMenu menu) public List<SysMenu> list(SysMenu menu) {
{
Long userId = ShiroUtils.getUserId(); Long userId = ShiroUtils.getUserId();
List<SysMenu> menuList = menuService.selectMenuList(menu, userId); List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
return menuList; return menuList;
} }
/** /**
* 删除菜单 * 删除菜单
*/ */
@ -61,33 +55,27 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:remove") @RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}") @GetMapping("/remove/{menuId}")
@ResponseBody @ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId) public AjaxResult remove(@PathVariable("menuId") Long menuId) {
{ if (menuService.selectCountMenuByParentId(menuId) > 0) {
if (menuService.selectCountMenuByParentId(menuId) > 0)
{
return AjaxResult.warn("存在子菜单,不允许删除"); return AjaxResult.warn("存在子菜单,不允许删除");
} }
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0) if (menuService.selectCountRoleMenuByMenuId(menuId) > 0) {
{
return AjaxResult.warn("菜单已分配,不允许删除"); return AjaxResult.warn("菜单已分配,不允许删除");
} }
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(menuService.deleteMenuById(menuId)); return toAjax(menuService.deleteMenuById(menuId));
} }
/** /**
* 新增 * 新增
*/ */
@GetMapping("/add/{parentId}") @GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
{
SysMenu menu = null; SysMenu menu = null;
if (0L != parentId) if (0L != parentId) {
{
menu = menuService.selectMenuById(parentId); menu = menuService.selectMenuById(parentId);
} }
else else {
{
menu = new SysMenu(); menu = new SysMenu();
menu.setMenuId(0L); menu.setMenuId(0L);
menu.setMenuName("主目录"); menu.setMenuName("主目录");
@ -95,7 +83,7 @@ public class SysMenuController extends BaseController
mmap.put("menu", menu); mmap.put("menu", menu);
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存菜单 * 新增保存菜单
*/ */
@ -103,27 +91,24 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:add") @RequiresPermissions("system:menu:add")
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysMenu menu) public AjaxResult addSave(@Validated SysMenu menu) {
{ if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} }
menu.setCreateBy(ShiroUtils.getLoginName()); menu.setCreateBy(ShiroUtils.getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(menuService.insertMenu(menu)); return toAjax(menuService.insertMenu(menu));
} }
/** /**
* 修改菜单 * 修改菜单
*/ */
@GetMapping("/edit/{menuId}") @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)); mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存菜单 * 修改保存菜单
*/ */
@ -131,66 +116,59 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:edit") @RequiresPermissions("system:menu:edit")
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysMenu menu) public AjaxResult editSave(@Validated SysMenu menu) {
{ if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} }
menu.setUpdateBy(ShiroUtils.getLoginName()); menu.setUpdateBy(ShiroUtils.getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(menuService.updateMenu(menu)); return toAjax(menuService.updateMenu(menu));
} }
/** /**
* 选择菜单图标 * 选择菜单图标
*/ */
@GetMapping("/icon") @GetMapping("/icon")
public String icon() public String icon() {
{
return prefix + "/icon"; return prefix + "/icon";
} }
/** /**
* 校验菜单名称 * 校验菜单名称
*/ */
@PostMapping("/checkMenuNameUnique") @PostMapping("/checkMenuNameUnique")
@ResponseBody @ResponseBody
public String checkMenuNameUnique(SysMenu menu) public String checkMenuNameUnique(SysMenu menu) {
{
return menuService.checkMenuNameUnique(menu); return menuService.checkMenuNameUnique(menu);
} }
/** /**
* 加载角色菜单列表树 * 加载角色菜单列表树
*/ */
@GetMapping("/roleMenuTreeData") @GetMapping("/roleMenuTreeData")
@ResponseBody @ResponseBody
public List<Ztree> roleMenuTreeData(SysRole role) public List<Ztree> roleMenuTreeData(SysRole role) {
{
Long userId = ShiroUtils.getUserId(); Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId); List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
return ztrees; return ztrees;
} }
/** /**
* 加载所有菜单列表树 * 加载所有菜单列表树
*/ */
@GetMapping("/menuTreeData") @GetMapping("/menuTreeData")
@ResponseBody @ResponseBody
public List<Ztree> menuTreeData() public List<Ztree> menuTreeData() {
{
Long userId = ShiroUtils.getUserId(); Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.menuTreeData(userId); List<Ztree> ztrees = menuService.menuTreeData(userId);
return ztrees; return ztrees;
} }
/** /**
* 选择菜单树 * 选择菜单树
*/ */
@GetMapping("/selectMenuTree/{menuId}") @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)); mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/tree"; return prefix + "/tree";
} }

View File

@ -1,15 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -18,50 +8,53 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService; import com.ruoyi.system.service.ISysNoticeService;
import 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;
/** /**
* 公告 信息操作处理 * 公告 信息操作处理
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/notice") @RequestMapping("/system/notice")
public class SysNoticeController extends BaseController public class SysNoticeController extends BaseController {
{
private String prefix = "system/notice"; private String prefix = "system/notice";
@Autowired @Autowired
private ISysNoticeService noticeService; private ISysNoticeService noticeService;
@RequiresPermissions("system:notice:view") @RequiresPermissions("system:notice:view")
@GetMapping() @GetMapping()
public String notice() public String notice() {
{
return prefix + "/notice"; return prefix + "/notice";
} }
/** /**
* 查询公告列表 * 查询公告列表
*/ */
@RequiresPermissions("system:notice:list") @RequiresPermissions("system:notice:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysNotice notice) public TableDataInfo list(SysNotice notice) {
{
startPage(); startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice); List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 新增公告 * 新增公告
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存公告 * 新增保存公告
*/ */
@ -69,22 +62,20 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.INSERT) @Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(SysNotice notice) public AjaxResult addSave(SysNotice notice) {
{
notice.setCreateBy(ShiroUtils.getLoginName()); notice.setCreateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.insertNotice(notice)); return toAjax(noticeService.insertNotice(notice));
} }
/** /**
* 修改公告 * 修改公告
*/ */
@GetMapping("/edit/{noticeId}") @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)); mmap.put("notice", noticeService.selectNoticeById(noticeId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存公告 * 修改保存公告
*/ */
@ -92,12 +83,11 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.UPDATE) @Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(SysNotice notice) public AjaxResult editSave(SysNotice notice) {
{
notice.setUpdateBy(ShiroUtils.getLoginName()); notice.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.updateNotice(notice)); return toAjax(noticeService.updateNotice(notice));
} }
/** /**
* 删除公告 * 删除公告
*/ */
@ -105,8 +95,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.DELETE) @Log(title = "通知公告", businessType = BusinessType.DELETE)
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(noticeService.deleteNoticeByIds(ids)); return toAjax(noticeService.deleteNoticeByIds(ids));
} }
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -21,74 +10,74 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import 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;
/** /**
* 岗位信息操作处理 * 岗位信息操作处理
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/post") @RequestMapping("/system/post")
public class SysPostController extends BaseController public class SysPostController extends BaseController {
{
private String prefix = "system/post"; private String prefix = "system/post";
@Autowired @Autowired
private ISysPostService postService; private ISysPostService postService;
@RequiresPermissions("system:post:view") @RequiresPermissions("system:post:view")
@GetMapping() @GetMapping()
public String operlog() public String operlog() {
{
return prefix + "/post"; return prefix + "/post";
} }
@RequiresPermissions("system:post:list") @RequiresPermissions("system:post:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysPost post) public TableDataInfo list(SysPost post) {
{
startPage(); startPage();
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "岗位管理", businessType = BusinessType.EXPORT) @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:post:export") @RequiresPermissions("system:post:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysPost post) public AjaxResult export(SysPost post) {
{
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
return util.exportExcel(list, "岗位数据"); return util.exportExcel(list, "岗位数据");
} }
@RequiresPermissions("system:post:remove") @RequiresPermissions("system:post:remove")
@Log(title = "岗位管理", businessType = BusinessType.DELETE) @Log(title = "岗位管理", businessType = BusinessType.DELETE)
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{ try {
try
{
return toAjax(postService.deletePostByIds(ids)); return toAjax(postService.deletePostByIds(ids));
} }
catch (Exception e) catch (Exception e) {
{
return error(e.getMessage()); return error(e.getMessage());
} }
} }
/** /**
* 新增岗位 * 新增岗位
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存岗位 * 新增保存岗位
*/ */
@ -96,30 +85,26 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.INSERT) @Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysPost post) public AjaxResult addSave(@Validated SysPost post) {
{ if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); 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() + "'失败,岗位编码已存在"); return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
} }
post.setCreateBy(ShiroUtils.getLoginName()); post.setCreateBy(ShiroUtils.getLoginName());
return toAjax(postService.insertPost(post)); return toAjax(postService.insertPost(post));
} }
/** /**
* 修改岗位 * 修改岗位
*/ */
@GetMapping("/edit/{postId}") @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)); mmap.put("post", postService.selectPostById(postId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存岗位 * 修改保存岗位
*/ */
@ -127,37 +112,32 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.UPDATE) @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysPost post) public AjaxResult editSave(@Validated SysPost post) {
{ if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); 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() + "'失败,岗位编码已存在"); return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
} }
post.setUpdateBy(ShiroUtils.getLoginName()); post.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(postService.updatePost(post)); return toAjax(postService.updatePost(post));
} }
/** /**
* 校验岗位名称 * 校验岗位名称
*/ */
@PostMapping("/checkPostNameUnique") @PostMapping("/checkPostNameUnique")
@ResponseBody @ResponseBody
public String checkPostNameUnique(SysPost post) public String checkPostNameUnique(SysPost post) {
{
return postService.checkPostNameUnique(post); return postService.checkPostNameUnique(post);
} }
/** /**
* 校验岗位编码 * 校验岗位编码
*/ */
@PostMapping("/checkPostCodeUnique") @PostMapping("/checkPostCodeUnique")
@ResponseBody @ResponseBody
public String checkPostCodeUnique(SysPost post) public String checkPostCodeUnique(SysPost post) {
{
return postService.checkPostCodeUnique(post); return postService.checkPostCodeUnique(post);
} }
} }

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -22,152 +11,141 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService; import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysUserService; 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;
/** /**
* 个人信息 业务处理 * 个人信息 业务处理
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/user/profile") @RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController public class SysProfileController extends BaseController {
{
private static final Logger log = LoggerFactory.getLogger(SysProfileController.class); private static final Logger log = LoggerFactory.getLogger(SysProfileController.class);
private String prefix = "system/user/profile"; private String prefix = "system/user/profile";
@Autowired @Autowired
private ISysUserService userService; private ISysUserService userService;
@Autowired @Autowired
private SysPasswordService passwordService; private SysPasswordService passwordService;
/** /**
* 个人信息 * 个人信息
*/ */
@GetMapping() @GetMapping()
public String profile(ModelMap mmap) public String profile(ModelMap mmap) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
mmap.put("user", user); mmap.put("user", user);
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId())); mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId())); mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId()));
return prefix + "/profile"; return prefix + "/profile";
} }
@GetMapping("/checkPassword") @GetMapping("/checkPassword")
@ResponseBody @ResponseBody
public boolean checkPassword(String password) public boolean checkPassword(String password) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
if (passwordService.matches(user, password)) if (passwordService.matches(user, password)) {
{
return true; return true;
} }
return false; return false;
} }
@GetMapping("/resetPwd") @GetMapping("/resetPwd")
public String resetPwd(ModelMap mmap) public String resetPwd(ModelMap mmap) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId())); mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/resetPwd"; return prefix + "/resetPwd";
} }
@Log(title = "重置密码", businessType = BusinessType.UPDATE) @Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd") @PostMapping("/resetPwd")
@ResponseBody @ResponseBody
public AjaxResult resetPwd(String oldPassword, String newPassword) public AjaxResult resetPwd(String oldPassword, String newPassword) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
if (!passwordService.matches(user, oldPassword)) if (!passwordService.matches(user, oldPassword)) {
{
return error("修改密码失败,旧密码错误"); return error("修改密码失败,旧密码错误");
} }
if (passwordService.matches(user, newPassword)) if (passwordService.matches(user, newPassword)) {
{
return error("新密码不能与旧密码相同"); return error("新密码不能与旧密码相同");
} }
user.setSalt(ShiroUtils.randomSalt()); user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt())); user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
user.setPwdUpdateDate(DateUtils.getNowDate()); user.setPwdUpdateDate(DateUtils.getNowDate());
if (userService.resetUserPwd(user) > 0) if (userService.resetUserPwd(user) > 0) {
{
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId())); ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
return success(); return success();
} }
return error("修改密码异常,请联系管理员"); return error("修改密码异常,请联系管理员");
} }
/** /**
* 修改用户 * 修改用户
*/ */
@GetMapping("/edit") @GetMapping("/edit")
public String edit(ModelMap mmap) public String edit(ModelMap mmap) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId())); mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改头像 * 修改头像
*/ */
@GetMapping("/avatar") @GetMapping("/avatar")
public String avatar(ModelMap mmap) public String avatar(ModelMap mmap) {
{
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId())); mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/avatar"; return prefix + "/avatar";
} }
/** /**
* 修改用户 * 修改用户
*/ */
@Log(title = "个人信息", businessType = BusinessType.UPDATE) @Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/update") @PostMapping("/update")
@ResponseBody @ResponseBody
public AjaxResult update(SysUser user) public AjaxResult update(SysUser user) {
{
SysUser currentUser = ShiroUtils.getSysUser(); SysUser currentUser = ShiroUtils.getSysUser();
currentUser.setUserName(user.getUserName()); currentUser.setUserName(user.getUserName());
currentUser.setEmail(user.getEmail()); currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber()); currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex()); currentUser.setSex(user.getSex());
if (userService.updateUserInfo(currentUser) > 0) if (userService.updateUserInfo(currentUser) > 0) {
{
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId())); ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
return success(); return success();
} }
return error(); return error();
} }
/** /**
* 保存头像 * 保存头像
*/ */
@Log(title = "个人信息", businessType = BusinessType.UPDATE) @Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateAvatar") @PostMapping("/updateAvatar")
@ResponseBody @ResponseBody
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file) public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file) {
{
SysUser currentUser = ShiroUtils.getSysUser(); SysUser currentUser = ShiroUtils.getSysUser();
try try {
{ if (!file.isEmpty()) {
if (!file.isEmpty())
{
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
currentUser.setAvatar(avatar); currentUser.setAvatar(avatar);
if (userService.updateUserInfo(currentUser) > 0) if (userService.updateUserInfo(currentUser) > 0) {
{
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId())); ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
return success(); return success();
} }
} }
return error(); return error();
} }
catch (Exception e) catch (Exception e) {
{
log.error("修改头像失败!", e); log.error("修改头像失败!", e);
return error(e.getMessage()); return error(e.getMessage());
} }

View File

@ -1,43 +1,39 @@
package com.ruoyi.web.controller.system; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody; 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;
/** /**
* 注册验证 * 注册验证
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
public class SysRegisterController extends BaseController public class SysRegisterController extends BaseController {
{
@Autowired @Autowired
private SysRegisterService registerService; private SysRegisterService registerService;
@Autowired @Autowired
private ISysConfigService configService; private ISysConfigService configService;
@GetMapping("/register") @GetMapping("/register")
public String register() public String register() {
{
return "register"; return "register";
} }
@PostMapping("/register") @PostMapping("/register")
@ResponseBody @ResponseBody
public AjaxResult ajaxRegister(SysUser user) public AjaxResult ajaxRegister(SysUser user) {
{ if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return error("当前系统没有开启注册功能!"); return error("当前系统没有开启注册功能!");
} }
String msg = registerService.register(user); String msg = registerService.register(user);

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -25,61 +14,64 @@ import com.ruoyi.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import 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;
/** /**
* 角色信息 * 角色信息
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/role") @RequestMapping("/system/role")
public class SysRoleController extends BaseController public class SysRoleController extends BaseController {
{
private String prefix = "system/role"; private String prefix = "system/role";
@Autowired @Autowired
private ISysRoleService roleService; private ISysRoleService roleService;
@Autowired @Autowired
private ISysUserService userService; private ISysUserService userService;
@RequiresPermissions("system:role:view") @RequiresPermissions("system:role:view")
@GetMapping() @GetMapping()
public String role() public String role() {
{
return prefix + "/role"; return prefix + "/role";
} }
@RequiresPermissions("system:role:list") @RequiresPermissions("system:role:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysRole role) public TableDataInfo list(SysRole role) {
{
startPage(); startPage();
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "角色管理", businessType = BusinessType.EXPORT) @Log(title = "角色管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:role:export") @RequiresPermissions("system:role:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysRole role) public AjaxResult export(SysRole role) {
{
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
return util.exportExcel(list, "角色数据"); return util.exportExcel(list, "角色数据");
} }
/** /**
* 新增角色 * 新增角色
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存角色 * 新增保存角色
*/ */
@ -87,32 +79,28 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.INSERT) @Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysRole role) public AjaxResult addSave(@Validated SysRole 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() + "'失败,角色名称已存在"); 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() + "'失败,角色权限已存在"); return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setCreateBy(ShiroUtils.getLoginName()); role.setCreateBy(ShiroUtils.getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(roleService.insertRole(role)); return toAjax(roleService.insertRole(role));
} }
/** /**
* 修改角色 * 修改角色
*/ */
@GetMapping("/edit/{roleId}") @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)); mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存角色 * 修改保存角色
*/ */
@ -120,32 +108,28 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.UPDATE) @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysRole role) public AjaxResult editSave(@Validated SysRole role) {
{
roleService.checkRoleAllowed(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() + "'失败,角色名称已存在"); 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() + "'失败,角色权限已存在"); return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setUpdateBy(ShiroUtils.getLoginName()); role.setUpdateBy(ShiroUtils.getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(roleService.updateRole(role)); return toAjax(roleService.updateRole(role));
} }
/** /**
* 角色分配数据权限 * 角色分配数据权限
*/ */
@GetMapping("/authDataScope/{roleId}") @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)); mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/dataScope"; return prefix + "/dataScope";
} }
/** /**
* 保存角色分配数据权限 * 保存角色分配数据权限
*/ */
@ -153,56 +137,50 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.UPDATE) @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/authDataScope") @PostMapping("/authDataScope")
@ResponseBody @ResponseBody
public AjaxResult authDataScopeSave(SysRole role) public AjaxResult authDataScopeSave(SysRole role) {
{
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
role.setUpdateBy(ShiroUtils.getLoginName()); role.setUpdateBy(ShiroUtils.getLoginName());
if (roleService.authDataScope(role) > 0) if (roleService.authDataScope(role) > 0) {
{
ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId())); ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
return success(); return success();
} }
return error(); return error();
} }
@RequiresPermissions("system:role:remove") @RequiresPermissions("system:role:remove")
@Log(title = "角色管理", businessType = BusinessType.DELETE) @Log(title = "角色管理", businessType = BusinessType.DELETE)
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(roleService.deleteRoleByIds(ids)); return toAjax(roleService.deleteRoleByIds(ids));
} }
/** /**
* 校验角色名称 * 校验角色名称
*/ */
@PostMapping("/checkRoleNameUnique") @PostMapping("/checkRoleNameUnique")
@ResponseBody @ResponseBody
public String checkRoleNameUnique(SysRole role) public String checkRoleNameUnique(SysRole role) {
{
return roleService.checkRoleNameUnique(role); return roleService.checkRoleNameUnique(role);
} }
/** /**
* 校验角色权限 * 校验角色权限
*/ */
@PostMapping("/checkRoleKeyUnique") @PostMapping("/checkRoleKeyUnique")
@ResponseBody @ResponseBody
public String checkRoleKeyUnique(SysRole role) public String checkRoleKeyUnique(SysRole role) {
{
return roleService.checkRoleKeyUnique(role); return roleService.checkRoleKeyUnique(role);
} }
/** /**
* 选择菜单树 * 选择菜单树
*/ */
@GetMapping("/selectMenuTree") @GetMapping("/selectMenuTree")
public String selectMenuTree() public String selectMenuTree() {
{
return prefix + "/tree"; return prefix + "/tree";
} }
/** /**
* 角色状态修改 * 角色状态修改
*/ */
@ -210,89 +188,81 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus") @PostMapping("/changeStatus")
@ResponseBody @ResponseBody
public AjaxResult changeStatus(SysRole role) public AjaxResult changeStatus(SysRole role) {
{
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
return toAjax(roleService.changeStatus(role)); return toAjax(roleService.changeStatus(role));
} }
/** /**
* 分配用户 * 分配用户
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@GetMapping("/authUser/{roleId}") @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)); mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/authUser"; return prefix + "/authUser";
} }
/** /**
* 查询已分配用户角色列表 * 查询已分配用户角色列表
*/ */
@RequiresPermissions("system:role:list") @RequiresPermissions("system:role:list")
@PostMapping("/authUser/allocatedList") @PostMapping("/authUser/allocatedList")
@ResponseBody @ResponseBody
public TableDataInfo allocatedList(SysUser user) public TableDataInfo allocatedList(SysUser user) {
{
startPage(); startPage();
List<SysUser> list = userService.selectAllocatedList(user); List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 取消授权 * 取消授权
*/ */
@Log(title = "角色管理", businessType = BusinessType.GRANT) @Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancel") @PostMapping("/authUser/cancel")
@ResponseBody @ResponseBody
public AjaxResult cancelAuthUser(SysUserRole userRole) public AjaxResult cancelAuthUser(SysUserRole userRole) {
{
return toAjax(roleService.deleteAuthUser(userRole)); return toAjax(roleService.deleteAuthUser(userRole));
} }
/** /**
* 批量取消授权 * 批量取消授权
*/ */
@Log(title = "角色管理", businessType = BusinessType.GRANT) @Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancelAll") @PostMapping("/authUser/cancelAll")
@ResponseBody @ResponseBody
public AjaxResult cancelAuthUserAll(Long roleId, String userIds) public AjaxResult cancelAuthUserAll(Long roleId, String userIds) {
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds)); return toAjax(roleService.deleteAuthUsers(roleId, userIds));
} }
/** /**
* 选择用户 * 选择用户
*/ */
@GetMapping("/authUser/selectUser/{roleId}") @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)); mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/selectUser"; return prefix + "/selectUser";
} }
/** /**
* 查询未分配用户角色列表 * 查询未分配用户角色列表
*/ */
@RequiresPermissions("system:role:list") @RequiresPermissions("system:role:list")
@PostMapping("/authUser/unallocatedList") @PostMapping("/authUser/unallocatedList")
@ResponseBody @ResponseBody
public TableDataInfo unallocatedList(SysUser user) public TableDataInfo unallocatedList(SysUser user) {
{
startPage(); startPage();
List<SysUser> list = userService.selectUnallocatedList(user); List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 批量选择用户授权 * 批量选择用户授权
*/ */
@Log(title = "角色管理", businessType = BusinessType.GRANT) @Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/selectAll") @PostMapping("/authUser/selectAll")
@ResponseBody @ResponseBody
public AjaxResult selectAuthUserAll(Long roleId, String userIds) public AjaxResult selectAuthUserAll(Long roleId, String userIds) {
{
return toAjax(roleService.insertAuthUsers(roleId, userIds)); return toAjax(roleService.insertAuthUsers(roleId, userIds));
} }
} }

View File

@ -1,18 +1,5 @@
package com.ruoyi.web.controller.system; 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.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -28,91 +15,94 @@ import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import 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;
/** /**
* 用户信息 * 用户信息
* *
* @author ruoyi * @author ruoyi
*/ */
@Controller @Controller
@RequestMapping("/system/user") @RequestMapping("/system/user")
public class SysUserController extends BaseController public class SysUserController extends BaseController {
{
private String prefix = "system/user"; private String prefix = "system/user";
@Autowired @Autowired
private ISysUserService userService; private ISysUserService userService;
@Autowired @Autowired
private ISysRoleService roleService; private ISysRoleService roleService;
@Autowired @Autowired
private ISysPostService postService; private ISysPostService postService;
@Autowired @Autowired
private SysPasswordService passwordService; private SysPasswordService passwordService;
@RequiresPermissions("system:user:view") @RequiresPermissions("system:user:view")
@GetMapping() @GetMapping()
public String user() public String user() {
{
return prefix + "/user"; return prefix + "/user";
} }
@RequiresPermissions("system:user:list") @RequiresPermissions("system:user:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(SysUser user) public TableDataInfo list(SysUser user) {
{
startPage(); startPage();
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "用户管理", businessType = BusinessType.EXPORT) @Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export") @RequiresPermissions("system:user:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(SysUser user) public AjaxResult export(SysUser user) {
{
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.exportExcel(list, "用户数据"); return util.exportExcel(list, "用户数据");
} }
@Log(title = "用户管理", businessType = BusinessType.IMPORT) @Log(title = "用户管理", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import") @RequiresPermissions("system:user:import")
@PostMapping("/importData") @PostMapping("/importData")
@ResponseBody @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); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream()); List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = ShiroUtils.getSysUser().getLoginName(); String operName = ShiroUtils.getSysUser().getLoginName();
String message = userService.importUser(userList, updateSupport, operName); String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message); return AjaxResult.success(message);
} }
@RequiresPermissions("system:user:view") @RequiresPermissions("system:user:view")
@GetMapping("/importTemplate") @GetMapping("/importTemplate")
@ResponseBody @ResponseBody
public AjaxResult importTemplate() public AjaxResult importTemplate() {
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.importTemplateExcel("用户数据"); return util.importTemplateExcel("用户数据");
} }
/** /**
* 新增用户 * 新增用户
*/ */
@GetMapping("/add") @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("roles", roleService.selectRoleAll().stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
mmap.put("posts", postService.selectPostAll()); mmap.put("posts", postService.selectPostAll());
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存用户 * 新增保存用户
*/ */
@ -120,20 +110,16 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.INSERT) @Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysUser user) public AjaxResult addSave(@Validated SysUser user) {
{ if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))) {
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
{
return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在"); return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
} }
else if (StringUtils.isNotEmpty(user.getPhonenumber()) 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() + "'失败,手机号码已存在"); return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
} }
else if (StringUtils.isNotEmpty(user.getEmail()) 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() + "'失败,邮箱账号已存在"); return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
} }
user.setSalt(ShiroUtils.randomSalt()); user.setSalt(ShiroUtils.randomSalt());
@ -141,20 +127,19 @@ public class SysUserController extends BaseController
user.setCreateBy(ShiroUtils.getLoginName()); user.setCreateBy(ShiroUtils.getLoginName());
return toAjax(userService.insertUser(user)); return toAjax(userService.insertUser(user));
} }
/** /**
* 修改用户 * 修改用户
*/ */
@GetMapping("/edit/{userId}") @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); List<SysRole> roles = roleService.selectRolesByUserId(userId);
mmap.put("user", userService.selectUserById(userId)); mmap.put("user", userService.selectUserById(userId));
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
mmap.put("posts", postService.selectPostsByUserId(userId)); mmap.put("posts", postService.selectPostsByUserId(userId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存用户 * 修改保存用户
*/ */
@ -162,57 +147,49 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.UPDATE) @Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysUser user) public AjaxResult editSave(@Validated SysUser user) {
{
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
if (StringUtils.isNotEmpty(user.getPhonenumber()) 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() + "'失败,手机号码已存在"); return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
} }
else if (StringUtils.isNotEmpty(user.getEmail()) 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() + "'失败,邮箱账号已存在"); return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
} }
user.setUpdateBy(ShiroUtils.getLoginName()); user.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(userService.updateUser(user)); return toAjax(userService.updateUser(user));
} }
@RequiresPermissions("system:user:resetPwd") @RequiresPermissions("system:user:resetPwd")
@GetMapping("/resetPwd/{userId}") @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)); mmap.put("user", userService.selectUserById(userId));
return prefix + "/resetPwd"; return prefix + "/resetPwd";
} }
@RequiresPermissions("system:user:resetPwd") @RequiresPermissions("system:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE) @Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd") @PostMapping("/resetPwd")
@ResponseBody @ResponseBody
public AjaxResult resetPwdSave(SysUser user) public AjaxResult resetPwdSave(SysUser user) {
{
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
user.setSalt(ShiroUtils.randomSalt()); user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
if (userService.resetUserPwd(user) > 0) if (userService.resetUserPwd(user) > 0) {
{ if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue()) {
if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue())
{
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId())); ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
} }
return success(); return success();
} }
return error(); return error();
} }
/** /**
* 进入授权角色页 * 进入授权角色页
*/ */
@GetMapping("/authRole/{userId}") @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); SysUser user = userService.selectUserById(userId);
// 获取用户所属的角色列表 // 获取用户所属的角色列表
List<SysRole> roles = roleService.selectRolesByUserId(userId); List<SysRole> roles = roleService.selectRolesByUserId(userId);
@ -220,7 +197,7 @@ public class SysUserController extends BaseController
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return prefix + "/authRole"; return prefix + "/authRole";
} }
/** /**
* 用户授权角色 * 用户授权角色
*/ */
@ -228,51 +205,46 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.GRANT) @Log(title = "用户管理", businessType = BusinessType.GRANT)
@PostMapping("/authRole/insertAuthRole") @PostMapping("/authRole/insertAuthRole")
@ResponseBody @ResponseBody
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
{
userService.insertUserAuth(userId, roleIds); userService.insertUserAuth(userId, roleIds);
return success(); return success();
} }
@RequiresPermissions("system:user:remove") @RequiresPermissions("system:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE) @Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(userService.deleteUserByIds(ids)); return toAjax(userService.deleteUserByIds(ids));
} }
/** /**
* 校验用户名 * 校验用户名
*/ */
@PostMapping("/checkLoginNameUnique") @PostMapping("/checkLoginNameUnique")
@ResponseBody @ResponseBody
public String checkLoginNameUnique(SysUser user) public String checkLoginNameUnique(SysUser user) {
{
return userService.checkLoginNameUnique(user.getLoginName()); return userService.checkLoginNameUnique(user.getLoginName());
} }
/** /**
* 校验手机号码 * 校验手机号码
*/ */
@PostMapping("/checkPhoneUnique") @PostMapping("/checkPhoneUnique")
@ResponseBody @ResponseBody
public String checkPhoneUnique(SysUser user) public String checkPhoneUnique(SysUser user) {
{
return userService.checkPhoneUnique(user); return userService.checkPhoneUnique(user);
} }
/** /**
* 校验email邮箱 * 校验email邮箱
*/ */
@PostMapping("/checkEmailUnique") @PostMapping("/checkEmailUnique")
@ResponseBody @ResponseBody
public String checkEmailUnique(SysUser user) public String checkEmailUnique(SysUser user) {
{
return userService.checkEmailUnique(user); return userService.checkEmailUnique(user);
} }
/** /**
* 用户状态修改 * 用户状态修改
*/ */
@ -280,8 +252,7 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:edit") @RequiresPermissions("system:user:edit")
@PostMapping("/changeStatus") @PostMapping("/changeStatus")
@ResponseBody @ResponseBody
public AjaxResult changeStatus(SysUser user) public AjaxResult changeStatus(SysUser user) {
{
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
return toAjax(userService.changeStatus(user)); return toAjax(userService.changeStatus(user));
} }

View File

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

View File

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

View File

@ -1,175 +1,143 @@
package com.ruoyi.web.controller.tool; 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.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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 用户测试方法 * swagger 用户测试方法
* *
* @author ruoyi * @author ruoyi
*/ */
@Api("用户信息管理") @Api("用户信息管理")
@RestController @RestController
@RequestMapping("/test/user") @RequestMapping("/test/user")
public class TestController extends BaseController public class TestController extends BaseController {
{
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>(); private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{ {
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888")); users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666")); users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
} }
@ApiOperation("获取用户列表") @ApiOperation("获取用户列表")
@GetMapping("/list") @GetMapping("/list")
public AjaxResult userList() public AjaxResult userList() {
{
List<UserEntity> userList = new ArrayList<UserEntity>(users.values()); List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return AjaxResult.success(userList); return AjaxResult.success(userList);
} }
@ApiOperation("获取用户详细") @ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@GetMapping("/{userId}") @GetMapping("/{userId}")
public AjaxResult getUser(@PathVariable Integer userId) public AjaxResult getUser(@PathVariable Integer userId) {
{ if (!users.isEmpty() && users.containsKey(userId)) {
if (!users.isEmpty() && users.containsKey(userId))
{
return AjaxResult.success(users.get(userId)); return AjaxResult.success(users.get(userId));
} }
else else {
{
return error("用户不存在"); return error("用户不存在");
} }
} }
@ApiOperation("新增用户") @ApiOperation("新增用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PostMapping("/save") @PostMapping("/save")
public AjaxResult save(UserEntity user) public AjaxResult save(UserEntity user) {
{ if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return error("用户ID不能为空"); return error("用户ID不能为空");
} }
return AjaxResult.success(users.put(user.getUserId(), user)); return AjaxResult.success(users.put(user.getUserId(), user));
} }
@ApiOperation("更新用户") @ApiOperation("更新用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PutMapping("/update") @PutMapping("/update")
public AjaxResult update(UserEntity user) public AjaxResult update(UserEntity user) {
{ if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return error("用户ID不能为空"); return error("用户ID不能为空");
} }
if (users.isEmpty() || !users.containsKey(user.getUserId())) if (users.isEmpty() || !users.containsKey(user.getUserId())) {
{
return error("用户不存在"); return error("用户不存在");
} }
users.remove(user.getUserId()); users.remove(user.getUserId());
return AjaxResult.success(users.put(user.getUserId(), user)); return AjaxResult.success(users.put(user.getUserId(), user));
} }
@ApiOperation("删除用户信息") @ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@DeleteMapping("/{userId}") @DeleteMapping("/{userId}")
public AjaxResult delete(@PathVariable Integer userId) public AjaxResult delete(@PathVariable Integer userId) {
{ if (!users.isEmpty() && users.containsKey(userId)) {
if (!users.isEmpty() && users.containsKey(userId))
{
users.remove(userId); users.remove(userId);
return success(); return success();
} }
else else {
{
return error("用户不存在"); return error("用户不存在");
} }
} }
} }
@ApiModel("用户实体") @ApiModel("用户实体")
class UserEntity class UserEntity {
{
@ApiModelProperty("用户ID") @ApiModelProperty("用户ID")
private Integer userId; private Integer userId;
@ApiModelProperty("用户名称") @ApiModelProperty("用户名称")
private String username; private String username;
@ApiModelProperty("用户密码") @ApiModelProperty("用户密码")
private String password; private String password;
@ApiModelProperty("用户手机") @ApiModelProperty("用户手机")
private String mobile; 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.userId = userId;
this.username = username; this.username = username;
this.password = password; this.password = password;
this.mobile = mobile; this.mobile = mobile;
} }
public Integer getUserId() public Integer getUserId() {
{
return userId; return userId;
} }
public void setUserId(Integer userId) public void setUserId(Integer userId) {
{
this.userId = userId; this.userId = userId;
} }
public String getUsername() public String getUsername() {
{
return username; return username;
} }
public void setUsername(String username) public void setUsername(String username) {
{
this.username = username; this.username = username;
} }
public String getPassword() public String getPassword() {
{
return password; return password;
} }
public void setPassword(String password) public void setPassword(String password) {
{
this.password = password; this.password = password;
} }
public String getMobile() public String getMobile() {
{
return mobile; return mobile;
} }
public void setMobile(String mobile) public void setMobile(String mobile) {
{
this.mobile = mobile; this.mobile = mobile;
} }
} }

View File

@ -1,10 +1,10 @@
package com.ruoyi.web.core.config; 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.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
@ -16,14 +16,16 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
/** /**
* Swagger2的接口配置 * Swagger2的接口配置
* *
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
@EnableSwagger2 @EnableSwagger2
public class SwaggerConfig public class SwaggerConfig {
{
/** 是否开启swagger */ /**
* 是否开启swagger
*/
@Value("${swagger.enabled}") @Value("${swagger.enabled}")
private boolean enabled; private boolean enabled;
@ -31,8 +33,7 @@ public class SwaggerConfig
* 创建API * 创建API
*/ */
@Bean @Bean
public Docket createRestApi() public Docket createRestApi() {
{
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
// 是否启用Swagger // 是否启用Swagger
.enable(enabled) .enable(enabled)
@ -48,12 +49,11 @@ public class SwaggerConfig
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build(); .build();
} }
/** /**
* 添加摘要信息 * 添加摘要信息
*/ */
private ApiInfo apiInfo() private ApiInfo apiInfo() {
{
// 用ApiInfoBuilder进行定制 // 用ApiInfoBuilder进行定制
return new ApiInfoBuilder() return new ApiInfoBuilder()
// 设置标题 // 设置标题

View File

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

View File

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

View File

@ -6,7 +6,7 @@
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/> <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs"/> <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" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

View File

@ -4,25 +4,27 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RuoYi - 403</title> <title>RuoYi - 403</title>
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/> <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{/css/animate.css}" rel="stylesheet"/> <link th:href="@{/css/animate.css}" rel="stylesheet"/>
<link th:href="@{/css/style.css}" rel="stylesheet"/> <link th:href="@{/css/style.css}" rel="stylesheet"/>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div class="middle-box text-center animated fadeInDown"> <div class="middle-box text-center animated fadeInDown">
<h1>403</h1> <h1>403</h1>
<h3 class="font-bold">您没有访问权限!</h3> <h3 class="font-bold">您没有访问权限!</h3>
<div class="error-desc"> <div class="error-desc">
对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面 对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面
<a href="javascript:index()" class="btn btn-outline btn-primary btn-xs">返回主页</a> <a href="javascript:index()" class="btn btn-outline btn-primary btn-xs">返回主页</a>
</div>
</div> </div>
<script th:inline="javascript"> </div>
var ctx = [[@{/}]];
function index() { <script th:inline="javascript">
window.top.location = ctx + "index"; var ctx = [[@{/}]];
} function index() {
</script> window.top.location = ctx + "index";
}
</script>
</body> </body>
</html> </html>

View File

@ -1,44 +1,44 @@
<!-- 通用CSS --> <!-- 通用CSS -->
<head th:fragment=header(title)> <head th:fragment=header(title)>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="keywords" content=""> <meta name="keywords" content="">
<meta name="description" content=""> <meta name="description" content="">
<title th:text="${title}"></title> <title th:text="${title}"></title>
<link rel="shortcut icon" href="favicon.ico"> <link rel="shortcut icon" href="favicon.ico">
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/> <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/> <link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
<!-- bootstrap-table 表格插件样式 --> <!-- bootstrap-table 表格插件样式 -->
<link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20210202}" rel="stylesheet"/> <link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20210202}" rel="stylesheet"/>
<link th:href="@{/css/animate.css}" rel="stylesheet"/> <link th:href="@{/css/animate.css}" rel="stylesheet"/>
<link th:href="@{/css/style.css?v=20200903}" rel="stylesheet"/> <link th:href="@{/css/style.css?v=20200903}" rel="stylesheet"/>
<link th:href="@{/ruoyi/css/ry-ui.css?v=4.6.0}" rel="stylesheet"/> <link th:href="@{/ruoyi/css/ry-ui.css?v=4.6.0}" rel="stylesheet"/>
</head> </head>
<!-- 通用JS --> <!-- 通用JS -->
<div th:fragment="footer"> <div th:fragment="footer">
<script th:inline="javascript"> var ctx = [[@{/}]]; var lockscreen = [[${session.lockscreen}]]; if(lockscreen){window.top.location=ctx+"lockscreen";} </script> <script th:inline="javascript"> var ctx = [[@{/}]]; var lockscreen = [[${session.lockscreen}]]; if(lockscreen){window.top.location=ctx+"lockscreen";} </script>
<a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a> <a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
<script th:src="@{/js/jquery.min.js}"></script> <script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script> <script th:src="@{/js/bootstrap.min.js}"></script>
<!-- bootstrap-table 表格插件 --> <!-- bootstrap-table 表格插件 -->
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20210202}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20210202}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js?v=20210202}"></script>
<!-- jquery-validate 表单验证插件 --> <!-- jquery-validate 表单验证插件 -->
<script th:src="@{/ajax/libs/validate/jquery.validate.min.js}"></script> <script th:src="@{/ajax/libs/validate/jquery.validate.min.js}"></script>
<script th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script> <script th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script>
<script th:src="@{/ajax/libs/validate/jquery.validate.extend.js}"></script> <script th:src="@{/ajax/libs/validate/jquery.validate.extend.js}"></script>
<!-- jquery-validate 表单树插件 --> <!-- jquery-validate 表单树插件 -->
<script th:src="@{/ajax/libs/bootstrap-treetable/bootstrap-treetable.js}"></script> <script th:src="@{/ajax/libs/bootstrap-treetable/bootstrap-treetable.js}"></script>
<!-- 遮罩层 --> <!-- 遮罩层 -->
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script> <script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script> <script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script> <script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ajax/libs/layui/layui.js}"></script> <script th:src="@{/ajax/libs/layui/layui.js}"></script>
<script th:src="@{/ruoyi/js/common.js?v=4.6.0}"></script> <script th:src="@{/ruoyi/js/common.js?v=4.6.0}"></script>
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.6.0}"></script> <script th:src="@{/ruoyi/js/ry-ui.js?v=4.6.0}"></script>
</div> </div>
<!-- ztree树插件 --> <!-- ztree树插件 -->
@ -85,11 +85,11 @@
<!-- summernote富文本编辑器插件 --> <!-- summernote富文本编辑器插件 -->
<div th:fragment="summernote-css"> <div th:fragment="summernote-css">
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/> <link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/> <link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>
</div> </div>
<div th:fragment="summernote-js"> <div th:fragment="summernote-js">
<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script> <script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script> <script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>
</div> </div>
<!-- cropper图像裁剪插件 --> <!-- cropper图像裁剪插件 -->
@ -172,13 +172,13 @@
<!-- 表格拖拽插件 --> <!-- 表格拖拽插件 -->
<div th:fragment="bootstrap-table-reorder-js"> <div th:fragment="bootstrap-table-reorder-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder/bootstrap-table-reorder.js}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder/bootstrap-table-reorder.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js}"></script>
</div> </div>
<!-- 表格列宽拖动插件 --> <!-- 表格列宽拖动插件 -->
<div th:fragment="bootstrap-table-resizable-js"> <div th:fragment="bootstrap-table-resizable-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/jquery.resizableColumns.min.js}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/jquery.resizableColumns.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.min.js?v=20210202}"></script>
</div> </div>
@ -187,27 +187,27 @@
<link th:href="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.css}" rel="stylesheet"/> <link th:href="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.css}" rel="stylesheet"/>
</div> </div>
<div th:fragment="bootstrap-table-editable-js"> <div th:fragment="bootstrap-table-editable-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.min.js}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js?v=20210202}"></script>
</div> </div>
<!-- 表格导出插件 --> <!-- 表格导出插件 -->
<div th:fragment="bootstrap-table-export-js"> <div th:fragment="bootstrap-table-export-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/export/tableExport.js}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/export/tableExport.js}"></script>
</div> </div>
<!-- 表格冻结列插件 --> <!-- 表格冻结列插件 -->
<div th:fragment="bootstrap-table-fixed-columns-js"> <div th:fragment="bootstrap-table-fixed-columns-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.min.js?v=20210202}"></script>
</div> </div>
<!-- 表格自动刷新插件 --> <!-- 表格自动刷新插件 -->
<div th:fragment="bootstrap-table-auto-refresh-js"> <div th:fragment="bootstrap-table-auto-refresh-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.min.js?v=20210202}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.min.js?v=20210202}"></script>
</div> </div>
<!-- 表格打印插件 --> <!-- 表格打印插件 -->
<div th:fragment="bootstrap-table-print-js"> <div th:fragment="bootstrap-table-print-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/print/bootstrap-table-print.min.js?v=20200729}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/print/bootstrap-table-print.min.js?v=20200729}"></script>
</div> </div>

View File

@ -1,12 +1,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"> <html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<title>若依系统首页</title> <title>若依系统首页</title>
<!-- 避免IE使用兼容模式 --> <!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link th:href="@{favicon.ico}" rel="shortcut icon"/> <link th:href="@{favicon.ico}" rel="shortcut icon"/>
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/> <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{/css/jquery.contextMenu.min.css}" rel="stylesheet"/> <link th:href="@{/css/jquery.contextMenu.min.css}" rel="stylesheet"/>
@ -18,7 +18,7 @@
</head> </head>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden"> <body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden">
<div id="wrapper"> <div id="wrapper">
<!--左侧导航开始--> <!--左侧导航开始-->
<nav class="navbar-default navbar-static-side" role="navigation"> <nav class="navbar-default navbar-static-side" role="navigation">
<div class="nav-close"> <div class="nav-close">
@ -28,198 +28,223 @@
<li class="logo hidden-xs"> <li class="logo hidden-xs">
<span class="logo-lg">RuoYi</span> <span class="logo-lg">RuoYi</span>
</li> </li>
</a> </a>
<div class="sidebar-collapse"> <div class="sidebar-collapse">
<ul class="nav" id="side-menu"> <ul class="nav" id="side-menu">
<li>
<div class="user-panel">
<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">
</div>
</a>
<div class="pull-left info">
<p>[[${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>
</div>
</div>
</li>
<li> <li>
<a class="menuItem" th:href="@{/system/main}"><i class="fa fa-home"></i> <span class="nav-label">首页</span> </a> <div class="user-panel">
<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">
</div>
</a>
<div class="pull-left info">
<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>
</div>
</div>
</li>
<li>
<a class="menuItem" th:href="@{/system/main}"><i class="fa fa-home"></i> <span
class="nav-label">首页</span> </a>
</li> </li>
<li th:each="menu : ${menus}"> <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}}"
<i class="fa fa-bar-chart-o" th:class="${menu.icon}"></i> th:href="@{${#strings.isEmpty(menu.url)} ? |#| : ${menu.url}}"
<span class="nav-label" th:text="${menu.menuName}">一级菜单</span> th:data-refresh="${menu.isRefresh == '0'}">
<span th:class="${#strings.isEmpty(menu.url) || menu.url == '#'} ? |fa arrow|"></span> <i class="fa fa-bar-chart-o" th:class="${menu.icon}"></i>
</a> <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"> <ul class="nav nav-second-level collapse">
<li th:each="cmenu : ${menu.children}"> <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="${#lists.isEmpty(cmenu.children)}"
<a th:if="${not #lists.isEmpty(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span class="fa arrow"></span></a> th:class="${#strings.isEmpty(cmenu.target)} ? |menuItem| : ${cmenu.target}"
<ul th:if="${not #lists.isEmpty(cmenu.children)}" class="nav nav-third-level"> th:utext="${cmenu.menuName}" th:href="@{${cmenu.url}}"
<li th:each="emenu : ${cmenu.children}"> th:data-refresh="${cmenu.isRefresh == '0'}">二级菜单</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(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span
<a th:if="${not #lists.isEmpty(emenu.children)}" href="#">[[${emenu.menuName}]]<span class="fa arrow"></span></a> class="fa arrow"></span></a>
<ul th:if="${not #lists.isEmpty(emenu.children)}" class="nav nav-four-level"> <ul th:if="${not #lists.isEmpty(cmenu.children)}" class="nav nav-third-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="emenu : ${cmenu.children}">
</ul> <a th:if="${#lists.isEmpty(emenu.children)}"
</li> th:class="${#strings.isEmpty(emenu.target)} ? |menuItem| : ${emenu.target}"
</ul> th:text="${emenu.menuName}" th:href="@{${emenu.url}}"
</li> th:data-refresh="${emenu.isRefresh == '0'}">三级菜单</a>
</ul> <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>
</ul>
</li>
</ul>
</li>
</ul>
</li> </li>
<li th:if="${demoEnabled}"> <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"> <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"> <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/button}">按钮</a></li>
<li><a class="menuItem" th:href="@{/demo/form/grid}">栅格</a></li> <li><a class="menuItem" th:href="@{/demo/form/grid}">栅格</a></li>
<li><a class="menuItem" th:href="@{/demo/form/select}">下拉框</a></li> <li><a class="menuItem" th:href="@{/demo/form/select}">下拉框</a></li>
<li><a class="menuItem" th:href="@{/demo/form/timeline}">时间轴</a></li> <li><a class="menuItem" th:href="@{/demo/form/timeline}">时间轴</a></li>
<li><a class="menuItem" th:href="@{/demo/form/basic}">基本表单</a></li> <li><a class="menuItem" th:href="@{/demo/form/basic}">基本表单</a></li>
<li><a class="menuItem" th:href="@{/demo/form/cards}">卡片列表</a></li> <li><a class="menuItem" th:href="@{/demo/form/cards}">卡片列表</a></li>
<li><a class="menuItem" th:href="@{/demo/form/jasny}">功能扩展</a></li> <li><a class="menuItem" th:href="@{/demo/form/jasny}">功能扩展</a></li>
<li><a class="menuItem" th:href="@{/demo/form/sortable}">拖动排序</a></li> <li><a class="menuItem" th:href="@{/demo/form/sortable}">拖动排序</a></li>
<li><a class="menuItem" th:href="@{/demo/form/invoice}">单据打印</a></li> <li><a class="menuItem" th:href="@{/demo/form/invoice}">单据打印</a></li>
<li><a class="menuItem" th:href="@{/demo/form/labels_tips}">标签 & 提示</a></li> <li><a class="menuItem" th:href="@{/demo/form/labels_tips}">标签 & 提示</a></li>
<li><a class="menuItem" th:href="@{/demo/form/tabs_panels}">选项卡 & 面板</a></li> <li><a class="menuItem" th:href="@{/demo/form/tabs_panels}">选项卡 & 面板</a></li>
<li><a class="menuItem" th:href="@{/demo/form/validate}">表单校验</a></li> <li><a class="menuItem" th:href="@{/demo/form/validate}">表单校验</a></li>
<li><a class="menuItem" th:href="@{/demo/form/wizard}">表单向导</a></li> <li><a class="menuItem" th:href="@{/demo/form/wizard}">表单向导</a></li>
<li><a class="menuItem" th:href="@{/demo/form/upload}">文件上传</a></li> <li><a class="menuItem" th:href="@{/demo/form/upload}">文件上传</a></li>
<li><a class="menuItem" th:href="@{/demo/form/datetime}">日期和时间</a></li> <li><a class="menuItem" th:href="@{/demo/form/datetime}">日期和时间</a></li>
<li><a class="menuItem" th:href="@{/demo/form/summernote}">富文本编辑器</a></li> <li><a class="menuItem" th:href="@{/demo/form/summernote}">富文本编辑器</a></li>
<li><a class="menuItem" th:href="@{/demo/form/duallistbox}">左右互选组件</a></li> <li><a class="menuItem" th:href="@{/demo/form/duallistbox}">左右互选组件</a></li>
<li><a class="menuItem" th:href="@{/demo/form/autocomplete}">搜索自动补全</a></li> <li><a class="menuItem" th:href="@{/demo/form/autocomplete}">搜索自动补全</a></li>
<li><a class="menuItem" th:href="@{/demo/form/cxselect}">多级联动下拉</a></li> <li><a class="menuItem" th:href="@{/demo/form/cxselect}">多级联动下拉</a></li>
<li><a class="menuItem" th:href="@{/demo/form/localrefresh}">Ajax局部刷新</a></li> <li><a class="menuItem" th:href="@{/demo/form/localrefresh}">Ajax局部刷新</a></li>
</ul> </ul>
</li> </li>
<li> <a>表格<span class="fa arrow"></span></a> <li><a>表格<span class="fa arrow"></span></a>
<ul class="nav nav-third-level"> <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/search}">查询条件</a></li>
<li><a class="menuItem" th:href="@{/demo/table/footer}">数据汇总</a></li> <li><a class="menuItem" th:href="@{/demo/table/footer}">数据汇总</a></li>
<li><a class="menuItem" th:href="@{/demo/table/groupHeader}">组合表头</a></li> <li><a class="menuItem" th:href="@{/demo/table/groupHeader}">组合表头</a></li>
<li><a class="menuItem" th:href="@{/demo/table/export}">表格导出</a></li> <li><a class="menuItem" th:href="@{/demo/table/export}">表格导出</a></li>
<li><a class="menuItem" th:href="@{/demo/table/remember}">翻页记住选择</a></li> <li><a class="menuItem" th:href="@{/demo/table/remember}">翻页记住选择</a></li>
<li><a class="menuItem" th:href="@{/demo/table/pageGo}">跳转至指定页</a></li> <li><a class="menuItem" th:href="@{/demo/table/pageGo}">跳转至指定页</a></li>
<li><a class="menuItem" th:href="@{/demo/table/params}">自定义查询参数</a></li> <li><a class="menuItem" th:href="@{/demo/table/params}">自定义查询参数</a></li>
<li><a class="menuItem" th:href="@{/demo/table/multi}">初始多表格</a></li> <li><a class="menuItem" th:href="@{/demo/table/multi}">初始多表格</a></li>
<li><a class="menuItem" th:href="@{/demo/table/button}">点击按钮加载表格</a></li> <li><a class="menuItem" th:href="@{/demo/table/button}">点击按钮加载表格</a></li>
<li><a class="menuItem" th:href="@{/demo/table/data}">直接加载表格数据</a></li> <li><a class="menuItem" th:href="@{/demo/table/data}">直接加载表格数据</a></li>
<li><a class="menuItem" th:href="@{/demo/table/fixedColumns}">表格冻结列</a></li> <li><a class="menuItem" th:href="@{/demo/table/fixedColumns}">表格冻结列</a></li>
<li><a class="menuItem" th:href="@{/demo/table/event}">自定义触发事件</a></li> <li><a class="menuItem" th:href="@{/demo/table/event}">自定义触发事件</a></li>
<li><a class="menuItem" th:href="@{/demo/table/headerStyle}">表格标题格式化</a></li> <li><a class="menuItem" th:href="@{/demo/table/headerStyle}">表格标题格式化</a></li>
<li><a class="menuItem" th:href="@{/demo/table/detail}">表格细节视图</a></li> <li><a class="menuItem" th:href="@{/demo/table/detail}">表格细节视图</a></li>
<li><a class="menuItem" th:href="@{/demo/table/child}">表格父子视图</a></li> <li><a class="menuItem" th:href="@{/demo/table/child}">表格父子视图</a></li>
<li><a class="menuItem" th:href="@{/demo/table/image}">表格图片预览</a></li> <li><a class="menuItem" th:href="@{/demo/table/image}">表格图片预览</a></li>
<li><a class="menuItem" th:href="@{/demo/table/curd}">动态增删改查</a></li> <li><a class="menuItem" th:href="@{/demo/table/curd}">动态增删改查</a></li>
<li><a class="menuItem" th:href="@{/demo/table/reorder}">表格拖拽操作</a></li> <li><a class="menuItem" th:href="@{/demo/table/reorder}">表格拖拽操作</a></li>
<li><a class="menuItem" th:href="@{/demo/table/resizable}">表格列宽拖动</a></li> <li><a class="menuItem" th:href="@{/demo/table/resizable}">表格列宽拖动</a></li>
<li><a class="menuItem" th:href="@{/demo/table/editable}">表格行内编辑</a></li> <li><a class="menuItem" th:href="@{/demo/table/editable}">表格行内编辑</a></li>
<li><a class="menuItem" th:href="@{/demo/table/subdata}">主子表提交</a></li> <li><a class="menuItem" th:href="@{/demo/table/subdata}">主子表提交</a></li>
<li><a class="menuItem" th:href="@{/demo/table/refresh}">表格自动刷新</a></li> <li><a class="menuItem" th:href="@{/demo/table/refresh}">表格自动刷新</a></li>
<li><a class="menuItem" th:href="@{/demo/table/print}">表格打印配置</a></li> <li><a class="menuItem" th:href="@{/demo/table/print}">表格打印配置</a></li>
<li><a class="menuItem" th:href="@{/demo/table/dynamicColumns}">表格动态列</a></li> <li><a class="menuItem" th:href="@{/demo/table/dynamicColumns}">表格动态列</a></li>
<li><a class="menuItem" th:href="@{/demo/table/other}">表格其他操作</a></li> <li><a class="menuItem" th:href="@{/demo/table/other}">表格其他操作</a></li>
</ul> </ul>
</li> </li>
<li> <a>弹框<span class="fa arrow"></span></a> <li><a>弹框<span class="fa arrow"></span></a>
<ul class="nav nav-third-level"> <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/dialog}">模态窗口</a></li>
<li><a class="menuItem" th:href="@{/demo/modal/layer}">弹层组件</a></li> <li><a class="menuItem" th:href="@{/demo/modal/layer}">弹层组件</a></li>
<li><a class="menuItem" th:href="@{/demo/modal/table}">弹层表格</a></li> <li><a class="menuItem" th:href="@{/demo/modal/table}">弹层表格</a></li>
</ul> </ul>
</li> </li>
<li> <a>操作<span class="fa arrow"></span></a> <li><a>操作<span class="fa arrow"></span></a>
<ul class="nav nav-third-level"> <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/table}">表格</a></li>
<li><a class="menuItem" th:href="@{/demo/operate/other}">其他</a></li> <li><a class="menuItem" th:href="@{/demo/operate/other}">其他</a></li>
</ul> </ul>
</li> </li>
<li> <a>报表<span class="fa arrow"></span></a> <li><a>报表<span class="fa arrow"></span></a>
<ul class="nav nav-third-level"> <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/echarts}">百度ECharts</a></li>
<li><a class="menuItem" th:href="@{/demo/report/peity}">peity</a></li> <li><a class="menuItem" th:href="@{/demo/report/peity}">peity</a></li>
<li><a class="menuItem" th:href="@{/demo/report/sparkline}">sparkline</a></li> <li><a class="menuItem" th:href="@{/demo/report/sparkline}">sparkline</a></li>
<li><a class="menuItem" th:href="@{/demo/report/metrics}">图表组合</a></li> <li><a class="menuItem" th:href="@{/demo/report/metrics}">图表组合</a></li>
</ul> </ul>
</li> </li>
<li> <a>图标<span class="fa arrow"></span></a> <li><a>图标<span class="fa arrow"></span></a>
<ul class="nav nav-third-level"> <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/fontawesome}">Font Awesome</a></li>
<li><a class="menuItem" th:href="@{/demo/icon/glyphicons}">Glyphicons</a></li> <li><a class="menuItem" th:href="@{/demo/icon/glyphicons}">Glyphicons</a></li>
</ul> </ul>
</li> </li>
<li> <li>
<a href="#"><i class="fa fa-sitemap"></i>四层菜单<span class="fa arrow"></span></a> <a href="#"><i class="fa fa-sitemap"></i>四层菜单<span class="fa arrow"></span></a>
<ul class="nav nav-third-level collapse"> <ul class="nav nav-third-level collapse">
<li> <li>
<a href="#" id="damian">三级菜单1<span class="fa arrow"></span></a> <a href="#" id="damian">三级菜单1<span class="fa arrow"></span></a>
<ul class="nav nav-third-level"> <ul class="nav nav-third-level">
<li> <li>
<a href="#">四级菜单1</a> <a href="#">四级菜单1</a>
</li> </li>
<li> <li>
<a href="#">四级菜单2</a> <a href="#">四级菜单2</a>
</li> </li>
</ul> </ul>
</li> </li>
<li><a href="#">三级菜单2</a></li> <li><a href="#">三级菜单2</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
</nav> </nav>
<!--左侧导航结束--> <!--左侧导航结束-->
<!--右侧部分开始--> <!--右侧部分开始-->
<div id="page-wrapper" class="gray-bg dashbard-1"> <div id="page-wrapper" class="gray-bg dashbard-1">
<div class="row border-bottom"> <div class="row border-bottom">
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0"> <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header"> <div class="navbar-header">
<a class="navbar-minimalize minimalize-styl-2" style="color:#FFF;" href="#" title="收起菜单"> <a class="navbar-minimalize minimalize-styl-2" style="color:#FFF;" href="#" title="收起菜单">
<i class="fa fa-bars"></i> <i class="fa fa-bars"></i>
</a> </a>
</div> </div>
<ul class="nav navbar-top-links navbar-right welcome-message"> <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="开发文档"
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="锁定屏幕" href="#" id="lockScreen"><i class="fa fa-lock"></i> 锁屏</a></li> href="http://doc.ruoyi.vip/ruoyi" target="_blank"><i class="fa fa-question-circle"></i>
<li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="全屏显示" href="#" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏</a></li> 文档</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"> <li class="dropdown user-menu">
<a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown"> <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}}"
<span class="hidden-xs">[[${#strings.defaultString(user.userName, '-')}]]</span> th:onerror="this.src='img/profile.jpg'" class="user-image">
</a> <span class="hidden-xs">[[${#strings.defaultString(user.userName, '-')}]]</span>
<ul class="dropdown-menu"> </a>
<li class="mt5"> <ul class="dropdown-menu">
<a th:href="@{/system/user/profile}" class="menuItem noactive"> <li class="mt5">
<i class="fa fa-user"></i> 个人中心</a> <a th:href="@{/system/user/profile}" class="menuItem noactive">
</li> <i class="fa fa-user"></i> 个人中心</a>
<li> </li>
<a onclick="resetPwd()"> <li>
<i class="fa fa-key"></i> 修改密码</a> <a onclick="resetPwd()">
</li> <i class="fa fa-key"></i> 修改密码</a>
<li> </li>
<a onclick="switchSkin()"> <li>
<i class="fa fa-dashboard"></i> 切换主题</a> <a onclick="switchSkin()">
</li> <i class="fa fa-dashboard"></i> 切换主题</a>
<li> </li>
<a onclick="toggleMenu()"> <li>
<i class="fa fa-toggle-off"></i> 横向菜单</a> <a onclick="toggleMenu()">
</li> <i class="fa fa-toggle-off"></i> 横向菜单</a>
<li class="divider"></li> </li>
<li> <li class="divider"></li>
<a th:href="@{logout}"> <li>
<i class="fa fa-sign-out"></i> 退出登录</a> <a th:href="@{logout}">
</li> <i class="fa fa-sign-out"></i> 退出登录</a>
</ul> </li>
</li> </ul>
</li>
</ul> </ul>
</nav> </nav>
</div> </div>
@ -237,16 +262,17 @@
</button> </button>
<a href="javascript:void(0);" class="roll-nav roll-right tabReload"><i class="fa fa-refresh"></i> 刷新</a> <a href="javascript:void(0);" class="roll-nav roll-right tabReload"><i class="fa fa-refresh"></i> 刷新</a>
</div> </div>
<a id="ax_close_max" class="ax_close_max" href="#" title="关闭全屏"> <i class="fa fa-times-circle-o"></i> </a> <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}" <iframe class="RuoYi_iframe" name="iframe0" width="100%" height="100%" th:data-id="@{/system/main}"
th:src="@{/system/main}" frameborder="0" seamless></iframe> th:src="@{/system/main}" frameborder="0" seamless></iframe>
</div> </div>
<div th:if="${ignoreFooter}" class="footer"> <div th:if="${ignoreFooter}" class="footer">
<div class="pull-right">© [[${copyrightYear}]] RuoYi Copyright </div> <div class="pull-right">© [[${copyrightYear}]] RuoYi Copyright</div>
</div> </div>
</div> </div>
<!--右侧部分结束--> <!--右侧部分结束-->
@ -264,107 +290,112 @@
<script th:src="@{/ruoyi/index.js?v=20201208}"></script> <script th:src="@{/ruoyi/index.js?v=20201208}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script> <script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<script th:inline="javascript"> <script th:inline="javascript">
window.history.forward(1); window.history.forward(1);
var ctx = [[@{/}]]; var ctx = [[@{/}]];
var lockscreen = [[${session.lockscreen}]]; var lockscreen = [[${session.lockscreen}]];
if(lockscreen){window.top.location=ctx+"lockscreen";} if (lockscreen) {
// 皮肤缓存 window.top.location = ctx + "lockscreen";
var skin = storage.get("skin"); }
// history表示去掉地址的#)否则地址以"#"形式展示 // 皮肤缓存
var mode = "history"; var skin = storage.get("skin");
// 历史访问路径缓存 // history表示去掉地址的#)否则地址以"#"形式展示
var historyPath = storage.get("historyPath"); var mode = "history";
// 是否页签与菜单联动 // 历史访问路径缓存
var isLinkage = true; var historyPath = storage.get("historyPath");
// 是否页签与菜单联动
// 本地主题优先,未设置取系统配置 var isLinkage = true;
if($.common.isNotEmpty(skin)){
$("body").addClass(skin.split('|')[0]); // 本地主题优先,未设置取系统配置
$("body").addClass(skin.split('|')[1]); if ($.common.isNotEmpty(skin)) {
} else { $("body").addClass(skin.split('|')[0]);
$("body").addClass([[${sideTheme}]]); $("body").addClass(skin.split('|')[1]);
$("body").addClass([[${skinName}]]); }
} else {
$("body").addClass([[${sideTheme}]]);
/* 用户管理-重置密码 */ $("body").addClass([[${skinName}]]);
function resetPwd() { }
var url = ctx + 'system/user/profile/resetPwd';
$.modal.open("重置密码", url, '770', '380'); /* 用户管理-重置密码 */
} function resetPwd() {
var url = ctx + 'system/user/profile/resetPwd';
/* 切换主题 */ $.modal.open("重置密码", url, '770', '380');
function switchSkin() { }
layer.open({
type : 2, /* 切换主题 */
shadeClose : true, function switchSkin() {
title : "切换主题", layer.open({
area : ["530px", "386px"], type: 2,
content : [ctx + "system/switchSkin", 'no'] shadeClose: true,
}) title: "切换主题",
} area: ["530px", "386px"],
content: [ctx + "system/switchSkin", 'no']
/* 切换菜单 */ })
function toggleMenu() { }
$.modal.confirm("确认要切换成横向菜单吗?", function() {
$.get(ctx + 'system/menuStyle/topnav', function(result) { /* 切换菜单 */
window.location.reload(); function toggleMenu() {
}); $.modal.confirm("确认要切换成横向菜单吗?", function () {
}) $.get(ctx + 'system/menuStyle/topnav', function (result) {
} window.location.reload();
});
/** 刷新时访问路径页签 */ })
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 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) { }
var url = storage.get('publicPath');
if ($.common.isNotEmpty(url)) { $(function () {
applyPath(url); if ($.common.equals("history", mode) && window.performance.navigation.type == 1) {
} var url = storage.get('publicPath');
} else { if ($.common.isNotEmpty(url)) {
var hash = location.hash; applyPath(url);
if ($.common.isNotEmpty(hash)) { }
var url = hash.substring(1, hash.length); }
applyPath(url); else {
} else { var hash = location.hash;
if($.common.equals("history", mode)) { if ($.common.isNotEmpty(hash)) {
storage.set('publicPath', ""); var url = hash.substring(1, hash.length);
} applyPath(url);
} }
} else {
if ($.common.equals("history", mode)) {
/* 初始密码提示 */ storage.set('publicPath', "");
if([[${isDefaultModifyPwd}]]) { }
layer.confirm("您的密码还是初始密码,请修改密码!", { }
icon: 0, }
title: "安全提示",
btn: ['确认' , '取消'], /* 初始密码提示 */
offset: ['30%'] if ([[${isDefaultModifyPwd}]]) {
}, function (index) { layer.confirm("您的密码还是初始密码,请修改密码!", {
resetPwd(); icon: 0,
layer.close(index); title: "安全提示",
}); btn: ['确认', '取消'],
} offset: ['30%']
}, function (index) {
/* 过期密码提示 */ resetPwd();
if([[${isPasswordExpired}]]) { layer.close(index);
layer.confirm("您的密码已过期,请尽快修改密码!", { });
icon: 0, }
title: "安全提示",
btn: ['确认' , '取消'], /* 过期密码提示 */
offset: ['30%'] if ([[${isPasswordExpired}]]) {
}, function (index) { layer.confirm("您的密码已过期,请尽快修改密码!", {
resetPwd(); icon: 0,
layer.close(index); title: "安全提示",
}); btn: ['确认', '取消'],
} offset: ['30%']
$("[data-toggle='tooltip']").tooltip(); }, function (index) {
}); resetPwd();
layer.close(index);
});
}
$("[data-toggle='tooltip']").tooltip();
});
</script> </script>
</body> </body>
</html> </html>

View File

@ -3,27 +3,108 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--360浏览器优先以webkit内核解析--> <!-- 360浏览器优先以webkit内核解析 -->
<title>锁定屏幕</title> <title>锁定屏幕</title>
<link th:href="@{favicon.ico}" rel="shortcut icon"/> <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/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"/> <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> </head>
<body class="lockscreen"> <body class="lockscreen">
<div class="lockscreen-wrapper"> <div class="lockscreen-wrapper">
<div class="lockscreen-time"></div> <div class="lockscreen-time"></div>
<div class="lockscreen-name">[[ ${user.loginName} ]] / [[${#strings.defaultString(user.userName, '-')}]]</div> <div class="lockscreen-name">[[ ${user.loginName} ]] / [[${#strings.defaultString(user.userName, '-')}]]</div>
<div class="lockscreen-item"> <div class="lockscreen-item">
<div class="lockscreen-image"> <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> </div>
<form class="lockscreen-credentials" method="post" action="#" onsubmit="return false;"> <form class="lockscreen-credentials" method="post" action="#" onsubmit="return false;">
<div class="input-group"> <div class="input-group">
<input type="password" name="password" autocomplete="off" class="form-control" placeholder="密码"> <input type="password" name="password" autocomplete="off" class="form-control" placeholder="密码">
<div class="input-group-btn"> <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>
</div> </div>
</form> </form>
@ -42,49 +123,49 @@
</body> </body>
<script th:inline="javascript"> <script th:inline="javascript">
var ctx = [[@{/}]]; var ctx = [[@{/}]];
Date.prototype.format = function(fmt) { Date.prototype.format = function (fmt) {
var o = { var o = {
"M+" : this.getMonth()+1, //月份 "M+": this.getMonth() + 1, //月份
"d+" : this.getDate(), //日 "d+": this.getDate(), //日
"h+" : this.getHours(), //小时 "h+": this.getHours(), //小时
"m+" : this.getMinutes(), //分 "m+": this.getMinutes(), //分
"s+" : this.getSeconds(), //秒 "s+": this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度 "q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S" : this.getMilliseconds() //毫秒 "S": this.getMilliseconds() //毫秒
}; };
if (/(y+)/.test(fmt)) { if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
} }
for (var k in o) { for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) { if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
} }
} }
return fmt; return fmt;
} }
$(function() { $(function () {
$('.lockscreen-time').text((new Date()).format('hh:mm:ss'));
setInterval(function() {
$('.lockscreen-time').text((new Date()).format('hh:mm:ss')); $('.lockscreen-time').text((new Date()).format('hh:mm:ss'));
}, 500); setInterval(function () {
init(); $('.lockscreen-time').text((new Date()).format('hh:mm:ss'));
animate(); }, 500);
init();
animate();
});
$(document).keydown(function (event) {
if (event.keyCode == 13) {
unlock();
}
}); });
$(document).keydown(function(event) {
if (event.keyCode == 13) {
unlock();
}
});
function unlock() { function unlock() {
var username = $("input[name='username']").val(); var username = $("input[name='username']").val();
var password = $("input[name='password']").val(); var password = $("input[name='password']").val();
if ($.common.isEmpty(password)) { if ($.common.isEmpty(password)) {
$.modal.msg("请输入密码"); $.modal.msg("请输入密码");
return; return;
} }
@ -93,14 +174,15 @@
url: ctx + "unlockscreen", url: ctx + "unlockscreen",
type: "post", type: "post",
dataType: "json", dataType: "json",
data: { password: password }, data: {password: password},
beforeSend: function() { beforeSend: function () {
index = layer.load(2, {shade: false}); index = layer.load(2, {shade: false});
}, },
success: function(result) { success: function (result) {
if (result.code == web_status.SUCCESS) { if (result.code == web_status.SUCCESS) {
location.href = ctx + 'index'; location.href = ctx + 'index';
} else { }
else {
$.modal.msg(result.msg); $.modal.msg(result.msg);
$("input[name='password']").val(""); $("input[name='password']").val("");
} }
@ -108,42 +190,46 @@
} }
}; };
$.ajax(config); $.ajax(config);
}; }
var container; var container;
var camera, scene, projector, renderer; var camera, scene, projector, renderer;
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var programFill = function(context) { var programFill = function (context) {
context.beginPath(); context.beginPath();
context.arc(0, 0, 1, 0, PI2, true); context.arc(0, 0, 1, 0, PI2, true);
context.closePath(); context.closePath();
context.fill(); context.fill();
}; };
var programStroke = function(context) { var programStroke = function (context) {
context.lineWidth = 0.05; context.lineWidth = 0.05;
context.beginPath(); context.beginPath();
context.arc(0, 0, 1, 0, PI2, true); context.arc(0, 0, 1, 0, PI2, true);
context.closePath(); context.closePath();
context.stroke(); context.stroke();
}; }
var mouse = { x: 0, y: 0 }, INTERSECTED; var mouse = {x: 0, y: 0}, INTERSECTED;
function init() { function init() {
container = document.createElement('div'); container = document.createElement('div');
container.id = 'bgc'; container.id = 'bgc';
container.style.position = 'absolute'; container.style.position = 'absolute';
container.style.zIndex = '0'; container.style.zIndex = '0';
container.style.top = '0px'; container.style.top = '0px';
$(".lockscreen-wrapper").before(container); $(".lockscreen-wrapper").before(container);
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 10000); camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.set(0, 300, 500); camera.position.set(0, 300, 500);
scene = new THREE.Scene(); scene = new THREE.Scene();
for (var i = 0; i < 100; i++) { 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.x = Math.random() * 800 - 400;
particle.position.y = Math.random() * 800 - 400; particle.position.y = Math.random() * 800 - 400;
particle.position.z = Math.random() * 800 - 400; particle.position.z = Math.random() * 800 - 400;
@ -156,49 +242,50 @@
container.appendChild(renderer.domElement); container.appendChild(renderer.domElement);
document.addEventListener('mousemove', onDocumentMouseMove, false); document.addEventListener('mousemove', onDocumentMouseMove, false);
window.addEventListener('resize', onWindowResize, false); window.addEventListener('resize', onWindowResize, false);
}; }
function onWindowResize() { function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight; camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight - 10); renderer.setSize(window.innerWidth, window.innerHeight - 10);
}; }
function onDocumentMouseMove(event) { function onDocumentMouseMove(event) {
event.preventDefault(); event.preventDefault();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1; mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
}; }
function animate() { function animate() {
requestAnimationFrame(animate); requestAnimationFrame(animate);
render(); render();
}; }
var radius = 600; var radius = 600;
var theta = 0; var theta = 0;
function render() { function render() {
theta += 0.2; theta += 0.2;
camera.position.x = radius * Math.sin(theta * Math.PI / 360); camera.position.x = radius * Math.sin(theta * Math.PI / 360);
camera.position.y = radius * Math.sin(theta * Math.PI / 360); camera.position.y = radius * Math.sin(theta * Math.PI / 360);
camera.position.z = radius * Math.cos(theta * Math.PI / 360); camera.position.z = radius * Math.cos(theta * Math.PI / 360);
camera.lookAt(scene.position); camera.lookAt(scene.position);
camera.updateMatrixWorld(); camera.updateMatrixWorld();
var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5); var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5);
projector.unprojectVector(vector, camera); projector.unprojectVector(vector, camera);
var ray = new THREE.Ray(camera.position, vector.subSelf(camera.position).normalize()); var ray = new THREE.Ray(camera.position, vector.subSelf(camera.position).normalize());
var intersects = ray.intersectObjects(scene.children); var intersects = ray.intersectObjects(scene.children);
if (intersects.length > 0) { if (intersects.length > 0) {
if (INTERSECTED != intersects[0].object) { if (INTERSECTED != intersects[0].object) {
if (INTERSECTED) INTERSECTED.material.program = programStroke; if (INTERSECTED) INTERSECTED.material.program = programStroke;
INTERSECTED = intersects[0].object; INTERSECTED = intersects[0].object;
INTERSECTED.material.program = programFill; INTERSECTED.material.program = programFill;
} }
} else { }
else {
if (INTERSECTED) INTERSECTED.material.program = programStroke; if (INTERSECTED) INTERSECTED.material.program = programStroke;
INTERSECTED = null; INTERSECTED = null;
} }

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"> <html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
@ -15,67 +15,80 @@
<!-- 避免IE使用兼容模式 --> <!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/> <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> <script>
if(window.top!==window.self){alert('未登录或登录超时。请重新登录');window.top.location=window.location}; if (window.top !== window.self) {
alert('未登录或登录超时。请重新登录');
window.top.location = window.location
}
</script> </script>
</head> </head>
<body class="signin"> <body class="signin">
<div class="signinpanel"> <div class="signinpanel">
<div class="row"> <div class="row">
<div class="col-sm-7"> <div class="col-sm-7">
<div class="signin-info"> <div class="signin-info">
<div class="logopanel m-b"> <div class="logopanel m-b">
<h1><img alt="[ 若依 ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1> <h1><img alt="[ 若依 ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>
</div>
<div class="m-b"></div>
<h4>欢迎使用 <strong>若依 后台管理系统</strong></h4>
<ul class="m-b">
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Shiro</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Thymeleaf</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Bootstrap</li>
</ul>
<strong th:if="${@config.getKey('sys.account.registerUser')}">还没有账号? <a th:href="@{/register}">立即注册&raquo;</a></strong>
</div> </div>
</div> <div class="m-b"></div>
<div class="col-sm-5"> <h4>欢迎使用 <strong>若依 后台管理系统</strong></h4>
<form id="signupForm" autocomplete="off"> <ul class="m-b">
<h4 class="no-margins">登录:</h4> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>
<p class="m-t-md">你若不离不弃,我必生死相依</p> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>
<input type="text" name="username" class="form-control uname" placeholder="用户名" value="admin" /> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Shiro</li>
<input type="password" name="password" class="form-control pword" placeholder="密码" value="admin123" /> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Thymeleaf</li>
<div class="row m-t" th:if="${captchaEnabled==true}"> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Bootstrap</li>
<div class="col-xs-6"> </ul>
<input type="text" name="validateCode" class="form-control code" placeholder="验证码" maxlength="5" /> <strong th:if="${@config.getKey('sys.account.registerUser')}">还没有账号? <a th:href="@{/register}">立即注册&raquo;</a></strong>
</div>
<div class="col-xs-6">
<a href="javascript:void(0);" title="点击更换验证码">
<img th:src="@{captcha/captchaImage(type=${captchaType})}" class="imgcode" width="85%"/>
</a>
</div>
</div>
<div class="checkbox-custom" th:classappend="${captchaEnabled==false} ? 'm-t'">
<input type="checkbox" id="rememberme" name="rememberme"> <label for="rememberme">记住我</label>
</div>
<button class="btn btn-success btn-block" id="btnSubmit" data-loading="正在验证登录,请稍后...">登录</button>
</form>
</div> </div>
</div> </div>
<div class="signup-footer"> <div class="col-sm-5">
<div class="pull-left"> <form id="signupForm" autocomplete="off">
Copyright © 2018-2021 ruoyi.vip All Rights Reserved. <br> <h4 class="no-margins">登录:</h4>
</div> <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"/>
<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"/>
</div>
<div class="col-xs-6">
<a href="javascript:void(0);" title="点击更换验证码">
<img th:src="@{captcha/captchaImage(type=${captchaType})}" class="imgcode" width="85%"/>
</a>
</div>
</div>
<div class="checkbox-custom" th:classappend="${captchaEnabled==false} ? 'm-t'">
<input type="checkbox" id="rememberme" name="rememberme"> <label for="rememberme">记住我</label>
</div>
<button class="btn btn-success btn-block" id="btnSubmit" data-loading="正在验证登录,请稍后...">登录</button>
</form>
</div> </div>
</div> </div>
<div class="signup-footer">
<div class="pull-left">
Copyright © 2018-2021 ruoyi.vip All Rights Reserved. <br>
</div>
</div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]]; var captchaType = [[${captchaType}]]; </script> <script th:inline="javascript"> var ctx = [[@{/}]]; var captchaType = [[${captchaType}]]; </script>
<!-- 全局js --> <!-- 全局js -->
<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script> <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/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/jquery.validate.min.js"
<script src="../static/ajax/libs/validate/messages_zh.min.js" th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script> 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/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/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> <script src="../static/ruoyi/js/ry-ui.js" th:src="@{/ruoyi/js/ry-ui.js?v=4.6.0}"></script>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"> <html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -12,154 +12,176 @@
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/> <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{/css/style.css}" rel="stylesheet"/> <link th:href="@{/css/style.css}" rel="stylesheet"/>
<style type="text/css"> <style type="text/css">
.list-unstyled{margin:10px;} .list-unstyled {
.full-opacity-hover{opacity:1;filter:alpha(opacity=1);border:1px solid #fff} margin: 10px;
.full-opacity-hover:hover{border:1px solid #f00;} }
</style>
.full-opacity-hover {
opacity: 1;
filter: alpha(opacity=1);
border: 1px solid #fff
}
.full-opacity-hover:hover {
border: 1px solid #f00;
}
</style>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<ul class="list-unstyled clearfix"> <ul class="list-unstyled clearfix">
<li style="float:left; width: 33.33333%; padding: 5px;"> <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"
<span style="width: 20%; float: left; height: 13px; background: #367fa9"></span> style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span> <span style="width: 20%; float: left; height: 13px; background: #367fa9"></span>
<span style="width: 20%; float: left; height: 30px; background: #2f4050"></span> <span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <span style="width: 20%; float: left; height: 30px; background: #2f4050"></span>
</a> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<p class="text-center"></p> </a>
</li> <p class="text-center"></p>
</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"> <li style="float:left; width: 33.33333%; padding: 5px;">
<span style="width: 20%; float: left; height: 13px; background: #008d4c"></span> <a href="javascript:" data-skin="skin-green|theme-dark"
<span style="width: 80%; float: left; height: 13px; background: #00a65a"></span> 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: 30px; background: #222d32"></span> <span style="width: 20%; float: left; height: 13px; background: #008d4c"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <span style="width: 80%; float: left; height: 13px; background: #00a65a"></span>
</a> <span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
<p class="text-center">绿</p> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
</li> </a>
<p class="text-center">绿</p>
<li style="float:left; width: 33.33333%; padding: 5px;"> </li>
<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> <li style="float:left; width: 33.33333%; padding: 5px;">
<span style="width: 80%; float: left; height: 13px; background: #605ca8"></span> <a href="javascript:" data-skin="skin-purple|theme-dark"
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span> style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <span style="width: 20%; float: left; height: 13px; background: #555299"></span>
</a> <span style="width: 80%; float: left; height: 13px; background: #605ca8"></span>
<p class="text-center"></p> <span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
</li> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
</a>
<li style="float:left; width: 33.33333%; padding: 5px;"> <p class="text-center"></p>
<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"> </li>
<span style="width: 20%; float: left; height: 13px; background: #dd4b39"></span>
<span style="width: 80%; float: left; height: 13px; background: #d73925"></span> <li style="float:left; width: 33.33333%; padding: 5px;">
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span> <a href="javascript:" data-skin="skin-red|theme-dark"
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
</a> <span style="width: 20%; float: left; height: 13px; background: #dd4b39"></span>
<p class="text-center"></p> <span style="width: 80%; float: left; height: 13px; background: #d73925"></span>
</li> <span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<li style="float:left; width: 33.33333%; padding: 5px;"> </a>
<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"> <p class="text-center"></p>
<span style="width: 20%; float: left; height: 13px; background: #f39c12"></span> </li>
<span style="width: 80%; float: left; height: 13px; background: #e08e0b"></span>
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span> <li style="float:left; width: 33.33333%; padding: 5px;">
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <a href="javascript:" data-skin="skin-yellow|theme-dark"
</a> style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
<p class="text-center"></p> <span style="width: 20%; float: left; height: 13px; background: #f39c12"></span>
</li> <span style="width: 80%; float: left; height: 13px; background: #e08e0b"></span>
<span style="width: 20%; float: left; height: 30px; background: #222d32"></span>
<li style="float:left; width: 33.33333%; padding: 5px;"> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<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>
<span style="width: 20%; float: left; height: 13px; background: #367fa9"></span> <p class="text-center"></p>
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span> </li>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <li style="float:left; width: 33.33333%; padding: 5px;">
</a> <a href="javascript:" data-skin="skin-blue|theme-light"
<p class="text-center">蓝灰</p> style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">
</li> <span style="width: 20%; float: left; height: 13px; background: #367fa9"></span>
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span>
<li style="float:left; width: 33.33333%; padding: 5px;"> <span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
<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: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<span style="width: 20%; float: left; height: 13px; background: #008d4c"></span> </a>
<span style="width: 80%; float: left; height: 13px; background: #00a65a"></span> <p class="text-center">蓝灰</p>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span> </li>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
</a> <li style="float:left; width: 33.33333%; padding: 5px;">
<p class="text-center">绿灰</p> <a href="javascript:" data-skin="skin-green|theme-light"
</li> 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>
<li style="float:left; width: 33.33333%; padding: 5px;"> <span style="width: 80%; float: left; height: 13px; background: #00a65a"></span>
<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: 30px; background: #f9fafc"></span>
<span style="width: 20%; float: left; height: 13px; background: #555299"></span> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<span style="width: 80%; float: left; height: 13px; background: #605ca8"></span> </a>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span> <p class="text-center">绿灰</p>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> </li>
</a>
<p class="text-center">紫灰</p> <li style="float:left; width: 33.33333%; padding: 5px;">
</li> <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">
<li style="float:left; width: 33.33333%; padding: 5px;"> <span style="width: 20%; float: left; height: 13px; background: #555299"></span>
<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: 80%; float: left; height: 13px; background: #605ca8"></span>
<span style="width: 20%; float: left; height: 13px; background: #dd4b39"></span> <span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
<span style="width: 80%; float: left; height: 13px; background: #d73925"></span> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span> </a>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <p class="text-center">紫灰</p>
</a> </li>
<p class="text-center">红灰</p>
</li> <li style="float:left; width: 33.33333%; padding: 5px;">
<a href="javascript:" data-skin="skin-red|theme-light"
<li style="float:left; width: 33.33333%; padding: 5px;"> 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: #dd4b39"></span>
<span style="width: 20%; float: left; height: 13px; background: #f39c12"></span> <span style="width: 80%; float: left; height: 13px; background: #d73925"></span>
<span style="width: 80%; float: left; height: 13px; background: #e08e0b"></span> <span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
<span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> </a>
</a> <p class="text-center">红灰</p>
<p class="text-center">黄灰</p> </li>
</li>
<li style="float:left; width: 33.33333%; padding: 5px;">
<li style="float:left; width: 33.33333%; padding: 5px;"> <a href="javascript:" data-skin="skin-yellow|theme-light"
<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"> 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: 20%; float: left; height: 13px; background: #f39c12"></span>
<span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span> <span style="width: 80%; float: left; height: 13px; background: #e08e0b"></span>
<span style="width: 20%; float: left; height: 30px; background: rgba(15,41,80,1)"></span> <span style="width: 20%; float: left; height: 30px; background: #f9fafc"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
</a> </a>
<p class="text-center">蓝浅(新)</p> <p class="text-center">黄灰</p>
</li> </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"> <li style="float:left; width: 33.33333%; padding: 5px;">
<span style="width: 20%; float: left; height: 13px; background: #008d4c"></span> <a href="javascript:" data-skin="skin-blue|theme-blue"
<span style="width: 80%; float: left; height: 13px; background: #00a65a"></span> 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: 30px; background: rgba(15,41,80,1)"></span> <span style="width: 20%; float: left; height: 13px; background: #367fa9"></span>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span> <span style="width: 80%; float: left; height: 13px; background: #3c8dbc"></span>
</a> <span style="width: 20%; float: left; height: 30px; background: rgba(15,41,80,1)"></span>
<p class="text-center">绿浅(新)</p> <span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
</li> </a>
<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">
<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>
<span style="width: 80%; float: left; height: 30px; background: #f4f5f7"></span>
</a>
<p class="text-center">绿浅(新)</p>
</li>
</ul> </ul>
</body> </body>
<script th:src="@{/js/jquery.min.js}"></script> <script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/ruoyi/js/common.js?v=4.6.0}"></script> <script th:src="@{/ruoyi/js/common.js?v=4.6.0}"></script>
<script type="text/javascript"> <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', $("[data-skin]").on('click',
function(e) { function (e) {
var skin = $(this).data('skin'); var skin = $(this).data('skin');
$.each(skins, function(i) { $.each(skins, function (i) {
parent.$("body").removeClass(skins[i]); parent.$("body").removeClass(skins[i]);
}); });
$.each(themes, function(i) { $.each(themes, function (i) {
parent.$("body").removeClass(themes[i]); parent.$("body").removeClass(themes[i]);
}); });
parent.$("body").addClass(skin.split('|')[0]); parent.$("body").addClass(skin.split('|')[0]);
parent.$("body").addClass(skin.split('|')[1]); parent.$("body").addClass(skin.split('|')[1]);
storage.set('skin', skin); storage.set('skin', skin);
}); });
</script> </script>
</html> </html>

View File

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

View File

@ -2,76 +2,76 @@ package com.ruoyi.common.constant;
/** /**
* Shiro通用常量 * Shiro通用常量
* *
* @author ruoyi * @author ruoyi
*/ */
public class ShiroConstants public class ShiroConstants {
{
/** /**
* 当前登录的用户 * 当前登录的用户
*/ */
public static final String CURRENT_USER = "currentUser"; public static final String CURRENT_USER = "currentUser";
/** /**
* 用户名字段 * 用户名字段
*/ */
public static final String CURRENT_USERNAME = "username"; public static final String CURRENT_USERNAME = "username";
/** /**
* 锁定屏幕字段 * 锁定屏幕字段
*/ */
public static final String LOCK_SCREEN = "lockscreen"; public static final String LOCK_SCREEN = "lockscreen";
/** /**
* 消息key * 消息key
*/ */
public static final String MESSAGE = "message"; public static final String MESSAGE = "message";
/** /**
* 错误key * 错误key
*/ */
public static final String ERROR = "errorMsg"; public static final String ERROR = "errorMsg";
/** /**
* 编码格式 * 编码格式
*/ */
public static final String ENCODING = "UTF-8"; public static final String ENCODING = "UTF-8";
/** /**
* 当前在线会话 * 当前在线会话
*/ */
public static final String ONLINE_SESSION = "online_session"; public static final String ONLINE_SESSION = "online_session";
/** /**
* 验证码key * 验证码key
*/ */
public static final String CURRENT_CAPTCHA = "captcha"; public static final String CURRENT_CAPTCHA = "captcha";
/** /**
* 验证码开关 * 验证码开关
*/ */
public static final String CURRENT_ENABLED = "captchaEnabled"; public static final String CURRENT_ENABLED = "captchaEnabled";
/** /**
* 验证码类型 * 验证码类型
*/ */
public static final String CURRENT_TYPE = "captchaType"; public static final String CURRENT_TYPE = "captchaType";
/** /**
* 验证码 * 验证码
*/ */
public static final String CURRENT_VALIDATECODE = "validateCode"; public static final String CURRENT_VALIDATECODE = "validateCode";
/** /**
* 验证码错误 * 验证码错误
*/ */
public static final String CAPTCHA_ERROR = "captchaError"; public static final String CAPTCHA_ERROR = "captchaError";
/** /**
* 登录记录缓存 * 登录记录缓存
*/ */
public static final String LOGINRECORDCACHE = "loginRecordCache"; public static final String LOGINRECORDCACHE = "loginRecordCache";
/** /**
* 系统活跃用户缓存 * 系统活跃用户缓存
*/ */

View File

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

View File

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

View File

@ -1,158 +1,138 @@
package com.ruoyi.common.utils; package com.ruoyi.common.utils;
import java.io.IOException; import com.ruoyi.common.core.text.Convert;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
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 * @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参数 * 获取String参数
*/ */
public static String getParameter(String name) public static String getParameter(String name) {
{
return getRequest().getParameter(name); return getRequest().getParameter(name);
} }
/** /**
* 获取String参数 * 获取String参数
*/ */
public static String getParameter(String name, String defaultValue) public static String getParameter(String name, String defaultValue) {
{
return Convert.toStr(getRequest().getParameter(name), defaultValue); return Convert.toStr(getRequest().getParameter(name), defaultValue);
} }
/** /**
* 获取Integer参数 * 获取Integer参数
*/ */
public static Integer getParameterToInt(String name) public static Integer getParameterToInt(String name) {
{
return Convert.toInt(getRequest().getParameter(name)); return Convert.toInt(getRequest().getParameter(name));
} }
/** /**
* 获取Integer参数 * 获取Integer参数
*/ */
public static Integer getParameterToInt(String name, Integer defaultValue) public static Integer getParameterToInt(String name, Integer defaultValue) {
{
return Convert.toInt(getRequest().getParameter(name), defaultValue); return Convert.toInt(getRequest().getParameter(name), defaultValue);
} }
/** /**
* 获取request * 获取request
*/ */
public static HttpServletRequest getRequest() public static HttpServletRequest getRequest() {
{
return getRequestAttributes().getRequest(); return getRequestAttributes().getRequest();
} }
/** /**
* 获取response * 获取response
*/ */
public static HttpServletResponse getResponse() public static HttpServletResponse getResponse() {
{
return getRequestAttributes().getResponse(); return getRequestAttributes().getResponse();
} }
/** /**
* 获取session * 获取session
*/ */
public static HttpSession getSession() public static HttpSession getSession() {
{
return getRequest().getSession(); return getRequest().getSession();
} }
public static ServletRequestAttributes getRequestAttributes() public static ServletRequestAttributes getRequestAttributes() {
{
RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes; return (ServletRequestAttributes) attributes;
} }
/** /**
* 将字符串渲染到客户端 * 将字符串渲染到客户端
* *
* @param response 渲染对象 * @param response 渲染对象
* @param string 待渲染的字符串 * @param string 待渲染的字符串
* @return null * @return null
*/ */
public static String renderString(HttpServletResponse response, String string) public static String renderString(HttpServletResponse response, String string) {
{ try {
try
{
response.setContentType("application/json"); response.setContentType("application/json");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.getWriter().print(string); response.getWriter().print(string);
} }
catch (IOException e) catch (IOException e) {
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
/** /**
* 是否是Ajax异步请求 * 是否是Ajax异步请求
* *
* @param request * @param request
*/ */
public static boolean isAjaxRequest(HttpServletRequest request) public static boolean isAjaxRequest(HttpServletRequest request) {
{
String accept = request.getHeader("accept"); String accept = request.getHeader("accept");
if (accept != null && accept.indexOf("application/json") != -1) if (accept != null && accept.indexOf("application/json") != -1) {
{
return true; return true;
} }
String xRequestedWith = request.getHeader("X-Requested-With"); String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
{
return true; return true;
} }
String uri = request.getRequestURI(); String uri = request.getRequestURI();
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) {
{
return true; return true;
} }
String ajax = request.getParameter("__ajax"); String ajax = request.getParameter("__ajax");
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) {
{
return true; return true;
} }
return false; return false;
} }
/** /**
* 判断User-Agent 是不是来自于手机 * 判断User-Agent 是不是来自于手机
*/ */
public static boolean checkAgentIsMobile(String ua) public static boolean checkAgentIsMobile(String ua) {
{
boolean flag = false; 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")) if (!ua.contains("Windows NT") && !ua.contains("Macintosh")) {
{ for (String item : agent) {
for (String item : agent) if (ua.contains(item)) {
{
if (ua.contains(item))
{
flag = true; flag = true;
break; break;
} }

View File

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

View File

@ -1,23 +1,24 @@
package com.ruoyi.framework.config; 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.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config; 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.*; import static com.google.code.kaptcha.Constants.*;
/** /**
* 验证码配置 * 验证码配置
* *
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
public class CaptchaConfig public class CaptchaConfig {
{
@Bean(name = "captchaProducer") @Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean() public DefaultKaptcha getKaptchaBean() {
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties(); Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yesno // 是否有边框 默认为true 我们可以自己设置yesno
@ -42,10 +43,9 @@ public class CaptchaConfig
defaultKaptcha.setConfig(config); defaultKaptcha.setConfig(config);
return defaultKaptcha; return defaultKaptcha;
} }
@Bean(name = "captchaProducerMath") @Bean(name = "captchaProducerMath")
public DefaultKaptcha getKaptchaBeanMath() public DefaultKaptcha getKaptchaBeanMath() {
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties(); Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yesno // 是否有边框 默认为true 我们可以自己设置yesno