开发代码提交

This commit is contained in:
zhengzheng 2022-03-15 20:10:26 +08:00
parent 28387c46e2
commit 5f1a33bd22
657 changed files with 95336 additions and 95336 deletions

42
pom.xml
View File

@ -3,13 +3,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi</artifactId> <artifactId>wzzt-admin</artifactId>
<version>4.7.3</version> <version>4.7.3</version>
<name>ruoyi</name> <name>wzzt-admin</name>
<url>http://www.ruoyi.vip</url> <url>http://www.wuzhen.vip</url>
<description>若依管理系统</description> <description>乌镇小程序后台管理系统</description>
<properties> <properties>
<ruoyi.version>4.7.3</ruoyi.version> <ruoyi.version>4.7.3</ruoyi.version>
@ -179,36 +179,36 @@
<!-- 定时任务--> <!-- 定时任务-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-quartz</artifactId> <artifactId>zt-quartz</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 代码生成--> <!-- 代码生成-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-generator</artifactId> <artifactId>zt-generator</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 核心模块--> <!-- 核心模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-framework</artifactId> <artifactId>zt-framework</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 系统模块--> <!-- 系统模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-system</artifactId> <artifactId>zt-system</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 通用工具--> <!-- 通用工具-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-common</artifactId> <artifactId>zt-common</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
@ -216,12 +216,12 @@
</dependencyManagement> </dependencyManagement>
<modules> <modules>
<module>ruoyi-admin</module> <module>zt-admin</module>
<module>ruoyi-framework</module> <module>zt-framework</module>
<module>ruoyi-system</module> <module>zt-system</module>
<module>ruoyi-quartz</module> <module>zt-quartz</module>
<module>ruoyi-generator</module> <module>zt-generator</module>
<module>ruoyi-common</module> <module>zt-common</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>ruoyi</artifactId> <artifactId>wzzt-admin</artifactId>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<version>4.7.3</version> <version>4.7.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging> <packaging>jar</packaging>
<artifactId>ruoyi-admin</artifactId> <artifactId>zt-admin</artifactId>
<description> <description>
web服务入口 web服务入口
@ -51,20 +51,20 @@
<!-- 核心模块--> <!-- 核心模块-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-framework</artifactId> <artifactId>zt-framework</artifactId>
</dependency> </dependency>
<!-- 定时任务--> <!-- 定时任务-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-quartz</artifactId> <artifactId>zt-generator</artifactId>
</dependency> </dependency>
<!-- 代码生成--> <!-- 代码生成-->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.wuzhen</groupId>
<artifactId>ruoyi-generator</artifactId> <artifactId>zt-generator</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -1,30 +1,30 @@
package com.ruoyi; package com.wuzhen;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/** /**
* 启动程序 * 启动程序
* *
* @author ruoyi * @author zhengzheng
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication public class ZtApplication
{ {
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(ZtApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" + System.out.println("(♥◠‿◠)ノ゙ 展厅后台管理服务启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" + " .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" + " | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" + " | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" + " |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" + " | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" + " | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" + " | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" + " | | \\ / \\ / \n" +
" ''-' `'-' `-..-' "); " ''-' `'-' `-..-' ");
} }
} }

View File

@ -1,18 +1,18 @@
package com.ruoyi; package com.wuzhen;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/** /**
* web容器中进行部署 * web容器中进行部署
* *
* @author ruoyi * @author zhengzheng
*/ */
public class RuoYiServletInitializer extends SpringBootServletInitializer public class ZtServletInitializer extends SpringBootServletInitializer
{ {
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{ {
return application.sources(RuoYiApplication.class); return application.sources(ZtApplication.class);
} }
} }

View File

@ -1,166 +1,166 @@
package com.ruoyi.web.controller.common; package com.wuzhen.web.controller.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
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.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 org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig; import com.wuzhen.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig; import com.wuzhen.common.config.ServerConfig;
import com.ruoyi.common.constant.Constants; import com.wuzhen.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils; import com.wuzhen.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils; import com.wuzhen.common.utils.file.FileUtils;
/** /**
* 通用请求处理 * 通用请求处理
* *
* @author ruoyi * @author zhengzheng
*/ */
@Controller @Controller
@RequestMapping("/common") @RequestMapping("/common")
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;
private static final String FILE_DELIMETER = ","; private static final String FILE_DELIMETER = ",";
/** /**
* 通用下载请求 * 通用下载请求
* *
* @param fileName 文件名称 * @param fileName 文件名称
* @param delete 是否删除 * @param delete 是否删除
*/ */
@GetMapping("/download") @GetMapping("/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("/upload") @PostMapping("/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();
// 上传并返回新文件名称 // 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file); String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("url", url); ajax.put("url", url);
ajax.put("fileName", fileName); ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename()); ajax.put("originalFilename", file.getOriginalFilename());
return ajax; return ajax;
} }
catch (Exception e) catch (Exception e)
{ {
return AjaxResult.error(e.getMessage()); return AjaxResult.error(e.getMessage());
} }
} }
/** /**
* 通用上传请求多个 * 通用上传请求多个
*/ */
@PostMapping("/uploads") @PostMapping("/uploads")
@ResponseBody @ResponseBody
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
{ {
try try
{ {
// 上传文件路径 // 上传文件路径
String filePath = RuoYiConfig.getUploadPath(); String filePath = RuoYiConfig.getUploadPath();
List<String> urls = new ArrayList<String>(); List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>(); List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>(); List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>(); List<String> originalFilenames = new ArrayList<String>();
for (MultipartFile file : files) for (MultipartFile file : files)
{ {
// 上传并返回新文件名称 // 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file); String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
urls.add(url); urls.add(url);
fileNames.add(fileName); fileNames.add(fileName);
newFileNames.add(FileUtils.getName(fileName)); newFileNames.add(FileUtils.getName(fileName));
originalFilenames.add(file.getOriginalFilename()); originalFilenames.add(file.getOriginalFilename());
} }
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER)); ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax; return ajax;
} }
catch (Exception e) catch (Exception e)
{ {
return AjaxResult.error(e.getMessage()); return AjaxResult.error(e.getMessage());
} }
} }
/** /**
* 本地资源通用下载 * 本地资源通用下载
*/ */
@GetMapping("/download/resource") @GetMapping("/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));
} }
// 本地资源路径 // 本地资源路径
String localPath = RuoYiConfig.getProfile(); String localPath = RuoYiConfig.getProfile();
// 数据库资源地址 // 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX); String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称 // 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
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

@ -1,98 +1,98 @@
package com.ruoyi.web.controller.demo.controller; package com.wuzhen.web.controller.demo.controller;
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;
/** /**
* 模态窗口 * 模态窗口
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 多层窗口frame1 * 多层窗口frame1
*/ */
@GetMapping("/frame1") @GetMapping("/frame1")
public String frame1() public String frame1()
{ {
return prefix + "/table/frame1"; return prefix + "/table/frame1";
} }
/** /**
* 多层窗口frame2 * 多层窗口frame2
*/ */
@GetMapping("/frame2") @GetMapping("/frame2")
public String frame2() public String frame2()
{ {
return prefix + "/table/frame2"; return prefix + "/table/frame2";
} }
} }

View File

@ -1,35 +1,35 @@
package com.ruoyi.web.controller.demo.controller; package com.wuzhen.web.controller.demo.controller;
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;
/** /**
* 图标相关 * 图标相关
* *
* @author ruoyi * @author zhengzheng
*/ */
@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,326 +1,326 @@
package com.ruoyi.web.controller.demo.controller; package com.wuzhen.web.controller.demo.controller;
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.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.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain; import com.wuzhen.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport; import com.wuzhen.common.core.page.TableSupport;
import com.ruoyi.common.core.text.Convert; import com.wuzhen.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException; import com.wuzhen.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.demo.domain.CustomerModel; import com.wuzhen.web.controller.demo.domain.CustomerModel;
import com.ruoyi.web.controller.demo.domain.UserOperateModel; import com.wuzhen.web.controller.demo.domain.UserOperateModel;
/** /**
* 操作控制 * 操作控制
* *
* @author ruoyi * @author zhengzheng
*/ */
@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"));
users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1")); users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1")); users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1")); users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1")); users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1")); users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1")); users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1")); users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1")); users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1")); users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1")); users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1")); users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1")); users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1")); users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1")); users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1")); users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1")); users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1")); users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1")); users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1")); users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1")); users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1")); users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1")); users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
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 ServiceException("导入用户数据不能为空!"); throw new ServiceException("导入用户数据不能为空!");
} }
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 ServiceException(failureMsg.toString()); throw new ServiceException(failureMsg.toString());
} }
else else
{ {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
} }
return successMsg.toString(); return successMsg.toString();
} }
} }

View File

@ -1,53 +1,53 @@
package com.ruoyi.web.controller.demo.controller; package com.wuzhen.web.controller.demo.controller;
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;
/** /**
* 报表 * 报表
* *
* @author ruoyi * @author zhengzheng
*/ */
@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,116 +1,116 @@
package com.ruoyi.web.controller.demo.domain; package com.wuzhen.web.controller.demo.domain;
import java.util.List; 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;
/** /**
* 客户测试信息 * 客户测试信息
* *
* @author ruoyi * @author zhengzheng
*/ */
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,99 +1,99 @@
package com.ruoyi.web.controller.demo.domain; package com.wuzhen.web.controller.demo.domain;
import java.util.Date; 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;
/** /**
* 商品测试信息 * 商品测试信息
* *
* @author ruoyi * @author zhengzheng
*/ */
public class GoodsModel public class GoodsModel
{ {
/** /**
* 商品名称 * 商品名称
*/ */
private String name; private String name;
/** /**
* 商品重量 * 商品重量
*/ */
private Integer weight; private Integer weight;
/** /**
* 商品价格 * 商品价格
*/ */
private Double price; private Double price;
/** /**
* 商品日期 * 商品日期
*/ */
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,149 +1,149 @@
package com.ruoyi.web.controller.demo.domain; package com.wuzhen.web.controller.demo.domain;
import java.util.Date; import java.util.Date;
import com.ruoyi.common.annotation.Excel; import com.wuzhen.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type; import com.wuzhen.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity; import com.wuzhen.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.DateUtils; import com.wuzhen.common.utils.DateUtils;
public class UserOperateModel extends BaseEntity 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;
this.userSex = userSex; this.userSex = userSex;
this.userPhone = userPhone; this.userPhone = userPhone;
this.userEmail = userEmail; this.userEmail = userEmail;
this.userBalance = userBalance; this.userBalance = userBalance;
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,90 +1,90 @@
package com.ruoyi.web.controller.monitor; package com.wuzhen.web.controller.monitor;
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;
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.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.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.CacheService; import com.wuzhen.framework.web.service.CacheService;
/** /**
* 缓存监控 * 缓存监控
* *
* @author ruoyi * @author zhengzheng
*/ */
@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;
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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";
} }
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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;
} }
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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;
} }
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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;
} }
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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();
} }
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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();
} }
@RequiresPermissions("monitor:cache:view") @RequiresPermissions("monitor:cache:view")
@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,26 @@
package com.ruoyi.web.controller.monitor; package com.wuzhen.web.controller.monitor;
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; import com.wuzhen.common.core.controller.BaseController;
/** /**
* druid 监控 * druid 监控
* *
* @author ruoyi * @author zhengzheng
*/ */
@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.html"); return redirect(prefix + "/index.html");
} }
} }

View File

@ -1,31 +1,31 @@
package com.ruoyi.web.controller.monitor; package com.wuzhen.web.controller.monitor;
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.wuzhen.common.core.controller.BaseController;
import com.ruoyi.framework.web.domain.Server; import com.wuzhen.framework.web.domain.Server;
/** /**
* 服务器监控 * 服务器监控
* *
* @author ruoyi * @author zhengzheng
*/ */
@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);
return prefix + "/server"; return prefix + "/server";
} }
} }

View File

@ -1,94 +1,94 @@
package com.ruoyi.web.controller.monitor; package com.wuzhen.web.controller.monitor;
import java.util.List; import java.util.List;
import com.ruoyi.framework.shiro.service.SysPasswordService; import com.wuzhen.framework.shiro.service.SysPasswordService;
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;
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.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.wuzhen.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysLogininfor; import com.wuzhen.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService; import com.wuzhen.system.service.ISysLogininforService;
/** /**
* 系统访问记录 * 系统访问记录
* *
* @author ruoyi * @author zhengzheng
*/ */
@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));
} }
@RequiresPermissions("monitor:logininfor:remove") @RequiresPermissions("monitor:logininfor:remove")
@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,90 +1,90 @@
package com.ruoyi.web.controller.monitor; package com.wuzhen.web.controller.monitor;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
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.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog; import com.wuzhen.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService; import com.wuzhen.system.service.ISysOperLogService;
/** /**
* 操作日志记录 * 操作日志记录
* *
* @author ruoyi * @author zhengzheng
*/ */
@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, "操作日志");
} }
@Log(title = "操作日志", businessType = BusinessType.DELETE) @Log(title = "操作日志", businessType = BusinessType.DELETE)
@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";
} }
@Log(title = "操作日志", businessType = BusinessType.CLEAN) @Log(title = "操作日志", businessType = BusinessType.CLEAN)
@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,88 +1,88 @@
package com.ruoyi.web.controller.monitor; package com.wuzhen.web.controller.monitor;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
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;
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.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.wuzhen.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert; import com.wuzhen.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.enums.OnlineStatus; import com.wuzhen.common.enums.OnlineStatus;
import com.ruoyi.common.utils.ShiroUtils; import com.wuzhen.common.utils.ShiroUtils;
import com.ruoyi.framework.shiro.session.OnlineSession; import com.wuzhen.framework.shiro.session.OnlineSession;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO; import com.wuzhen.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.system.domain.SysUserOnline; import com.wuzhen.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService; import com.wuzhen.system.service.ISysUserOnlineService;
/** /**
* 在线用户监控 * 在线用户监控
* *
* @author ruoyi * @author zhengzheng
*/ */
@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);
online.setStatus(OnlineStatus.off_line); online.setStatus(OnlineStatus.off_line);
userOnlineService.saveOnline(online); userOnlineService.saveOnline(online);
userOnlineService.removeUserCache(online.getLoginName(), sessionId); userOnlineService.removeUserCache(online.getLoginName(), sessionId);
} }
return success(); return success();
} }
} }

View File

@ -1,92 +1,92 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
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 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 org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.google.code.kaptcha.Constants; import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer; import com.google.code.kaptcha.Producer;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
/** /**
* 图片验证码支持算术形式 * 图片验证码支持算术形式
* *
* @author ruoyi * @author zhengzheng
*/ */
@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);
} }
session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code); session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code);
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();
} }
} }
return null; return null;
} }
} }

View File

@ -1,158 +1,158 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig; import com.wuzhen.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService; import com.wuzhen.system.service.ISysConfigService;
/** /**
* 参数配置 信息操作处理 * 参数配置 信息操作处理
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 新增保存参数配置 * 新增保存参数配置
*/ */
@RequiresPermissions("system:config:add") @RequiresPermissions("system:config:add")
@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(getLoginName()); config.setCreateBy(getLoginName());
return toAjax(configService.insertConfig(config)); return toAjax(configService.insertConfig(config));
} }
/** /**
* 修改参数配置 * 修改参数配置
*/ */
@RequiresPermissions("system:config:edit") @RequiresPermissions("system:config:edit")
@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";
} }
/** /**
* 修改保存参数配置 * 修改保存参数配置
*/ */
@RequiresPermissions("system:config:edit") @RequiresPermissions("system:config:edit")
@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(getLoginName()); config.setUpdateBy(getLoginName());
return toAjax(configService.updateConfig(config)); return toAjax(configService.updateConfig(config));
} }
/** /**
* 删除参数配置 * 删除参数配置
*/ */
@RequiresPermissions("system:config:remove") @RequiresPermissions("system:config: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)
{ {
configService.deleteConfigByIds(ids); configService.deleteConfigByIds(ids);
return success(); return success();
} }
/** /**
* 刷新参数缓存 * 刷新参数缓存
*/ */
@RequiresPermissions("system:config:remove") @RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.CLEAN) @Log(title = "参数管理", businessType = BusinessType.CLEAN)
@GetMapping("/refreshCache") @GetMapping("/refreshCache")
@ResponseBody @ResponseBody
public AjaxResult refreshCache() public AjaxResult refreshCache()
{ {
configService.resetConfigCache(); configService.resetConfigCache();
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,210 +1,210 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.Ztree; import com.wuzhen.common.core.domain.Ztree;
import com.ruoyi.common.core.domain.entity.SysDept; import com.wuzhen.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole; import com.wuzhen.common.core.domain.entity.SysRole;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService; import com.wuzhen.system.service.ISysDeptService;
/** /**
* 部门信息 * 部门信息
* *
* @author ruoyi * @author zhengzheng
*/ */
@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)
{ {
if (!getSysUser().isAdmin()) if (!getSysUser().isAdmin())
{ {
parentId = getSysUser().getDeptId(); parentId = getSysUser().getDeptId();
} }
mmap.put("dept", deptService.selectDeptById(parentId)); mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存部门 * 新增保存部门
*/ */
@Log(title = "部门管理", businessType = BusinessType.INSERT) @Log(title = "部门管理", businessType = BusinessType.INSERT)
@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(getLoginName()); dept.setCreateBy(getLoginName());
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
} }
/** /**
* 修改部门 * 修改部门
*/ */
@RequiresPermissions("system:dept:edit") @RequiresPermissions("system:dept:edit")
@GetMapping("/edit/{deptId}") @GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{ {
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
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";
} }
/** /**
* 修改保存部门 * 修改保存部门
*/ */
@Log(title = "部门管理", businessType = BusinessType.UPDATE) @Log(title = "部门管理", businessType = BusinessType.UPDATE)
@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)
{ {
Long deptId = dept.getDeptId(); Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
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(deptId)) else if (dept.getParentId().equals(deptId))
{ {
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} }
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{ {
return AjaxResult.error("该部门包含未停用的子部门!"); return AjaxResult.error("该部门包含未停用的子部门!");
} }
dept.setUpdateBy(getLoginName()); dept.setUpdateBy(getLoginName());
return toAjax(deptService.updateDept(dept)); return toAjax(deptService.updateDept(dept));
} }
/** /**
* 删除 * 删除
*/ */
@Log(title = "部门管理", businessType = BusinessType.DELETE) @Log(title = "部门管理", businessType = BusinessType.DELETE)
@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("部门存在用户,不允许删除");
} }
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
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.setExcludeId(excludeId); dept.setExcludeId(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,121 +1,121 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData; import com.wuzhen.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictDataService; import com.wuzhen.system.service.ISysDictDataService;
/** /**
* 数据字典信息 * 数据字典信息
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 新增保存字典类型 * 新增保存字典类型
*/ */
@Log(title = "字典数据", businessType = BusinessType.INSERT) @Log(title = "字典数据", businessType = BusinessType.INSERT)
@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(getLoginName()); dict.setCreateBy(getLoginName());
return toAjax(dictDataService.insertDictData(dict)); return toAjax(dictDataService.insertDictData(dict));
} }
/** /**
* 修改字典类型 * 修改字典类型
*/ */
@RequiresPermissions("system:dict:edit") @RequiresPermissions("system:dict:edit")
@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";
} }
/** /**
* 修改保存字典类型 * 修改保存字典类型
*/ */
@Log(title = "字典数据", businessType = BusinessType.UPDATE) @Log(title = "字典数据", businessType = BusinessType.UPDATE)
@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(getLoginName()); dict.setUpdateBy(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)
{ {
dictDataService.deleteDictDataByIds(ids); dictDataService.deleteDictDataByIds(ids);
return success(); return success();
} }
} }

View File

@ -1,189 +1,189 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.Ztree; import com.wuzhen.common.core.domain.Ztree;
import com.ruoyi.common.core.domain.entity.SysDictType; import com.wuzhen.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService; import com.wuzhen.system.service.ISysDictTypeService;
/** /**
* 数据字典信息 * 数据字典信息
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 新增保存字典类型 * 新增保存字典类型
*/ */
@Log(title = "字典类型", businessType = BusinessType.INSERT) @Log(title = "字典类型", businessType = BusinessType.INSERT)
@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(getLoginName()); dict.setCreateBy(getLoginName());
return toAjax(dictTypeService.insertDictType(dict)); return toAjax(dictTypeService.insertDictType(dict));
} }
/** /**
* 修改字典类型 * 修改字典类型
*/ */
@RequiresPermissions("system:dict:edit") @RequiresPermissions("system:dict:edit")
@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";
} }
/** /**
* 修改保存字典类型 * 修改保存字典类型
*/ */
@Log(title = "字典类型", businessType = BusinessType.UPDATE) @Log(title = "字典类型", businessType = BusinessType.UPDATE)
@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(getLoginName()); dict.setUpdateBy(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)
{ {
dictTypeService.deleteDictTypeByIds(ids); dictTypeService.deleteDictTypeByIds(ids);
return success(); return success();
} }
/** /**
* 刷新字典缓存 * 刷新字典缓存
*/ */
@RequiresPermissions("system:dict:remove") @RequiresPermissions("system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.CLEAN) @Log(title = "字典类型", businessType = BusinessType.CLEAN)
@GetMapping("/refreshCache") @GetMapping("/refreshCache")
@ResponseBody @ResponseBody
public AjaxResult refreshCache() public AjaxResult refreshCache()
{ {
dictTypeService.resetDictCache(); dictTypeService.resetDictCache();
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,178 +1,178 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
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;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.config.RuoYiConfig; import com.wuzhen.common.config.RuoYiConfig;
import com.ruoyi.common.constant.ShiroConstants; import com.wuzhen.common.constant.ShiroConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu; import com.wuzhen.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser; import com.wuzhen.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert; import com.wuzhen.common.core.text.Convert;
import com.ruoyi.common.utils.CookieUtils; import com.wuzhen.common.utils.CookieUtils;
import com.ruoyi.common.utils.DateUtils; import com.wuzhen.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils; import com.wuzhen.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService; import com.wuzhen.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysConfigService; import com.wuzhen.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysMenuService; import com.wuzhen.system.service.ISysMenuService;
/** /**
* 首页 业务处理 * 首页 业务处理
* *
* @author ruoyi * @author zhengzheng
*/ */
@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 = getSysUser(); SysUser user = getSysUser();
// 根据用户id取出菜单 // 根据用户id取出菜单
List<SysMenu> menus = menuService.selectMenusByUser(user); List<SysMenu> menus = menuService.selectMenusByUser(user);
mmap.put("menus", menus); mmap.put("menus", menus);
mmap.put("user", user); mmap.put("user", user);
mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme")); mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme"));
mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName")); mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName"));
Boolean footer = Convert.toBool(configService.selectConfigByKey("sys.index.footer"), true); Boolean footer = Convert.toBool(configService.selectConfigByKey("sys.index.footer"), true);
Boolean tagsView = Convert.toBool(configService.selectConfigByKey("sys.index.tagsView"), true); Boolean tagsView = Convert.toBool(configService.selectConfigByKey("sys.index.tagsView"), true);
mmap.put("footer", footer); mmap.put("footer", footer);
mmap.put("tagsView", tagsView); mmap.put("tagsView", tagsView);
mmap.put("mainClass", contentMainClass(footer, tagsView)); mmap.put("mainClass", contentMainClass(footer, tagsView));
mmap.put("copyrightYear", RuoYiConfig.getCopyrightYear()); mmap.put("copyrightYear", RuoYiConfig.getCopyrightYear());
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()));
mmap.put("isMobile", ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent"))); mmap.put("isMobile", ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")));
// 菜单导航显示风格 // 菜单导航显示风格
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;
} }
} }
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", getSysUser()); mmap.put("user", 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 = getSysUser(); SysUser user = 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)
{ {
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";
} }
// content-main class // content-main class
public String contentMainClass(Boolean footer, Boolean tagsView) public String contentMainClass(Boolean footer, Boolean tagsView)
{ {
if (!footer && !tagsView) if (!footer && !tagsView)
{ {
return "tagsview-footer-hide"; return "tagsview-footer-hide";
} }
else if (!footer) else if (!footer)
{ {
return "footer-hide"; return "footer-hide";
} }
else if (!tagsView) else if (!tagsView)
{ {
return "tagsview-hide"; return "tagsview-hide";
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
// 检查初始密码是否提醒修改 // 检查初始密码是否提醒修改
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;
} }
Date nowDate = DateUtils.getNowDate(); Date nowDate = DateUtils.getNowDate();
return DateUtils.differentDaysByMillisecond(nowDate, pwdUpdateDate) > passwordValidateDays; return DateUtils.differentDaysByMillisecond(nowDate, pwdUpdateDate) > passwordValidateDays;
} }
return false; return false;
} }
} }

View File

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -13,17 +13,17 @@ 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.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.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert; import com.wuzhen.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils; import com.wuzhen.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.framework.web.service.ConfigService; import com.wuzhen.framework.web.service.ConfigService;
/** /**
* 登录验证 * 登录验证
* *
* @author ruoyi * @author zhengzheng
*/ */
@Controller @Controller
public class SysLoginController extends BaseController public class SysLoginController extends BaseController

View File

@ -1,198 +1,198 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.Ztree; import com.wuzhen.common.core.domain.Ztree;
import com.ruoyi.common.core.domain.entity.SysMenu; import com.wuzhen.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysRole; import com.wuzhen.common.core.domain.entity.SysRole;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.wuzhen.common.utils.ShiroUtils;
import com.ruoyi.framework.shiro.util.AuthorizationUtils; import com.wuzhen.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.service.ISysMenuService; import com.wuzhen.system.service.ISysMenuService;
/** /**
* 菜单信息 * 菜单信息
* *
* @author ruoyi * @author zhengzheng
*/ */
@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;
} }
/** /**
* 删除菜单 * 删除菜单
*/ */
@Log(title = "菜单管理", businessType = BusinessType.DELETE) @Log(title = "菜单管理", businessType = BusinessType.DELETE)
@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("主目录");
} }
mmap.put("menu", menu); mmap.put("menu", menu);
return prefix + "/add"; return prefix + "/add";
} }
/** /**
* 新增保存菜单 * 新增保存菜单
*/ */
@Log(title = "菜单管理", businessType = BusinessType.INSERT) @Log(title = "菜单管理", businessType = BusinessType.INSERT)
@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(getLoginName()); menu.setCreateBy(getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(menuService.insertMenu(menu)); return toAjax(menuService.insertMenu(menu));
} }
/** /**
* 修改菜单 * 修改菜单
*/ */
@RequiresPermissions("system:menu:edit") @RequiresPermissions("system:menu:edit")
@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";
} }
/** /**
* 修改保存菜单 * 修改保存菜单
*/ */
@Log(title = "菜单管理", businessType = BusinessType.UPDATE) @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@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(getLoginName()); menu.setUpdateBy(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,113 +1,113 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNotice; import com.wuzhen.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService; import com.wuzhen.system.service.ISysNoticeService;
/** /**
* 公告 信息操作处理 * 公告 信息操作处理
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 新增保存公告 * 新增保存公告
*/ */
@RequiresPermissions("system:notice:add") @RequiresPermissions("system:notice:add")
@Log(title = "通知公告", businessType = BusinessType.INSERT) @Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@Validated SysNotice notice) public AjaxResult addSave(@Validated SysNotice notice)
{ {
notice.setCreateBy(getLoginName()); notice.setCreateBy(getLoginName());
return toAjax(noticeService.insertNotice(notice)); return toAjax(noticeService.insertNotice(notice));
} }
/** /**
* 修改公告 * 修改公告
*/ */
@RequiresPermissions("system:notice:edit") @RequiresPermissions("system:notice:edit")
@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";
} }
/** /**
* 修改保存公告 * 修改保存公告
*/ */
@RequiresPermissions("system:notice:edit") @RequiresPermissions("system:notice:edit")
@Log(title = "通知公告", businessType = BusinessType.UPDATE) @Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@Validated SysNotice notice) public AjaxResult editSave(@Validated SysNotice notice)
{ {
notice.setUpdateBy(getLoginName()); notice.setUpdateBy(getLoginName());
return toAjax(noticeService.updateNotice(notice)); return toAjax(noticeService.updateNotice(notice));
} }
/** /**
* 删除公告 * 删除公告
*/ */
@RequiresPermissions("system:notice:remove") @RequiresPermissions("system:notice: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(noticeService.deleteNoticeByIds(ids)); return toAjax(noticeService.deleteNoticeByIds(ids));
} }
} }

View File

@ -1,163 +1,163 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost; import com.wuzhen.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService; import com.wuzhen.system.service.ISysPostService;
/** /**
* 岗位信息操作处理 * 岗位信息操作处理
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 新增保存岗位 * 新增保存岗位
*/ */
@RequiresPermissions("system:post:add") @RequiresPermissions("system:post:add")
@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(getLoginName()); post.setCreateBy(getLoginName());
return toAjax(postService.insertPost(post)); return toAjax(postService.insertPost(post));
} }
/** /**
* 修改岗位 * 修改岗位
*/ */
@RequiresPermissions("system:post:edit") @RequiresPermissions("system:post:edit")
@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";
} }
/** /**
* 修改保存岗位 * 修改保存岗位
*/ */
@RequiresPermissions("system:post:edit") @RequiresPermissions("system:post:edit")
@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(getLoginName()); post.setUpdateBy(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,187 +1,187 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import 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.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
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.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig; import com.wuzhen.common.config.RuoYiConfig;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.wuzhen.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils; import com.wuzhen.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.wuzhen.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils; import com.wuzhen.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService; import com.wuzhen.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.service.ISysUserService; import com.wuzhen.system.service.ISysUserService;
/** /**
* 个人信息 业务处理 * 个人信息 业务处理
* *
* @author ruoyi * @author zhengzheng
*/ */
@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 = getSysUser(); SysUser user = 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 = getSysUser(); SysUser user = 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 = getSysUser(); SysUser user = 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 = getSysUser(); SysUser user = 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)
{ {
setSysUser(userService.selectUserById(user.getUserId())); 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 = getSysUser(); SysUser user = 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 = getSysUser(); SysUser user = 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 = getSysUser(); SysUser currentUser = 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 (StringUtils.isNotEmpty(user.getPhonenumber()) if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(currentUser))) && UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(currentUser)))
{ {
return error("修改用户'" + currentUser.getLoginName() + "'失败,手机号码已存在"); return error("修改用户'" + currentUser.getLoginName() + "'失败,手机号码已存在");
} }
else if (StringUtils.isNotEmpty(user.getEmail()) else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(currentUser))) && UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(currentUser)))
{ {
return error("修改用户'" + currentUser.getLoginName() + "'失败,邮箱账号已存在"); return error("修改用户'" + currentUser.getLoginName() + "'失败,邮箱账号已存在");
} }
if (userService.updateUserInfo(currentUser) > 0) if (userService.updateUserInfo(currentUser) > 0)
{ {
setSysUser(userService.selectUserById(currentUser.getUserId())); 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 = getSysUser(); SysUser currentUser = 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)
{ {
setSysUser(userService.selectUserById(currentUser.getUserId())); 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,46 +1,46 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
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.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.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.wuzhen.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.framework.shiro.service.SysRegisterService; import com.wuzhen.framework.shiro.service.SysRegisterService;
import com.ruoyi.system.service.ISysConfigService; import com.wuzhen.system.service.ISysConfigService;
/** /**
* 注册验证 * 注册验证
* *
* @author ruoyi * @author zhengzheng
*/ */
@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);
return StringUtils.isEmpty(msg) ? success() : error(msg); return StringUtils.isEmpty(msg) ? success() : error(msg);
} }
} }

View File

@ -1,306 +1,306 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole; import com.wuzhen.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.wuzhen.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.shiro.util.AuthorizationUtils; import com.wuzhen.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.domain.SysUserRole; import com.wuzhen.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService; import com.wuzhen.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.wuzhen.system.service.ISysUserService;
/** /**
* 角色信息 * 角色信息
* *
* @author ruoyi * @author zhengzheng
*/ */
@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";
} }
/** /**
* 新增保存角色 * 新增保存角色
*/ */
@RequiresPermissions("system:role:add") @RequiresPermissions("system:role:add")
@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(getLoginName()); role.setCreateBy(getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(roleService.insertRole(role)); return toAjax(roleService.insertRole(role));
} }
/** /**
* 修改角色 * 修改角色
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@GetMapping("/edit/{roleId}") @GetMapping("/edit/{roleId}")
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
{ {
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
mmap.put("role", roleService.selectRoleById(roleId)); mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/edit"; return prefix + "/edit";
} }
/** /**
* 修改保存角色 * 修改保存角色
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@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);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
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(getLoginName()); role.setUpdateBy(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";
} }
/** /**
* 保存角色分配数据权限 * 保存角色分配数据权限
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@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);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getLoginName()); role.setUpdateBy(getLoginName());
if (roleService.authDataScope(role) > 0) if (roleService.authDataScope(role) > 0)
{ {
setSysUser(userService.selectUserById(getUserId())); setSysUser(userService.selectUserById(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";
} }
/** /**
* 角色状态修改 * 角色状态修改
*/ */
@Log(title = "角色管理", businessType = BusinessType.UPDATE) @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@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);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
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);
} }
/** /**
* 取消授权 * 取消授权
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@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));
} }
/** /**
* 批量取消授权 * 批量取消授权
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@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);
} }
/** /**
* 批量选择用户授权 * 批量选择用户授权
*/ */
@RequiresPermissions("system:role:edit") @RequiresPermissions("system:role:edit")
@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)
{ {
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds)); return toAjax(roleService.insertAuthUsers(roleId, userIds));
} }
} }

View File

@ -1,302 +1,302 @@
package com.ruoyi.web.controller.system; package com.wuzhen.web.controller.system;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
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;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log; import com.wuzhen.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.wuzhen.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole; import com.wuzhen.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.wuzhen.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.wuzhen.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert; import com.wuzhen.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType; import com.wuzhen.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils; import com.wuzhen.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.wuzhen.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.shiro.service.SysPasswordService; import com.wuzhen.framework.shiro.service.SysPasswordService;
import com.ruoyi.framework.shiro.util.AuthorizationUtils; import com.wuzhen.framework.shiro.util.AuthorizationUtils;
import com.ruoyi.system.service.ISysPostService; import com.wuzhen.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService; import com.wuzhen.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.wuzhen.system.service.ISysUserService;
/** /**
* 用户信息 * 用户信息
* *
* @author ruoyi * @author zhengzheng
*/ */
@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 message = userService.importUser(userList, updateSupport, getLoginName()); String message = userService.importUser(userList, updateSupport, getLoginName());
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";
} }
/** /**
* 新增保存用户 * 新增保存用户
*/ */
@RequiresPermissions("system:user:add") @RequiresPermissions("system:user:add")
@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());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setCreateBy(getLoginName()); user.setCreateBy(getLoginName());
return toAjax(userService.insertUser(user)); return toAjax(userService.insertUser(user));
} }
/** /**
* 修改用户 * 修改用户
*/ */
@RequiresPermissions("system:user:edit") @RequiresPermissions("system:user:edit")
@GetMapping("/edit/{userId}") @GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Long userId, ModelMap mmap) public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
{ {
userService.checkUserDataScope(userId); userService.checkUserDataScope(userId);
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";
} }
/** /**
* 修改保存用户 * 修改保存用户
*/ */
@RequiresPermissions("system:user:edit") @RequiresPermissions("system:user:edit")
@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);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
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(getLoginName()); user.setUpdateBy(getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
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);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
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())
{ {
setSysUser(userService.selectUserById(user.getUserId())); 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);
mmap.put("user", user); mmap.put("user", user);
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";
} }
/** /**
* 用户授权角色 * 用户授权角色
*/ */
@RequiresPermissions("system:user:edit") @RequiresPermissions("system:user:edit")
@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.checkUserDataScope(userId); userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds); userService.insertUserAuth(userId, roleIds);
AuthorizationUtils.clearAllCachedAuthorizationInfo(); AuthorizationUtils.clearAllCachedAuthorizationInfo();
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)
{ {
if (ArrayUtils.contains(Convert.toLongArray(ids), getUserId())) if (ArrayUtils.contains(Convert.toLongArray(ids), getUserId()))
{ {
return error("当前用户不能删除"); return error("当前用户不能删除");
} }
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);
} }
/** /**
* 用户状态修改 * 用户状态修改
*/ */
@Log(title = "用户管理", businessType = BusinessType.UPDATE) @Log(title = "用户管理", businessType = BusinessType.UPDATE)
@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);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
return toAjax(userService.changeStatus(user)); return toAjax(userService.changeStatus(user));
} }
} }

View File

@ -1,26 +1,26 @@
package com.ruoyi.web.controller.tool; package com.wuzhen.web.controller.tool;
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; import com.wuzhen.common.core.controller.BaseController;
/** /**
* build 表单构建 * build 表单构建
* *
* @author ruoyi * @author zhengzheng
*/ */
@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,24 @@
package com.ruoyi.web.controller.tool; package com.wuzhen.web.controller.tool;
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; import com.wuzhen.common.core.controller.BaseController;
/** /**
* swagger 接口 * swagger 接口
* *
* @author ruoyi * @author zhengzheng
*/ */
@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/index.html"); return redirect("/swagger-ui/index.html");
} }
} }

View File

@ -1,181 +1,181 @@
package com.ruoyi.web.controller.tool; package com.wuzhen.web.controller.tool;
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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController; import com.wuzhen.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.wuzhen.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils; import com.wuzhen.common.utils.StringUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
/** /**
* swagger 用户测试方法 * swagger 用户测试方法
* *
* @author ruoyi * @author zhengzheng
*/ */
@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", dataTypeClass = Integer.class) @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@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("新增用户")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class), @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class), @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class), @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class) @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
}) })
@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("更新用户")
@PutMapping("/update") @PutMapping("/update")
public AjaxResult update(@RequestBody UserEntity user) public AjaxResult update(@RequestBody 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", dataTypeClass = Integer.class) @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@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(value = "UserEntity", description = "用户实体") @ApiModel(value = "UserEntity", description = "用户实体")
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,67 +1,67 @@
package com.ruoyi.web.core.config; package com.wuzhen.web.core.config;
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 com.wuzhen.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation; 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;
import springfox.documentation.service.ApiInfo; import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact; import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
/** /**
* Swagger2的接口配置 * Swagger2的接口配置
* *
* @author ruoyi * @author zhengzheng
*/ */
@Configuration @Configuration
public class SwaggerConfig public class SwaggerConfig
{ {
/** 是否开启swagger */ /** 是否开启swagger */
@Value("${swagger.enabled}") @Value("${swagger.enabled}")
private boolean enabled; private boolean enabled;
/** /**
* 创建API * 创建API
*/ */
@Bean @Bean
public Docket createRestApi() public Docket createRestApi()
{ {
return new Docket(DocumentationType.OAS_30) return new Docket(DocumentationType.OAS_30)
// 是否启用Swagger // 是否启用Swagger
.enable(enabled) .enable(enabled)
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息 // 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
.apiInfo(apiInfo()) .apiInfo(apiInfo())
// 设置哪些接口暴露给Swagger展示 // 设置哪些接口暴露给Swagger展示
.select() .select()
// 扫描所有有注解的api用这种方式更灵活 // 扫描所有有注解的api用这种方式更灵活
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解 // 扫描指定包中的swagger注解
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
// 扫描所有 .apis(RequestHandlerSelectors.any()) // 扫描所有 .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build(); .build();
} }
/** /**
* 添加摘要信息 * 添加摘要信息
*/ */
private ApiInfo apiInfo() private ApiInfo apiInfo()
{ {
// 用ApiInfoBuilder进行定制 // 用ApiInfoBuilder进行定制
return new ApiInfoBuilder() return new ApiInfoBuilder()
// 设置标题 // 设置标题
.title("标题若依管理系统_接口文档") .title("标题若依管理系统_接口文档")
// 描述 // 描述
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// 作者信息 // 作者信息
.contact(new Contact(RuoYiConfig.getName(), null, null)) .contact(new Contact(RuoYiConfig.getName(), null, null))
// 版本 // 版本
.version("版本号:" + RuoYiConfig.getVersion()) .version("版本号:" + RuoYiConfig.getVersion())
.build(); .build();
} }
} }

View File

@ -1,57 +1,57 @@
# 数据源配置 # 数据源配置
spring: spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://localhost:3306/zt_admin?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: password password: root
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: false enabled: false
url: url:
username: username:
password: password:
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5
# 最小连接池数量 # 最小连接池数量
minIdle: 10 minIdle: 10
# 最大连接池数量 # 最大连接池数量
maxActive: 20 maxActive: 20
# 配置获取连接等待超时的时间 # 配置获取连接等待超时的时间
maxWait: 60000 maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒 # 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒 # 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000 maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效 # 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true testWhileIdle: true
testOnBorrow: false testOnBorrow: false
testOnReturn: false testOnReturn: false
webStatFilter: webStatFilter:
enabled: true enabled: true
statViewServlet: statViewServlet:
enabled: true enabled: true
# 设置白名单,不填则允许所有访问 # 设置白名单,不填则允许所有访问
allow: allow:
url-pattern: /druid/* url-pattern: /druid/*
# 控制台管理用户名和密码 # 控制台管理用户名和密码
login-username: ruoyi login-username: admin
login-password: 123456 login-password: admin
filter: filter:
stat: stat:
enabled: true enabled: true
# 慢SQL记录 # 慢SQL记录
log-slow-sql: true log-slow-sql: true
slow-sql-millis: 1000 slow-sql-millis: 1000
merge-sql: true merge-sql: true
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true

View File

@ -1,142 +1,142 @@
# 项目相关配置 # 项目相关配置
ruoyi: ruoyi:
# 名称 # 名称
name: RuoYi name: 乌镇展厅小程序
# 版本 # 版本
version: 4.7.3 version: 4.7.3
# 版权年份 # 版权年份
copyrightYear: 2022 copyrightYear: 2022
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath profile: D:/ruoyi/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口默认为80 # 服务器的HTTP端口默认为80
port: 80 port: 80
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
tomcat: tomcat:
# tomcat的URI编码 # tomcat的URI编码
uri-encoding: UTF-8 uri-encoding: UTF-8
# 连接数满后的排队数默认为100 # 连接数满后的排队数默认为100
accept-count: 1000 accept-count: 1000
threads: threads:
# tomcat最大线程数默认为200 # tomcat最大线程数默认为200
max: 800 max: 800
# Tomcat启动初始化的线程数默认值10 # Tomcat启动初始化的线程数默认值10
min-spare: 100 min-spare: 100
# 日志配置 # 日志配置
logging: logging:
level: level:
com.ruoyi: debug com.wuzhen: debug
org.springframework: warn org.springframework: warn
# 用户配置 # 用户配置
user: user:
password: password:
# 密码错误{maxRetryCount}次锁定10分钟 # 密码错误{maxRetryCount}次锁定10分钟
maxRetryCount: 5 maxRetryCount: 5
# Spring配置 # Spring配置
spring: spring:
# 模板引擎 # 模板引擎
thymeleaf: thymeleaf:
mode: HTML mode: HTML
encoding: utf-8 encoding: utf-8
# 禁用缓存 # 禁用缓存
cache: false cache: false
# 资源信息 # 资源信息
messages: messages:
# 国际化资源文件路径 # 国际化资源文件路径
basename: static/i18n/messages basename: static/i18n/messages
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
profiles: profiles:
active: druid active: druid
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:
# 单个文件大小 # 单个文件大小
max-file-size: 10MB max-file-size: 10MB
# 设置总上传的文件大小 # 设置总上传的文件大小
max-request-size: 20MB max-request-size: 20MB
# 服务模块 # 服务模块
devtools: devtools:
restart: restart:
# 热部署开关 # 热部署开关
enabled: true enabled: true
# MyBatis # MyBatis
mybatis: mybatis:
# 搜索指定包别名 # 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain typeAliasesPackage: com.wuzhen.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件 # 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件 # 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件 # PageHelper分页插件
pagehelper: pagehelper:
helperDialect: mysql helperDialect: mysql
supportMethodsArguments: true supportMethodsArguments: true
params: count=countSql params: count=countSql
# Shiro # Shiro
shiro: shiro:
user: user:
# 登录地址 # 登录地址
loginUrl: /login loginUrl: /login
# 权限认证失败地址 # 权限认证失败地址
unauthorizedUrl: /unauth unauthorizedUrl: /unauth
# 首页地址 # 首页地址
indexUrl: /index indexUrl: /index
# 验证码开关 # 验证码开关
captchaEnabled: true captchaEnabled: true
# 验证码类型 math 数组计算 char 字符 # 验证码类型 math 数组计算 char 字符
captchaType: math captchaType: math
cookie: cookie:
# 设置Cookie的域名 默认空,即当前访问的域名 # 设置Cookie的域名 默认空,即当前访问的域名
domain: domain:
# 设置cookie的有效访问路径 # 设置cookie的有效访问路径
path: / path: /
# 设置HttpOnly属性 # 设置HttpOnly属性
httpOnly: true httpOnly: true
# 设置Cookie的过期时间天为单位 # 设置Cookie的过期时间天为单位
maxAge: 30 maxAge: 30
# 设置密钥务必保持唯一性生成方式直接拷贝到main运行即可Base64.encodeToString(CipherUtils.generateNewKey(128, "AES").getEncoded()) 默认启动生成随机秘钥随机秘钥会导致之前客户端RememberMe Cookie无效如设置固定秘钥RememberMe Cookie则有效 # 设置密钥务必保持唯一性生成方式直接拷贝到main运行即可Base64.encodeToString(CipherUtils.generateNewKey(128, "AES").getEncoded()) 默认启动生成随机秘钥随机秘钥会导致之前客户端RememberMe Cookie无效如设置固定秘钥RememberMe Cookie则有效
cipherKey: cipherKey:
session: session:
# Session超时时间-1代表永不过期默认30分钟 # Session超时时间-1代表永不过期默认30分钟
expireTime: 30 expireTime: 30
# 同步session到数据库的周期默认1分钟 # 同步session到数据库的周期默认1分钟
dbSyncPeriod: 1 dbSyncPeriod: 1
# 相隔多久检查一次session的有效性默认就是10分钟 # 相隔多久检查一次session的有效性默认就是10分钟
validationInterval: 10 validationInterval: 10
# 同一个用户最大会话数比如2的意思是同一个账号允许最多同时两个人登录默认-1不限制 # 同一个用户最大会话数比如2的意思是同一个账号允许最多同时两个人登录默认-1不限制
maxSession: -1 maxSession: -1
# 踢出之前登录的/之后登录的用户,默认踢出之前登录的用户 # 踢出之前登录的/之后登录的用户,默认踢出之前登录的用户
kickoutAfter: false kickoutAfter: false
rememberMe: rememberMe:
# 是否开启记住我 # 是否开启记住我
enabled: true enabled: true
# 防止XSS攻击 # 防止XSS攻击
xss: xss:
# 过滤开关 # 过滤开关
enabled: true enabled: true
# 排除链接(多个用逗号分隔) # 排除链接(多个用逗号分隔)
excludes: /system/notice/* excludes: /system/notice/*
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /system/*,/monitor/*,/tool/*
# Swagger配置 # Swagger配置
swagger: swagger:
# 是否开启swagger # 是否开启swagger
enabled: true enabled: true

View File

@ -1,24 +1,24 @@
Application Version: ${ruoyi.version} Application Version: ${ruoyi.version}
Spring Boot Version: ${spring-boot.version} Spring Boot Version: ${spring-boot.version}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// _ooOoo_ // // _ooOoo_ //
// o8888888o // // o8888888o //
// 88" . "88 // // 88" . "88 //
// (| ^_^ |) // // (| ^_^ |) //
// O\ = /O // // O\ = /O //
// ____/`---'\____ // // ____/`---'\____ //
// .' \\| |// `. // // .' \\| |// `. //
// / \\||| : |||// \ // // / \\||| : |||// \ //
// / _||||| -:- |||||- \ // // / _||||| -:- |||||- \ //
// | | \\\ - /// | | // // | | \\\ - /// | | //
// | \_| ''\---/'' | | // // | \_| ''\---/'' | | //
// \ .-\__ `-` ___/-. / // // \ .-\__ `-` ___/-. / //
// ___`. .' /--.--\ `. . ___ // // ___`. .' /--.--\ `. . ___ //
// ."" '< `.___\_<|>_/___.' >'"". // // ."" '< `.___\_<|>_/___.' >'"". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | // // | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `-. \_ __\ /__ _/ .-` / / // // \ \ `-. \_ __\ /__ _/ .-` / / //
// ========`-.____`-.___\_____/___.-`____.-'======== // // ========`-.____`-.___\_____/___.-`____.-'======== //
// `=---=' // // `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG // // 佛祖保佑 永不宕机 永无BUG //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -1,91 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ehcache name="ruoyi" updateCheck="false"> <ehcache name="wuzhen" updateCheck="false">
<!-- 磁盘缓存位置 --> <!-- 磁盘缓存位置 -->
<diskStore path="java.io.tmpdir"/> <diskStore path="java.io.tmpdir"/>
<!-- maxEntriesLocalHeap:堆内存中最大缓存对象数0没有限制 --> <!-- maxEntriesLocalHeap:堆内存中最大缓存对象数0没有限制 -->
<!-- maxElementsInMemory 在内存中缓存的element的最大数目。--> <!-- maxElementsInMemory 在内存中缓存的element的最大数目。-->
<!-- eternal:elements是否永久有效如果为truetimeouts将被忽略element将永不过期 --> <!-- eternal:elements是否永久有效如果为truetimeouts将被忽略element将永不过期 -->
<!-- timeToIdleSeconds:失效前的空闲秒数当eternal为false时这个属性才有效0为不限制 --> <!-- timeToIdleSeconds:失效前的空闲秒数当eternal为false时这个属性才有效0为不限制 -->
<!-- timeToLiveSeconds:失效前的存活秒数创建时间到失效时间的间隔为存活时间当eternal为false时这个属性才有效0为不限制 --> <!-- timeToLiveSeconds:失效前的存活秒数创建时间到失效时间的间隔为存活时间当eternal为false时这个属性才有效0为不限制 -->
<!-- overflowToDisk 如果内存中数据超过内存限制,是否要缓存到磁盘上 --> <!-- overflowToDisk 如果内存中数据超过内存限制,是否要缓存到磁盘上 -->
<!-- statistics是否收集统计信息。如果需要监控缓存使用情况应该打开这个选项。默认为关闭统计会影响性能。设置statistics="true"开启统计 --> <!-- statistics是否收集统计信息。如果需要监控缓存使用情况应该打开这个选项。默认为关闭统计会影响性能。设置statistics="true"开启统计 -->
<!-- 默认缓存 --> <!-- 默认缓存 -->
<defaultCache <defaultCache
maxEntriesLocalHeap="1000" maxEntriesLocalHeap="1000"
eternal="false" eternal="false"
timeToIdleSeconds="3600" timeToIdleSeconds="3600"
timeToLiveSeconds="3600" timeToLiveSeconds="3600"
overflowToDisk="false"> overflowToDisk="false">
</defaultCache> </defaultCache>
<!-- 登录记录缓存 锁定10分钟 --> <!-- 登录记录缓存 锁定10分钟 -->
<cache name="loginRecordCache" <cache name="loginRecordCache"
maxEntriesLocalHeap="2000" maxEntriesLocalHeap="2000"
eternal="false" eternal="false"
timeToIdleSeconds="600" timeToIdleSeconds="600"
timeToLiveSeconds="0" timeToLiveSeconds="0"
overflowToDisk="false" overflowToDisk="false"
statistics="false"> statistics="false">
</cache> </cache>
<!-- 系统活跃用户缓存 --> <!-- 系统活跃用户缓存 -->
<cache name="sys-userCache" <cache name="sys-userCache"
maxEntriesLocalHeap="10000" maxEntriesLocalHeap="10000"
overflowToDisk="false" overflowToDisk="false"
eternal="false" eternal="false"
diskPersistent="false" diskPersistent="false"
timeToLiveSeconds="0" timeToLiveSeconds="0"
timeToIdleSeconds="0" timeToIdleSeconds="0"
statistics="false"> statistics="false">
</cache> </cache>
<!-- 系统用户授权缓存 没必要过期 --> <!-- 系统用户授权缓存 没必要过期 -->
<cache name="sys-authCache" <cache name="sys-authCache"
maxEntriesLocalHeap="10000" maxEntriesLocalHeap="10000"
overflowToDisk="false" overflowToDisk="false"
eternal="false" eternal="false"
diskPersistent="false" diskPersistent="false"
timeToLiveSeconds="0" timeToLiveSeconds="0"
timeToIdleSeconds="0" timeToIdleSeconds="0"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
statistics="false"/> statistics="false"/>
<!-- 系统缓存 --> <!-- 系统缓存 -->
<cache name="sys-cache" <cache name="sys-cache"
maxEntriesLocalHeap="1000" maxEntriesLocalHeap="1000"
eternal="true" eternal="true"
overflowToDisk="true" overflowToDisk="true"
statistics="false"> statistics="false">
</cache> </cache>
<!-- 系统参数缓存 --> <!-- 系统参数缓存 -->
<cache name="sys-config" <cache name="sys-config"
maxEntriesLocalHeap="1000" maxEntriesLocalHeap="1000"
eternal="true" eternal="true"
overflowToDisk="true" overflowToDisk="true"
statistics="false"> statistics="false">
</cache> </cache>
<!-- 系统字典缓存 --> <!-- 系统字典缓存 -->
<cache name="sys-dict" <cache name="sys-dict"
maxEntriesLocalHeap="1000" maxEntriesLocalHeap="1000"
eternal="true" eternal="true"
overflowToDisk="true" overflowToDisk="true"
statistics="false"> statistics="false">
</cache> </cache>
<!-- 系统会话缓存 --> <!-- 系统会话缓存 -->
<cache name="shiro-activeSessionCache" <cache name="shiro-activeSessionCache"
maxEntriesLocalHeap="10000" maxEntriesLocalHeap="10000"
overflowToDisk="false" overflowToDisk="false"
eternal="false" eternal="false"
diskPersistent="false" diskPersistent="false"
timeToLiveSeconds="0" timeToLiveSeconds="0"
timeToIdleSeconds="0" timeToIdleSeconds="0"
statistics="false"/> statistics="false"/>
</ehcache> </ehcache>

View File

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

View File

@ -1,459 +1,459 @@
/*! /*!
* Bootstrap-select v1.13.18 (https://developer.snapappointments.com/bootstrap-select) * Bootstrap-select v1.13.18 (https://developer.snapappointments.com/bootstrap-select)
* *
* Copyright 2012-2020 SnapAppointments, LLC * Copyright 2012-2020 SnapAppointments, LLC
* Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
*/ */
@-webkit-keyframes bs-notify-fadeOut { @-webkit-keyframes bs-notify-fadeOut {
0% { 0% {
opacity: 0.9; opacity: 0.9;
} }
100% { 100% {
opacity: 0; opacity: 0;
} }
} }
@-o-keyframes bs-notify-fadeOut { @-o-keyframes bs-notify-fadeOut {
0% { 0% {
opacity: 0.9; opacity: 0.9;
} }
100% { 100% {
opacity: 0; opacity: 0;
} }
} }
@keyframes bs-notify-fadeOut { @keyframes bs-notify-fadeOut {
0% { 0% {
opacity: 0.9; opacity: 0.9;
} }
100% { 100% {
opacity: 0; opacity: 0;
} }
} }
select.bs-select-hidden, select.bs-select-hidden,
.bootstrap-select > select.bs-select-hidden, .bootstrap-select > select.bs-select-hidden,
select.selectpicker { select.selectpicker {
display: none !important; display: none !important;
} }
.bootstrap-select { .bootstrap-select {
width: 220px \0; width: 220px \0;
/*IE9 and below*/ /*IE9 and below*/
vertical-align: middle; vertical-align: middle;
} }
.bootstrap-select > .dropdown-toggle { .bootstrap-select > .dropdown-toggle {
position: relative; position: relative;
width: 100%; width: 100%;
text-align: right; text-align: right;
white-space: nowrap; white-space: nowrap;
display: -webkit-inline-box; display: -webkit-inline-box;
display: -webkit-inline-flex; display: -webkit-inline-flex;
display: -ms-inline-flexbox; display: -ms-inline-flexbox;
display: inline-flex; display: inline-flex;
-webkit-box-align: center; -webkit-box-align: center;
-webkit-align-items: center; -webkit-align-items: center;
-ms-flex-align: center; -ms-flex-align: center;
align-items: center; align-items: center;
-webkit-box-pack: justify; -webkit-box-pack: justify;
-webkit-justify-content: space-between; -webkit-justify-content: space-between;
-ms-flex-pack: justify; -ms-flex-pack: justify;
justify-content: space-between; justify-content: space-between;
} }
.bootstrap-select > .dropdown-toggle:after { .bootstrap-select > .dropdown-toggle:after {
margin-top: -1px; margin-top: -1px;
} }
.bootstrap-select > .dropdown-toggle.bs-placeholder, .bootstrap-select > .dropdown-toggle.bs-placeholder,
.bootstrap-select > .dropdown-toggle.bs-placeholder:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder:active { .bootstrap-select > .dropdown-toggle.bs-placeholder:active {
color: #999; color: #999;
} }
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary:active, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-primary:active,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary:active, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-secondary:active,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success:active, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-success:active,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger:active, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-danger:active,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info:active, .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-info:active,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark:active { .bootstrap-select > .dropdown-toggle.bs-placeholder.btn-dark:active {
color: rgba(255, 255, 255, 0.5); color: rgba(255, 255, 255, 0.5);
} }
.bootstrap-select > select { .bootstrap-select > select {
position: absolute !important; position: absolute !important;
bottom: 0; bottom: 0;
left: 50%; left: 50%;
display: block !important; display: block !important;
width: 0.5px !important; width: 0.5px !important;
height: 100% !important; height: 100% !important;
padding: 0 !important; padding: 0 !important;
opacity: 0 !important; opacity: 0 !important;
border: none; border: none;
z-index: 0 !important; z-index: 0 !important;
} }
.bootstrap-select > select.mobile-device { .bootstrap-select > select.mobile-device {
top: 0; top: 0;
left: 0; left: 0;
display: block !important; display: block !important;
width: 100% !important; width: 100% !important;
z-index: 2 !important; z-index: 2 !important;
} }
.has-error .bootstrap-select .dropdown-toggle, .has-error .bootstrap-select .dropdown-toggle,
.error .bootstrap-select .dropdown-toggle, .error .bootstrap-select .dropdown-toggle,
.bootstrap-select.is-invalid .dropdown-toggle, .bootstrap-select.is-invalid .dropdown-toggle,
.was-validated .bootstrap-select select:invalid + .dropdown-toggle { .was-validated .bootstrap-select select:invalid + .dropdown-toggle {
border-color: #b94a48; border-color: #b94a48;
} }
.bootstrap-select.is-valid .dropdown-toggle, .bootstrap-select.is-valid .dropdown-toggle,
.was-validated .bootstrap-select select:valid + .dropdown-toggle { .was-validated .bootstrap-select select:valid + .dropdown-toggle {
border-color: #28a745; border-color: #28a745;
} }
.bootstrap-select.fit-width { .bootstrap-select.fit-width {
width: auto !important; width: auto !important;
} }
.bootstrap-select:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) { .bootstrap-select:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) {
width: 220px; width: 220px;
} }
.bootstrap-select > select.mobile-device:focus + .dropdown-toggle, .bootstrap-select > select.mobile-device:focus + .dropdown-toggle,
.bootstrap-select .dropdown-toggle:focus { .bootstrap-select .dropdown-toggle:focus {
outline: thin dotted #333333 !important; outline: thin dotted #333333 !important;
outline: 5px auto -webkit-focus-ring-color !important; outline: 5px auto -webkit-focus-ring-color !important;
outline-offset: -2px; outline-offset: -2px;
} }
.bootstrap-select.form-control { .bootstrap-select.form-control {
margin-bottom: 0; margin-bottom: 0;
padding: 0; padding: 0;
border: none; border: none;
height: auto; height: auto;
} }
:not(.input-group) > .bootstrap-select.form-control:not([class*="col-"]) { :not(.input-group) > .bootstrap-select.form-control:not([class*="col-"]) {
width: 100%; width: 100%;
} }
.bootstrap-select.form-control.input-group-btn { .bootstrap-select.form-control.input-group-btn {
float: none; float: none;
z-index: auto; z-index: auto;
} }
.form-inline .bootstrap-select, .form-inline .bootstrap-select,
.form-inline .bootstrap-select.form-control:not([class*="col-"]) { .form-inline .bootstrap-select.form-control:not([class*="col-"]) {
width: auto; width: auto;
} }
.bootstrap-select:not(.input-group-btn), .bootstrap-select:not(.input-group-btn),
.bootstrap-select[class*="col-"] { .bootstrap-select[class*="col-"] {
float: none; float: none;
display: inline-block; display: inline-block;
margin-left: 0; margin-left: 0;
} }
.bootstrap-select.dropdown-menu-right, .bootstrap-select.dropdown-menu-right,
.bootstrap-select[class*="col-"].dropdown-menu-right, .bootstrap-select[class*="col-"].dropdown-menu-right,
.row .bootstrap-select[class*="col-"].dropdown-menu-right { .row .bootstrap-select[class*="col-"].dropdown-menu-right {
float: right; float: right;
} }
.form-inline .bootstrap-select, .form-inline .bootstrap-select,
.form-horizontal .bootstrap-select, .form-horizontal .bootstrap-select,
.form-group .bootstrap-select { .form-group .bootstrap-select {
margin-bottom: 0; margin-bottom: 0;
} }
.form-group-lg .bootstrap-select.form-control, .form-group-lg .bootstrap-select.form-control,
.form-group-sm .bootstrap-select.form-control { .form-group-sm .bootstrap-select.form-control {
padding: 0; padding: 0;
} }
.form-group-lg .bootstrap-select.form-control .dropdown-toggle, .form-group-lg .bootstrap-select.form-control .dropdown-toggle,
.form-group-sm .bootstrap-select.form-control .dropdown-toggle { .form-group-sm .bootstrap-select.form-control .dropdown-toggle {
height: 100%; height: 100%;
font-size: inherit; font-size: inherit;
line-height: inherit; line-height: inherit;
border-radius: inherit; border-radius: inherit;
} }
.bootstrap-select.form-control-sm .dropdown-toggle, .bootstrap-select.form-control-sm .dropdown-toggle,
.bootstrap-select.form-control-lg .dropdown-toggle { .bootstrap-select.form-control-lg .dropdown-toggle {
font-size: inherit; font-size: inherit;
line-height: inherit; line-height: inherit;
border-radius: inherit; border-radius: inherit;
} }
.bootstrap-select.form-control-sm .dropdown-toggle { .bootstrap-select.form-control-sm .dropdown-toggle {
padding: 0.25rem 0.5rem; padding: 0.25rem 0.5rem;
} }
.bootstrap-select.form-control-lg .dropdown-toggle { .bootstrap-select.form-control-lg .dropdown-toggle {
padding: 0.5rem 1rem; padding: 0.5rem 1rem;
} }
.form-inline .bootstrap-select .form-control { .form-inline .bootstrap-select .form-control {
width: 100%; width: 100%;
} }
.bootstrap-select.disabled, .bootstrap-select.disabled,
.bootstrap-select > .disabled { .bootstrap-select > .disabled {
cursor: not-allowed; cursor: not-allowed;
} }
.bootstrap-select.disabled:focus, .bootstrap-select.disabled:focus,
.bootstrap-select > .disabled:focus { .bootstrap-select > .disabled:focus {
outline: none !important; outline: none !important;
} }
.bootstrap-select.bs-container { .bootstrap-select.bs-container {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
height: 0 !important; height: 0 !important;
padding: 0 !important; padding: 0 !important;
} }
.bootstrap-select.bs-container .dropdown-menu { .bootstrap-select.bs-container .dropdown-menu {
z-index: 1060; z-index: 1060;
} }
.bootstrap-select .dropdown-toggle .filter-option { .bootstrap-select .dropdown-toggle .filter-option {
position: static; position: static;
top: 0; top: 0;
left: 0; left: 0;
float: left; float: left;
height: 100%; height: 100%;
width: 100%; width: 100%;
text-align: left; text-align: left;
overflow: hidden; overflow: hidden;
-webkit-box-flex: 0; -webkit-box-flex: 0;
-webkit-flex: 0 1 auto; -webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto; -ms-flex: 0 1 auto;
flex: 0 1 auto; flex: 0 1 auto;
} }
.bs3.bootstrap-select .dropdown-toggle .filter-option { .bs3.bootstrap-select .dropdown-toggle .filter-option {
padding-right: inherit; padding-right: inherit;
} }
.input-group .bs3-has-addon.bootstrap-select .dropdown-toggle .filter-option { .input-group .bs3-has-addon.bootstrap-select .dropdown-toggle .filter-option {
position: absolute; position: absolute;
padding-top: inherit; padding-top: inherit;
padding-bottom: inherit; padding-bottom: inherit;
padding-left: inherit; padding-left: inherit;
float: none; float: none;
} }
.input-group .bs3-has-addon.bootstrap-select .dropdown-toggle .filter-option .filter-option-inner { .input-group .bs3-has-addon.bootstrap-select .dropdown-toggle .filter-option .filter-option-inner {
padding-right: inherit; padding-right: inherit;
} }
.bootstrap-select .dropdown-toggle .filter-option-inner-inner { .bootstrap-select .dropdown-toggle .filter-option-inner-inner {
overflow: hidden; overflow: hidden;
} }
.bootstrap-select .dropdown-toggle .filter-expand { .bootstrap-select .dropdown-toggle .filter-expand {
width: 0 !important; width: 0 !important;
float: left; float: left;
opacity: 0 !important; opacity: 0 !important;
overflow: hidden; overflow: hidden;
} }
.bootstrap-select .dropdown-toggle .caret { .bootstrap-select .dropdown-toggle .caret {
position: absolute; position: absolute;
top: 50%; top: 50%;
right: 12px; right: 12px;
margin-top: -2px; margin-top: -2px;
vertical-align: middle; vertical-align: middle;
} }
.input-group .bootstrap-select.form-control .dropdown-toggle { .input-group .bootstrap-select.form-control .dropdown-toggle {
border-radius: inherit; border-radius: inherit;
} }
.bootstrap-select[class*="col-"] .dropdown-toggle { .bootstrap-select[class*="col-"] .dropdown-toggle {
width: 100%; width: 100%;
} }
.bootstrap-select .dropdown-menu { .bootstrap-select .dropdown-menu {
min-width: 100%; min-width: 100%;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
.bootstrap-select .dropdown-menu > .inner:focus { .bootstrap-select .dropdown-menu > .inner:focus {
outline: none !important; outline: none !important;
} }
.bootstrap-select .dropdown-menu.inner { .bootstrap-select .dropdown-menu.inner {
position: static; position: static;
float: none; float: none;
border: 0; border: 0;
padding: 0; padding: 0;
margin: 0; margin: 0;
border-radius: 0; border-radius: 0;
-webkit-box-shadow: none; -webkit-box-shadow: none;
box-shadow: none; box-shadow: none;
} }
.bootstrap-select .dropdown-menu li { .bootstrap-select .dropdown-menu li {
position: relative; position: relative;
} }
.bootstrap-select .dropdown-menu li.active small { .bootstrap-select .dropdown-menu li.active small {
color: rgba(255, 255, 255, 0.5) !important; color: rgba(255, 255, 255, 0.5) !important;
} }
.bootstrap-select .dropdown-menu li.disabled a { .bootstrap-select .dropdown-menu li.disabled a {
cursor: not-allowed; cursor: not-allowed;
} }
.bootstrap-select .dropdown-menu li a { .bootstrap-select .dropdown-menu li a {
cursor: pointer; cursor: pointer;
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
.bootstrap-select .dropdown-menu li a.opt { .bootstrap-select .dropdown-menu li a.opt {
position: relative; position: relative;
padding-left: 2.25em; padding-left: 2.25em;
} }
.bootstrap-select .dropdown-menu li a span.check-mark { .bootstrap-select .dropdown-menu li a span.check-mark {
display: none; display: none;
} }
.bootstrap-select .dropdown-menu li a span.text { .bootstrap-select .dropdown-menu li a span.text {
display: inline-block; display: inline-block;
} }
.bootstrap-select .dropdown-menu li small { .bootstrap-select .dropdown-menu li small {
padding-left: 0.5em; padding-left: 0.5em;
} }
.bootstrap-select .dropdown-menu .notify { .bootstrap-select .dropdown-menu .notify {
position: absolute; position: absolute;
bottom: 5px; bottom: 5px;
width: 96%; width: 96%;
margin: 0 2%; margin: 0 2%;
min-height: 26px; min-height: 26px;
padding: 3px 5px; padding: 3px 5px;
background: #f5f5f5; background: #f5f5f5;
border: 1px solid #e3e3e3; border: 1px solid #e3e3e3;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
pointer-events: none; pointer-events: none;
opacity: 0.9; opacity: 0.9;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
.bootstrap-select .dropdown-menu .notify.fadeOut { .bootstrap-select .dropdown-menu .notify.fadeOut {
-webkit-animation: 300ms linear 750ms forwards bs-notify-fadeOut; -webkit-animation: 300ms linear 750ms forwards bs-notify-fadeOut;
-o-animation: 300ms linear 750ms forwards bs-notify-fadeOut; -o-animation: 300ms linear 750ms forwards bs-notify-fadeOut;
animation: 300ms linear 750ms forwards bs-notify-fadeOut; animation: 300ms linear 750ms forwards bs-notify-fadeOut;
} }
.bootstrap-select .no-results { .bootstrap-select .no-results {
padding: 3px; padding: 3px;
background: #f5f5f5; background: #f5f5f5;
margin: 0 5px; margin: 0 5px;
white-space: nowrap; white-space: nowrap;
} }
.bootstrap-select.fit-width .dropdown-toggle .filter-option { .bootstrap-select.fit-width .dropdown-toggle .filter-option {
position: static; position: static;
display: inline; display: inline;
padding: 0; padding: 0;
} }
.bootstrap-select.fit-width .dropdown-toggle .filter-option-inner, .bootstrap-select.fit-width .dropdown-toggle .filter-option-inner,
.bootstrap-select.fit-width .dropdown-toggle .filter-option-inner-inner { .bootstrap-select.fit-width .dropdown-toggle .filter-option-inner-inner {
display: inline; display: inline;
} }
.bootstrap-select.fit-width .dropdown-toggle .bs-caret:before { .bootstrap-select.fit-width .dropdown-toggle .bs-caret:before {
content: '\00a0'; content: '\00a0';
} }
.bootstrap-select.fit-width .dropdown-toggle .caret { .bootstrap-select.fit-width .dropdown-toggle .caret {
position: static; position: static;
top: auto; top: auto;
margin-top: -1px; margin-top: -1px;
} }
.bootstrap-select.show-tick .dropdown-menu .selected span.check-mark { .bootstrap-select.show-tick .dropdown-menu .selected span.check-mark {
position: absolute; position: absolute;
display: inline-block; display: inline-block;
right: 15px; right: 15px;
top: 5px; top: 5px;
} }
.bootstrap-select.show-tick .dropdown-menu li a span.text { .bootstrap-select.show-tick .dropdown-menu li a span.text {
margin-right: 34px; margin-right: 34px;
} }
.bootstrap-select .bs-ok-default:after { .bootstrap-select .bs-ok-default:after {
content: ''; content: '';
display: block; display: block;
width: 0.5em; width: 0.5em;
height: 1em; height: 1em;
border-style: solid; border-style: solid;
border-width: 0 0.26em 0.26em 0; border-width: 0 0.26em 0.26em 0;
-webkit-transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
transform-style: preserve-3d; transform-style: preserve-3d;
-webkit-transform: rotate(45deg); -webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg); -ms-transform: rotate(45deg);
-o-transform: rotate(45deg); -o-transform: rotate(45deg);
transform: rotate(45deg); transform: rotate(45deg);
} }
.bootstrap-select.show-menu-arrow.open > .dropdown-toggle, .bootstrap-select.show-menu-arrow.open > .dropdown-toggle,
.bootstrap-select.show-menu-arrow.show > .dropdown-toggle { .bootstrap-select.show-menu-arrow.show > .dropdown-toggle {
z-index: 1061; z-index: 1061;
} }
.bootstrap-select.show-menu-arrow .dropdown-toggle .filter-option:before { .bootstrap-select.show-menu-arrow .dropdown-toggle .filter-option:before {
content: ''; content: '';
border-left: 7px solid transparent; border-left: 7px solid transparent;
border-right: 7px solid transparent; border-right: 7px solid transparent;
border-bottom: 7px solid rgba(204, 204, 204, 0.2); border-bottom: 7px solid rgba(204, 204, 204, 0.2);
position: absolute; position: absolute;
bottom: -4px; bottom: -4px;
left: 9px; left: 9px;
display: none; display: none;
} }
.bootstrap-select.show-menu-arrow .dropdown-toggle .filter-option:after { .bootstrap-select.show-menu-arrow .dropdown-toggle .filter-option:after {
content: ''; content: '';
border-left: 6px solid transparent; border-left: 6px solid transparent;
border-right: 6px solid transparent; border-right: 6px solid transparent;
border-bottom: 6px solid white; border-bottom: 6px solid white;
position: absolute; position: absolute;
bottom: -4px; bottom: -4px;
left: 10px; left: 10px;
display: none; display: none;
} }
.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle .filter-option:before { .bootstrap-select.show-menu-arrow.dropup .dropdown-toggle .filter-option:before {
bottom: auto; bottom: auto;
top: -4px; top: -4px;
border-top: 7px solid rgba(204, 204, 204, 0.2); border-top: 7px solid rgba(204, 204, 204, 0.2);
border-bottom: 0; border-bottom: 0;
} }
.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle .filter-option:after { .bootstrap-select.show-menu-arrow.dropup .dropdown-toggle .filter-option:after {
bottom: auto; bottom: auto;
top: -4px; top: -4px;
border-top: 6px solid white; border-top: 6px solid white;
border-bottom: 0; border-bottom: 0;
} }
.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle .filter-option:before { .bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle .filter-option:before {
right: 12px; right: 12px;
left: auto; left: auto;
} }
.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle .filter-option:after { .bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle .filter-option:after {
right: 13px; right: 13px;
left: auto; left: auto;
} }
.bootstrap-select.show-menu-arrow.open > .dropdown-toggle .filter-option:before, .bootstrap-select.show-menu-arrow.open > .dropdown-toggle .filter-option:before,
.bootstrap-select.show-menu-arrow.show > .dropdown-toggle .filter-option:before, .bootstrap-select.show-menu-arrow.show > .dropdown-toggle .filter-option:before,
.bootstrap-select.show-menu-arrow.open > .dropdown-toggle .filter-option:after, .bootstrap-select.show-menu-arrow.open > .dropdown-toggle .filter-option:after,
.bootstrap-select.show-menu-arrow.show > .dropdown-toggle .filter-option:after { .bootstrap-select.show-menu-arrow.show > .dropdown-toggle .filter-option:after {
display: block; display: block;
} }
.bs-searchbox, .bs-searchbox,
.bs-actionsbox, .bs-actionsbox,
.bs-donebutton { .bs-donebutton {
padding: 4px 8px; padding: 4px 8px;
} }
.bs-actionsbox { .bs-actionsbox {
width: 100%; width: 100%;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
.bs-actionsbox .btn-group button { .bs-actionsbox .btn-group button {
width: 50%; width: 50%;
} }
.bs-donebutton { .bs-donebutton {
float: left; float: left;
width: 100%; width: 100%;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
.bs-donebutton .btn-group button { .bs-donebutton .btn-group button {
width: 100%; width: 100%;
} }
.bs-searchbox + .bs-actionsbox { .bs-searchbox + .bs-actionsbox {
padding: 0 8px 4px; padding: 0 8px 4px;
} }
.bs-searchbox .form-control { .bs-searchbox .form-control {
margin-bottom: 0; margin-bottom: 0;
width: 100%; width: 100%;
float: none; float: none;
} }

View File

@ -1,95 +1,95 @@
/** /**
* @author: Alec Fenichel * @author: Alec Fenichel
* @webSite: https://fenichelar.com * @webSite: https://fenichelar.com
* @update: zhixin wen <wenzhixin2010@gmail.com> * @update: zhixin wen <wenzhixin2010@gmail.com>
*/ */
var Utils = $.fn.bootstrapTable.utils var Utils = $.fn.bootstrapTable.utils
$.extend($.fn.bootstrapTable.defaults, { $.extend($.fn.bootstrapTable.defaults, {
autoRefresh: false, autoRefresh: false,
showAutoRefresh: true, showAutoRefresh: true,
autoRefreshInterval: 60, autoRefreshInterval: 60,
autoRefreshSilent: true, autoRefreshSilent: true,
autoRefreshStatus: true, autoRefreshStatus: true,
autoRefreshFunction: null autoRefreshFunction: null
}) })
$.extend($.fn.bootstrapTable.defaults.icons, { $.extend($.fn.bootstrapTable.defaults.icons, {
autoRefresh: { autoRefresh: {
bootstrap3: 'glyphicon-time icon-time', bootstrap3: 'glyphicon-time icon-time',
bootstrap5: 'bi-clock', bootstrap5: 'bi-clock',
materialize: 'access_time', materialize: 'access_time',
'bootstrap-table': 'icon-clock' 'bootstrap-table': 'icon-clock'
}[$.fn.bootstrapTable.theme] || 'fa-clock' }[$.fn.bootstrapTable.theme] || 'fa-clock'
}) })
$.extend($.fn.bootstrapTable.locales, { $.extend($.fn.bootstrapTable.locales, {
formatAutoRefresh () { formatAutoRefresh () {
return 'Auto Refresh' return 'Auto Refresh'
} }
}) })
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales) $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
init (...args) { init (...args) {
super.init(...args) super.init(...args)
if (this.options.autoRefresh && this.options.autoRefreshStatus) { if (this.options.autoRefresh && this.options.autoRefreshStatus) {
this.setupRefreshInterval() this.setupRefreshInterval()
} }
} }
initToolbar (...args) { initToolbar (...args) {
if (this.options.autoRefresh) { if (this.options.autoRefresh) {
this.buttons = Object.assign(this.buttons, { this.buttons = Object.assign(this.buttons, {
autoRefresh: { autoRefresh: {
html: ` html: `
<button class="auto-refresh ${this.constants.buttonsClass} <button class="auto-refresh ${this.constants.buttonsClass}
${this.options.autoRefreshStatus ? ` ${this.constants.classes.buttonActive}` : ''}" ${this.options.autoRefreshStatus ? ` ${this.constants.classes.buttonActive}` : ''}"
type="button" name="autoRefresh" title="${this.options.formatAutoRefresh()}"> type="button" name="autoRefresh" title="${this.options.formatAutoRefresh()}">
${ this.options.showButtonIcons ? Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.autoRefresh) : ''} ${ this.options.showButtonIcons ? Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.autoRefresh) : ''}
${ this.options.showButtonText ? this.options.formatAutoRefresh() : ''} ${ this.options.showButtonText ? this.options.formatAutoRefresh() : ''}
</button> </button>
`, `,
event: this.toggleAutoRefresh event: this.toggleAutoRefresh
} }
}) })
} }
super.initToolbar(...args) super.initToolbar(...args)
} }
toggleAutoRefresh () { toggleAutoRefresh () {
if (this.options.autoRefresh) { if (this.options.autoRefresh) {
if (this.options.autoRefreshStatus) { if (this.options.autoRefreshStatus) {
clearInterval(this.options.autoRefreshFunction) clearInterval(this.options.autoRefreshFunction)
this.$toolbar.find('>.columns .auto-refresh') this.$toolbar.find('>.columns .auto-refresh')
.removeClass(this.constants.classes.buttonActive) .removeClass(this.constants.classes.buttonActive)
} else { } else {
this.setupRefreshInterval() this.setupRefreshInterval()
this.$toolbar.find('>.columns .auto-refresh') this.$toolbar.find('>.columns .auto-refresh')
.addClass(this.constants.classes.buttonActive) .addClass(this.constants.classes.buttonActive)
} }
this.options.autoRefreshStatus = !this.options.autoRefreshStatus this.options.autoRefreshStatus = !this.options.autoRefreshStatus
} }
} }
destroy () { destroy () {
if (this.options.autoRefresh && this.options.autoRefreshStatus) { if (this.options.autoRefresh && this.options.autoRefreshStatus) {
clearInterval(this.options.autoRefreshFunction) clearInterval(this.options.autoRefreshFunction)
} }
super.destroy() super.destroy()
} }
setupRefreshInterval () { setupRefreshInterval () {
this.options.autoRefreshFunction = setInterval(() => { this.options.autoRefreshFunction = setInterval(() => {
if (!this.options.autoRefresh || !this.options.autoRefreshStatus) { if (!this.options.autoRefresh || !this.options.autoRefreshStatus) {
return return
} }
this.refresh({ silent: this.options.autoRefreshSilent }) this.refresh({ silent: this.options.autoRefreshSilent })
}, this.options.autoRefreshInterval * 1000) }, this.options.autoRefreshInterval * 1000)
} }
} }

View File

@ -1,213 +1,213 @@
/** /**
* @author: Dennis Hernández * @author: Dennis Hernández
* @webSite: http://djhvscf.github.io/Blog * @webSite: http://djhvscf.github.io/Blog
* @update: https://github.com/wenzhixin * @update: https://github.com/wenzhixin
* @version: v1.2.0 * @version: v1.2.0
*/ */
$.akottr.dragtable.prototype._restoreState = function (persistObj) { $.akottr.dragtable.prototype._restoreState = function (persistObj) {
let i = 0 let i = 0
for (const [field, value] of Object.entries(persistObj)) { for (const [field, value] of Object.entries(persistObj)) {
const $th = this.originalTable.el.find(`th[data-field="${field}"]`) const $th = this.originalTable.el.find(`th[data-field="${field}"]`)
if (!$th.length) { if (!$th.length) {
i++ i++
continue continue
} }
this.originalTable.startIndex = $th.prevAll().length + 1 this.originalTable.startIndex = $th.prevAll().length + 1
this.originalTable.endIndex = parseInt(value, 10) + 1 - i this.originalTable.endIndex = parseInt(value, 10) + 1 - i
this._bubbleCols() this._bubbleCols()
} }
} }
// From MDN site, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter // From MDN site, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
const filterFn = () => { const filterFn = () => {
if (!Array.prototype.filter) { if (!Array.prototype.filter) {
Array.prototype.filter = function (fun/* , thisArg*/) { Array.prototype.filter = function (fun/* , thisArg*/) {
if (this === undefined || this === null) { if (this === undefined || this === null) {
throw new TypeError() throw new TypeError()
} }
const t = Object(this) const t = Object(this)
const len = t.length >>> 0 const len = t.length >>> 0
if (typeof fun !== 'function') { if (typeof fun !== 'function') {
throw new TypeError() throw new TypeError()
} }
const res = [] const res = []
const thisArg = arguments.length >= 2 ? arguments[1] : undefined const thisArg = arguments.length >= 2 ? arguments[1] : undefined
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
if (i in t) { if (i in t) {
const val = t[i] const val = t[i]
// NOTE: Technically this should Object.defineProperty at // NOTE: Technically this should Object.defineProperty at
// the next index, as push can be affected by // the next index, as push can be affected by
// properties on Object.prototype and Array.prototype. // properties on Object.prototype and Array.prototype.
// But this method's new, and collisions should be // But this method's new, and collisions should be
// rare, so use the more-compatible alternative. // rare, so use the more-compatible alternative.
if (fun.call(thisArg, val, i, t)) { if (fun.call(thisArg, val, i, t)) {
res.push(val) res.push(val)
} }
} }
} }
return res return res
} }
} }
} }
$.extend($.fn.bootstrapTable.defaults, { $.extend($.fn.bootstrapTable.defaults, {
reorderableColumns: false, reorderableColumns: false,
maxMovingRows: 10, maxMovingRows: 10,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
onReorderColumn (headerFields) { onReorderColumn (headerFields) {
return false return false
}, },
dragaccept: null dragaccept: null
}) })
$.extend($.fn.bootstrapTable.Constructor.EVENTS, { $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
'reorder-column.bs.table': 'onReorderColumn' 'reorder-column.bs.table': 'onReorderColumn'
}) })
$.fn.bootstrapTable.methods.push('orderColumns') $.fn.bootstrapTable.methods.push('orderColumns')
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
initHeader (...args) { initHeader (...args) {
super.initHeader(...args) super.initHeader(...args)
if (!this.options.reorderableColumns) { if (!this.options.reorderableColumns) {
return return
} }
this.makeRowsReorderable() this.makeRowsReorderable()
} }
_toggleColumn (...args) { _toggleColumn (...args) {
super._toggleColumn(...args) super._toggleColumn(...args)
if (!this.options.reorderableColumns) { if (!this.options.reorderableColumns) {
return return
} }
this.makeRowsReorderable() this.makeRowsReorderable()
} }
toggleView (...args) { toggleView (...args) {
super.toggleView(...args) super.toggleView(...args)
if (!this.options.reorderableColumns) { if (!this.options.reorderableColumns) {
return return
} }
if (this.options.cardView) { if (this.options.cardView) {
return return
} }
this.makeRowsReorderable() this.makeRowsReorderable()
} }
resetView (...args) { resetView (...args) {
super.resetView(...args) super.resetView(...args)
if (!this.options.reorderableColumns) { if (!this.options.reorderableColumns) {
return return
} }
this.makeRowsReorderable() this.makeRowsReorderable()
} }
makeRowsReorderable (order = null) { makeRowsReorderable (order = null) {
try { try {
$(this.$el).dragtable('destroy') $(this.$el).dragtable('destroy')
} catch (e) { } catch (e) {
// do nothing // do nothing
} }
$(this.$el).dragtable({ $(this.$el).dragtable({
maxMovingRows: this.options.maxMovingRows, maxMovingRows: this.options.maxMovingRows,
dragaccept: this.options.dragaccept, dragaccept: this.options.dragaccept,
clickDelay: 200, clickDelay: 200,
dragHandle: '.th-inner', dragHandle: '.th-inner',
restoreState: order ? order : this.columnsSortOrder, restoreState: order ? order : this.columnsSortOrder,
beforeStop: table => { beforeStop: table => {
const sortOrder = {} const sortOrder = {}
table.el.find('th').each((i, el) => { table.el.find('th').each((i, el) => {
sortOrder[$(el).data('field')] = i sortOrder[$(el).data('field')] = i
}) })
this.columnsSortOrder = sortOrder this.columnsSortOrder = sortOrder
if (this.options.cookie) { if (this.options.cookie) {
this.persistReorderColumnsState(this) this.persistReorderColumnsState(this)
} }
const ths = [] const ths = []
const formatters = [] const formatters = []
const columns = [] const columns = []
let columnsHidden = [] let columnsHidden = []
let columnIndex = -1 let columnIndex = -1
const optionsColumns = [] const optionsColumns = []
this.$header.find('th:not(.detail)').each((i, el) => { this.$header.find('th:not(.detail)').each((i, el) => {
ths.push($(el).data('field')) ths.push($(el).data('field'))
formatters.push($(el).data('formatter')) formatters.push($(el).data('formatter'))
}) })
// Exist columns not shown // Exist columns not shown
if (ths.length < this.columns.length) { if (ths.length < this.columns.length) {
columnsHidden = this.columns.filter(column => !column.visible) columnsHidden = this.columns.filter(column => !column.visible)
for (let i = 0; i < columnsHidden.length; i++) { for (let i = 0; i < columnsHidden.length; i++) {
ths.push(columnsHidden[i].field) ths.push(columnsHidden[i].field)
formatters.push(columnsHidden[i].formatter) formatters.push(columnsHidden[i].formatter)
} }
} }
for (let i = 0; i < ths.length; i++) { for (let i = 0; i < ths.length; i++) {
columnIndex = this.fieldsColumnsIndex[ths[i]] columnIndex = this.fieldsColumnsIndex[ths[i]]
if (columnIndex !== -1) { if (columnIndex !== -1) {
this.fieldsColumnsIndex[ths[i]] = i this.fieldsColumnsIndex[ths[i]] = i
this.columns[columnIndex].fieldIndex = i this.columns[columnIndex].fieldIndex = i
columns.push(this.columns[columnIndex]) columns.push(this.columns[columnIndex])
} }
} }
this.columns = columns this.columns = columns
filterFn() // Support <IE9 filterFn() // Support <IE9
$.each(this.columns, (i, column) => { $.each(this.columns, (i, column) => {
let found = false let found = false
const field = column.field const field = column.field
this.options.columns[0].filter(item => { this.options.columns[0].filter(item => {
if (!found && item['field'] === field) { if (!found && item['field'] === field) {
optionsColumns.push(item) optionsColumns.push(item)
found = true found = true
return false return false
} }
return true return true
}) })
}) })
this.options.columns[0] = optionsColumns this.options.columns[0] = optionsColumns
this.header.fields = ths this.header.fields = ths
this.header.formatters = formatters this.header.formatters = formatters
this.initHeader() this.initHeader()
this.initToolbar() this.initToolbar()
this.initSearchText() this.initSearchText()
this.initBody() this.initBody()
this.resetView() this.resetView()
this.trigger('reorder-column', ths) this.trigger('reorder-column', ths)
} }
}) })
} }
orderColumns (order) { orderColumns (order) {
this.columnsSortOrder = order this.columnsSortOrder = order
this.makeRowsReorderable() this.makeRowsReorderable()
} }
} }

View File

@ -1,69 +1,69 @@
/** /**
* @author: Dennis Hernández * @author: Dennis Hernández
* @webSite: http://djhvscf.github.io/Blog * @webSite: http://djhvscf.github.io/Blog
* @version: v2.0.0 * @version: v2.0.0
*/ */
const isInit = that => that.$el.data('resizableColumns') !== undefined const isInit = that => that.$el.data('resizableColumns') !== undefined
const initResizable = that => { const initResizable = that => {
if ( if (
that.options.resizable && that.options.resizable &&
!that.options.cardView && !that.options.cardView &&
!isInit(that) && !isInit(that) &&
that.$el.is(':visible') that.$el.is(':visible')
) { ) {
that.$el.resizableColumns({ that.$el.resizableColumns({
store: window.store store: window.store
}) })
} }
} }
const destroy = that => { const destroy = that => {
if (isInit(that)) { if (isInit(that)) {
that.$el.data('resizableColumns').destroy() that.$el.data('resizableColumns').destroy()
} }
} }
const reInitResizable = that => { const reInitResizable = that => {
destroy(that) destroy(that)
initResizable(that) initResizable(that)
} }
$.extend($.fn.bootstrapTable.defaults, { $.extend($.fn.bootstrapTable.defaults, {
resizable: false resizable: false
}) })
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
initBody (...args) { initBody (...args) {
super.initBody(...args) super.initBody(...args)
this.$el.off('column-switch.bs.table page-change.bs.table') this.$el.off('column-switch.bs.table page-change.bs.table')
.on('column-switch.bs.table page-change.bs.table', () => { .on('column-switch.bs.table page-change.bs.table', () => {
reInitResizable(this) reInitResizable(this)
}) })
reInitResizable(this) reInitResizable(this)
} }
toggleView (...args) { toggleView (...args) {
super.toggleView(...args) super.toggleView(...args)
if (this.options.resizable && this.options.cardView) { if (this.options.resizable && this.options.cardView) {
// Destroy the plugin // Destroy the plugin
destroy(this) destroy(this)
} }
} }
resetView (...args) { resetView (...args) {
super.resetView(...args) super.resetView(...args)
if (this.options.resizable) { if (this.options.resizable) {
// because in fitHeader function, we use setTimeout(func, 100); // because in fitHeader function, we use setTimeout(func, 100);
setTimeout(() => { setTimeout(() => {
initResizable(this) initResizable(this)
}, 100) }, 100)
} }
} }
} }

View File

@ -1,109 +1,109 @@
/** /**
* Bootstrap Table Chinese translation * Bootstrap Table Chinese translation
* Author: Zhixin Wen<wenzhixin2010@gmail.com> * Author: Zhixin Wen<wenzhixin2010@gmail.com>
*/ */
$.fn.bootstrapTable.locales['zh-CN'] = { $.fn.bootstrapTable.locales['zh-CN'] = {
formatShowSearch: function formatShowSearch() { formatShowSearch: function formatShowSearch() {
return '隐藏/显示搜索'; return '隐藏/显示搜索';
}, },
formatPageGo: function formatPageGo() { formatPageGo: function formatPageGo() {
return '跳转'; return '跳转';
}, },
formatCopyRows: function formatCopyRows() { formatCopyRows: function formatCopyRows() {
return '复制行'; return '复制行';
}, },
formatPrint: function formatPrint() { formatPrint: function formatPrint() {
return '打印'; return '打印';
}, },
formatLoadingMessage: function formatLoadingMessage() { formatLoadingMessage: function formatLoadingMessage() {
return '正在努力地加载数据中,请稍候'; return '正在努力地加载数据中,请稍候';
}, },
formatRecordsPerPage: function formatRecordsPerPage(pageNumber) { formatRecordsPerPage: function formatRecordsPerPage(pageNumber) {
return "每页显示 ".concat(pageNumber, " 条记录"); return "每页显示 ".concat(pageNumber, " 条记录");
}, },
formatShowingRows: function formatShowingRows(pageFrom, pageTo, totalRows, totalNotFiltered) { formatShowingRows: function formatShowingRows(pageFrom, pageTo, totalRows, totalNotFiltered) {
if (totalNotFiltered !== undefined && totalNotFiltered > 0 && totalNotFiltered > totalRows) { if (totalNotFiltered !== undefined && totalNotFiltered > 0 && totalNotFiltered > totalRows) {
return "显示第 ".concat(pageFrom, " 到第 ").concat(pageTo, " 条记录,总共 ").concat(totalRows, " 条记录(从 ").concat(totalNotFiltered, " 总记录中过滤)"); return "显示第 ".concat(pageFrom, " 到第 ").concat(pageTo, " 条记录,总共 ").concat(totalRows, " 条记录(从 ").concat(totalNotFiltered, " 总记录中过滤)");
} }
return "显示第 ".concat(pageFrom, " 到第 ").concat(pageTo, " 条记录,总共 ").concat(totalRows, " 条记录"); return "显示第 ".concat(pageFrom, " 到第 ").concat(pageTo, " 条记录,总共 ").concat(totalRows, " 条记录");
}, },
formatSRPaginationPreText: function formatSRPaginationPreText() { formatSRPaginationPreText: function formatSRPaginationPreText() {
return '上一页'; return '上一页';
}, },
formatSRPaginationPageText: function formatSRPaginationPageText(page) { formatSRPaginationPageText: function formatSRPaginationPageText(page) {
return "第".concat(page, "页"); return "第".concat(page, "页");
}, },
formatSRPaginationNextText: function formatSRPaginationNextText() { formatSRPaginationNextText: function formatSRPaginationNextText() {
return '下一页'; return '下一页';
}, },
formatDetailPagination: function formatDetailPagination(totalRows) { formatDetailPagination: function formatDetailPagination(totalRows) {
return "总共 ".concat(totalRows, " 条记录"); return "总共 ".concat(totalRows, " 条记录");
}, },
formatClearSearch: function formatClearSearch() { formatClearSearch: function formatClearSearch() {
return '清空过滤'; return '清空过滤';
}, },
formatSearch: function formatSearch() { formatSearch: function formatSearch() {
return '搜索'; return '搜索';
}, },
formatNoMatches: function formatNoMatches() { formatNoMatches: function formatNoMatches() {
return '没有找到匹配的记录'; return '没有找到匹配的记录';
}, },
formatPaginationSwitch: function formatPaginationSwitch() { formatPaginationSwitch: function formatPaginationSwitch() {
return '隐藏/显示分页'; return '隐藏/显示分页';
}, },
formatPaginationSwitchDown: function formatPaginationSwitchDown() { formatPaginationSwitchDown: function formatPaginationSwitchDown() {
return '显示分页'; return '显示分页';
}, },
formatPaginationSwitchUp: function formatPaginationSwitchUp() { formatPaginationSwitchUp: function formatPaginationSwitchUp() {
return '隐藏分页'; return '隐藏分页';
}, },
formatRefresh: function formatRefresh() { formatRefresh: function formatRefresh() {
return '刷新'; return '刷新';
}, },
formatToggle: function formatToggle() { formatToggle: function formatToggle() {
return '切换'; return '切换';
}, },
formatToggleOn: function formatToggleOn() { formatToggleOn: function formatToggleOn() {
return '显示卡片视图'; return '显示卡片视图';
}, },
formatToggleOff: function formatToggleOff() { formatToggleOff: function formatToggleOff() {
return '隐藏卡片视图'; return '隐藏卡片视图';
}, },
formatColumns: function formatColumns() { formatColumns: function formatColumns() {
return '列'; return '列';
}, },
formatColumnsToggleAll: function formatColumnsToggleAll() { formatColumnsToggleAll: function formatColumnsToggleAll() {
return '切换所有'; return '切换所有';
}, },
formatFullscreen: function formatFullscreen() { formatFullscreen: function formatFullscreen() {
return '全屏'; return '全屏';
}, },
formatAllRows: function formatAllRows() { formatAllRows: function formatAllRows() {
return '所有'; return '所有';
}, },
formatAutoRefresh: function formatAutoRefresh() { formatAutoRefresh: function formatAutoRefresh() {
return '自动刷新'; return '自动刷新';
}, },
formatExport: function formatExport() { formatExport: function formatExport() {
return '导出数据'; return '导出数据';
}, },
formatJumpTo: function formatJumpTo() { formatJumpTo: function formatJumpTo() {
return '跳转'; return '跳转';
}, },
formatAdvancedSearch: function formatAdvancedSearch() { formatAdvancedSearch: function formatAdvancedSearch() {
return '高级搜索'; return '高级搜索';
}, },
formatAdvancedCloseButton: function formatAdvancedCloseButton() { formatAdvancedCloseButton: function formatAdvancedCloseButton() {
return '关闭'; return '关闭';
}, },
formatFilterControlSwitch: function formatFilterControlSwitch() { formatFilterControlSwitch: function formatFilterControlSwitch() {
return '隐藏/显示过滤控制'; return '隐藏/显示过滤控制';
}, },
formatFilterControlSwitchHide: function formatFilterControlSwitchHide() { formatFilterControlSwitchHide: function formatFilterControlSwitchHide() {
return '隐藏过滤控制'; return '隐藏过滤控制';
}, },
formatFilterControlSwitchShow: function formatFilterControlSwitchShow() { formatFilterControlSwitchShow: function formatFilterControlSwitchShow() {
return '显示过滤控制'; return '显示过滤控制';
} }
}; };
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']); $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);

View File

@ -1,406 +1,406 @@
/*! /*!
* jQuery cxSelect * jQuery cxSelect
* @name jquery.cxselect.js * @name jquery.cxselect.js
* @version 1.4.2 * @version 1.4.2
* @date 2017-09-26 * @date 2017-09-26
* @author ciaoca * @author ciaoca
* @email ciaoca@gmail.com * @email ciaoca@gmail.com
* @site https://github.com/ciaoca/cxSelect * @site https://github.com/ciaoca/cxSelect
* @license Released under the MIT license * @license Released under the MIT license
*/ */
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define(['jquery'], factory); define(['jquery'], factory);
} else { } else {
factory(window.jQuery || window.Zepto || window.$); factory(window.jQuery || window.Zepto || window.$);
}; };
}(function($) { }(function($) {
var cxSelect = function() { var cxSelect = function() {
var self = this; var self = this;
var dom, settings, callback; var dom, settings, callback;
// 分配参数 // 分配参数
for (var i = 0, l = arguments.length; i < l; i++) { for (var i = 0, l = arguments.length; i < l; i++) {
if (cxSelect.isJquery(arguments[i]) || cxSelect.isZepto(arguments[i])) { if (cxSelect.isJquery(arguments[i]) || cxSelect.isZepto(arguments[i])) {
dom = arguments[i]; dom = arguments[i];
} else if (cxSelect.isElement(arguments[i])) { } else if (cxSelect.isElement(arguments[i])) {
dom = $(arguments[i]); dom = $(arguments[i]);
} else if (typeof arguments[i] === 'function') { } else if (typeof arguments[i] === 'function') {
callback = arguments[i]; callback = arguments[i];
} else if (typeof arguments[i] === 'object') { } else if (typeof arguments[i] === 'object') {
settings = arguments[i]; settings = arguments[i];
}; };
}; };
var api = new cxSelect.init(dom, settings); var api = new cxSelect.init(dom, settings);
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(api); callback(api);
}; };
return api; return api;
}; };
cxSelect.isElement = function(o){ cxSelect.isElement = function(o){
if (o && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object') && o instanceof HTMLElement) { if (o && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object') && o instanceof HTMLElement) {
return true; return true;
} else { } else {
return (o && o.nodeType && o.nodeType === 1) ? true : false; return (o && o.nodeType && o.nodeType === 1) ? true : false;
}; };
}; };
cxSelect.isJquery = function(o){ cxSelect.isJquery = function(o){
return (o && o.length && (typeof jQuery === 'function' || typeof jQuery === 'object') && o instanceof jQuery) ? true : false; return (o && o.length && (typeof jQuery === 'function' || typeof jQuery === 'object') && o instanceof jQuery) ? true : false;
}; };
cxSelect.isZepto = function(o){ cxSelect.isZepto = function(o){
return (o && o.length && (typeof Zepto === 'function' || typeof Zepto === 'object') && Zepto.zepto.isZ(o)) ? true : false; return (o && o.length && (typeof Zepto === 'function' || typeof Zepto === 'object') && Zepto.zepto.isZ(o)) ? true : false;
}; };
cxSelect.getIndex = function(n, required) { cxSelect.getIndex = function(n, required) {
return required ? n : n - 1; return required ? n : n - 1;
}; };
cxSelect.getData = function(data, space) { cxSelect.getData = function(data, space) {
if (typeof space === 'string' && space.length) { if (typeof space === 'string' && space.length) {
space = space.split('.'); space = space.split('.');
for (var i = 0, l = space.length; i < l; i++) { for (var i = 0, l = space.length; i < l; i++) {
data = data[space[i]]; data = data[space[i]];
}; };
}; };
return data; return data;
}; };
cxSelect.init = function(dom, settings) { cxSelect.init = function(dom, settings) {
var self = this; var self = this;
if (!cxSelect.isJquery(dom) && !cxSelect.isZepto(dom)) {return}; if (!cxSelect.isJquery(dom) && !cxSelect.isZepto(dom)) {return};
var theSelect = { var theSelect = {
dom: { dom: {
box: dom box: dom
} }
}; };
self.attach = cxSelect.attach.bind(theSelect); self.attach = cxSelect.attach.bind(theSelect);
self.detach = cxSelect.detach.bind(theSelect); self.detach = cxSelect.detach.bind(theSelect);
self.setOptions = cxSelect.setOptions.bind(theSelect); self.setOptions = cxSelect.setOptions.bind(theSelect);
self.clear = cxSelect.clear.bind(theSelect); self.clear = cxSelect.clear.bind(theSelect);
theSelect.changeEvent = function() { theSelect.changeEvent = function() {
cxSelect.selectChange.call(theSelect, this.className); cxSelect.selectChange.call(theSelect, this.className);
}; };
theSelect.settings = $.extend({}, $.cxSelect.defaults, settings, { theSelect.settings = $.extend({}, $.cxSelect.defaults, settings, {
url: theSelect.dom.box.data('url'), url: theSelect.dom.box.data('url'),
emptyStyle: theSelect.dom.box.data('emptyStyle'), emptyStyle: theSelect.dom.box.data('emptyStyle'),
required: theSelect.dom.box.data('required'), required: theSelect.dom.box.data('required'),
firstTitle: theSelect.dom.box.data('firstTitle'), firstTitle: theSelect.dom.box.data('firstTitle'),
firstValue: theSelect.dom.box.data('firstValue'), firstValue: theSelect.dom.box.data('firstValue'),
jsonSpace: theSelect.dom.box.data('jsonSpace'), jsonSpace: theSelect.dom.box.data('jsonSpace'),
jsonName: theSelect.dom.box.data('jsonName'), jsonName: theSelect.dom.box.data('jsonName'),
jsonValue: theSelect.dom.box.data('jsonValue'), jsonValue: theSelect.dom.box.data('jsonValue'),
jsonSub: theSelect.dom.box.data('jsonSub') jsonSub: theSelect.dom.box.data('jsonSub')
}); });
var _dataSelects = theSelect.dom.box.data('selects'); var _dataSelects = theSelect.dom.box.data('selects');
if (typeof _dataSelects === 'string' && _dataSelects.length) { if (typeof _dataSelects === 'string' && _dataSelects.length) {
theSelect.settings.selects = _dataSelects.split(','); theSelect.settings.selects = _dataSelects.split(',');
}; };
self.setOptions(); self.setOptions();
self.attach(); self.attach();
// 使用独立接口获取数据 // 使用独立接口获取数据
if (!theSelect.settings.url && !theSelect.settings.data) { if (!theSelect.settings.url && !theSelect.settings.data) {
cxSelect.start.apply(theSelect); cxSelect.start.apply(theSelect);
// 设置自定义数据 // 设置自定义数据
} else if ($.isArray(theSelect.settings.data)) { } else if ($.isArray(theSelect.settings.data)) {
cxSelect.start.call(theSelect, theSelect.settings.data); cxSelect.start.call(theSelect, theSelect.settings.data);
// 设置 URL通过 Ajax 获取数据 // 设置 URL通过 Ajax 获取数据
} else if (typeof theSelect.settings.url === 'string' && theSelect.settings.url.length) { } else if (typeof theSelect.settings.url === 'string' && theSelect.settings.url.length) {
$.getJSON(theSelect.settings.url, function(json) { $.getJSON(theSelect.settings.url, function(json) {
cxSelect.start.call(theSelect, json); cxSelect.start.call(theSelect, json);
}); });
}; };
}; };
// 设置参数 // 设置参数
cxSelect.setOptions = function(opts) { cxSelect.setOptions = function(opts) {
var self = this; var self = this;
if (opts) { if (opts) {
$.extend(self.settings, opts); $.extend(self.settings, opts);
}; };
// 初次或重设选择器组 // 初次或重设选择器组
if (!$.isArray(self.selectArray) || !self.selectArray.length || (opts && opts.selects)) { if (!$.isArray(self.selectArray) || !self.selectArray.length || (opts && opts.selects)) {
self.selectArray = []; self.selectArray = [];
if ($.isArray(self.settings.selects) && self.settings.selects.length) { if ($.isArray(self.settings.selects) && self.settings.selects.length) {
var _tempSelect; var _tempSelect;
for (var i = 0, l = self.settings.selects.length; i < l; i++) { for (var i = 0, l = self.settings.selects.length; i < l; i++) {
_tempSelect = self.dom.box.find('select.' + self.settings.selects[i]); _tempSelect = self.dom.box.find('select.' + self.settings.selects[i]);
if (!_tempSelect || !_tempSelect.length) {break}; if (!_tempSelect || !_tempSelect.length) {break};
self.selectArray.push(_tempSelect); self.selectArray.push(_tempSelect);
}; };
}; };
}; };
if (opts) { if (opts) {
if (!$.isArray(opts.data) && typeof opts.url === 'string' && opts.url.length) { if (!$.isArray(opts.data) && typeof opts.url === 'string' && opts.url.length) {
$.getJSON(self.settings.url, function(json) { $.getJSON(self.settings.url, function(json) {
cxSelect.start.call(self, json); cxSelect.start.call(self, json);
}); });
} else { } else {
cxSelect.start.call(self, opts.data); cxSelect.start.call(self, opts.data);
}; };
}; };
}; };
// 绑定 // 绑定
cxSelect.attach = function() { cxSelect.attach = function() {
var self = this; var self = this;
if (!self.attachStatus) { if (!self.attachStatus) {
self.dom.box.on('change', 'select', self.changeEvent); self.dom.box.on('change', 'select', self.changeEvent);
}; };
if (typeof self.attachStatus === 'boolean') { if (typeof self.attachStatus === 'boolean') {
cxSelect.start.call(self); cxSelect.start.call(self);
}; };
self.attachStatus = true; self.attachStatus = true;
}; };
// 移除绑定 // 移除绑定
cxSelect.detach = function() { cxSelect.detach = function() {
var self = this; var self = this;
self.dom.box.off('change', 'select', self.changeEvent); self.dom.box.off('change', 'select', self.changeEvent);
self.attachStatus = false; self.attachStatus = false;
}; };
// 清空选项 // 清空选项
cxSelect.clear = function(index) { cxSelect.clear = function(index) {
var self = this; var self = this;
var _style = { var _style = {
display: '', display: '',
visibility: '' visibility: ''
}; };
index = isNaN(index) ? 0 : index; index = isNaN(index) ? 0 : index;
// 清空后面的 select // 清空后面的 select
for (var i = index, l = self.selectArray.length; i < l; i++) { for (var i = index, l = self.selectArray.length; i < l; i++) {
self.selectArray[i].empty().prop('disabled', true); self.selectArray[i].empty().prop('disabled', true);
if (self.settings.emptyStyle === 'none') { if (self.settings.emptyStyle === 'none') {
_style.display = 'none'; _style.display = 'none';
} else if (self.settings.emptyStyle === 'hidden') { } else if (self.settings.emptyStyle === 'hidden') {
_style.visibility = 'hidden'; _style.visibility = 'hidden';
}; };
self.selectArray[i].css(_style); self.selectArray[i].css(_style);
}; };
}; };
cxSelect.start = function(data) { cxSelect.start = function(data) {
var self = this; var self = this;
if ($.isArray(data)) { if ($.isArray(data)) {
self.settings.data = cxSelect.getData(data, self.settings.jsonSpace); self.settings.data = cxSelect.getData(data, self.settings.jsonSpace);
}; };
if (!self.selectArray.length) {return}; if (!self.selectArray.length) {return};
// 保存默认值 // 保存默认值
for (var i = 0, l = self.selectArray.length; i < l; i++) { for (var i = 0, l = self.selectArray.length; i < l; i++) {
if (typeof self.selectArray[i].attr('data-value') !== 'string' && self.selectArray[i][0].options.length) { if (typeof self.selectArray[i].attr('data-value') !== 'string' && self.selectArray[i][0].options.length) {
self.selectArray[i].attr('data-value', self.selectArray[i].val()); self.selectArray[i].attr('data-value', self.selectArray[i].val());
}; };
}; };
if (self.settings.data || (typeof self.selectArray[0].data('url') === 'string' && self.selectArray[0].data('url').length)) { if (self.settings.data || (typeof self.selectArray[0].data('url') === 'string' && self.selectArray[0].data('url').length)) {
cxSelect.getOptionData.call(self, 0); cxSelect.getOptionData.call(self, 0);
} else if (self.selectArray[0][0].options.length && typeof self.selectArray[0].attr('data-value') === 'string' && self.selectArray[0].attr('data-value').length) { } else if (self.selectArray[0][0].options.length && typeof self.selectArray[0].attr('data-value') === 'string' && self.selectArray[0].attr('data-value').length) {
self.selectArray[0].val(self.selectArray[0].attr('data-value')); self.selectArray[0].val(self.selectArray[0].attr('data-value'));
cxSelect.getOptionData.call(self, 1); cxSelect.getOptionData.call(self, 1);
} else { } else {
self.selectArray[0].prop('disabled', false).css({ self.selectArray[0].prop('disabled', false).css({
'display': '', 'display': '',
'visibility': '' 'visibility': ''
}); });
}; };
}; };
// 获取选项数据 // 获取选项数据
cxSelect.getOptionData = function(index) { cxSelect.getOptionData = function(index) {
var self = this; var self = this;
if (typeof index !== 'number' || isNaN(index) || index < 0 || index >= self.selectArray.length) {return}; if (typeof index !== 'number' || isNaN(index) || index < 0 || index >= self.selectArray.length) {return};
var _indexPrev = index - 1; var _indexPrev = index - 1;
var _select = self.selectArray[index]; var _select = self.selectArray[index];
var _selectData; var _selectData;
var _valueIndex; var _valueIndex;
var _dataUrl = _select.data('url'); var _dataUrl = _select.data('url');
var _jsonSpace = typeof _select.data('jsonSpace') === 'undefined' ? self.settings.jsonSpace : _select.data('jsonSpace'); var _jsonSpace = typeof _select.data('jsonSpace') === 'undefined' ? self.settings.jsonSpace : _select.data('jsonSpace');
var _query = {}; var _query = {};
var _queryName; var _queryName;
var _selectName; var _selectName;
var _selectValue; var _selectValue;
cxSelect.clear.call(self, index); cxSelect.clear.call(self, index);
// 使用独立接口 // 使用独立接口
if (typeof _dataUrl === 'string' && _dataUrl.length) { if (typeof _dataUrl === 'string' && _dataUrl.length) {
if (index > 0) { if (index > 0) {
for (var i = 0, j = 1; i < index; i++, j++) { for (var i = 0, j = 1; i < index; i++, j++) {
_queryName = self.selectArray[j].data('queryName'); _queryName = self.selectArray[j].data('queryName');
_selectName = self.selectArray[i].attr('name'); _selectName = self.selectArray[i].attr('name');
_selectValue = self.selectArray[i].val(); _selectValue = self.selectArray[i].val();
if (typeof _queryName === 'string' && _queryName.length) { if (typeof _queryName === 'string' && _queryName.length) {
_query[_queryName] = _selectValue; _query[_queryName] = _selectValue;
} else if (typeof _selectName === 'string' && _selectName.length) { } else if (typeof _selectName === 'string' && _selectName.length) {
_query[_selectName] = _selectValue; _query[_selectName] = _selectValue;
}; };
}; };
}; };
$.getJSON(_dataUrl, _query, function(json) { $.getJSON(_dataUrl, _query, function(json) {
_selectData = cxSelect.getData(json, _jsonSpace); _selectData = cxSelect.getData(json, _jsonSpace);
cxSelect.buildOption.call(self, index, _selectData); cxSelect.buildOption.call(self, index, _selectData);
}); });
// 使用整合数据 // 使用整合数据
} else if (self.settings.data && typeof self.settings.data === 'object') { } else if (self.settings.data && typeof self.settings.data === 'object') {
_selectData = self.settings.data; _selectData = self.settings.data;
for (var i = 0; i < index; i++) { for (var i = 0; i < index; i++) {
_valueIndex = cxSelect.getIndex(self.selectArray[i][0].selectedIndex, typeof self.selectArray[i].data('required') === 'boolean' ? self.selectArray[i].data('required') : self.settings.required); _valueIndex = cxSelect.getIndex(self.selectArray[i][0].selectedIndex, typeof self.selectArray[i].data('required') === 'boolean' ? self.selectArray[i].data('required') : self.settings.required);
if (typeof _selectData[_valueIndex] === 'object' && $.isArray(_selectData[_valueIndex][self.settings.jsonSub]) && _selectData[_valueIndex][self.settings.jsonSub].length) { if (typeof _selectData[_valueIndex] === 'object' && $.isArray(_selectData[_valueIndex][self.settings.jsonSub]) && _selectData[_valueIndex][self.settings.jsonSub].length) {
_selectData = _selectData[_valueIndex][self.settings.jsonSub]; _selectData = _selectData[_valueIndex][self.settings.jsonSub];
} else { } else {
_selectData = null; _selectData = null;
break; break;
}; };
}; };
cxSelect.buildOption.call(self, index, _selectData); cxSelect.buildOption.call(self, index, _selectData);
}; };
}; };
// 构建选项列表 // 构建选项列表
cxSelect.buildOption = function(index, data) { cxSelect.buildOption = function(index, data) {
var self = this; var self = this;
var _select = self.selectArray[index]; var _select = self.selectArray[index];
var _required = typeof _select.data('required') === 'boolean' ? _select.data('required') : self.settings.required; var _required = typeof _select.data('required') === 'boolean' ? _select.data('required') : self.settings.required;
var _firstTitle = typeof _select.data('firstTitle') === 'undefined' ? self.settings.firstTitle : _select.data('firstTitle'); var _firstTitle = typeof _select.data('firstTitle') === 'undefined' ? self.settings.firstTitle : _select.data('firstTitle');
var _firstValue = typeof _select.data('firstValue') === 'undefined' ? self.settings.firstValue : _select.data('firstValue'); var _firstValue = typeof _select.data('firstValue') === 'undefined' ? self.settings.firstValue : _select.data('firstValue');
var _jsonName = typeof _select.data('jsonName') === 'undefined' ? self.settings.jsonName : _select.data('jsonName'); var _jsonName = typeof _select.data('jsonName') === 'undefined' ? self.settings.jsonName : _select.data('jsonName');
var _jsonValue = typeof _select.data('jsonValue') === 'undefined' ? self.settings.jsonValue : _select.data('jsonValue'); var _jsonValue = typeof _select.data('jsonValue') === 'undefined' ? self.settings.jsonValue : _select.data('jsonValue');
if (!$.isArray(data)) {return}; if (!$.isArray(data)) {return};
var _html = !_required ? '<option value="' + String(_firstValue) + '">' + String(_firstTitle) + '</option>' : ''; var _html = !_required ? '<option value="' + String(_firstValue) + '">' + String(_firstTitle) + '</option>' : '';
// 区分标题、值的数据 // 区分标题、值的数据
if (typeof _jsonName === 'string' && _jsonName.length) { if (typeof _jsonName === 'string' && _jsonName.length) {
// 无值字段时使用标题作为值 // 无值字段时使用标题作为值
if (typeof _jsonValue !== 'string' || !_jsonValue.length) { if (typeof _jsonValue !== 'string' || !_jsonValue.length) {
_jsonValue = _jsonName; _jsonValue = _jsonName;
}; };
for (var i = 0, l = data.length; i < l; i++) { for (var i = 0, l = data.length; i < l; i++) {
_html += '<option value="' + String(data[i][_jsonValue]) + '">' + String(data[i][_jsonName]) + '</option>'; _html += '<option value="' + String(data[i][_jsonValue]) + '">' + String(data[i][_jsonName]) + '</option>';
}; };
// 数组即为值的数据 // 数组即为值的数据
} else { } else {
for (var i = 0, l = data.length; i < l; i++) { for (var i = 0, l = data.length; i < l; i++) {
_html += '<option value="' + String(data[i]) + '">' + String(data[i]) + '</option>'; _html += '<option value="' + String(data[i]) + '">' + String(data[i]) + '</option>';
}; };
}; };
_select.html(_html).prop('disabled', false).css({ _select.html(_html).prop('disabled', false).css({
'display': '', 'display': '',
'visibility': '' 'visibility': ''
}); });
// 初次加载设置默认值 // 初次加载设置默认值
if (typeof _select.attr('data-value') === 'string') { if (typeof _select.attr('data-value') === 'string') {
_select.val(String(_select.attr('data-value'))).removeAttr('data-value'); _select.val(String(_select.attr('data-value'))).removeAttr('data-value');
if (_select[0].selectedIndex < 0) { if (_select[0].selectedIndex < 0) {
_select[0].options[0].selected = true; _select[0].options[0].selected = true;
}; };
}; };
if (_required || _select[0].selectedIndex > 0) { if (_required || _select[0].selectedIndex > 0) {
_select.trigger('change'); _select.trigger('change');
}; };
}; };
// 改变选择时的处理 // 改变选择时的处理
cxSelect.selectChange = function(name) { cxSelect.selectChange = function(name) {
var self = this; var self = this;
if (typeof name !== 'string' || !name.length) {return}; if (typeof name !== 'string' || !name.length) {return};
var index; var index;
name = name.replace(/\s+/g, ','); name = name.replace(/\s+/g, ',');
name = ',' + name + ','; name = ',' + name + ',';
// 获取当前 select 位置 // 获取当前 select 位置
for (var i = 0, l = self.selectArray.length; i < l; i++) { for (var i = 0, l = self.selectArray.length; i < l; i++) {
if (name.indexOf(',' + self.settings.selects[i] + ',') > -1) { if (name.indexOf(',' + self.settings.selects[i] + ',') > -1) {
index = i; index = i;
break; break;
}; };
}; };
if (typeof index === 'number' && index > -1) { if (typeof index === 'number' && index > -1) {
index += 1; index += 1;
cxSelect.getOptionData.call(self, index); cxSelect.getOptionData.call(self, index);
}; };
}; };
$.cxSelect = function() { $.cxSelect = function() {
return cxSelect.apply(this, arguments); return cxSelect.apply(this, arguments);
}; };
// 默认值 // 默认值
$.cxSelect.defaults = { $.cxSelect.defaults = {
selects: [], // 下拉选框组 selects: [], // 下拉选框组
url: null, // 列表数据文件路径URL或数组数据 url: null, // 列表数据文件路径URL或数组数据
data: null, // 自定义数据 data: null, // 自定义数据
emptyStyle: null, // 无数据状态显示方式 emptyStyle: null, // 无数据状态显示方式
required: false, // 是否为必选 required: false, // 是否为必选
firstTitle: '请选择', // 第一个选项的标题 firstTitle: '请选择', // 第一个选项的标题
firstValue: '', // 第一个选项的值 firstValue: '', // 第一个选项的值
jsonSpace: '', // 数据命名空间 jsonSpace: '', // 数据命名空间
jsonName: 'n', // 数据标题字段名称 jsonName: 'n', // 数据标题字段名称
jsonValue: '', // 数据值字段名称 jsonValue: '', // 数据值字段名称
jsonSub: 's' // 子集数据字段名称 jsonSub: 's' // 子集数据字段名称
}; };
$.fn.cxSelect = function(settings, callback) { $.fn.cxSelect = function(settings, callback) {
this.each(function(i) { this.each(function(i) {
$.cxSelect(this, settings, callback); $.cxSelect(this, settings, callback);
}); });
return this; return this;
}; };
})); }));

Some files were not shown because too many files have changed in this diff Show More