Browse Source

init

master
许孟阳 4 years ago
commit
67c5cc265e
  1. 6
      java/.gitignore
  2. 9
      java/application.properties
  3. 21
      java/log4j2.xml
  4. 98
      java/pom.xml
  5. 30
      java/src/main/java/com/mengyxu/admin/AdminApplocation.java
  6. 43
      java/src/main/java/com/mengyxu/admin/PageController.java
  7. 60
      java/src/main/java/com/mengyxu/admin/PublicContoller.java
  8. 126
      java/src/main/java/com/mengyxu/admin/conf/BaseSprtWebMvcConfigurer.java
  9. 131
      java/src/main/java/com/mengyxu/admin/conf/PermissionInteceptor.java
  10. 57
      java/src/main/java/com/mengyxu/admin/sys/controller/DictionaryController.java
  11. 38
      java/src/main/java/com/mengyxu/admin/sys/controller/LogController.java
  12. 66
      java/src/main/java/com/mengyxu/admin/sys/controller/MemoryController.java
  13. 50
      java/src/main/java/com/mengyxu/admin/sys/controller/UserItemController.java
  14. 20
      java/src/main/java/com/mengyxu/admin/sys/mapper/IActionLogMapper.java
  15. 16
      java/src/main/java/com/mengyxu/admin/sys/mapper/IConfigMapper.java
  16. 29
      java/src/main/java/com/mengyxu/admin/sys/mapper/IDictionaryMapper.java
  17. 22
      java/src/main/java/com/mengyxu/admin/sys/mapper/IUserItemMapper.java
  18. 24
      java/src/main/java/com/mengyxu/admin/sys/pojo/ActionLog.java
  19. 29
      java/src/main/java/com/mengyxu/admin/sys/pojo/Dictionary.java
  20. 33
      java/src/main/java/com/mengyxu/admin/sys/pojo/SysConfig.java
  21. 32
      java/src/main/java/com/mengyxu/admin/sys/pojo/UserItem.java
  22. 31
      java/src/main/java/com/mengyxu/admin/sys/service/IConfigService.java
  23. 35
      java/src/main/java/com/mengyxu/admin/sys/service/IDictionaryService.java
  24. 23
      java/src/main/java/com/mengyxu/admin/sys/service/ILogService.java
  25. 24
      java/src/main/java/com/mengyxu/admin/sys/service/IUserItemService.java
  26. 100
      java/src/main/java/com/mengyxu/admin/sys/service/impl/ConfigService.java
  27. 99
      java/src/main/java/com/mengyxu/admin/sys/service/impl/DictionaryService.java
  28. 61
      java/src/main/java/com/mengyxu/admin/sys/service/impl/LogService.java
  29. 53
      java/src/main/java/com/mengyxu/admin/sys/service/impl/UserItemService.java
  30. 120
      java/src/main/java/com/mengyxu/admin/um/controller/LoginController.java
  31. 113
      java/src/main/java/com/mengyxu/admin/um/controller/PermissionController.java
  32. 123
      java/src/main/java/com/mengyxu/admin/um/controller/UserController.java
  33. 101
      java/src/main/java/com/mengyxu/admin/um/mapper/IPermissionMapper.java
  34. 24
      java/src/main/java/com/mengyxu/admin/um/mapper/IRolePermissionMapper.java
  35. 22
      java/src/main/java/com/mengyxu/admin/um/mapper/IUserMapper.java
  36. 22
      java/src/main/java/com/mengyxu/admin/um/pojo/Menu.java
  37. 18
      java/src/main/java/com/mengyxu/admin/um/pojo/MenuParam.java
  38. 23
      java/src/main/java/com/mengyxu/admin/um/pojo/Permission.java
  39. 25
      java/src/main/java/com/mengyxu/admin/um/pojo/Rockey.java
  40. 29
      java/src/main/java/com/mengyxu/admin/um/pojo/Role.java
  41. 54
      java/src/main/java/com/mengyxu/admin/um/pojo/User.java
  42. 25
      java/src/main/java/com/mengyxu/admin/um/service/IMenuService.java
  43. 25
      java/src/main/java/com/mengyxu/admin/um/service/IPermissionService.java
  44. 27
      java/src/main/java/com/mengyxu/admin/um/service/IPermissionValidationService.java
  45. 22
      java/src/main/java/com/mengyxu/admin/um/service/IRolePermissionService.java
  46. 27
      java/src/main/java/com/mengyxu/admin/um/service/IUserService.java
  47. 103
      java/src/main/java/com/mengyxu/admin/um/service/impl/PermissionService.java
  48. 71
      java/src/main/java/com/mengyxu/admin/um/service/impl/RolePermissionService.java
  49. 178
      java/src/main/java/com/mengyxu/admin/um/service/impl/UserService.java
  50. 75
      java/src/main/java/com/mengyxu/admin/utils/AdminLogUtil.java
  51. 66
      java/src/main/java/com/mengyxu/admin/utils/BaseLogUtil.java
  52. 181
      java/src/main/java/com/mengyxu/admin/utils/LoginUtil.java
  53. 35
      java/src/main/resources/application.properties
  54. 77
      java/src/main/resources/mapper/sys/IActionLogMapper.xml
  55. 66
      java/src/main/resources/mapper/sys/IConfigMapper.xml
  56. 153
      java/src/main/resources/mapper/sys/IDictionaryMapper.xml
  57. 95
      java/src/main/resources/mapper/sys/IUserItemMapper.xml
  58. 257
      java/src/main/resources/mapper/um/IPermissionMapper.xml
  59. 114
      java/src/main/resources/mapper/um/IRolePermissionMapper.xml
  60. 146
      java/src/main/resources/mapper/um/IUserMapper.xml
  61. 143
      sql/admin_data_01.sql
  62. 120
      sql/admin_schemal_01.sql
  63. 5
      vue/.editorconfig
  64. 2
      vue/.env.development
  65. 2
      vue/.env.preview
  66. 2
      vue/.env.production
  67. 2
      vue/.env.test
  68. 22
      vue/.gitignore
  69. 24
      vue/README.md
  70. 5
      vue/babel.config.js
  71. 70
      vue/package.json
  72. BIN
      vue/public/favicon.ico
  73. 17
      vue/public/index.html
  74. BIN
      vue/src/assets/logo.png
  75. 168
      vue/src/components/main/NavHeader.vue
  76. 250
      vue/src/components/template/manage.vue
  77. 62
      vue/src/components/template/modifyItem.vue
  78. 15
      vue/src/main.ts
  79. 61
      vue/src/router/index.ts
  80. 13
      vue/src/shims-tsx.d.ts
  81. 4
      vue/src/shims-vue.d.ts
  82. 248
      vue/src/static/plugins/axios.ts
  83. 47
      vue/src/static/plugins/element.ts
  84. 75
      vue/src/static/tool/dateUtil.js
  85. 222
      vue/src/static/tool/validate.js
  86. 13
      vue/src/store/actions.js
  87. 15
      vue/src/store/index.ts
  88. 3
      vue/src/store/modules.js
  89. 155
      vue/src/store/mutations.js
  90. 9
      vue/src/store/state.js
  91. 175
      vue/src/views/main/App.vue
  92. 43
      vue/src/views/main/home.vue
  93. 194
      vue/src/views/main/login.vue
  94. 184
      vue/src/views/operator/buffer.vue
  95. 252
      vue/src/views/operator/dictionary.vue
  96. 268
      vue/src/views/operator/permission.vue
  97. 159
      vue/src/views/operator/status.vue
  98. 101
      vue/src/views/sys/log.vue
  99. 196
      vue/src/views/sys/role.vue
  100. 189
      vue/src/views/sys/user.vue
  101. Some files were not shown because too many files have changed in this diff Show More

6
java/.gitignore vendored

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
/.classpath
/.project
/.settings
/bin/
/logs
/target

9
java/application.properties

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
server.port=80
server.servlet.context-path=/
logging.config:log4j2.xml
# 程序自身数据源配置
spring.datasource.url=jdbc:mysql://localhost:3306/admin?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=51131420

21
java/log4j2.xml

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configuration后面的status,这个用于设置log4j2自身内部的信息输出 -->
<!-- monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数。 -->
<configuration status="error" monitorInterval="60">
<appenders>
<!--控制台 -->
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" />
<!--输出日志的格式 -->
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%p] %class{36} %L %M - %msg%xEx%n" />
</Console>
</appenders>
<loggers>
<logger name="com.sprt" level="DEBUG"></logger>
<root level="warn">
<appender-ref ref="Console" />
</root>
</loggers>
</configuration>

98
java/pom.xml

@ -0,0 +1,98 @@ @@ -0,0 +1,98 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<groupId>com.mengyxu.admin</groupId>
<artifactId>mengyxu_admin</artifactId>
<version>0.0.1</version>
<name>admin</name>
<description>mengyxu-admin</description>
<packaging>jar</packaging>
<properties>
<mengyxu.core.version>0.0.1</mengyxu.core.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<mybatis.pagehelper.version>1.2.5</mybatis.pagehelper.version>
<mybatis-spring-boot.version>1.3.2</mybatis-spring-boot.version>
<druid.version>1.1.9</druid.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<dependencies>
<dependency>
<groupId>com.mengyxu.core</groupId>
<artifactId>mengyxu_core</artifactId>
<version>${mengyxu.core.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 代码修改之后可以实时生效,该模块在完整的打包环境下运行的时候会被禁用 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!-- Log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- spring-boot整合mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot.version}</version>
</dependency>
<!-- mybatis的pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${mybatis.pagehelper.version}</version>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- alibaba的druid数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.commons</groupId> -->
<!-- <artifactId>commons-lang3</artifactId> -->
<!-- </dependency> -->
</dependencies>
</project>

30
java/src/main/java/com/mengyxu/admin/AdminApplocation.java

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
package com.mengyxu.admin;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
@ComponentScan(value = "com.mengyxu", useDefaultFilters = true)
@MapperScan("com.mengyxu.admin.**.mapper")
public class AdminApplocation extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AdminApplocation.class);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(AdminApplocation.class);
}
}

43
java/src/main/java/com/mengyxu/admin/PageController.java

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
package com.mengyxu.admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("page")
public class PageController {
@RequestMapping("{page}")
public String toPage(@PathVariable("page") String page) {
return page;
}
@RequestMapping("{path}/{page}")
public String toPathPage(@PathVariable("path") String path, @PathVariable("page") String page) {
return path + "/" + page;
}
@RequestMapping("{path1}/{path2}/{page}")
public String toDoublePathPage(@PathVariable("path1") String path1, @PathVariable("path2") String path2,
@PathVariable("page") String page) {
return path1 + "/" + path2 + "/" + page;
}
@RequestMapping("adapter/{page}")
public String toPageAdapter(@PathVariable("page") String page) {
return page;
}
@RequestMapping("adapter/{path}/{page}")
public String toPathPageAdapter(@PathVariable("path") String path, @PathVariable("page") String page) {
return path + "/" + page;
}
@RequestMapping("adapter/{path1}/{path2}/{page}")
public String toDoublePathPageAdapter(@PathVariable("path1") String path1, @PathVariable("path2") String path2,
@PathVariable("page") String page) {
return path1 + "/" + path2 + "/" + page;
}
}

60
java/src/main/java/com/mengyxu/admin/PublicContoller.java

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
package com.mengyxu.admin;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.mengyxu.admin.sys.pojo.Dictionary;
import com.mengyxu.admin.sys.service.IDictionaryService;
import com.mengyxu.admin.um.pojo.Permission;
import com.mengyxu.admin.um.service.IPermissionService;
import com.mengyxu.admin.um.service.IRolePermissionService;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.Entry;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年10月21日
*/
@RestController
@RequestMapping("public")
public class PublicContoller {
@Autowired
private IRolePermissionService roleService;
@Autowired
private IPermissionService perService;
@Autowired
private IDictionaryService dictService;
@RequestMapping(value = "role/map", method = RequestMethod.GET)
public List<Entry<String, String>> queryRoleMaps() {
return roleService.queryRoleMaps();
}
@RequestMapping(value = "per/list", method = RequestMethod.GET)
public List<Permission> queryPermissionTree(HttpServletRequest request) throws CoreException{
return perService.queryPermissionTree(false);
}
@RequestMapping(value = "my/action/per")
public List<String> queryMyActionPermissions(HttpServletRequest request) throws CoreException {
String userName = LoginUtil.getUserId(request);
String parentContent = LoginUtil.getParentContent(request);
return perService.myPermissions(userName, parentContent);
}
@RequestMapping(value = "get/dict", method = RequestMethod.POST)
public Map<String, List<Dictionary>> getDictionarys(@RequestBody String[] codes) {
return dictService.getDicts(codes);
}
}

126
java/src/main/java/com/mengyxu/admin/conf/BaseSprtWebMvcConfigurer.java

@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
package com.mengyxu.admin.conf;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.mengyxu.admin.sys.service.ILogService;
import com.mengyxu.admin.utils.BaseLogUtil;
import com.mengyxu.admin.utils.LoginUtil;
@Configuration
public class BaseSprtWebMvcConfigurer implements WebMvcConfigurer {
@Autowired
private PermissionInteceptor permissionInteceptor;
@Autowired
public void setLogService(ILogService logService) {
BaseLogUtil.logService = logService;
}
@Autowired
public void setEnvironment(Environment env) {
// String packageType = env.getProperty("service.package.type");
// if ("jar".equals(packageType)) {
// GlobalConstant.RESOURCES_ROOT_PATH = GlobalConstant.JAR_RESOURCES_PATH;
// GlobalConstant.FILE_DOWNLOAD_PATH = GlobalConstant.JAR_DOWNLOAD_PATH;
// }
String timeout = env.getProperty("timeout.login.token", "30");
LoginUtil.timeout = Integer.parseInt(timeout);
LoginUtil.domain = env.getProperty("login.token.domain");
}
/**
* 跨域支持
*
* @param registry
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*").allowedHeaders("*").allowCredentials(true).allowedMethods("*")
.maxAge(3600 * 24);
}
/**
* 权限拦截器
*
* @param registry
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
List<String> patterns = new ArrayList<>();
patterns.add("/um/**");
patterns.add("/public/**");
patterns.add("/*.html");
patterns.add("/css/**");
patterns.add("/fonts/**");
patterns.add("/image/**");
patterns.add("/js/**");
patterns.add("/lib/**");
patterns.add("/plugs/**");
patterns.add("/private/**");
patterns.add("/error");
registry.addInterceptor(permissionInteceptor).addPathPatterns("/**").excludePathPatterns(patterns);
WebMvcConfigurer.super.addInterceptors(registry);
}
/**
* 默认JSON解析器从Jackson改为FastJson
*
* @param registry
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
Iterator<HttpMessageConverter<?>> iterator = converters.iterator();
while (iterator.hasNext()) {
HttpMessageConverter<?> converter = iterator.next();
if (converter instanceof MappingJackson2HttpMessageConverter) {
iterator.remove();
}
}
// 升级最新版本需加======解决报错:Content-Type' cannot contain wildcard type '*
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
supportedMediaTypes.add(MediaType.APPLICATION_ATOM_XML);
supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
supportedMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM);
supportedMediaTypes.add(MediaType.APPLICATION_PDF);
supportedMediaTypes.add(MediaType.APPLICATION_RSS_XML);
supportedMediaTypes.add(MediaType.APPLICATION_XHTML_XML);
supportedMediaTypes.add(MediaType.APPLICATION_XML);
supportedMediaTypes.add(MediaType.IMAGE_GIF);
supportedMediaTypes.add(MediaType.IMAGE_JPEG);
supportedMediaTypes.add(MediaType.IMAGE_PNG);
supportedMediaTypes.add(MediaType.TEXT_EVENT_STREAM);
supportedMediaTypes.add(MediaType.TEXT_HTML);
supportedMediaTypes.add(MediaType.TEXT_MARKDOWN);
supportedMediaTypes.add(MediaType.TEXT_PLAIN);
supportedMediaTypes.add(MediaType.TEXT_XML);
fastConverter.setSupportedMediaTypes(supportedMediaTypes);
// 2、添加fastjson的配置信息,比如 是否要格式化返回json数据
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
// 3、在convert中添加配置信息.
fastConverter.setFastJsonConfig(fastJsonConfig);
// 4、将convert添加到converters当中.
converters.add(fastConverter);
}
}

131
java/src/main/java/com/mengyxu/admin/conf/PermissionInteceptor.java

@ -0,0 +1,131 @@ @@ -0,0 +1,131 @@
package com.mengyxu.admin.conf;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import com.alibaba.fastjson.JSON;
import com.mengyxu.admin.um.service.IPermissionValidationService;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.AjaxResponse;
import com.mengyxu.core.utils.StringUtil;
import lombok.extern.log4j.Log4j2;
/**
* 权限验证拦截器
* @author v_mengyxu
*
*/
@Log4j2
@Component
public class PermissionInteceptor implements HandlerInterceptor {
@Autowired
private IPermissionValidationService validationService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
log.debug("Permission interceptor : preHandle ...");
response.setContentType("application/json;charset:UTF-8");
//获取此次请求需要的权限
String path = request.getServletPath();
try {
verifyPath(path);
//return if start with /public
if(isPublicResource(path)){
return true;
}
List<String> resourceCodes = getResourceCodes(path);
String userId = getLogonUser(request);
//判断用户是否拥有该权限
getPermissionCode(userId, resourceCodes);
} catch (CoreException e){
log.warn(e.getMessage());
response.getWriter().write(JSON.toJSONString(new AjaxResponse(false, e.getMessage())));
return false;
}
return true;
}
/**
* Lookup the login user from request/session.
* @param request
* @return
* @throws CrsPermissionException if no "loginid" found.
*/
private String getLogonUser(HttpServletRequest request) throws CoreException {
//获取用户id
String userName = LoginUtil.getUserNameAndRefresh(request);
if(userName == null){
throw new CoreException("session timeout");
}
return userName;
}
/**
* Verify if it is null or empty.
* @param path
* @throws CrsMvcException if path is null or empty.
*/
private void verifyPath(String path) throws CoreException {
if(StringUtil.isEmpty(path)){
throw new CoreException("It is an empty request path");
}
}
/**
* Search and return the resource codes by the resource content.
*
* @param path
* @return
* @throws CrsPermissionException if no resource code found.
*/
private List<String> getResourceCodes(String path) throws CoreException {
String resourcePath = path.substring(1);
List<String> resCodes = validationService.queryCodeByContent(resourcePath);
if(resCodes == null || resCodes.isEmpty()){
throw new CoreException("no permission for " + resourcePath);
}
return resCodes;
}
/**
* Verify if it an public resource.
* @param path
* @return
*/
private boolean isPublicResource(String path) {
return path.startsWith("/public");
}
/**
* Get the match resource code by user.
* @param userId
* @param resCodes
* @return
* @throws CrsPermissionException if no resource code found.
*/
private String getPermissionCode(String userId, List<String> resCodes) throws CoreException{
for (String resCode : resCodes) {
if (validationService.havePermission(userId, resCode)){
return resCode;
}
}
//No permission match.
throw new CoreException("no permission");
}
}

57
java/src/main/java/com/mengyxu/admin/sys/controller/DictionaryController.java

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
package com.mengyxu.admin.sys.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mengyxu.admin.sys.pojo.Dictionary;
import com.mengyxu.admin.sys.service.IDictionaryService;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.AjaxResponse;
import com.mengyxu.core.pojo.com.PageResponse;
/**
* Ownership belongs to the company author:mengyxu date:2019年12月6日
*/
@RestController
@RequestMapping("admin/dict")
public class DictionaryController {
@Autowired
private IDictionaryService distService;
@RequestMapping(value = "list", method = RequestMethod.GET)
public PageResponse<Dictionary> queryDistList(Dictionary example) {
Page<Dictionary> pages = PageHelper.startPage(example.getPage(), example.getSize());
List<Dictionary> list = distService.queryType(example);
PageResponse<Dictionary> rsp = new PageResponse<>();
rsp.setRows(list);
rsp.setTotal(pages.getTotal());
return rsp;
}
@RequestMapping(value = "save", method = RequestMethod.POST)
public AjaxResponse saveDistionary(@RequestBody Dictionary dist) {
distService.save(dist);
return new AjaxResponse(true, "添加数据字典成功");
}
@RequestMapping(value = "update", method = RequestMethod.POST)
public AjaxResponse updateDistionary(@RequestBody Dictionary dist) {
distService.update(dist);
return new AjaxResponse(true, "修改数据字典成功");
}
@RequestMapping(value = "delete", method = RequestMethod.POST)
public AjaxResponse deleteDistionary(@RequestBody Dictionary dist) throws CoreException {
distService.delete(dist);
return new AjaxResponse(true, "删除数据字典成功");
}
}

38
java/src/main/java/com/mengyxu/admin/sys/controller/LogController.java

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
package com.mengyxu.admin.sys.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mengyxu.admin.sys.pojo.ActionLog;
import com.mengyxu.admin.sys.service.ILogService;
import com.mengyxu.core.pojo.com.PageResponse;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月5日
*/
@RestController
@RequestMapping("admin")
public class LogController {
@Autowired
private ILogService LogService;
@RequestMapping(value = "log/action", method = RequestMethod.GET)
public PageResponse<ActionLog> queryActionLogList(ActionLog example){
Page<ActionLog> pages = PageHelper.startPage(example.getPage(), example.getSize());
List<ActionLog> list = LogService.queryActionLog(example);
PageResponse<ActionLog> rsp = new PageResponse<>();
rsp.setRows(list);
rsp.setStatus("0");
rsp.setTotal(pages.getTotal());
return rsp;
}
}

66
java/src/main/java/com/mengyxu/admin/sys/controller/MemoryController.java

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
package com.mengyxu.admin.sys.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.golbal.GlobalBuffer;
import com.mengyxu.core.pojo.BufferResult;
import com.mengyxu.core.pojo.com.AjaxResponse;
import com.mengyxu.core.pojo.com.Cache;
import lombok.extern.log4j.Log4j2;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月13日
*/
@Log4j2
@RestController
@RequestMapping("admin/memory")
public class MemoryController {
@RequestMapping("buffer/list")
public List<BufferResult> getBufferList(HttpServletRequest request){
log.info("查询缓存列表,当前登陆用户:" + LoginUtil.getUserId(request));
List<BufferResult> list = new ArrayList<>();
Map<String, Cache> buffer = GlobalBuffer.getBuffer();
for(String key : buffer.keySet()) {
list.add(new BufferResult(key, buffer.get(key)));
}
return list;
}
@RequestMapping("buffer/clean")
public AjaxResponse cleanBuffer(HttpServletRequest request){
log.info("清空失效缓存,当前登陆用户:" + LoginUtil.getUserId(request));
GlobalBuffer.cleanCache();
return new AjaxResponse(true, "清空失效缓存成功");
}
@RequestMapping(value = "buffer/delete", method = RequestMethod.POST)
public AjaxResponse deleteBuffer(@RequestBody BufferResult buffer, HttpServletRequest request){
String key = buffer.getKey();
log.info("删除缓存:"+key+",当前登陆用户:" + LoginUtil.getUserId(request));
GlobalBuffer.removeCache(key);
return new AjaxResponse(true, "删除缓存成功");
}
@RequestMapping(value = "buffer/delay", method = RequestMethod.POST)
public AjaxResponse delayBuffer(@RequestBody BufferResult buffer, HttpServletRequest request) throws CoreException{
log.info("修改缓存失效时间:"+buffer.getKey()+",当前登陆用户:" + LoginUtil.getUserId(request));
GlobalBuffer.setLoseTime(buffer.getKey(), buffer.getLoseTime());
return new AjaxResponse(true, "修改缓存失效时间成功");
}
}

50
java/src/main/java/com/mengyxu/admin/sys/controller/UserItemController.java

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
package com.mengyxu.admin.sys.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.mengyxu.admin.sys.pojo.UserItem;
import com.mengyxu.admin.sys.service.IUserItemService;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.pojo.com.AjaxResponse;
import com.mengyxu.core.utils.StringUtil;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年3月18日
*/
@RestController
@RequestMapping("public/item")
public class UserItemController {
@Autowired
private IUserItemService itemService;
@RequestMapping(value = "list", method = RequestMethod.GET)
public List<UserItem> queryList(UserItem example, HttpServletRequest request){
String userId = LoginUtil.getUserId(request);
if(StringUtil.isEmpty(userId)) {
return null;
}
example.setUserId(userId);
Integer page = example.getPage();
Integer size = example.getSize();
if(page != null && size != null) {
example.setLimitStart((page - 1) * size);
}
return itemService.queryByExample(example);
}
@RequestMapping(value = "read", method = RequestMethod.POST)
public AjaxResponse queryList(Integer id, HttpServletRequest request){
itemService.read(id);
return new AjaxResponse(true, null);
}
}

20
java/src/main/java/com/mengyxu/admin/sys/mapper/IActionLogMapper.java

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
package com.mengyxu.admin.sys.mapper;
import java.util.List;
import com.mengyxu.admin.sys.pojo.ActionLog;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年2月13日
*/
public interface IActionLogMapper {
List<ActionLog> queryByExample(ActionLog example);
void insert(ActionLog log);
void insertBatch(List<ActionLog> logs);
}

16
java/src/main/java/com/mengyxu/admin/sys/mapper/IConfigMapper.java

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
package com.mengyxu.admin.sys.mapper;
import java.util.List;
import com.mengyxu.admin.sys.pojo.SysConfig;
public interface IConfigMapper {
public String queryValueByKey(String cfgKey);
public List<SysConfig> queryByExample(SysConfig example);
public void update(SysConfig sysConfig);
}

29
java/src/main/java/com/mengyxu/admin/sys/mapper/IDictionaryMapper.java

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
package com.mengyxu.admin.sys.mapper;
import java.util.List;
import com.mengyxu.admin.sys.pojo.Dictionary;
import com.mengyxu.core.pojo.com.Entry;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月6日
*/
public interface IDictionaryMapper {
List<Dictionary> queryType(Dictionary example);
List<Dictionary> queryDict(Dictionary example);
void insertType(Dictionary type);
void insertDict(Dictionary dist);
void updateType(Dictionary type);
void updateDict(Dictionary dist);
void deleteType(String code);
void deleteDicts(String parent);
void deleteDict(Integer id);
List<Entry<String, String>> queryProvince();
List<Entry<String, String>> queryCity(String parent);
List<Entry<String, String>> queryCounty(String parent);
}

22
java/src/main/java/com/mengyxu/admin/sys/mapper/IUserItemMapper.java

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
package com.mengyxu.admin.sys.mapper;
import java.util.List;
import com.mengyxu.admin.sys.pojo.UserItem;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年3月17日
*/
public interface IUserItemMapper {
List<UserItem> queryByExample(UserItem example);
void insert(UserItem item);
void insertBatch(List<UserItem> items);
void update(UserItem item);
}

24
java/src/main/java/com/mengyxu/admin/sys/pojo/ActionLog.java

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
package com.mengyxu.admin.sys.pojo;
import com.mengyxu.core.pojo.base.BasePeriod;
import lombok.Getter;
import lombok.Setter;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年2月13日
*/
@Setter
@Getter
public class ActionLog extends BasePeriod {
private Integer id;
private String type;
private String module;
private String userId;
private String loginIp;
private String context;
}

29
java/src/main/java/com/mengyxu/admin/sys/pojo/Dictionary.java

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
package com.mengyxu.admin.sys.pojo;
import java.util.List;
import com.mengyxu.core.pojo.base.BasePageParam;
import lombok.Getter;
import lombok.Setter;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月6日
*/
@Setter
@Getter
public class Dictionary extends BasePageParam {
private String key;
private Integer id;
private String code;
private String name;
private String desc;
private String parent;
private String status;
private List<Dictionary> children;
}

33
java/src/main/java/com/mengyxu/admin/sys/pojo/SysConfig.java

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
package com.mengyxu.admin.sys.pojo;
import java.text.MessageFormat;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.alibaba.fastjson.annotation.JSONField;
import com.mengyxu.core.pojo.base.BasePageParam;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class SysConfig extends BasePageParam{
private String cfgKey;
private String cfgName;
private String cfgValue;
private String cfgType;
private String cfgDesc;
private String cfgStatus;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JSONField(format="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private String updateUser;
public String briefInfo() {
return MessageFormat.format("参数名:{0},参数值:{1}", cfgName, cfgValue);
}
}

32
java/src/main/java/com/mengyxu/admin/sys/pojo/UserItem.java

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
package com.mengyxu.admin.sys.pojo;
import java.util.Date;
import com.alibaba.fastjson.annotation.JSONField;
import com.mengyxu.core.pojo.base.BasePageParam;
import com.mengyxu.core.utils.DateUtil;
import lombok.Getter;
import lombok.Setter;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年3月17日
*/
@Setter
@Getter
public class UserItem extends BasePageParam{
private Integer id;
private String userId;
private String itemName;
private String itemDesc;
private String itemType;
private String itemFlag;
private String addUser;
@JSONField(format = DateUtil.FORMAT19_LINE_YYYYMMDDHHMMSS)
private Date addTime;
private Integer status;
}

31
java/src/main/java/com/mengyxu/admin/sys/service/IConfigService.java

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
package com.mengyxu.admin.sys.service;
import java.util.List;
import com.mengyxu.admin.sys.pojo.SysConfig;
public interface IConfigService {
public String queryValueByKey(String cfgKey);
/**
* Query the configuration by the key.
* Return the default value as provided if no item found.
* @param cfgKey
* @param defaultVal
* @return
*/
String getStringConfig(String cfgKey, String defaultVal);
long getLongConfig(String key, long defValue);
Integer getIntConfig(String key, Integer defValue);
public List<SysConfig> queryPageByExample(SysConfig example);
public void update(SysConfig sysConfig);
public void updateCfg(String key, String value, String userId);
}

35
java/src/main/java/com/mengyxu/admin/sys/service/IDictionaryService.java

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
package com.mengyxu.admin.sys.service;
import java.util.List;
import java.util.Map;
import com.mengyxu.admin.sys.pojo.Dictionary;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.Entry;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月6日
*/
public interface IDictionaryService {
List<Dictionary> queryType(Dictionary example);
void save(Dictionary dist);
void update(Dictionary dist);
void delete(Dictionary dict) throws CoreException;
Map<String, List<Dictionary>> getDicts(String[] codes);
List<Dictionary> getDict(String code);
List<Entry<String, String>> queryProvince();
List<Entry<String, String>> queryCity(String parent);
List<Entry<String, String>> queryCounty(String parent);
}

23
java/src/main/java/com/mengyxu/admin/sys/service/ILogService.java

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
package com.mengyxu.admin.sys.service;
import java.util.List;
import java.util.Map;
import com.mengyxu.admin.sys.pojo.ActionLog;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月5日
*/
public interface ILogService {
List<ActionLog> queryActionLog(ActionLog example);
void insertActionLog(ActionLog log);
void insertActionLogs(List<ActionLog> logs);
Map<String, String> getTypeMap();
}

24
java/src/main/java/com/mengyxu/admin/sys/service/IUserItemService.java

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
package com.mengyxu.admin.sys.service;
import java.util.List;
import com.mengyxu.admin.sys.pojo.UserItem;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年3月17日
*/
public interface IUserItemService {
List<UserItem> queryByExample(UserItem example);
void save(UserItem item);
void save(List<UserItem> items);
void read(Integer id);
void dealWith(Integer id);
}

100
java/src/main/java/com/mengyxu/admin/sys/service/impl/ConfigService.java

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
package com.mengyxu.admin.sys.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mengyxu.admin.sys.mapper.IConfigMapper;
import com.mengyxu.admin.sys.pojo.SysConfig;
import com.mengyxu.admin.sys.service.IConfigService;
import com.mengyxu.core.utils.StringUtil;
@Service
public class ConfigService implements IConfigService {
@Autowired
private IConfigMapper cfgMapper;
@Override
public String queryValueByKey(String cfgKey) {
return cfgMapper.queryValueByKey(cfgKey);
}
/**
* 读取Long类型配置参数值
* @param key
* @param defValue
* @return
*/
@Override
public long getLongConfig(String key, long defValue) {
String value = queryValueByKey(key);
if (!StringUtil.isEmpty(value)) {
return Long.parseLong(value);
} else {
return defValue;
}
}
/**
* 读取Integer类型配置参数值
* @param key
* @param defValue
* @return
*/
@Override
public Integer getIntConfig(String key, Integer defValue) {
String value = queryValueByKey(key);
if (!StringUtil.isEmpty(value)) {
return new Integer(value);
} else {
return defValue;
}
}
@Override
public String getStringConfig(String key, String defValue) {
String value = queryValueByKey(key);
if (StringUtil.isEmpty(value)){
return defValue;
}
return value;
}
@Override
public List<SysConfig> queryPageByExample(SysConfig example) {
return cfgMapper.queryByExample(example);
}
@Override
public void update(SysConfig sysConfig) {
cfgMapper.update(sysConfig);
}
@Override
public void updateCfg(String key, String value, String userId) {
SysConfig cfg = get(key);
if(cfg != null) {
cfg.setCfgValue(value);
cfg.setUpdateUser(userId);
update(cfg);
}
}
private SysConfig get(String key) {
SysConfig example = new SysConfig();
example.setCfgKey(key);
List<SysConfig> list = cfgMapper.queryByExample(example);
if(list == null || list.isEmpty()) {
return null;
}
return list.get(0);
}
}

99
java/src/main/java/com/mengyxu/admin/sys/service/impl/DictionaryService.java

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
package com.mengyxu.admin.sys.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.mengyxu.admin.sys.mapper.IDictionaryMapper;
import com.mengyxu.admin.sys.pojo.Dictionary;
import com.mengyxu.admin.sys.service.IDictionaryService;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.Entry;
import com.mengyxu.core.utils.StringUtil;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月6日
*/
@Service
public class DictionaryService implements IDictionaryService {
@Autowired
private IDictionaryMapper dictMapper;
@Override
public List<Dictionary> queryType(Dictionary example) {
return dictMapper.queryType(example);
}
@Override
public void save(Dictionary dict) {
if(StringUtil.isEmpty(dict.getParent())) {
dictMapper.insertType(dict);
}else {
dictMapper.insertDict(dict);
}
}
@Override
public void update(Dictionary dict) {
if(StringUtil.isEmpty(dict.getParent())) {
dictMapper.updateType(dict);
}else {
dictMapper.updateDict(dict);
}
}
@Override
@Transactional
public void delete(Dictionary dict) throws CoreException {
Integer id = dict.getId();
String code = dict.getCode();
if(id != null) {
dictMapper.deleteDict(id);
}else {
dictMapper.deleteType(code);
dictMapper.deleteDicts(code);
}
}
@Override
public Map<String, List<Dictionary>> getDicts(String[] codes) {
if(codes == null || codes.length == 0) {
return null;
}
Map<String, List<Dictionary>> map = new HashMap<>();
for (String code : codes) {
map.put(code, getDict(code));
}
return map;
}
@Override
public List<Dictionary> getDict(String code) {
Dictionary example = new Dictionary();
example.setStatus("A");
example.setParent(code);
return dictMapper.queryDict(example);
}
@Override
public List<Entry<String, String>> queryProvince() {
return dictMapper.queryProvince();
}
@Override
public List<Entry<String, String>> queryCity(String parent) {
return dictMapper.queryCity(parent);
}
@Override
public List<Entry<String, String>> queryCounty(String parent) {
return dictMapper.queryCounty(parent);
}
}

61
java/src/main/java/com/mengyxu/admin/sys/service/impl/LogService.java

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
package com.mengyxu.admin.sys.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mengyxu.admin.sys.mapper.IActionLogMapper;
import com.mengyxu.admin.sys.pojo.ActionLog;
import com.mengyxu.admin.sys.pojo.Dictionary;
import com.mengyxu.admin.sys.service.IDictionaryService;
import com.mengyxu.admin.sys.service.ILogService;
import com.mengyxu.core.golbal.GlobalBuffer;
import com.mengyxu.core.pojo.com.Cache;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年2月13日
*/
@Service
public class LogService implements ILogService {
private static final String MAP_BUFFER_KEY = "log_type_mapping";
@Autowired
private IActionLogMapper actionLogMapper;
@Autowired
private IDictionaryService dictService;
@Override
public List<ActionLog> queryActionLog(ActionLog example) {
return actionLogMapper.queryByExample(example);
}
@Override
public void insertActionLog(ActionLog log) {
actionLogMapper.insert(log);
}
@Override
public void insertActionLogs(List<ActionLog> logs) {
actionLogMapper.insertBatch(logs);
}
@Override
public Map<String, String> getTypeMap() {
Cache cache = GlobalBuffer.getCache(MAP_BUFFER_KEY);
if(Cache.isEmpty(cache)) {
Map<String, String> map = new HashMap<>();
for (Dictionary dict : dictService.getDict("log_type")) {
map.put(dict.getCode(), dict.getName());
}
GlobalBuffer.addCache(MAP_BUFFER_KEY, new Cache(map,3600));
return map;
}else {
return cache.getValue();
}
}
}

53
java/src/main/java/com/mengyxu/admin/sys/service/impl/UserItemService.java

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
package com.mengyxu.admin.sys.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mengyxu.admin.sys.mapper.IUserItemMapper;
import com.mengyxu.admin.sys.pojo.UserItem;
import com.mengyxu.admin.sys.service.IUserItemService;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年3月17日
*/
@Service
public class UserItemService implements IUserItemService {
@Autowired
private IUserItemMapper itemMapper;
@Override
public List<UserItem> queryByExample(UserItem example) {
return itemMapper.queryByExample(example);
}
@Override
public void save(UserItem item) {
itemMapper.insert(item);
}
@Override
public void save(List<UserItem> items) {
itemMapper.insertBatch(items);
}
@Override
public void read(Integer id) {
UserItem item = new UserItem();
item.setId(id);
item.setStatus(1);
itemMapper.update(item);
}
@Override
public void dealWith(Integer id) {
UserItem item = new UserItem();
item.setId(id);
item.setStatus(2);
itemMapper.update(item);
}
}

120
java/src/main/java/com/mengyxu/admin/um/controller/LoginController.java

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
package com.mengyxu.admin.um.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.mengyxu.admin.um.pojo.Menu;
import com.mengyxu.admin.um.pojo.User;
import com.mengyxu.admin.um.service.IMenuService;
import com.mengyxu.admin.um.service.IUserService;
import com.mengyxu.admin.utils.AdminLogUtil;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.AjaxResponse;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月10日
*/
@RestController
@RequestMapping("um")
public class LoginController {
@Autowired
private IUserService userService;
@Autowired
private IMenuService permissionService;
/**
* 类型一用户登陆接口登陆成功后用户信息保存在resdis中,将token信息保存在cookie中
*/
@RequestMapping(value = "sso/login", method = RequestMethod.POST)
public AjaxResponse loginWithSso(@RequestBody User param, HttpServletRequest request,
HttpServletResponse response) throws CoreException{
String userId = param.getUserId();
String key = param.getKey();
User user = userService.findUser(userId,key);
if(user == null){
return new AjaxResponse(false, "用户名或密码错误!");
}
if("0".equals(user.getStatus())) {
AjaxResponse rsp = new AjaxResponse(true, null);
rsp.setData(0);
return rsp;
}
userService.updateLogin(userId);
//保存登陆信息
LoginUtil.saveLoginInfo(user, request, response);
//记录日志
AdminLogUtil.Login(request, user);
return new AjaxResponse(true, "登录成功!");
}
/**
* 注销登陆接口
*/
@RequestMapping(value = "login/out", method = RequestMethod.GET)
public AjaxResponse loginOut(HttpServletRequest request) throws CoreException{
//记录日志
AdminLogUtil.Logout(request);
LoginUtil.loginOut(request);
return new AjaxResponse(true, "已销登陆!");
}
/**
* 获取登陆用户信息
*/
@RequestMapping(value = "user/info", method = RequestMethod.GET)
public User getUserInfo(String token, HttpServletRequest request){
User userInfo = LoginUtil.getUserInfo(token, request, true);
return userInfo;
}
/**
* 检查登陆状态接口
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "check", method = RequestMethod.GET)
public AjaxResponse checkSession(HttpServletRequest request) throws CoreException{
User user = LoginUtil.getUserInfo(request);
if(user != null){
AjaxResponse rsp = new AjaxResponse();
rsp.setSuccess(true);
return rsp;
}
return new AjaxResponse(false, "session timeout");
}
/**
* 修改密码
* @return
* @throws Exception
*/
@RequestMapping(value = "update/password", method = RequestMethod.POST)
public AjaxResponse updatePassword(@RequestBody User user, HttpServletRequest request) throws CoreException{
userService.updateKey(user);
AdminLogUtil.updatePassword(request, user);
return new AjaxResponse(true, "修改密码成功!");
}
@RequestMapping(value = "menu/tree", method = RequestMethod.GET)
public List<Menu> queryMenuTree(HttpServletRequest request){
String userId = LoginUtil.getUserId(request);
return permissionService.queryMenuTree(userId,null);
}
}

113
java/src/main/java/com/mengyxu/admin/um/controller/PermissionController.java

@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
package com.mengyxu.admin.um.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mengyxu.admin.um.pojo.Permission;
import com.mengyxu.admin.um.pojo.Role;
import com.mengyxu.admin.um.service.IPermissionService;
import com.mengyxu.admin.um.service.IRolePermissionService;
import com.mengyxu.admin.utils.AdminLogUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.base.BasePageParam;
import com.mengyxu.core.pojo.com.AjaxResponse;
import com.mengyxu.core.pojo.com.PageResponse;
import lombok.extern.log4j.Log4j2;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月2日
*/
@Log4j2
@RestController
@RequestMapping("admin")
public class PermissionController {
@Autowired
private IPermissionService perService;
@Autowired
private IRolePermissionService roleService;
@RequestMapping(value = "per/list", method = RequestMethod.GET)
public List<Permission> queryPermissionTree(HttpServletRequest request) throws CoreException{
log.info("查询所有权限");
return perService.queryPermissionTree(true);
}
@RequestMapping(value = "per/save", method = RequestMethod.POST)
public AjaxResponse savePermission(@RequestBody Permission permission) throws CoreException{
log.info("添加权限");
perService.save(permission);
return new AjaxResponse(true, "权限添加成功!");
}
@RequestMapping(value = "per/delete", method = RequestMethod.POST)
public AjaxResponse deletePermission(@RequestBody Permission permission){
log.info("删除权限");
perService.delete(permission.getId());
return new AjaxResponse(true, "权限删除成功!");
}
@RequestMapping(value = "per/update", method = RequestMethod.POST)
public AjaxResponse updatePermission(@RequestBody Permission permission) throws CoreException{
log.info("修改权限");
perService.update(permission);
return new AjaxResponse(true, "权限修改成功!");
}
@RequestMapping(value = "role/list")
public PageResponse<Role> queryRoleList(BasePageParam example){
log.info("查询角色列表");
Page<Role> pages = PageHelper.startPage(example.getPage(), example.getSize());
List<Role> list = roleService.queryList();
PageResponse<Role> rsp = new PageResponse<>();
rsp.setRows(list);
rsp.setStatus("0");
rsp.setTotal(pages.getTotal());
return rsp;
}
@RequestMapping(value = "role/list/all")
public PageResponse<Role> queryAll(BasePageParam example){
log.info("查询所有角色");
Page<Role> pages = PageHelper.startPage(example.getPage(), example.getSize());
List<Role> list = roleService.queryAll();
PageResponse<Role> rsp = new PageResponse<>();
rsp.setRows(list);
rsp.setStatus("0");
rsp.setTotal(pages.getTotal());
return rsp;
}
@RequestMapping(value = "role/save", method = RequestMethod.POST)
public AjaxResponse saveRole(@RequestBody Role role, HttpServletRequest request){
AdminLogUtil.addRole(request, role);
roleService.save(role);
return new AjaxResponse(true, "角色添加成功!");
}
@RequestMapping(value = "role/delete", method = RequestMethod.POST)
public AjaxResponse deleteRole(@RequestBody Role role, HttpServletRequest request){
AdminLogUtil.deleteRole(request, role);
roleService.delete(role.getCode());
return new AjaxResponse(true, "角色删除成功!");
}
@RequestMapping(value = "role/update", method = RequestMethod.POST)
public AjaxResponse updateRole(@RequestBody Role role, HttpServletRequest request) throws CoreException{
AdminLogUtil.updateRole(request, role);
String msg = roleService.update(role);
return new AjaxResponse(true, msg);
}
}

123
java/src/main/java/com/mengyxu/admin/um/controller/UserController.java

@ -0,0 +1,123 @@ @@ -0,0 +1,123 @@
package com.mengyxu.admin.um.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mengyxu.admin.um.pojo.User;
import com.mengyxu.admin.um.service.IUserService;
import com.mengyxu.admin.utils.AdminLogUtil;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.base.BasePageParam;
import com.mengyxu.core.pojo.com.AjaxResponse;
import com.mengyxu.core.pojo.com.PageResponse;
import lombok.extern.log4j.Log4j2;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月10日
*/
@Log4j2
@RestController
@SuppressWarnings("all")
@RequestMapping("admin/user")
public class UserController {
@Autowired
private IUserService userService;
/**
* 用户管理条件查询
* @param example 查询参数
* @return 分页查询数据
*/
@RequestMapping(value = "list", method = RequestMethod.GET)
public PageResponse<User> queryPageListByExample(User example, HttpServletRequest request){
Page<User> pages = PageHelper.startPage(example.getPage(), example.getSize());
List<User> list = userService.queryByExample(example);
PageResponse<User> rsp = new PageResponse<>();
rsp.setRows(list);
rsp.setStatus("0");
rsp.setTotal(pages.getTotal());
return rsp;
}
/**
* 状态管理分页查询
* @param
* @return 分页查询数据
*/
@RequestMapping(value = "list/all", method = RequestMethod.GET)
public PageResponse<User> queryAll(BasePageParam example, HttpServletRequest request){
Page<User> pages = PageHelper.startPage(example.getPage(), example.getSize());
List<User> list = userService.queryAll();
PageResponse<User> rsp = new PageResponse<>();
rsp.setRows(list);
rsp.setStatus("0");
rsp.setTotal(pages.getTotal());
return rsp;
}
/**
* 新增用户
* @param user 新增用户信息
* @return
* @throws CoreException
*/
@RequestMapping(value = "save", method = RequestMethod.POST)
public AjaxResponse addUser(@RequestBody User user, HttpServletRequest request) throws CoreException{
userService.insert(user);
//记录、打印日志
AdminLogUtil.saveUser(request, user);
return new AjaxResponse(true, "新增用户成功!");
}
/**
* 修改用户其他信息
* @param user 用户信息
* @return
* @throws CoreException
*/
@RequestMapping(value = "update", method = RequestMethod.POST)
public AjaxResponse updateUserInfo(@RequestBody User userInfo, HttpServletRequest request) throws CoreException{
userService.updateInfo(userInfo);
AdminLogUtil.updateUser(request, userInfo);
return new AjaxResponse(true, "修改用户信息成功!");
}
/**
* 删除用户
* @param userId 待删除的用户名
* @return
*/
@RequestMapping(value = "delete", method = RequestMethod.POST)
public AjaxResponse removeUser(@RequestBody User user, HttpServletRequest request){
String userId = user.getUserId();
userService.deleteById(userId);
AdminLogUtil.deleteUser(request, userId);
return new AjaxResponse(true, "成功删除用户:"+userId+"!");
}
/**
* 重置密码
* @param userName 待重置密码的用户名
* @return
*/
@RequestMapping(value = "reset", method = RequestMethod.POST)
public AjaxResponse resetPassword(@RequestBody User user, HttpServletRequest request){
String userId = user.getUserId();
userService.resetKey(userId);
AdminLogUtil.resetUserLog(request, userId);
return new AjaxResponse(true, "成功重置用户:"+userId+"的密码!");
}
}

101
java/src/main/java/com/mengyxu/admin/um/mapper/IPermissionMapper.java

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
package com.mengyxu.admin.um.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.mengyxu.admin.um.pojo.Menu;
import com.mengyxu.admin.um.pojo.Permission;
import com.mengyxu.core.pojo.com.Entry;
/**
* 权限管理Dao
* @author v_mengyxu
*
*/
public interface IPermissionMapper {
/**
* 增加记录
* @param permission 新增的记录
*/
public void insertOne(Permission permission);
/**
* 批量添加
* @param permissions
*/
public void insertBatch(List<Permission> permissions);
/**
* 更新记录
* @param permission 更新的记录
*/
public void updateByCode(Permission permission);
/**
* 删除记录
* @param resCode 权限编码
*/
public void deleteByCode(String resCode);
/**
* 删除全部
*/
public void deleteAll();
/**
* 判断是否存在该记录
* @param resCode 权限编码
* @return
*/
public long isExist(String resCode);
/**
* 根据权限内容查询权限信息
* @param resContent 权限内容
* @return
*/
public List<String> queryCodeByContent(String resContent);
/**
* 判断用户是否拥有某权限
* @param userId 用户号
* @param resCode 权限编码
* @return
*/
public long havePermission(@Param("userId")String userId ,@Param("preCode")String resCode);
/**
* 查询所有系统
* @param userId
*/
public List<Entry<String, String>> queryAllModule(String userId);
/**
* 用户个人菜单
* @param userId
* @return
*/
public List<Menu> queryMenuTree(@Param("userId")String userId ,@Param("perParent")String perParent);
/**
* 查询action权限
* @return
*/
public List<String> queryContentByParentContent(@Param("userId")String userId ,@Param("parentContent")String parentContent);
/**
* 查询权限树
* @param perParent
* @return
*/
public List<Permission> queryPermissionTree();
/**
* 查询权限树
* @param perParent
* @return
*/
public List<Permission> queryPublicPerTree();
}

24
java/src/main/java/com/mengyxu/admin/um/mapper/IRolePermissionMapper.java

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
package com.mengyxu.admin.um.mapper;
import java.util.List;
import com.mengyxu.admin.um.pojo.Role;
import com.mengyxu.core.pojo.com.Entry;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月3日
*/
public interface IRolePermissionMapper {
List<Role> queryAll();
List<Role> queryList();
void insertOne(Role role);
void insertBatch(List<Role> roles);
void delete(String roleCode);
void deleteRolePer(String roleCode);
void insertRolePer(Role role);
void update(Role role);
List<Entry<String, String>> queryRoleMaps();
}

22
java/src/main/java/com/mengyxu/admin/um/mapper/IUserMapper.java

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
package com.mengyxu.admin.um.mapper;
import java.util.List;
import com.mengyxu.admin.um.pojo.User;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月10日
*/
public interface IUserMapper {
List<User> queryByExample(User example);
List<User> findUser(User example);
void insert(User user);
void update(User user);
void delete(String userId);
void deleteUserRole(String userName);
void insertUserRole(User user);
}

22
java/src/main/java/com/mengyxu/admin/um/pojo/Menu.java

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
package com.mengyxu.admin.um.pojo;
import com.mengyxu.core.pojo.base.BaseTree;
import lombok.Getter;
import lombok.Setter;
/**
* 菜单实体类
* @author v_mengyxu
*
*/
@Setter
@Getter
public class Menu extends BaseTree<Menu>{
private String title;
private String href;
private boolean show = false;
}

18
java/src/main/java/com/mengyxu/admin/um/pojo/MenuParam.java

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
package com.mengyxu.admin.um.pojo;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class MenuParam {
private String parentId;
private boolean includeCom;
private String userId;
public MenuParam(String parentId, boolean includeCom) {
super();
this.parentId = parentId;
this.includeCom = includeCom;
}
}

23
java/src/main/java/com/mengyxu/admin/um/pojo/Permission.java

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
package com.mengyxu.admin.um.pojo;
import com.mengyxu.core.pojo.base.BaseTree;
import lombok.Getter;
import lombok.Setter;
/**
* 权限实体类
* @author v_mengyxu
*
*/
@Getter
@Setter
public class Permission extends BaseTree<Permission>{
private String perParent;//父权限编码
private String perLevel;//权限级层
private String perContent;//权限内容
private String perStatus;//权限状态
private Integer perOrder;
}

25
java/src/main/java/com/mengyxu/admin/um/pojo/Rockey.java

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
package com.mengyxu.admin.um.pojo;
import com.alibaba.fastjson.annotation.JSONField;
import com.mengyxu.core.pojo.base.BasePageParam;
import lombok.Getter;
import lombok.Setter;
/** Ownership belongs to the company
* author:mengyxu
* date:2020年6月10日
*/
@Setter
@Getter
public class Rockey extends BasePageParam{
private String hid;
@JSONField(serialize = false)
private String key;
private String status;
@JSONField(serialize = false)
private boolean flag = false;
}

29
java/src/main/java/com/mengyxu/admin/um/pojo/Role.java

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
package com.mengyxu.admin.um.pojo;
import java.text.MessageFormat;
import java.util.List;
import lombok.Data;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月3日
*/
@Data
public class Role {
private String code;
private String name;
private String desc;
private String status;
private List<String> permissions;
private boolean flag;
public String briefInfo() {
return MessageFormat.format("角色编码:{0},角色名称:{1},备注:{2},权限数量:{3}", code, name, desc, permissions == null ? 0 : permissions.size());
}
}

54
java/src/main/java/com/mengyxu/admin/um/pojo/User.java

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
package com.mengyxu.admin.um.pojo;
import java.text.MessageFormat;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
import com.mengyxu.core.pojo.base.BasePageParam;
import com.mengyxu.core.utils.StringUtil;
import lombok.Getter;
import lombok.Setter;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月10日
* The entity for table UserManagement
*/
@Setter
@Getter
public class User extends BasePageParam {
private String userId;
private String key;
private String name;
private String phone;
private String idCard;
private String email;
private String lastLogin;
private String status;
private String newKey;
private List<String> roles;
public String briefInfo() {
return MessageFormat.format("用户名:{0},姓名:{1},手机号码:{2},用户角色:{3}", userId, name, phone, roles);
}
@JSONField(serialize = false)
public boolean isEmpty(){
if(StringUtil.isEmpty(userId)) {
return true;
}
if(roles == null) {
return true;
}
if(roles.isEmpty()) {
return true;
}
return false;
}
}

25
java/src/main/java/com/mengyxu/admin/um/service/IMenuService.java

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
package com.mengyxu.admin.um.service;
import java.util.List;
import com.mengyxu.admin.um.pojo.Menu;
import com.mengyxu.core.pojo.com.Entry;
public interface IMenuService {
/**
* 查询所有系统
* @param userId
*/
public List<Entry<String, String>> queryAllModule(String userId);
/**
* 查询主页菜单树
* @param userId
* @return
*/
public List<Menu> queryMenuTree(String userId, String perParent);
public List<String> queryNodeContent(String userId, String parentContent);
}

25
java/src/main/java/com/mengyxu/admin/um/service/IPermissionService.java

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
package com.mengyxu.admin.um.service;
import java.util.List;
import com.mengyxu.admin.um.pojo.Permission;
import com.mengyxu.core.exception.CoreException;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月2日
*/
public interface IPermissionService {
List<Permission> queryPermissionTree(boolean isOperater);
void save(Permission permission) throws CoreException;
void update(Permission permission) throws CoreException;
void delete(String code);
List<String> myPermissions(String userName, String parentContent);
}

27
java/src/main/java/com/mengyxu/admin/um/service/IPermissionValidationService.java

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
package com.mengyxu.admin.um.service;
import java.util.List;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月2日
*/
public interface IPermissionValidationService {
/**
* 根据servletPath查询对应权限编码
* @param resContent
* @return
*/
List<String> queryCodeByContent(String resContent);
/**
* 判断指定用户是否拥有指定权限
* @param userId
* @param resCode
* @return
*/
boolean havePermission(String userId, String resCode);
}

22
java/src/main/java/com/mengyxu/admin/um/service/IRolePermissionService.java

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
package com.mengyxu.admin.um.service;
import java.util.List;
import com.mengyxu.admin.um.pojo.Role;
import com.mengyxu.core.pojo.com.Entry;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月3日
*/
public interface IRolePermissionService {
List<Role> queryAll();
List<Role> queryList();
void save(Role role);
void delete(String roleCode);
String update(Role role);
List<Entry<String, String>> queryRoleMaps();
}

27
java/src/main/java/com/mengyxu/admin/um/service/IUserService.java

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
package com.mengyxu.admin.um.service;
import java.util.List;
import com.mengyxu.admin.um.pojo.User;
import com.mengyxu.core.exception.CoreException;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月10日
*/
public interface IUserService {
User findUser(String userId, String key);
User getById(String userId);
List<User> queryByExample(User example);
List<User> queryAll();
void insert(User user) throws CoreException;
void updateInfo(User user) throws CoreException;
void updateKey(User user) throws CoreException;
void deleteById(String userId);
void updateLogin(String userId);
void resetKey(String userId);
}

103
java/src/main/java/com/mengyxu/admin/um/service/impl/PermissionService.java

@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
package com.mengyxu.admin.um.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.mengyxu.admin.um.mapper.IPermissionMapper;
import com.mengyxu.admin.um.pojo.Menu;
import com.mengyxu.admin.um.pojo.Permission;
import com.mengyxu.admin.um.service.IMenuService;
import com.mengyxu.admin.um.service.IPermissionService;
import com.mengyxu.admin.um.service.IPermissionValidationService;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.pojo.com.Entry;
import com.mengyxu.core.utils.StringUtil;
@Service
@Transactional
public class PermissionService implements IMenuService,IPermissionValidationService,IPermissionService{
@Autowired
private IPermissionMapper permissionMapper;
@Override
public List<Entry<String, String>> queryAllModule(String userId) {
return permissionMapper.queryAllModule(userId);
}
@Override
public List<Menu> queryMenuTree(String userName, String perParent) {
if(StringUtils.isEmpty(userName)){
return new ArrayList<>();
}
return permissionMapper.queryMenuTree(userName, perParent);
}
@Override
public List<String> queryNodeContent(String userId, String parentContent) {
return permissionMapper.queryContentByParentContent(userId,parentContent);
}
@Override
public List<String> queryCodeByContent(String resContent) {
return permissionMapper.queryCodeByContent(resContent);
}
@Override
public boolean havePermission(String userId, String resCode) {
long l = permissionMapper.havePermission(userId, resCode);
return l > 0L;
}
@Override
public List<Permission> queryPermissionTree(boolean isOperater) {
if(isOperater) {
return permissionMapper.queryPermissionTree();
}
return permissionMapper.queryPublicPerTree();
}
@Override
public void save(Permission permission) throws CoreException{
setDefault(permission);
if(permissionMapper.isExist(permission.getId()) > 0L) {
throw new CoreException("权限编号已经存在,请修改");
}
permissionMapper.insertOne(permission);
}
private void setDefault(Permission permission) throws CoreException {
if(StringUtil.isEmpty(permission.getId(),permission.getName())) {
throw new CoreException("权限编号,权限名称不能为空");
}
if(permission.getDesc() == null) {
permission.setDesc("");
}
if(StringUtil.isEmpty(permission.getPerContent())) {
permission.setPerContent(permission.getName());
}
if(StringUtil.isEmpty(permission.getPerStatus())) {
permission.setPerStatus("A");
}
}
@Override
public void update(Permission permission) throws CoreException {
permissionMapper.updateByCode(permission);
}
@Override
public void delete(String code) {
permissionMapper.deleteByCode(code);
}
@Override
public List<String> myPermissions(String userName, String parentContent) {
return permissionMapper.queryContentByParentContent(userName, parentContent);
}
}

71
java/src/main/java/com/mengyxu/admin/um/service/impl/RolePermissionService.java

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
package com.mengyxu.admin.um.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.mengyxu.admin.um.mapper.IRolePermissionMapper;
import com.mengyxu.admin.um.pojo.Role;
import com.mengyxu.admin.um.service.IRolePermissionService;
import com.mengyxu.core.pojo.com.Entry;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年12月3日
*/
@Service
public class RolePermissionService implements IRolePermissionService {
@Autowired
private IRolePermissionMapper rolePermissionMapper;
@Override
public List<Role> queryAll() {
return rolePermissionMapper.queryAll();
}
@Override
public List<Role> queryList() {
return rolePermissionMapper.queryList();
}
@Override
@Transactional
public void save(Role role) {
role.setStatus("E");
rolePermissionMapper.insertOne(role);
if(role.getPermissions() != null && !role.getPermissions().isEmpty()) {
rolePermissionMapper.insertRolePer(role);
}
}
@Override
@Transactional
public void delete(String roleCode) {
rolePermissionMapper.delete(roleCode);
rolePermissionMapper.deleteRolePer(roleCode);
}
@Override
@Transactional
public String update(Role role) {
if(role.isFlag()) {
rolePermissionMapper.deleteRolePer(role.getCode());
if(role.getPermissions() != null && !role.getPermissions().isEmpty()) {
rolePermissionMapper.insertRolePer(role);
}
return "角色权限分配成功";
}else {
rolePermissionMapper.update(role);
return "角色修改成功";
}
}
@Override
public List<Entry<String, String>> queryRoleMaps() {
return rolePermissionMapper.queryRoleMaps();
}
}

178
java/src/main/java/com/mengyxu/admin/um/service/impl/UserService.java

@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
package com.mengyxu.admin.um.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
import com.mengyxu.admin.um.mapper.IUserMapper;
import com.mengyxu.admin.um.pojo.User;
import com.mengyxu.admin.um.service.IUserService;
import com.mengyxu.admin.utils.LoginUtil;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.golbal.GlobalConstant;
import com.mengyxu.core.utils.DateUtil;
import com.mengyxu.core.utils.StringUtil;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月10日
*/
@Service
public class UserService implements IUserService {
@Autowired
private IUserMapper userMapper;
@Override
public List<User> queryAll() {
List<User> list = userMapper.findUser(new User());
return list;
}
@Override
public User findUser(String userId, String key) {
User user = getById(userId);
if(user != null && StringUtil.equals(user.getKey(), key)) {
return user;
}
return null;
}
public User getById(String userId) {
if(StringUtil.isEmpty(userId)){
return null;
}
User exp = new User();
exp.setUserId(userId);
List<User> list = userMapper.findUser(exp);
if(list == null || list.isEmpty()) {
return null;
}
return list.get(0);
}
private User getByPhone(String phone) {
if(StringUtil.isEmpty(phone)){
return null;
}
User exp = new User();
exp.setPhone(phone);
List<User> list = userMapper.findUser(exp);
if(list == null || list.isEmpty()) {
return null;
}
return list.get(0);
}
private User getByidNum(String idCard) {
if(StringUtil.isEmpty(idCard)){
return null;
}
User exp = new User();
exp.setIdCard(idCard);
List<User> list = userMapper.findUser(exp);
if(list == null || list.isEmpty()) {
return null;
}
return list.get(0);
}
@Override
public List<User> queryByExample(User example) {
return userMapper.queryByExample(example);
}
@Override
@Transactional
public void insert(User user) throws CoreException {
//判断用户名是否重复
String userId = user.getUserId();
if(getById(userId) != null){
throw new CoreException("用户名:"+userId+"已经存在");
}
String idCard = user.getIdCard();
if(getByidNum(idCard) != null){
throw new CoreException("身份证号码:"+idCard+"已绑定其他用户");
}
String phone = user.getPhone();
if(getByPhone(phone) != null){
throw new CoreException("手机号码:"+phone+"已绑定其他用户");
}
//设置默认值后插入数据库
user.setKey(DigestUtils.md5DigestAsHex(user.getKey().getBytes()));
user.setStatus("0");
userMapper.insert(user);
userMapper.deleteUserRole(userId);
if(user.getRoles() != null && !user.getRoles().isEmpty()) {
userMapper.insertUserRole(user);
}
}
@Override
@Transactional
public void updateInfo(User user) throws CoreException {
String phone = user.getPhone();
User old = getByPhone(phone);
if(old != null && !StringUtil.equals(user.getUserId(), old.getUserId())){
throw new CoreException("手机号码:"+phone+"已绑定其他用户");
}
String idCard = user.getIdCard();
old = getByidNum(idCard);
if(old != null && !StringUtil.equals(user.getUserId(), old.getUserId())){
throw new CoreException("身份证号码:"+idCard+"已绑定其他用户");
}
user.setKey(null);
userMapper.update(user);
userMapper.deleteUserRole(user.getUserId());
if(user.getRoles() != null && !user.getRoles().isEmpty()) {
userMapper.insertUserRole(user);
}
}
@Override
@Transactional
public void deleteById(String userId) {
//删除用户
userMapper.delete(userId);
userMapper.deleteUserRole(userId);
LoginUtil.remveLoginInfo(userId);
}
@Override
public void updateLogin(String userId) {
User user = new User();
user.setUserId(userId);
user.setLastLogin(DateUtil.format(new Date(), DateUtil.FORMAT19_LINE_YYYYMMDDHHMMSS));
userMapper.update(user);
}
@Override
@Transactional
public void updateKey(User user) throws CoreException {
User old = getById(user.getUserId());
if(user != null && StringUtil.equals(user.getKey(), old.getKey())) {
if("0".equals(old.getStatus())) {
user.setStatus("1");
}
userMapper.update(user);
LoginUtil.remveLoginInfo(user.getUserId());
}else {
throw new CoreException("修改密码失败,用户名或密码错误");
}
}
@Override
public void resetKey(String userId) {
User user = getById(userId);
user.setNewKey(GlobalConstant.DEFAULT_PASSWORD);
user.setStatus("0");
userMapper.update(user);
}
}

75
java/src/main/java/com/mengyxu/admin/utils/AdminLogUtil.java

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
package com.mengyxu.admin.utils;
import javax.servlet.http.HttpServletRequest;
import com.mengyxu.admin.sys.pojo.ActionLog;
import com.mengyxu.admin.um.pojo.Role;
import com.mengyxu.admin.um.pojo.User;
import com.mengyxu.core.utils.StringUtil;
public class AdminLogUtil extends BaseLogUtil {
public static void Login(HttpServletRequest request, User user) {
ActionLog log = createLog(request, "0", "0");
log.setUserId(user.getUserId());
logToFileAndDatabase(log);
}
public static void Logout(HttpServletRequest request) {
ActionLog log = createLog(request, "0", "1");
if (StringUtil.isEmpty(log.getUserId())) {
return;
}
logToFileAndDatabase(log);
}
public static void updatePassword(HttpServletRequest request, User user) {
ActionLog log = createLog(request, "0", "2");
log.setUserId(user.getUserId());
logToFileAndDatabase(log);
}
public static void saveUser(HttpServletRequest request, User user) {
ActionLog log = createLog(request, "0", "3");
log.setContext(user.briefInfo());
logToFileAndDatabase(log);
}
public static void updateUser(HttpServletRequest request, User user) {
ActionLog log = createLog(request, "0", "4");
log.setContext(user.briefInfo());
logToFileAndDatabase(log);
}
public static void deleteUser(HttpServletRequest request, String userId) {
ActionLog log = createLog(request, "0", "5");
log.setContext("目标用户名:" + userId);
logToFileAndDatabase(log);
}
public static void resetUserLog(HttpServletRequest request, String userId) {
ActionLog log = createLog(request, "0", "6");
log.setContext("目标用户名:" + userId);
}
public static void addRole(HttpServletRequest request, Role role) {
ActionLog log = createLog(request, "0", "7");
log.setContext(role.briefInfo());
logToFileAndDatabase(log);
}
public static void updateRole(HttpServletRequest request, Role role) {
ActionLog log = createLog(request, "0", "8");
log.setType("8");
log.setModule("0");
log.setContext(role.briefInfo());
logToFileAndDatabase(log);
}
public static void deleteRole(HttpServletRequest request, Role role) {
ActionLog log = createLog(request, "0", "9");
log.setContext("角色编码:" + role.getCode());
logToFileAndDatabase(log);
}
}

66
java/src/main/java/com/mengyxu/admin/utils/BaseLogUtil.java

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
package com.mengyxu.admin.utils;
import java.text.MessageFormat;
import javax.servlet.http.HttpServletRequest;
import com.mengyxu.admin.sys.pojo.ActionLog;
import com.mengyxu.admin.sys.service.ILogService;
import com.mengyxu.core.utils.StringUtil;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class BaseLogUtil {
public static ILogService logService;
protected BaseLogUtil() {
// Add a protected constructor to hide the implicit public one.
}
/**
* 获取访问者IP
*
* 在一般情况下使用Request.getRemoteAddr()即可但是经过nginx等反向代理软件后这个方法会失效
*
* 本方法先从Header中获取X-Real-IP如果不存在再从X-Forwarded-For获得第一个IP(,分割) 如果还不存在则调用Request
* .getRemoteAddr()
*
* @param request
* @return
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Real-IP");
if (!StringUtil.isBlank(ip) && !"unknown".equalsIgnoreCase(ip)) {
return ip;
}
ip = request.getHeader("X-Forwarded-For");
if (!StringUtil.isBlank(ip) && !"unknown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个IP值,第一个为真实IP。
int index = ip.indexOf(',');
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
} else {
return request.getRemoteAddr();
}
}
public static ActionLog createLog(HttpServletRequest request, String module, String type) {
ActionLog log = new ActionLog();
log.setLoginIp(getIpAddr(request));
log.setUserId(LoginUtil.getUserId(request));
log.setModule(module);
log.setType(type);
return log;
}
protected static void logToFileAndDatabase(ActionLog actionLog) {
log.info(MessageFormat.format("{0}-------操作用户:{1},{2}", logService.getTypeMap().get(actionLog.getType()),
actionLog.getUserId(), actionLog.getContext()));
logService.insertActionLog(actionLog);
}
}

181
java/src/main/java/com/mengyxu/admin/utils/LoginUtil.java

@ -0,0 +1,181 @@ @@ -0,0 +1,181 @@
package com.mengyxu.admin.utils;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mengyxu.admin.um.pojo.User;
import com.mengyxu.core.exception.CoreException;
import com.mengyxu.core.golbal.GlobalBuffer;
import com.mengyxu.core.golbal.GlobalConstant;
import com.mengyxu.core.pojo.com.Cache;
import com.mengyxu.core.utils.StringUtil;
/** Ownership belongs to the company
* author:mengyxu
* date:2019年5月27日
*/
public class LoginUtil {
public static Integer timeout;
public static String domain;
private static String getTokenKey(String userId) {
return GlobalConstant.TIKEN_KEY_PREFIX+userId;
}
public static boolean isLogin(String userId) {
Cache cache = GlobalBuffer.getCache(getTokenKey(userId));
return !Cache.isEmpty(cache);
}
public static void remveLoginInfo(String userId) {
String tokenKey = LoginUtil.getTokenKey(userId);
Cache token = GlobalBuffer.getCache(tokenKey);
if(!Cache.isEmpty(token)){
String value = token.getValue();
GlobalBuffer.removeCache(value.substring(0, 10));
GlobalBuffer.removeCache(tokenKey);
}
}
public static void saveLoginInfo(User user, HttpServletRequest request,
HttpServletResponse response) throws CoreException{
//删除旧的token信息
String userId = user.getUserId();
Cache exitToken = GlobalBuffer.getCache(LoginUtil.getTokenKey(userId));
if(!Cache.isEmpty(exitToken)){
String value = exitToken.getValue();
GlobalBuffer.removeCache(value.substring(0, 10));
}
//计算新的token
String ip = BaseLogUtil.getIpAddr(request);
String seq = GlobalBuffer.getSeq();
String token = seq + StringUtil.md5(user.getUserId() + ip + System.currentTimeMillis(), false);
//保存用户token
GlobalBuffer.addCache(LoginUtil.getTokenKey(userId), new Cache(token, timeout*60));
//保存token的用户信息
GlobalBuffer.addCache(seq, new Cache(user, timeout*60));
//删除验证码
GlobalBuffer.removeCache(getCodeKey(userId));
LoginUtil.addToken(request, token, response);
}
private static void addToken(HttpServletRequest request, String token, HttpServletResponse response){
Cookie cookie = new Cookie(GlobalConstant.LOGIN_COOKIE_NAME, token);
if(!StringUtil.isEmpty(domain)) {
cookie.setDomain(domain);
}
cookie.setPath("/");
response.addCookie(cookie);
}
public static User getUserInfo(String token, HttpServletRequest request, boolean refresh){
if(StringUtil.isEmpty(token)){
token = getToken(request);
}
if(StringUtil.isEmpty(token) || token.length() != 42){
return null;
}
Cache userCache = GlobalBuffer.getCache(token.substring(0, 10));
if(Cache.isEmpty(userCache)){
return null;
}
User user = userCache.getValue();
String userId = user.getUserId();
Cache exitToken = GlobalBuffer.getCache(LoginUtil.getTokenKey(userId));
if(Cache.isEmpty(exitToken)){
return null;
}
if(StringUtil.equals(token, exitToken.getValue())) {
if(refresh) {
userCache.refresh();
exitToken.refresh();
}
return user;
}
return null;
}
public static String getUserId(HttpServletRequest request) {
User user = getUserInfo(null, request, false);
if(user == null) {
return null;
}
return user.getUserId();
}
public static String getUserNameAndRefresh(HttpServletRequest request) {
return getUserInfo(null, request, true).getUserId();
}
public static User getUserInfo(HttpServletRequest request){
return getUserInfo(null, request, false);
}
public static void loginOut(HttpServletRequest request){
String token = LoginUtil.getToken(request);
if(!StringUtil.isEmpty(token)){
String seq = token.substring(0, 10);
Cache userCache = GlobalBuffer.getCache(seq);
if(!Cache.isEmpty(userCache)){
User user = userCache.getValue();
String userId = user.getUserId();
GlobalBuffer.removeCache(getTokenKey(userId));
}
GlobalBuffer.removeCache(seq);
}
}
public static String getToken(HttpServletRequest request){
Cookie[] cookies = request.getCookies();
if(cookies == null){
return null;
}
for (Cookie cookie : cookies) {
if(GlobalConstant.LOGIN_COOKIE_NAME.equals(cookie.getName())){
return cookie.getValue();
}
}
return null;
}
public static String getParentContent(HttpServletRequest request) {
return request.getParameter("content");
// String refer = request.getHeader("Referer");
// try {
// URL url = new URL(refer);
// String prefix = request.getContextPath() + "/";
// return url.getPath().replace(prefix, "");
// } catch (Exception e) {
// log.error("获取ParentContent失败",e);
// }
// return null;
}
public static String getCode(String userId) {
String code = StringUtil.getStringNum(10);
GlobalBuffer.addCache(getCodeKey(userId), new Cache(code, timeout*60));
return code;
}
private static String getCodeKey(String userId) {
return GlobalConstant.CODE_KEY_PREFIX+userId;
}
public static boolean checkCode(String userId, String code) {
if(code == null) {
return false;
}
Cache cache = GlobalBuffer.getCache(getCodeKey(userId));
if(!Cache.isEmpty(cache) && code.equals(cache.getValue())) {
return true;
}
return false;
}
}

35
java/src/main/resources/application.properties

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
service.package.type=jar
# 定位模板的目录(配合ResourceHandler使用,控制页面访问)
spring.mvc.view.prefix=/private/
spring.mvc.view.suffix=.html
spring.main.banner-mode=off
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialSize=3
spring.datasource.minIdle=3
spring.datasource.maxActive=20
spring.datasource.maxWait=60000
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=SELECT 1 FROM DUAL
spring.datasource.keepAlive=true
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=false
mybatis.mapper-locations= classpath*:mapper/**/*.xml
mybatis.configuration.log-impl= org.apache.ibatis.logging.stdout.StdOutImpl
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
pagehelper.returnPageInfo=check
#缓存定时器cron
quartz.cron.clean.global=0 */10 * * * ?
#用户登陆token有效期(分钟)
timeout.login.token=30

77
java/src/main/resources/mapper/sys/IActionLogMapper.xml

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.mengyxu.admin.sys.mapper.IActionLogMapper">
<sql id="base_column">
id,type,module,user_id,login_ip,time,context
</sql>
<resultMap type="com.mengyxu.admin.sys.pojo.ActionLog" id="logRM">
<id column="id" property="id"/>
<result column="type" property="type"/>
<result column="module" property="module"/>
<result column="user_id" property="userId"/>
<result column="login_ip" property="loginIp"/>
<result column="time" property="time"/>
<result column="context" property="context"/>
</resultMap>
<select id="queryByExample" parameterType="com.mengyxu.admin.sys.pojo.ActionLog" resultMap="logRM">
SELECT
<include refid="base_column"/>
FROM
sys_action_log
<where>
<if test="type != null and type != ''">
AND type = #{type}
</if>
<if test="module != null and module != ''">
AND module = #{module}
</if>
<if test="userId != null and userId != ''">
AND user_id like CONCAT('%',#{userId},'%')
</if>
<if test="context != null and context != ''">
AND context like CONCAT('%',#{context},'%')
</if>
<if test="startTime != null and startTime != ''">
AND time >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND #{endTime} > time
</if>
</where>
ORDER BY time DESC
</select>
<insert id="insert" parameterType="com.mengyxu.admin.sys.pojo.ActionLog">
INSERT INTO sys_action_log
(<include refid="base_column"/>)
VALUES (
#{id},
#{type},
#{module},
#{userId},
#{loginIp},
#{time},
#{context}
)
</insert>
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO BusinessLog
(<include refid="base_column"/>)
VALUES
<foreach collection="list" item="log" separator=",">
(
#{log.id},
#{log.type},
#{log.module},
#{log.userId},
#{log.loginIp},
#{log.time},
#{log.context}
)
</foreach>
</insert>
</mapper>

66
java/src/main/resources/mapper/sys/IConfigMapper.xml

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mengyxu.admin.sys.mapper.IConfigMapper">
<sql id="baseColumn">
cfg_key,
cfg_name,
cfg_value,
cfg_type,
cfg_desc,
cfg_status,
update_time,
update_user
</sql>
<resultMap type="com.mengyxu.admin.sys.pojo.SysConfig" id="cfgResultMap">
<result column="cfg_key" property="cfgKey"/>
<result column="cfg_name" property="cfgName"/>
<result column="cfg_value" property="cfgValue"/>
<result column="cfg_type" property="cfgType"/>
<result column="cfg_desc" property="cfgDesc"/>
<result column="cfg_status" property="cfgStatus"/>
<result column="update_time" property="updateTime"/>
<result column="update_user" property="updateUser"/>
</resultMap>
<select id="queryValueByKey" parameterType="java.lang.String" resultType="java.lang.String">
SELECT cfg_value FROM sys_config WHERE cfg_key = #{cfgKey} AND cfg_status != 'I'
</select>
<select id="queryByExample" parameterType="com.mengyxu.admin.sys.pojo.SysConfig" resultMap="cfgResultMap">
SELECT
<include refid="baseColumn"/>
FROM
sys_config
<where>
<if test="cfgKey != null and cfgKey !=''">
AND cfg_key = #{cfgKey}
</if>
<if test="cfgStatus != null and cfgStatus !=''">
AND cfg_status = #{cfgStatus}
</if>
<if test="cfgName != null and cfgName !=''">
AND cfg_name like CONCAT('%',#{cfgName},'%')
</if>
</where>
</select>
<update id="update" parameterType="com.mengyxu.admin.sys.pojo.SysConfig">
UPDATE
sys_config
SET
cfg_name = #{cfgName},
cfg_value = #{cfgValue},
cfg_desc = #{cfgDesc},
cfg_status = #{cfgStatus},
update_time = NOW(),
update_user = #{updateUser}
WHERE
cfg_key = #{cfgKey}
</update>
</mapper>

153
java/src/main/resources/mapper/sys/IDictionaryMapper.xml

@ -0,0 +1,153 @@ @@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mengyxu.admin.sys.mapper.IDictionaryMapper">
<sql id="typeColumn">
type_code,
type_name,
type_desc,
type_status
</sql>
<sql id="dictColumn">
dict_id,
dict_code,
dict_name,
dict_desc,
dict_parent,
dict_status
</sql>
<resultMap type="com.mengyxu.admin.sys.pojo.Dictionary" id="typeRM">
<result column="type_code" property="key"/>
<result column="type_code" property="code"/>
<result column="type_name" property="name"/>
<result column="type_desc" property="desc"/>
<result column="type_status" property="status"/>
<collection property="children" column="{parent=type_code}" select="queryDict"/>
</resultMap>
<resultMap type="com.mengyxu.admin.sys.pojo.Dictionary" id="dictRM">
<id column="dict_id" property="id"/>
<result column="dict_id" property="key"/>
<result column="dict_code" property="code"/>
<result column="dict_name" property="name"/>
<result column="dict_desc" property="desc"/>
<result column="dict_parent" property="parent"/>
<result column="dict_status" property="status"/>
</resultMap>
<select id="queryType" resultMap="typeRM" parameterType="com.mengyxu.admin.sys.pojo.Dictionary">
SELECT
<include refid="typeColumn"/>
FROM
sys_dict_type
<where>
<if test="code != null and code != ''">
AND type_code = #{code}
</if>
<if test="name != null and name != ''">
AND type_name like CONCAT('%',#{name},'%')
</if>
<if test="status != null and status != ''">
AND type_status = #{status}
</if>
</where>
ORDER BY type_name ASC
</select>
<select id="queryDict" resultMap="dictRM" parameterType="com.mengyxu.admin.sys.pojo.Dictionary">
SELECT
<include refid="dictColumn"/>
FROM
sys_dictionary
<where>
<if test="id != null">
AND dict_id = #{id}
</if>
<if test="parent != null and parent != ''">
AND dict_parent = #{parent}
</if>
<if test="status != null and status != ''">
AND dict_status = #{status}
</if>
</where>
ORDER BY dict_id ASC
</select>
<insert id="insertDict" parameterType="com.mengyxu.admin.sys.pojo.Dictionary" >
INSERT INTO sys_dictionary
(<include refid="dictColumn"></include>)
VALUES
(
#{id},
#{code},
#{name},
#{desc},
#{parent},
#{status}
)
</insert>
<insert id="insertType" parameterType="com.mengyxu.admin.sys.pojo.Dictionary">
INSERT INTO sys_dict_type
(<include refid="typeColumn"></include>)
VALUES
(
#{code},
#{name},
#{desc},
#{status}
)
</insert>
<update id="updateDict" parameterType="com.mengyxu.admin.sys.pojo.Dictionary">
UPDATE sys_dictionary SET
dict_code = #{code},
dict_name = #{name},
dict_desc = #{desc},
dict_parent = #{parent},
dict_status = #{status}
WHERE
dict_id = #{id}
</update>
<update id="updateType" parameterType="com.mengyxu.admin.sys.pojo.Dictionary">
UPDATE sys_dict_type SET
type_name = #{name},
type_desc = #{desc},
type_status = #{status}
WHERE
type_code = #{code}
</update>
<delete id="deleteType" parameterType="java.lang.String">
DELETE FROM sys_dict_type WHERE type_code = #{code}
</delete>
<delete id="deleteDict" parameterType="java.lang.Integer">
DELETE FROM sys_dictionary WHERE dict_id = #{id}
</delete>
<delete id="deleteDicts" parameterType="java.lang.String">
DELETE FROM sys_dictionary WHERE dict_parent = #{parent}
</delete>
<select id="queryProvince" resultType="com.mengyxu.core.pojo.com.Entry">
select code as 'key', name as 'value' from province
</select>
<select id="queryCity" resultType="com.mengyxu.core.pojo.com.Entry" parameterType="java.lang.String">
select code as 'key', name as 'value' from city where provinceCode = #{parent}
</select>
<select id="queryCounty" resultType="com.mengyxu.core.pojo.com.Entry" parameterType="java.lang.String">
select countycode as 'key', countyname as 'value' from county where cityCode = #{parent}
</select>
</mapper>

95
java/src/main/resources/mapper/sys/IUserItemMapper.xml

@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.mengyxu.admin.sys.mapper.IUserItemMapper">
<sql id="base_column">
id,user_id,item_name,item_desc,item_type,item_flag,add_user,add_time,status
</sql>
<resultMap type="com.mengyxu.admin.sys.pojo.UserItem" id="itemRM">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="item_name" property="itemName"/>
<result column="item_desc" property="itemDesc"/>
<result column="item_type" property="itemType"/>
<result column="item_flag" property="itemFlag"/>
<result column="add_user" property="addUser"/>
<result column="add_time" property="addTime"/>
<result column="status" property="status"/>
</resultMap>
<select id="queryByExample" parameterType="com.mengyxu.admin.sys.pojo.UserItem" resultMap="itemRM">
SELECT
<include refid="base_column"/>
FROM
sys_user_item
<where>
<if test="id != null and id != ''">
AND id = #{id}
</if>
<if test="userId != null and userId != ''">
AND user_id = #{userId}
</if>
<if test="itemType != null and itemType != ''">
AND item_type = #{itemType}
</if>
<if test="itemFlag != null and itemFlag != ''">
AND item_flag = #{itemFlag}
</if>
<if test="addUser != null and addUser != ''">
AND add_user = #{addUser}
</if>
<if test="status != null">
AND status = #{status}
</if>
</where>
ORDER BY status ASC, add_time DESC
<if test="limitStart != null">
LIMIT #{limitStart},#{size}
</if>
</select>
<insert id="insert" parameterType="com.mengyxu.admin.sys.pojo.UserItem">
INSERT INTO sys_user_item
(<include refid="base_column"/>)
VALUES (
#{id},
#{userId},
#{itemName},
#{itemDesc},
#{itemType},
#{itemFlag},
#{addUser},
#{addTime},
'0'
)
</insert>
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO sys_user_item
(<include refid="base_column"/>)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.userId},
#{item.itemName},
#{item.itemDesc},
#{item.itemType},
#{item.itemFlag},
#{item.addUser},
#{item.addTime},
'0'
)
</foreach>
</insert>
<update id="update" parameterType="com.mengyxu.admin.sys.pojo.UserItem">
UPDATE sys_user_item
SET
status = #{status}
WHERE
id = #{id}
</update>
</mapper>

257
java/src/main/resources/mapper/um/IPermissionMapper.xml

@ -0,0 +1,257 @@ @@ -0,0 +1,257 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mengyxu.admin.um.mapper.IPermissionMapper">
<sql id="baseColumn">
per_code,
per_name,
per_desc,
per_parent,
per_level,
per_content,
per_status,
per_order
</sql>
<insert id="insertOne" parameterType="com.mengyxu.admin.um.pojo.Permission" >
INSERT INTO um_permission_full
(<include refid="baseColumn"></include>)
VALUES
(
#{id},
#{name},
#{desc},
#{perParent},
#{perLevel},
#{perContent},
#{perStatus},
#{perOrder}
)
</insert>
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO um_permission_full
(<include refid="baseColumn"></include>)
VALUES
<foreach collection="list" item="permission" index="index" separator=",">
(
#{permission.id},
#{permission.name},
#{permission.desc},
#{permission.perParent},
#{permission.perLevel},
#{permission.perContent},
#{permission.perStatus},
#{permission.perOrder}
)
</foreach>
</insert>
<update id="updateByCode" parameterType="com.mengyxu.admin.um.pojo.Permission">
UPDATE um_permission_full SET
per_name = #{name},
per_desc = #{desc},
per_parent = #{perParent},
per_level = #{perLevel},
per_content = #{perContent},
per_status = #{perStatus},
per_order = #{perOrder}
WHERE
per_code = #{id}
</update>
<sql id="deletChild">
DELETE
FROM
um_permission_full
WHERE
per_code IN (
SELECT
*
FROM
(
SELECT
a.per_code
FROM
um_permission_full a
LEFT JOIN um_permission_full b ON b.per_code = a.per_parent
WHERE
a.per_level in ('view','action')
AND b.per_code IS NULL
) c
);
</sql>
<delete id="deleteByCode" parameterType="java.lang.String">
DELETE FROM um_permission_full WHERE per_code = #{code};
<include refid="deletChild"></include>
<include refid="deletChild"></include>
</delete>
<select id="isExist" parameterType="java.lang.String" resultType="_long">
SELECT COUNT(1) FROM um_permission_full WHERE per_code = #{code}
</select>
<select id="queryCodeByContent" parameterType="java.lang.String" resultType="java.lang.String">
SELECT per_code FROM um_permission_full WHERE per_content = #{perContent}
</select>
<select id="havePermission" parameterType="java.util.Map" resultType="_long">
SELECT
COUNT(1)
FROM
um_user_role ur,
um_role_permission rp,
um_permission_full p
WHERE
ur.role_code = rp.role_code
AND rp.per_code = p.per_code
AND ur.user_id = #{userId}
AND p.per_code = #{preCode}
</select>
<select id="queryAllModule" parameterType="java.lang.String" resultType="com.mengyxu.core.pojo.com.Entry">
SELECT
p.per_code as 'key',
p.per_name as 'value'
FROM
um_user_role u,
um_role_permission r,
um_permission_full p
WHERE
u.role_code = r.role_code
AND r.per_code = p.per_code
AND p.per_level = 'module'
AND u.user_id = #{userId}
ORDER BY per_order ASC
</select>
<resultMap type="com.mengyxu.admin.um.pojo.Menu" id="menuResultMap">
<result property="id" column="per_code"/>
<result property="title" column="per_name"/>
<result property="desc" column="per_desc"/>
<result property="href" column="per_content"/>
<collection property="children" column="{perParent=per_code,userId=user_id}" select="queryNodes" />
</resultMap>
<select id="queryMenuTree" resultMap="menuResultMap">
SELECT DISTINCT
u.user_id,
p.per_code,
p.per_name,
p.per_desc,
p.per_content
FROM
um_user_role u,
um_role_permission r,
um_permission_full p
WHERE
u.role_code = r.role_code
AND r.per_code = p.per_code
AND per_level = 'group'
<if test="perParent != null and perParent != ''">
AND per_parent = #{perParent}
</if>
AND u.user_id = #{userId}
AND per_status != 'I'
ORDER BY per_order ASC
</select>
<select id="queryNodes" parameterType="java.util.Map" resultMap="menuResultMap">
SELECT DISTINCT
u.user_id,
p.per_code,
p.per_name,
p.per_desc,
p.per_content
FROM
um_user_role u,
um_role_permission r,
um_permission_full p
WHERE
u.role_code = r.role_code
AND r.per_code = p.per_code
AND p.per_parent = #{perParent}
AND p.per_level = 'view'
AND u.user_id = #{userId}
AND per_status != 'I'
ORDER BY per_order ASC
</select>
<select id="queryContentByParentContent" resultType="java.lang.String">
SELECT
DISTINCT per_content
FROM
um_user_role u,
um_role_permission r,
um_permission_full p
WHERE
u.role_code = r.role_code
AND r.per_code = p.per_code
AND u.user_id = #{userId}
AND p.per_parent = (
SELECT
per_code
FROM
um_permission_full
WHERE
per_content = #{parentContent}
)
AND p.per_level = 'action'
</select>
<resultMap type="com.mengyxu.admin.um.pojo.Permission" id="permissionRm">
<result property="id" column="per_code"/>
<result property="name" column="per_name"/>
<result property="desc" column="per_desc"/>
<result property="perParent" column="per_parent"/>
<result property="perLevel" column="per_level"/>
<result property="perContent" column="per_content"/>
<result property="perStatus" column="per_status"/>
<result property="perOrder" column="per_order"/>
<collection property="children" column="{perParent=per_code}" select="queryPermissionTree" />
</resultMap>
<select id="queryPermissionTree" resultMap="permissionRm">
SELECT
<include refid="baseColumn"/>
FROM
um_permission_full
WHERE
<if test="perParent != null and perParent != ''">
per_parent = #{perParent}
</if>
<if test="perParent == null or perParent == ''">
per_parent is null
</if>
ORDER BY per_order ASC
</select>
<resultMap type="com.mengyxu.admin.um.pojo.Permission" id="publicPerRm">
<result property="id" column="per_code"/>
<result property="name" column="per_name"/>
<collection property="children" column="{perParent=per_code}" select="queryPublicPerTree" />
</resultMap>
<select id="queryPublicPerTree" resultMap="publicPerRm">
SELECT
per_code,per_name
FROM
um_permission_full
WHERE
<if test="perParent != null and perParent != ''">
per_parent = #{perParent}
</if>
<if test="perParent == null or perParent == ''">
per_parent is null
</if>
AND per_status != 'H'
ORDER BY per_order ASC
</select>
</mapper>

114
java/src/main/resources/mapper/um/IRolePermissionMapper.xml

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mengyxu.admin.um.mapper.IRolePermissionMapper">
<sql id="baseColumn">
role_code,
role_name,
role_desc,
role_status
</sql>
<resultMap type="com.mengyxu.admin.um.pojo.Role" id="baseRM">
<result column="role_code" property="code"/>
<result column="role_name" property="name"/>
<result column="role_desc" property="desc"/>
<result column="role_status" property="status"/>
</resultMap>
<resultMap type="com.mengyxu.admin.um.pojo.Role" id="roleRM" extends="baseRM">
<collection property="permissions" column="role_code" select="queryPermissions" />
</resultMap>
<sql id="withOutOperater">
WHERE role_status != 'H'
</sql>
<select id="queryAll" resultMap="baseRM">
SELECT <include refid="baseColumn"/> FROM um_role_full
</select>
<select id="queryList" resultMap="roleRM">
SELECT <include refid="baseColumn"/> FROM um_role_full <include refid="withOutOperater"/>
</select>
<select id="queryPermissions" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
DISTINCT per_code
FROM
um_role_permission
WHERE
role_code = #{roleCode}
</select>
<insert id="insertOne" parameterType="com.mengyxu.admin.um.pojo.Role" >
INSERT INTO um_role_full
(<include refid="baseColumn"/>)
VALUES
(
#{code},
#{name},
#{desc},
#{status}
)
</insert>
<insert id="insertBatch" parameterType="java.util.List" >
INSERT INTO um_role_full
(<include refid="baseColumn"></include>)
VALUES
<foreach collection="list" item="role" separator=",">
(
#{role.code},
#{role.name},
#{role.desc},
#{role.status}
)
</foreach>
</insert>
<delete id="delete" parameterType="java.lang.String">
DELETE FROM um_role_full WHERE role_code = #{roleCode}
</delete>
<delete id="deleteRolePer" parameterType="java.lang.String">
DELETE FROM um_role_permission WHERE role_code = #{roleCode}
</delete>
<insert id="insertRolePer" parameterType="com.mengyxu.admin.um.pojo.Role" >
INSERT INTO um_role_permission
(role_code, per_code)
VALUES
<foreach collection="permissions" item="perCode" separator=",">
(
#{code},
#{perCode}
)
</foreach>
</insert>
<update id="update" parameterType="com.mengyxu.admin.um.pojo.Role">
UPDATE
um_role_full
<set>
<if test="name != null and name != ''">
role_name = #{name},
</if>
<if test="desc != null and desc != ''">
role_desc = #{desc},
</if>
<if test="status != null and status != ''">
role_status = #{status},
</if>
</set>
WHERE
role_code = #{code}
</update>
<select id="queryRoleMaps" resultType="com.mengyxu.core.pojo.com.Entry">
SELECT role_code as 'key', role_name as 'value' FROM um_role_full <include refid="withOutOperater"/>
</select>
</mapper>

146
java/src/main/resources/mapper/um/IUserMapper.xml

@ -0,0 +1,146 @@ @@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mengyxu.admin.um.mapper.IUserMapper">
<sql id="baseColumn">
user_id,
`key`,
name,
phone,
id_card,
email,
last_login,
status
</sql>
<resultMap type="com.mengyxu.admin.um.pojo.User" id="userResultMap">
<id column="user_id" property="userId" />
<result column="id_card" property="idCard" />
<result column="last_login" property="lastLogin" />
<collection property="roles" column="{userId=user_id,flag=flag}" select="queryRoles" />
</resultMap>
<select id="findUser" resultMap="userResultMap" parameterType="com.mengyxu.admin.um.pojo.User">
SELECT
u.*, false as flag
FROM
um_user u
<where>
<if test="userId != null and userId !=''">
AND u.user_id = #{userId}
</if>
<if test="key != null and key !=''">
AND u.key = #{key}
</if>
<if test="idCard != null and idCard !=''">
AND u.id_card = #{idCard}
</if>
<if test="phone != null and phone !=''">
AND u.phone = #{phone}
</if>
</where>
</select>
<select id="queryByExample" resultMap="userResultMap" parameterType="com.mengyxu.admin.um.pojo.User">
SELECT
*, true as flag
FROM
um_user
WHERE
status != 'H'
<if test="userId != null and userId !=''">
AND user_id like CONCAT('%',#{userId},'%')
</if>
<if test="name != null and name !=''">
AND name like CONCAT('%',#{name},'%')
</if>
<if test="idCard != null and idCard !=''">
AND id_card like CONCAT('%',#{idCard},'%')
</if>
<if test="phone != null and phone !=''">
AND phone like CONCAT('%',#{phone},'%')
</if>
</select>
<select id="queryRoles" resultType="java.lang.String">
SELECT
DISTINCT a.role_code
FROM
um_user_role a
JOIN um_role_full b
ON a.role_code = b.role_code
WHERE
a.user_id = #{userId}
<if test="flag">
AND b.role_status != 'H'
</if>
</select>
<insert id="insert" parameterType="com.mengyxu.admin.um.pojo.User">
INSERT INTO um_user
(<include refid="baseColumn"></include>)
VALUES
(
#{userId},
#{key},
#{name},
#{phone},
#{idCard},
#{email},
#{lastLogin},
#{status}
)
</insert>
<update id="update" parameterType="com.mengyxu.admin.um.pojo.User">
UPDATE um_user
<set>
<if test="newKey != null and newKey !=''">
`key` = #{newKey},
</if>
<if test="name != null and name !=''">
name = #{name},
</if>
<if test="phone != null and phone !=''">
phone = #{phone},
</if>
<if test="idCard != null and idCard !=''">
id_card = #{idCard},
</if>
<if test="email != null and email !=''">
email = #{email},
</if>
<if test="lastLogin != null and lastLogin !=''">
last_login = #{lastLogin},
</if>
<if test="status != null and status !=''">
status = #{status},
</if>
</set>
WHERE user_id = #{userId}
</update>
<delete id="delete" parameterType="java.lang.String">
DELETE FROM um_user WHERE user_id = #{userId}
</delete>
<delete id="deleteUserRole" parameterType="java.lang.String">
DELETE FROM um_user_role WHERE user_id = #{userId}
</delete>
<insert id="insertUserRole" parameterType="com.mengyxu.admin.um.pojo.User" >
INSERT INTO um_user_role
(user_id, role_code)
VALUES
<foreach collection="roles" item="roleCode" separator=",">
(
#{userId},
#{roleCode}
)
</foreach>
</insert>
</mapper>

143
sql/admin_data_01.sql

@ -0,0 +1,143 @@ @@ -0,0 +1,143 @@
-- ----------------------------
-- Records of sys_dictionary
-- ----------------------------
INSERT INTO `sys_dictionary` VALUES (NULL, 'action', '按钮', '控制按钮显示及接口访问权限', 'per_level', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'group', '菜单组', '控制主页菜单组权限', 'per_level', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'view', '页面', '页面', 'per_level', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '0', '登录', '登录', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '1', '退出登录', '退出登录', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '2', '修改密码', '修改密码', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '3', '添加用户', '添加用户', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '4', '修改用户', '修改用户', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '5', '删除用户', '删除用户', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '6', '重置用户密码', '重置用户密码', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'E', '可读写', '可读可写', 'role_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'R', '只读', '只可读不可写', 'role_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'H', '隐藏', '页面隐藏不显示', 'role_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'A', '启用', '启用', 'active_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'I', '禁用', '禁用', 'active_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'H', '专用', '专用', 'active_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '0', '正常', '正常', 'base_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '1', '异常', '异常', 'base_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '0', '初始', '初始', 'user_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'H', '隐藏', '隐藏', 'user_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '1', '', '', 'boolean', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '0', '', '', 'boolean', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '1', '正常', '正常', 'user_status', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '0', '异常', '异常', 'common_staus', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '1', '正常', '正常', 'common_staus', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '0', '权限日志', '登录、用户角色管理', 'log_module', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '1', '业务日志', '业务日志', 'log_module', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '7', '添加角色', '添加角色', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '8', '修改角色', '修改角色', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, '9', '删除角色', '删除角色', 'log_type', 'A');
INSERT INTO `sys_dictionary` VALUES (NULL, 'R', '只读', '只读', 'user_status', 'A');
-- ----------------------------
-- Records of sys_dict_type
-- ----------------------------
INSERT INTO `sys_dict_type` VALUES ('active_status', '启用状态', '启用状态', 'A');
INSERT INTO `sys_dict_type` VALUES ('base_status', '通用状态', '通用状态(0正常)', 'A');
INSERT INTO `sys_dict_type` VALUES ('boolean', '是否', '是否', 'A');
INSERT INTO `sys_dict_type` VALUES ('common_staus', '通用状态', '通用状态(0异常)', 'A');
INSERT INTO `sys_dict_type` VALUES ('log_module', '日志模块', '日志模块', 'A');
INSERT INTO `sys_dict_type` VALUES ('log_type', '日志类型', '日志类型', 'A');
INSERT INTO `sys_dict_type` VALUES ('per_level', '权限级别', '权限级别', 'A');
INSERT INTO `sys_dict_type` VALUES ('role_status', '角色状态', '角色状态', 'A');
INSERT INTO `sys_dict_type` VALUES ('user_status', '系统用户状态', '系统用户状态', 'A');
-- ----------------------------
-- Records of um_permission_full
-- ----------------------------
INSERT INTO `um_permission_full` VALUES ('admin_dictionary', '数据字典', 'el-icon-collection', 'operater_manage', 'view', 'dictionary', 'A', '2');
INSERT INTO `um_permission_full` VALUES ('admin_permission', '权限管理', 'el-icon-unlock', 'operater_manage', 'view', 'permission', 'A', '1');
INSERT INTO `um_permission_full` VALUES ('admin_role', '角色管理', 'el-icon-user', 'system_setting', 'view', 'role', 'A', '3');
INSERT INTO `um_permission_full` VALUES ('admin_user', '用户管理', 'el-icon-user-solid', 'system_setting', 'view', 'user', 'A', '2');
INSERT INTO `um_permission_full` VALUES ('dict_delete', '删除字典', '', 'admin_dictionary', 'action', 'admin/dict/delete', 'A', null);
INSERT INTO `um_permission_full` VALUES ('dict_list', '数据字典查询', '', 'admin_dictionary', 'action', 'admin/dict/list', 'A', null);
INSERT INTO `um_permission_full` VALUES ('dict_save', '新增字典', '', 'admin_dictionary', 'action', 'admin/dict/save', 'A', null);
INSERT INTO `um_permission_full` VALUES ('dict_update', '修改字典', '', 'admin_dictionary', 'action', 'admin/dict/update', 'A', null);
INSERT INTO `um_permission_full` VALUES ('operater_buffer', '缓存管理', 'el-icon-warning', 'operater_manage', 'view', 'buffer', 'A', '3');
INSERT INTO `um_permission_full` VALUES ('operater_manage', '运维管理', 'el-icon-s-platform', null, 'group', null, 'H', null);
INSERT INTO `um_permission_full` VALUES ('operater_status', '状态控制', 'el-icon-setting', 'operater_manage', 'view', 'status', 'A', '4');
INSERT INTO `um_permission_full` VALUES ('oper_buffer_clean', '清空失效缓存', '', 'operater_buffer', 'action', 'admin/memory/buffer/clean', 'A', null);
INSERT INTO `um_permission_full` VALUES ('oper_buffer_delay', '修改缓存失效时间', '', 'operater_buffer', 'action', 'admin/memory/buffer/delay', 'A', null);
INSERT INTO `um_permission_full` VALUES ('oper_buffer_delete', '删除缓存', '', 'operater_buffer', 'action', 'admin/memory/buffer/delete', 'A', null);
INSERT INTO `um_permission_full` VALUES ('oper_buffer_list', '缓存列表', '', 'operater_buffer', 'action', 'admin/memory/buffer/list', 'A', null);
INSERT INTO `um_permission_full` VALUES ('per_delete', '删除权限', '', 'admin_permission', 'action', 'admin/per/delete', 'A', null);
INSERT INTO `um_permission_full` VALUES ('per_list', '权限查询', '', 'admin_permission', 'action', 'admin/per/list', 'A', null);
INSERT INTO `um_permission_full` VALUES ('per_save', '添加权限', '', 'admin_permission', 'action', 'admin/per/save', 'A', null);
INSERT INTO `um_permission_full` VALUES ('per_update', '修改权限', '', 'admin_permission', 'action', 'admin/per/update', 'A', null);
INSERT INTO `um_permission_full` VALUES ('role_delete', '删除角色', '', 'admin_role', 'action', 'admin/role/delete', 'A', null);
INSERT INTO `um_permission_full` VALUES ('role_list', '角色查询', '', 'admin_role', 'action', 'admin/role/list', 'A', null);
INSERT INTO `um_permission_full` VALUES ('role_save', '新增角色', '', 'admin_role', 'action', 'admin/role/save', 'A', null);
INSERT INTO `um_permission_full` VALUES ('role_update', '更新角色及其权限', '', 'admin_role', 'action', 'admin/role/update', 'A', null);
INSERT INTO `um_permission_full` VALUES ('status_role_list', '角色状态查询', '', 'operater_status', 'action', 'admin/role/list/all', 'A', null);
INSERT INTO `um_permission_full` VALUES ('status_role_update', '角色状态修改', '', 'operater_status', 'action', 'admin/role/update', 'A', null);
INSERT INTO `um_permission_full` VALUES ('status_user_list', '用户状态查询', '', 'operater_status', 'action', 'admin/user/list/all', 'A', null);
INSERT INTO `um_permission_full` VALUES ('status_user_update', '用户状态修改', '', 'operater_status', 'action', 'admin/user/update', 'A', null);
INSERT INTO `um_permission_full` VALUES ('system_log', '日志查询', null, 'system_setting', 'view', 'system_log', 'A', '4');
INSERT INTO `um_permission_full` VALUES ('system_log_list', '查询日志列表', null, 'system_log', 'action', 'admin/log/action', 'A', null);
INSERT INTO `um_permission_full` VALUES ('system_setting', '权限控制', 'el-icon-s-tools', null, 'group', null, 'A', '8');
INSERT INTO `um_permission_full` VALUES ('user_delete', '删除用户', '', 'admin_user', 'action', 'admin/user/delete', 'A', null);
INSERT INTO `um_permission_full` VALUES ('user_list', '用户查询', '', 'admin_user', 'action', 'admin/user/list', 'A', null);
INSERT INTO `um_permission_full` VALUES ('user_reset', '重置密码', '', 'admin_user', 'action', 'admin/user/reset', 'A', null);
INSERT INTO `um_permission_full` VALUES ('user_save', '添加用户', '', 'admin_user', 'action', 'admin/user/save', 'A', null);
INSERT INTO `um_permission_full` VALUES ('user_update', '修改用户', '', 'admin_user', 'action', 'admin/user/update', 'A', null);
-- ----------------------------
-- Records of um_role_full
-- ----------------------------
INSERT INTO `um_role_full` VALUES ('admin', '超级管理员', '拥有系统最高权限,默认不可更改', 'R');
INSERT INTO `um_role_full` VALUES ('operator', '系统运维', '负责系统维护工作,默认不可更改', 'H');
-- ----------------------------
-- Records of um_role_permission
-- ----------------------------
INSERT INTO `um_role_permission` VALUES ('admin', 'admin_role');
INSERT INTO `um_role_permission` VALUES ('admin', 'admin_user');
INSERT INTO `um_role_permission` VALUES ('admin', 'role_delete');
INSERT INTO `um_role_permission` VALUES ('admin', 'role_list');
INSERT INTO `um_role_permission` VALUES ('admin', 'role_save');
INSERT INTO `um_role_permission` VALUES ('admin', 'role_update');
INSERT INTO `um_role_permission` VALUES ('admin', 'system_log');
INSERT INTO `um_role_permission` VALUES ('admin', 'system_log_list');
INSERT INTO `um_role_permission` VALUES ('admin', 'system_setting');
INSERT INTO `um_role_permission` VALUES ('admin', 'user_delete');
INSERT INTO `um_role_permission` VALUES ('admin', 'user_list');
INSERT INTO `um_role_permission` VALUES ('admin', 'user_reset');
INSERT INTO `um_role_permission` VALUES ('admin', 'user_save');
INSERT INTO `um_role_permission` VALUES ('admin', 'user_update');
INSERT INTO `um_role_permission` VALUES ('operator', 'admin_dictionary');
INSERT INTO `um_role_permission` VALUES ('operator', 'admin_permission');
INSERT INTO `um_role_permission` VALUES ('operator', 'dict_delete');
INSERT INTO `um_role_permission` VALUES ('operator', 'dict_list');
INSERT INTO `um_role_permission` VALUES ('operator', 'dict_save');
INSERT INTO `um_role_permission` VALUES ('operator', 'dict_update');
INSERT INTO `um_role_permission` VALUES ('operator', 'operater_buffer');
INSERT INTO `um_role_permission` VALUES ('operator', 'operater_manage');
INSERT INTO `um_role_permission` VALUES ('operator', 'operater_status');
INSERT INTO `um_role_permission` VALUES ('operator', 'oper_buffer_clean');
INSERT INTO `um_role_permission` VALUES ('operator', 'oper_buffer_delay');
INSERT INTO `um_role_permission` VALUES ('operator', 'oper_buffer_delete');
INSERT INTO `um_role_permission` VALUES ('operator', 'oper_buffer_list');
INSERT INTO `um_role_permission` VALUES ('operator', 'per_delete');
INSERT INTO `um_role_permission` VALUES ('operator', 'per_list');
INSERT INTO `um_role_permission` VALUES ('operator', 'per_save');
INSERT INTO `um_role_permission` VALUES ('operator', 'per_update');
INSERT INTO `um_role_permission` VALUES ('operator', 'status_role_list');
INSERT INTO `um_role_permission` VALUES ('operator', 'status_role_update');
INSERT INTO `um_role_permission` VALUES ('operator', 'status_user_list');
INSERT INTO `um_role_permission` VALUES ('operator', 'status_user_update');
-- ----------------------------
-- Records of um_user
-- ----------------------------
INSERT INTO `um_user` VALUES ('admin', 'e10adc3949ba59abbe56e057f20f883e', '超级管理员', '13333333333', null, null, '2021-07-09 16:56:10', 'R');
INSERT INTO `um_user` VALUES ('operator', 'e10adc3949ba59abbe56e057f20f883e', '运维管理员', '13333333334', null, null, '2021-07-09 16:50:04', 'H');
-- ----------------------------
-- Records of um_user_role
-- ----------------------------
INSERT INTO `um_user_role` VALUES ('admin', 'admin');
INSERT INTO `um_user_role` VALUES ('operator', 'operator');

120
sql/admin_schemal_01.sql

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
-- ----------------------------
-- Table structure for sys_action_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_action_log`;
CREATE TABLE `sys_action_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(3) NOT NULL,
`module` varchar(2) NOT NULL,
`user_id` varchar(20) DEFAULT NULL,
`login_ip` varchar(20) DEFAULT NULL,
`time` datetime NOT NULL,
`context` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2687 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for sys_config
-- ----------------------------
DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config` (
`cfg_key` varchar(32) NOT NULL COMMENT '配置唯一键',
`cfg_name` varchar(32) NOT NULL COMMENT '配置名称',
`cfg_value` varchar(64) NOT NULL COMMENT '配置值',
`cfg_type` varchar(32) NOT NULL COMMENT '配置类型TEXT,DATA,NUMBER(]',
`cfg_desc` varchar(128) DEFAULT NULL COMMENT '配置描述',
`cfg_status` varchar(1) NOT NULL COMMENT '配置状态A:active,I:inactive',
`update_time` datetime DEFAULT NULL COMMENT '最近一次修改时间',
`update_user` varchar(32) DEFAULT NULL COMMENT '最近一次修改用户',
PRIMARY KEY (`cfg_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for sys_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `sys_dictionary`;
CREATE TABLE `sys_dictionary` (
`dict_id` int(11) NOT NULL AUTO_INCREMENT,
`dict_code` varchar(32) CHARACTER SET utf8 NOT NULL,
`dict_name` varchar(32) CHARACTER SET utf8 NOT NULL,
`dict_desc` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`dict_parent` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`dict_status` varchar(1) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`dict_id`)
) ENGINE=InnoDB AUTO_INCREMENT=398 DEFAULT CHARSET=ascii;
-- ----------------------------
-- Table structure for sys_dict_type
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_type`;
CREATE TABLE `sys_dict_type` (
`type_code` varchar(32) CHARACTER SET utf8 NOT NULL,
`type_name` varchar(32) CHARACTER SET utf8 NOT NULL,
`type_desc` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`type_status` varchar(1) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`type_code`)
) ENGINE=InnoDB DEFAULT CHARSET=ascii;
-- ----------------------------
-- Table structure for um_permission_full
-- ----------------------------
DROP TABLE IF EXISTS `um_permission_full`;
CREATE TABLE `um_permission_full` (
`per_code` varchar(100) NOT NULL COMMENT '权限编号',
`per_name` varchar(100) NOT NULL COMMENT '权限名称',
`per_desc` varchar(100) DEFAULT NULL COMMENT '权限描述',
`per_parent` varchar(100) DEFAULT NULL COMMENT '父权限',
`per_level` varchar(10) NOT NULL COMMENT '权限等级',
`per_content` varchar(100) DEFAULT NULL COMMENT '权限内容',
`per_status` varchar(1) NOT NULL COMMENT '是否启用',
`per_order` int(2) DEFAULT NULL,
PRIMARY KEY (`per_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限信息表';
-- ----------------------------
-- Table structure for um_role_full
-- ----------------------------
DROP TABLE IF EXISTS `um_role_full`;
CREATE TABLE `um_role_full` (
`role_code` varchar(50) NOT NULL COMMENT '角色编号',
`role_name` varchar(20) NOT NULL COMMENT '角色名称',
`role_desc` varchar(100) NOT NULL COMMENT '角色描述',
`role_status` varchar(1) NOT NULL,
PRIMARY KEY (`role_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色信息表';
-- ----------------------------
-- Table structure for um_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `um_role_permission`;
CREATE TABLE `um_role_permission` (
`role_code` varchar(50) NOT NULL COMMENT '角色编号',
`per_code` varchar(100) NOT NULL COMMENT '权限编号',
PRIMARY KEY (`role_code`,`per_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色权限表';
-- ----------------------------
-- Table structure for um_user
-- ----------------------------
DROP TABLE IF EXISTS `um_user`;
CREATE TABLE `um_user` (
`user_id` varchar(32) NOT NULL COMMENT '用户名',
`key` varchar(64) NOT NULL COMMENT '密码',
`name` varchar(10) NOT NULL COMMENT '姓名',
`phone` varchar(11) NOT NULL COMMENT '电话',
`id_card` varchar(18) DEFAULT NULL COMMENT '身份证号码',
`email` varchar(32) DEFAULT NULL COMMENT '电子邮箱',
`last_login` datetime DEFAULT NULL COMMENT '上次登陆时间',
`status` varchar(1) NOT NULL COMMENT '状态',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for um_user_role
-- ----------------------------
DROP TABLE IF EXISTS `um_user_role`;
CREATE TABLE `um_user_role` (
`user_id` varchar(50) NOT NULL COMMENT '用户编号',
`role_code` varchar(50) NOT NULL COMMENT '角色编号',
PRIMARY KEY (`user_id`,`role_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户角色表';

5
vue/.editorconfig

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

2
vue/.env.development

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
NODE_ENV="development"
VUE_APP_BASE_URL="http://localhost"

2
vue/.env.preview

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
NODE_ENV="preview"
VUE_APP_BASE_URL=""

2
vue/.env.production

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
NODE_ENV="production"
VUE_APP_BASE_URL=""

2
vue/.env.test

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
NODE_ENV="test"
VUE_APP_BASE_URL=""

22
vue/.gitignore vendored

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

24
vue/README.md

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
# monitor-vue
## Project setup
```
yarn install
```
### Compiles and hot-reloads for development
```
yarn serve
```
### Compiles and minifies for production
```
yarn build
```
### Lints and fixes files
```
yarn lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

5
vue/babel.config.js

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

70
vue/package.json

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
{
"name": "admin-vue",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build --mode production",
"lint": "vue-cli-service lint",
"preview": "vue-cli-service build --mode preview",
"test": "vue-cli-service build --mode test"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.15.3",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^8.4.2",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@babel/core": "^7.10.5",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "^4.4.0",
"@vue/cli-plugin-eslint": "^4.4.0",
"@vue/cli-plugin-router": "^4.4.6",
"@vue/cli-plugin-typescript": "^4.4.0",
"@vue/cli-plugin-vuex": "^4.4.6",
"@vue/cli-service": "^4.4.0",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/eslint-config-typescript": "^5.0.2",
"axios": "^0.19.2",
"babel-loader": "^8.1.0",
"cache-loader": "^4.1.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"js-md5": "^0.7.3",
"node-sass": "^4.14.1",
"sass-loader": "^9.0.2",
"typescript": "~3.9.3",
"vue-cli-plugin-axios": "^0.0.4",
"vue-cli-plugin-element": "^1.0.1",
"vue-clipboard2": "^0.3.1",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/recommended",
"@vue/standard",
"@vue/typescript/recommended"
],
"parserOptions": {
"ecmaVersion": 2020
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

BIN
vue/public/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

17
vue/public/index.html

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>LRobust platform</title>
</head>
<body style="margin: 0px;">
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

BIN
vue/src/assets/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

168
vue/src/components/main/NavHeader.vue

@ -0,0 +1,168 @@ @@ -0,0 +1,168 @@
<template>
<div id="header">
<el-row class="info" type="flex" justify="end" align="middle">
<el-button class="info-btn" icon="el-icon-user-solid" type="text">
{{ $store.state.userInfo.userId }}
</el-button>
<el-button class="info-btn" icon="el-icon-setting" type="text" @click="update = true">
修改密码
</el-button>
<el-button class="info-btn" icon="el-icon-switch-button" type="text" @click="$store.commit('logout')">
注销登录
</el-button>
</el-row>
<el-row class="menu-row">
<el-menu class="el-menu-demo" :default-active="activeGroup" mode="horizontal" background-color="#FFF" text-color="#000" active-text-color="#4669e7">
<el-menu-item v-for="item in $store.state.menuGroups" :key="item.id" :index="item.id" @click="clickGroup(item)">
{{ item.title }}
<!-- <i :class="item.desc"></i> -->
</el-menu-item>
</el-menu>
<el-radio-group v-model="active" fill="#edf2f7" text-color="#4669e7">
<el-radio-button v-for="item in menus" :label="item.href">
{{ item.title }}
</el-radio-button>
</el-radio-group>
</el-row>
<el-dialog title="修改密码" :visible.sync="update" width="40%" top="15vh" :close-on-click-modal="false"
@keydown.enter.native="confirm()">
<el-form ref="update" :model="user" :rules="rules" label-width="180px">
<el-form-item label="旧密码" prop="key">
<el-input type="password" v-model="user.key"></el-input>
</el-form-item>
<el-form-item label="新密码" prop="newKey">
<el-input type="password" v-model="user.newKey"></el-input>
</el-form-item>
<el-form-item label="重复新密码" prop="reKey">
<el-input type="password" v-model="user.reKey" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="update = false;"> </el-button>
<el-button type="primary" @click="confrim"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
Vue,
Component,
Prop,
Watch
} from 'vue-property-decorator';
import md5 from 'js-md5';
import {
password
} from '@/static/tool/validate.js';
@Component
export default class NavHeader extends Vue {
menus = [];
active = 'home';
activeGroup = 'home';
update = false;
user = {};
rules = {
key: [{
required: true,
message: '请输入密码',
trigger: 'blur'
}],
newKey: [{
validator: password,
trigger: 'blur'
}],
reKey: [{
validator: this.reKey,
trigger: 'blur'
}]
};
clickGroup(group) {
this.activeGroup = group.id
this.menus = group.children
const children = group.children
if (children.length == 0) {
this.active = group.href
} else {
this.active = children[0].href
}
}
clickMenu(id) {
this.active = id
}
toHome() {
this.clickGroup(this.$store.state.menuGroups[0])
}
confrim() {
const that = this
this.$refs.update.validate((valid) => {
if (valid) {
const param = JSON.parse(JSON.stringify(that.user));
param.userId = that.$store.state.userInfo.userId;
param.key = md5(param.key)
param.newKey = md5(param.newKey)
delete param.reKey;
that.$post('um/update/password', param).then(rsp => {
if (rsp) {
that.update = false;
that.user = {};
that.$store.commit('logout')
}
});
} else {
return false
}
});
}
reKey(rule, value, callback) {
if (!value) {
callback(new Error('请重复输入新密码'));
} else if (value != this.user.newKey) {
callback(new Error('两次输入的新密码不一致'));
}else{
callback();
}
}
@Watch('active')
activeChang(n, o) {
this.$router.push('/' + n)
}
created() {}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style scoped>
.info {
background-color: cadetblue;
height: 50px;
padding-right: 100px;
}
.info-btn {
font-size: 17px;
color: #2D3748;
margin-left: 30px !important;
}
.menu-row {
background-color: #FFFFFF;
/* padding-left: 20px; */
}
</style>

250
vue/src/components/template/manage.vue

@ -0,0 +1,250 @@ @@ -0,0 +1,250 @@
<template>
<div id="mamageTemp">
<el-container>
<el-header class="main-head">
<el-row type="flex" justify="end">
<span v-for="term in terms">
<el-date-picker v-if="term.datePicker" v-model="example[term.code]" :value-format="term.valueFormat" :type="term.type"
:class="term.claze ? term.claze : 'query-medium'" :placeholder="term.desc"></el-date-picker>
<el-select v-if="term.dict" v-model="example[term.code]" :class="term.claze ? term.claze : 'query-medium'"
:placeholder="term.desc" :filterable="term.filterable" clearable>
<el-option v-for="(val, key, i) in $store.state.dict[term.dict]" :key="key" :value="key" :label="val" />
</el-select>
<el-input v-if="!term.datePicker && !term.dict" v-model="example[term.code]" :class="term.claze ? term.claze : 'query-medium'"
:placeholder="term.desc" clearable />
</span>
<el-button type="primary" icon="el-icon-search" @click="query(1)" v-if="urls.list && $store.state.buttons[urls.list]">
查询 </el-button>
<el-button type="success" icon="el-icon-plus" @click="add()" v-if="urls.save && $store.state.buttons[urls.save]">
添加{{name}} </el-button>
</el-row>
</el-header>
<el-main class="app-main">
<el-table :data="result.rows" :height="$store.state.sizes.pTableHei" border stripe>
<el-table-column v-for="prop in props" v-if="!prop.tableHide" :prop="prop.code" :label="prop.name"
:min-width="prop.width" :width="prop.type ? prop.width : ''" :type="prop.type" :formatter="(row,column,value) => getValue(prop.dict,value)"
show-overflow-tooltip />
<el-table-column v-if="urls.update || urls.del || actions" label="操作" :width="actionWidth" fixed="right">
<template slot-scope="scope" v-if="!stateProp || scope.row[stateProp] != 'R'">
<el-button v-if="urls.update && $store.state.buttons[urls.update]" size="mini" type="primary" @click="modify(scope.row)">
修改 </el-button>
<el-button v-if="urls.del && $store.state.buttons[urls.del]" size="mini" type="danger" @click="delate(scope.row)">
删除 </el-button>
<el-button v-for="action in actions" v-if="!action.url || $store.state.buttons[action.url]" size="mini"
:type="action.type" @click="$emit(action.emit,scope.row)">{{action.name}}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination :current-page="example.page" :page-sizes="[10, 20, 50, 100]" :page-size="example.size" layout="total, sizes, prev, pager, next, jumper"
:total="result.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</el-main>
</el-container>
<el-dialog :title="(flag.add ? '添加':'修改') + name" :visible.sync="flag.modify" :close-on-click-modal="false"
top="15vh" :width="props.length > 8 ? '60%' : '40%'" @keydown.enter.native="confirm()">
<el-form ref="update" class="full-item-form" label-width="180px" :rules="rules" :model="param">
<el-row v-if="props.length > 8">
<el-col :span="12" v-for="prop in props">
<ModifyItem :prop="prop" :flag="flag" :param="param"></ModifyItem>
</el-col>
</el-row>
<el-row v-else>
<span v-for="prop in props">
<ModifyItem :prop="prop" :flag="flag" :param="param"></ModifyItem>
</span>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="flag.modify = false"> 取消 </el-button>
<el-button type="primary" @click="confirm"> 确认 </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
Vue,
Component,
Prop,
Watch
} from 'vue-property-decorator';
import ModifyItem from './modifyItem.vue';
@Component({
components: {
ModifyItem
}
})
export default class MamageTemp extends Vue {
@Prop({
type: String
}) name;
@Prop({
type: Object
}) urls;
@Prop({
type: Array
}) terms;
@Prop({
type: Array
}) props;
@Prop({
type: Array
}) actions;
@Prop({
type: Object
}) rules;
@Prop({
type: String
}) stateProp;
actionWidth = 30;
example = {
page: 1,
size: 20
};
result = {
rows: [],
total: 0
};
param = {};
flag = {
add: false,
modify: false
};
handleSizeChange(val) {
this.example.size = val
this.query()
}
handleCurrentChange(val) {
this.example.page = val
this.query()
}
query(page) {
const that = this
if (page != null) {
this.example.page = page
}
this.$get(that.urls.list, that.example).then(function(response) {
if (response) {
that.result = response
} else {
that.result = {
rows: [],
total: 0
}
}
})
}
add() {
if (this.$refs.update != null) {
this.$refs.update.clearValidate()
}
this.param = {};
this.flag.add = true
this.flag.modify = true
}
modify(row) {
if (this.$refs.update != null) {
this.$refs.update.clearValidate()
}
this.flag.add = false
this.param = JSON.parse(JSON.stringify(row))
this.flag.modify = true
}
delate(row) {
const that = this
const msg = this.name ? this.name : "记录"
this.$confirm('确定要删除该' + msg + '吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$post(that.urls.del, row).then(function(response) {
if (response) {
that.query()
that.$emit('change');
}
})
}).catch(() => {
that.showMessage('info', '已取消删除')
})
}
confirm() {
const that = this
this.$refs.update.validate((valid) => {
if (valid) {
const url = that.flag.add ? that.urls.save : that.urls.update;
that.$post(url, that.param).then(function(response) {
if (response) {
that.query()
that.flag.modify = false
that.$emit('change');
}
})
} else {
return false
}
})
}
getValue(dictKey, value) {
if (!dictKey) {
return value;
}
const dict = this.$store.state.dict[dictKey]
if (dict == null) {
return value;
}
return dict[value] == null ? value : dict[value]
}
created() {
this.query();
if (this.urls.update) {
this.actionWidth += 60;
}
if (this.urls.del) {
this.actionWidth += 60;
}
const that = this;
if (this.actions) {
this.actions.forEach(i => {
that.actionWidth += i.width;
})
}
}
@Watch('flag.modify')
modifyChang(n, o) {
if(!n){
this.param = {};
}
}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style scoped>
#mamageTemp {
padding: 20px 20px 0px 20px;
}
</style>

62
vue/src/components/template/modifyItem.vue

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
<template>
<div id="modifyItem">
<!-- <el-form-item :label="prop.name" :prop="prop.code" v-if="!prop.hide && (!prop.addHide || !flag.add)"> -->
<el-form-item :label="prop.name" :prop="prop.code"
v-if="!(prop.hide || (flag.add && prop.addHide) || (!flag.add && prop.modifyHide))">
<el-select v-if="prop.dict" v-model="param[prop.code]" :disabled="!flag.add && prop.readOnly" filterable
:placeholder="'请选择'+prop.name" clearable>
<el-option v-if="prop.dict == 'order'" v-for="index in 99" :key="index" :value="index+''" :label="index" />
<el-option v-if="prop.dict != 'order'" v-for="(val, key, i) in $store.state.dict[prop.dict]" :key="key"
:value="prop.int ? parseInt(key):key+''" :label="val" />
</el-select>
<el-select v-if="prop.state" :multiple="prop.multiple" v-model="param[prop.code]"
:disabled="!flag.add && prop.readOnly" :placeholder="'请选择'+prop.name" filterable clearable>
<el-option v-for="item in $store.state[prop.state]" :key="item.key" :value="item.key" :label="item.value" />
</el-select>
<el-autocomplete v-if="prop.autocomplete" v-model="param[prop.code]" :fetch-suggestions="prop.getData" onKeypress="return(event.keyCode != 32)"
:placeholder="'请输入'+prop.name" clearable>
<template slot-scope="{ item }">
<div>{{ item.value + '--' + item[prop.labelKey] }}</div>
</template>
</el-autocomplete>
<el-input v-if="!prop.dict && !prop.state && !prop.autocomplete" v-model="param[prop.code]" onKeypress="return(event.keyCode != 32)"
:disabled="!flag.add && prop.readOnly" :placeholder="prop.desc ? prop.desc : '请输入'+prop.name" clearable />
</el-form-item>
</div>
</template>
<script>
import {
Vue,
Component,
Prop
} from "vue-property-decorator";
@Component
export default class ModifyItem extends Vue {
@Prop({
type: Object
}) prop;
@Prop({
type: Object
}) flag;
@Prop({
type: Object
}) param;
created() {} // - 访this
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} //keep-alive
}
</script>
<style scoped>
</style>

15
vue/src/main.ts

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
import Vue from 'vue'
import './static/plugins/axios'
import App from './views/main/App.vue'
import './static/plugins/element'
import router from './router'
import store from './store'
Vue.config.productionTip = false
const vue = new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
export default vue

61
vue/src/router/index.ts

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
Vue.use(VueRouter)
const routes: Array<RouteConfig> = [
{
path: '/',
redirect: '/home'
},{
path: '/home',
name: 'home',
component: () => import('../views/main/home.vue')
},{
path: '/login',
name: 'Login',
component: () => import('../views/main/login.vue')
},{
path: '/permission',
name: 'Premission',
component: () => import('../views/operator/permission.vue')
},{
path: '/dictionary',
name: 'Dictionary',
component: () => import('../views/operator/dictionary.vue')
},{
path: '/buffer',
name: 'Buffer',
component: () => import('../views/operator/buffer.vue')
},{
path: '/status',
name: 'Status',
component: () => import('../views/operator/status.vue')
},{
path: '/user',
name: 'User',
component: () => import('../views/sys/user.vue')
},{
path: '/role',
name: 'Role',
component: () => import('../views/sys/role.vue')
},{
path: '/system_log',
name: 'SystemLog',
component: () => import('../views/sys/log.vue')
}
]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
routes
})
router.afterEach((to, from) => {
// ...
})
export default router

13
vue/src/shims-tsx.d.ts vendored

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
import Vue, { VNode } from 'vue'
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
}
}

4
vue/src/shims-vue.d.ts vendored

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}

248
vue/src/static/plugins/axios.ts

@ -0,0 +1,248 @@ @@ -0,0 +1,248 @@
/* eslint-disable */
import Vue from "vue";
import { Message } from "element-ui";
import axios from "axios";
import store from "@/store";
import loading from "./element"
const config = {
// baseURL: process.env.VUE_APP_BASE_URL || process.env.apiUrl || "",
baseURL: process.env.VUE_APP_BASE_URL ? "/api" : "",
timeout: 60 * 1000,
withCredentials: true // Check cross-site Access-Control
};
const _axios = axios.create(config);
let curMsg: any;
// Add a request interceptor
_axios.interceptors.request.use(
function(config) {
const time = new Date().getTime().toString();
if(config.params){
delEmpty(config.params);
config.params.t = time;
}
if (config.data) {
delEmpty(config.params);
config.data.t = time;
}
return config;
},
function(error) {
return Promise.reject(error);
}
);
function delEmpty(data){
if(data){
for (const item in data) {
if (data.hasOwnProperty(item)) {
const val = data[item];
if ((val == null || val == "null" || val == "") && val !== 0) {
delete data[item];
}
}
}
}
}
// Add a response interceptor
_axios.interceptors.response.use(
function(response) {
if (!response.data.message) {
return { success: true, data: response.data };
}
return response.data;
},
function(error) {
return Promise.reject(error);
}
);
function post(url, data = {}, noMsg, noLoading) {
return new Promise((resolve, reject) => {
if(!noLoading){
loading.start();
}
_axios.post(url, data).then(
(response: any) => {
if(!noLoading){
loading.stop();
}
if (response.success) {
if (response.message) {
showMessage("success", response.message, false, noMsg);
resolve(true);
} else {
resolve(response.data);
}
} else {
if (response.message == "session timeout") {
store.commit("loginOut");
}
if (response.message == "no permission") {
response.message = "您暂无权访问,请联系管理员添加";
}
if (response.message.indexOf("no permission for ") == 0) {
response.message = "此权限尚未开放,请勿越权访问";
}
showMessage("error", response.message, false, noMsg);
if (response.error != null) {
console.log(response.error);
}
resolve(response.data);
}
},
err => {
if(!noLoading){
loading.stop();
}
showMessage("error", "后台连接失败,网络异常!", false, noMsg);
reject(err);
}
);
});
}
function get(url, data = {}, noMsg, noLoading) {
return new Promise((resolve, reject) => {
if(!noLoading){
loading.start();
}
_axios.get(url, {params:data}).then(
(response: any) => {
if(!noLoading){
loading.stop();
}
if (response.success) {
if (response.message) {
showMessage("success", response.message, false, noMsg);
resolve(true);
} else {
resolve(response.data);
}
} else {
if (response.message == "session timeout") {
store.commit("loginOut");
}
if (response.message == "no permission") {
response.message = "您暂无权访问,请联系管理员添加";
}
if (response.message.indexOf("no permission for ") == 0) {
response.message = "此权限尚未开放,请勿越权访问";
}
showMessage("error", response.message, false, noMsg);
console.log(response.error);
resolve(false);
}
},
err => {
if(!noLoading){
loading.stop();
}
showMessage("error", "后台连接失败,网络异常!", false, noMsg);
reject(err);
}
);
});
}
function download(fileName, url, data = {}, callBack) {
loading.start();
_axios({
method: "post",
url: url, // 请求地址
data: data, // 参数
responseType: "blob" // 表明返回服务器返回的数据类型
}).then(
response => {
loading.stop();
const data = response.data;
const reader = new FileReader() as any;
reader.readAsText(data);
reader.onload = function() {
try {
const result = JSON.parse(reader.result);
if (typeof result === "object") {
showMessage("error", result.message, false, false);
if (callBack != null) {
callBack(false);
}
return;
}
} catch (err) {}
const blob = new Blob([data], {
type: "application/vnd.ms-excel"
});
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName);
} else {
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
link.click();
window.URL.revokeObjectURL(link.href);
}
if (callBack != null) {
callBack(true);
}
};
},
err => {
loading.stop();
showMessage("error", "下载失败,网络异常!", false, false);
if (callBack != null) {
callBack(false);
}
}
);
}
function showMessage(type, info, unClose, noMsg) {
const vue = Vue as any;
if (noMsg) {
return;
}
if (curMsg != null) {
curMsg.close();
}
const tmp = Message({
type: type,
showClose: true,
message: info,
duration: 3000
});
if (!unClose) {
curMsg = tmp;
}
}
function showNotify(type, title, message, position) {
const vue = Vue as any;
if (position == null) {
position = "top-right";
}
vue.$notify({
title: title,
type: type,
message: message,
position: position,
duration: 0
});
}
Vue.prototype.$post = post;
Vue.prototype.$get = get;
Vue.prototype.$download = download;
Vue.prototype.$showMessage = showMessage;
Vue.prototype.$showNotify = showNotify;
export default {
post,
get,
download,
showMessage,
showNotify
}

47
vue/src/static/plugins/element.ts

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
import Vue from 'vue'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
let count = 0
let ld = null
const start = () => {
if (count === 0) {
ld = Element.Loading.service({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
}
count++
}
const stop = () => {
if (count <= 0) {
return
}
count--
if (count === 0) {
ld.close()
}
}
Vue.prototype.$start = start
Vue.prototype.$stop = stop
Vue.use(Element)
const icons = [
'el-icon-s-platform', 'el-icon-user-solid', 'el-icon-user', 'el-icon-unlock', 'el-icon-notebook-2', 'el-icon-school',
'el-icon-check', 'el-icon-video-play', 'el-icon-s-tools', 'el-icon-setting', 'el-icon-message-solid', 'el-icon-bell',
'el-icon-mobile-phone', 'el-icon-map-location', 'el-icon-location', 'el-icon-document', 'el-icon-s-check', 'el-icon-data-analysis',
'el-icon-view', 'el-icon-s-home', 'el-icon-office-building', 'el-icon-picture', 'el-icon-odometer', 'el-icon-s-data',
'el-icon-tickets', 'el-icon-delete-solid', 'el-icon-phone-outline', 'el-icon-phone', 'el-icon-star-on', 'el-icon-star-off',
'el-icon-warning', 'el-icon-upload', 'el-icon-download', 'el-icon-s-custom', 'el-icon-house', 'el-icon-message', 'el-icon-thumb',
'el-icon-search', 'el-icon-collection', 'el-icon-s-promotion', 'el-icon-refresh'
]
export default {
start,
stop,
icons
}

75
vue/src/static/tool/dateUtil.js

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
const formatterDateTime = function(date, type) {
if (date == null) {
date = new Date()
}
const month = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
const hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
const minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
const second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
switch (type) {
case 0:
return date.getFullYear() + '年' + month + '月' + day + '日' + hour + '时' + minute + '分' + second + '秒';
default:
return date.getFullYear() + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
}
}
const formatterDate = function(date, type) {
if (date == null) {
date = new Date()
}
const month = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
switch (type) {
case 0:
return date.getFullYear() + '年' + month + '月' + day + '日';
default:
return date.getFullYear() + '-' + month + '-' + day;
}
}
const formatterTime = function(date, type) {
if (date == null) {
date = new Date()
}
const hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
const minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
const second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
const month = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
switch (type) {
case 0:
return hour + '时' + minute + '分' + second + '秒';
default:
return hour + ':' + minute + ':' + second;
}
}
const formatterMonth = function(date, type) {
if (date == null) {
date = new Date()
}
const month = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
switch (type) {
case 0:
return date.getFullYear() + '年' + month + '月';
default:
return date.getFullYear() + '-' + month;
}
}
const formatterWeekDay = function(date, type) {
if (date == null) {
date = new Date()
}
return weeks[date.getDay()]
}
export {
formatterDateTime,
formatterDate,
formatterTime,
formatterMonth,
formatterWeekDay
}

222
vue/src/static/tool/validate.js

@ -0,0 +1,222 @@ @@ -0,0 +1,222 @@
function password(rule, value, callback) {
if (value == null || value === '') {
callback(new Error('请输入密码'))
} else if (value.length < 8 || value.length > 16) {
callback(new Error('密码长度为:8~16位'))
} else if (!new RegExp('^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$').test(value)) {
callback(new Error('密码至少包含大小写字母、数字和特殊字符'))
} else if (!new RegExp('.*[^A-Za-z0-9]+.*').test(value)) {
callback(new Error('密码至少包含大小写字母、数字和特殊字符'))
} else if (!new RegExp('^[^ ]+$').test(value)) {
callback(new Error('密码不能包含空格'))
}
callback()
}
function code(rule, value, callback) {
if (value == null || value == '') {
callback(new Error('验证码不能为空'))
} else if (!new RegExp('^[0-9]+$').test(value)) {
callback(new Error('验证码只能为数字'))
}
callback()
}
function email(rule, value, callback) {
if (value != null && value.length != 0) {
if (
!new RegExp(
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
).test(value)
) {
callback(new Error('请输入正确的电子邮箱'))
}
}
callback()
}
function phone(rule, value, callback) {
if (value != null && value.length != 0) {
if (
!new RegExp(
'^(0|86|17951)?(13[0-9]|15[012356789]|17[0135678]|18[0-9]|14[57])[0-9]{8}$'
).test(value)
) {
callback(new Error('请输入正确的手机号码'))
}
}
callback()
}
function imsi(rule, value, callback) {
// if(value != null && value.length != 0){
// }
callback()
}
function userName(rule, value, callback) {
if (value != null && value.length != 0) {
if (!new RegExp('^[a-zA-Z0-9]{5,16}$').test(value)) {
callback(new Error('用户名由字母,数字组成,长度5-16之间'))
}
if (/(^\_)|(\__)|(\_+$)/.test(value)) {
callback(new Error("用户名首尾不能出现下划线'_'"))
}
if (!new RegExp('^[^ ]+$').test(value)) {
callback(new Error('用户名不能包含空格'))
}
}
callback()
}
function name(rule, value, callback) {
if (value) {
if (!new RegExp('^[a-zA-Z\u4e00-\u9fa5]{1,10}$').test(value)) {
callback(new Error('姓名由汉字或字母组成,且长度不超过10'))
}
}
callback()
}
function idCard(rule, value, callback) {
if (value != null && value.length != 0) {
let iSum = 0
const aCity = {
11: '北京',
12: '天津',
13: '河北',
14: '山西',
15: '内蒙古',
21: '辽宁',
22: '吉林',
23: '黑龙江',
31: '上海',
32: '江苏',
33: '浙江',
34: '安徽',
35: '福建',
36: '江西',
37: '山东',
41: '河南',
42: '湖北',
43: '湖南',
44: '广东',
45: '广西',
46: '海南',
50: '重庆',
51: '四川',
52: '贵州',
53: '云南',
54: '西藏',
61: '陕西',
62: '甘肃',
63: '青海',
64: '宁夏',
65: '新疆',
71: '台湾',
81: '香港',
82: '澳门',
91: '国外'
}
if (!/^\d{17}(\d|x)$/i.test(value)) {
callback(new Error('你输入的身份证长度或格式错误'))
}
value = value.replace(/x$/i, 'a')
if (aCity[parseInt(value.substr(0, 2))] == null) {
callback(new Error('你的身份证地区非法'))
}
const sBirthday = value.substr(6, 4) + '-' + Number(value.substr(10, 2)) + '-' + Number(value.substr(12, 2))
const d = new Date(sBirthday.replace(/-/g, '/'))
if (
sBirthday !=
d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
) {
callback(new Error('身份证上的出生日期非法'))
}
for (let i = 17; i >= 0; i--) {
iSum += (Math.pow(2, i) % 11) * parseInt(value.charAt(17 - i), 11)
}
if (iSum % 11 != 1) {
callback(new Error('你输入的身份证号非法'))
}
}
callback()
}
function ipv4(rule, value, callback) {
if (value != null && value.length != 0) {
if (
!new RegExp(/^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$/).test(
value
)
) {
callback(new Error('错误的IPV4地址格式'))
}
}
callback()
}
function lon(rule, value, callback) {
if (
!new RegExp(
/^-?((0|1?[0-7]?[0-9]?)(([.][0-9]{1,6})?)|180(([.][0]{1,6})?))$/
).test(value)
) {
callback(new Error('请输入正确的经度'))
}
callback()
}
function lat(rule, value, callback) {
if (
!new RegExp(
/^-?((0|[1-8]?[0-9]?)(([.][0-9]{1,6})?)|90(([.][0]{1,6})?))$/
).test(value)
) {
callback(new Error('请输入正确的纬度'))
}
callback()
}
function number(rule, value, callback) {
if (value) {
const min = rule.min;
const max = rule.max;
let msg = '';
if (min != null && max != null) {
msg = 'from ' + min + ' to ' + max;
} else if (min != null && max == null) {
msg = 'more than or equal to' + min;
} else if (min == null && max != null) {
msg = 'less than or equal to' + max + '的';
}
const error = new Error('Please enter an integer ' + msg);
const num = parseInt(value);
if (isNaN(num)) {
callback(error);
}
if (min !== null && num < min) {
callback(error);
}
if (max !== null && num > max) {
callback(error);
}
}
callback();
}
export {
password,
code,
email,
phone,
imsi,
userName,
name,
idCard,
ipv4,
lon,
lat,
number
}

13
vue/src/store/actions.js

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
export default {
init(context) {
context.commit('queryMenus');
context.commit('getUserInfo');
context.commit('updateState', {
prop: 'showHeader',
value: true
})
context.commit('initSizes')
}
}

15
vue/src/store/index.ts

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import mutations from './mutations.js'
import actions from './actions.js'
import modules from './modules.js'
Vue.use(Vuex)
export default new Vuex.Store({
state,
mutations,
actions,
modules
})

3
vue/src/store/modules.js

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
export default class {
}

155
vue/src/store/mutations.js

@ -0,0 +1,155 @@ @@ -0,0 +1,155 @@
import http from '../static/plugins/axios'
import vue from '../main'
import Vue from 'vue'
let interval = null
function stop() {
if (interval == null) {
return
}
clearInterval(interval)
interval = null
}
function start() {
stop()
interval = setInterval(() => {
http.get('um/user/info', null, true, true).then(rsp => {
if (!rsp) {
stop()
vue.$router.push('/login')
}
})
}, 5000)
}
export default {
updateState(state, param) {
state[param.prop] = param.value;
},
initSizes(state) {
const height = window.innerHeight;
const width = window.innerWidth;
const loginHeight = 350;
const loginWidth = 450;
const navHead = state.showHeader ? 150 : 0;
const head = 60;
const pd = 40;
const page = 37;
Vue.set(state.sizes, 'fullHeight', height + 'px');
Vue.set(state.sizes, 'loginHeight', loginHeight + 'px');
Vue.set(state.sizes, 'loginWidth', loginWidth + 'px');
Vue.set(state.sizes, 'loginTop', (height - loginHeight) * 0.4 + 'px');
Vue.set(state.sizes, 'loginLeft', (width - loginWidth) * 0.49 + 'px');
Vue.set(state.sizes, 'headHeight', navHead + 'px');
Vue.set(state.sizes, 'mainHeight', height - navHead + 'px');
Vue.set(state.sizes, 'tableHei', height - navHead - head - pd);
Vue.set(state.sizes, 'pTableHei', state.sizes.tableHei - page);
},
getUserInfo(state) {
http.get('um/user/info').then(response => {
if (response) {
state.userInfo = response
start()
} else {
vue.$router.push('/login')
}
})
.catch(() => {
vue.$router.push('/login')
})
},
queryMenus(state) {
const tmp = [{
title: '主页',
id: 'home',
href: 'home',
children: []
}];
http.get('um/menu/tree').then(response => {
if (response) {
state.menuGroups = tmp.concat(response);
} else {
state.menuGroups = tmp;
}
}).catch(() => {
state.menuGroups = tmp;
});
},
queryRoleMap(state, refresh) {
if (!refresh && state.roles != null) {
return
}
http.get('public/role/map').then(function(response) {
response = response == null ? [] : response;
Vue.set(state, 'roles', response)
})
},
getDictMap(state, codes, callBack) {
if (codes == null) {
return
}
const arr = []
for (let i = 0; i < codes.length; i++) {
if (Object.keys(state.dict).indexOf(codes[i]) == -1) {
arr.push(codes[i])
}
}
if (arr.length == 0) {
return
}
http.post('public/get/dict', arr).then(function(response) {
if (response) {
for (let i = 0; i < arr.length; i++) {
const key = arr[i]
state.dict[key] = {}
const dicts = response[key]
if (dicts == null) {
continue
}
for (let j = 0; j < dicts.length; j++) {
const tmp = dicts[j]
const num = parseInt(tmp.code)
if (!isNaN(num)) {
state.dict[key][num] = tmp.name
} else {
state.dict[key][tmp.code] = tmp.name
}
}
}
if (callBack != null) {
callBack()
}
}
})
},
logout(state) {
http.get('um/login/out').then(response => {
if (response) {
vue.$router.push('/login')
state.userInfo = {}
}
})
},
getActionPers(state, content) {
http.get('public/my/action/per', {
content: content
}).then(function(response) {
if (response) {
state.buttons = {}
for (let i = 0; i < response.length; i++) {
state.buttons[response[i]] = true
}
}
})
}
}

9
vue/src/store/state.js

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
export default {
sizes: {},
userInfo: {},
showHeader: true,
menuGroups: [],
buttons: {},
dict: {},
roles: null
}

175
vue/src/views/main/App.vue

@ -0,0 +1,175 @@ @@ -0,0 +1,175 @@
<template>
<div id="app">
<el-container :style="{ height: $store.state.sizes.height }">
<el-header v-show="$store.state.showHeader" class="app-head" :height="$store.state.sizes.headHeight">
<NavHeader ref="header" />
</el-header>
<el-main class="app-main" :style="{ height: $store.state.sizes.mainHeight }">
<router-view @init="init" @clickMenu="clickMenu" />
</el-main>
</el-container>
</div>
</template>
<script>
import {
Component,
Prop,
Vue,
Watch
} from 'vue-property-decorator'
import NavHeader from '@/components/main/NavHeader'
@Component({
components: {
NavHeader
}
})
export default class App extends Vue {
initSize() {
this.$store.commit('initSizes')
}
init() {
this.$store.dispatch('init');
this.$router.push('/home')
if (this.$refs.header) {
this.$refs.header.toHome()
}
}
clickMenu(groupId, menuId) {
const arr = this.$store.state.menuGroups;
for (let i = 0; i < arr.length; i++) {
const tmp = arr[i];
if (groupId == tmp.id) {
this.$refs.header.clickGroup(tmp);
this.$refs.header.clickMenu(menuId);
}
}
}
created() {
this.init()
this.initSize()
window.onresize = this.initSize;
}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style>
#app {
background-color: #edf2f7;
}
.app-head {
padding: 0px !important;
}
.app-main {
/* background-color: #ffffff; */
padding: 0px 20px !important;
}
/* .el-main{
padding-top: 0px !important;
} */
.main-head {
padding-top: 10px;
}
.query-mini {
width: 100px !important;
margin-right: 10px;
}
.query-smart {
width: 120px !important;
margin-right: 10px;
}
.query-short {
width: 150px !important;
margin-right: 10px;
}
.query-medium {
width: 200px !important;
margin-right: 10px;
}
.query-long {
width: 250px !important;
margin-right: 10px;
}
.query-tree {
width: 300px !important;
margin-right: 10px;
}
.query-longest {
width: 350px !important;
margin-right: 10px;
}
.query-400 {
width: 400px !important;
margin-right: 10px;
}
.query-450 {
width: 450px !important;
margin-right: 10px;
}
.query-500 {
width: 500px !important;
margin-right: 10px;
}
.modify-dialog .el-dialog {
background-color: #edf2f7;
}
.form-title {
font-size: 18px;
background-color: cadetblue;
padding: 10px;
height: 25px;
font-weight: bold;
margin-bottom: 20px;
color: #FFFFFF;
}
.full-item-form .el-select,
.full-item-form .el-date-editor,
.full-item-form .el-autocomplete {
width: 100% !important;
}
.dialog-footer {
text-align: right;
}
.infomation-form .el-form-item {
margin-top: 20px;
font-size: 1.5rem;
}
.infomation-form .el-input {
width: 350px;
margin-right: 20px;
}
.infomation-form .el-input__inner{
background-color: #4472c4 !important;
color: #FFFFFF;
}
</style>

43
vue/src/views/main/home.vue

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
<template>
<div id="home">
欢迎使用后台管理模版系统
</div>
</template>
<script>
import {
Component,
Prop,
Vue
} from 'vue-property-decorator'
@Component
export default class Home extends Vue {
created() {} // - 访this
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style lang="scss" scoped>
//@import url(); css
#home {
padding: 0px 10px;
}
.item-to {
background-color: #fef0f0;
color: #f56c6c;
}
.item-read {
background-color: #f4f4f5;
color: #909399;
}
</style>

194
vue/src/views/main/login.vue

@ -0,0 +1,194 @@ @@ -0,0 +1,194 @@
<template>
<div id="login">
<div class="loginForm" :style="{ height:$store.state.sizes.loginHeight,width:$store.state.sizes.loginWidth,
'margin-top': $store.state.sizes.loginTop,'margin-left':$store.state.sizes.loginLeft}">
<el-form ref="login" class="login-form" :model="user" :rules="rules" hide-required-asterisk label-width="30px">
<div class="login-title">
后台管理模版系统
</div>
<br><br>
<el-form-item prop="userId">
<el-input v-model="user.userId" placeholder="用户名">
<el-button slot="prepend" icon="el-icon-user" />
</el-input>
</el-form-item>
<el-form-item prop="key">
<el-input v-model="user.key" type="password" placeholder="密码">
<el-button slot="prepend" icon="el-icon-key" />
</el-input>
</el-form-item>
<br>
<el-form-item>
<el-button class="login-btn" type="primary" @click="loginSubmit">登录</el-button>
<el-button style="float: right;" class="login-btn" type="primary" @click="reset">重置</el-button>
</el-form-item>
</el-form>
</div>
<el-dialog ref="dialog" title="您的密码为初始密码,请修改后再登录"
:visible.sync="updateFlag" width="30%" top="15vh" :close-on-click-modal="false">
<el-form ref="update" :model="user" :rules="rules" label-width="120px">
<el-form-item label="新密码" prop="newPassword">
<el-input type="password" v-model="user.newKey"></el-input>
</el-form-item>
<el-form-item label="重复新密码" prop="rePassword">
<el-input type="password" v-model="user.reKey" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="updateFlag = false"> 取消 </el-button>
<el-button type="primary" @click="update"> 确定 </el-button>
</div>
</el-dialog>
</div>
</template>
<script lang="ts">
import {
Component,
Prop,
Vue
} from 'vue-property-decorator'
import md5 from 'js-md5'
import {
password
} from '@/static/tool/validate.js';
@Component
export default class Login extends Vue {
marginTop = (window.innerHeight - 350) * 0.4 + 'px';
urls = {
login: "um/sso/login",
update: "um/update/password"
}
updateFlag = false;
user = {
userId: null,
key: null
};
rules = {
userId: [{
required: true,
message: '请输入用户名',
trigger: 'blur'
}],
key: [{
required: true,
message: '请输入密码',
trigger: 'blur'
}],
newKey: [{
validator: password,
trigger: 'blur'
}],
reKey: [{
validator: this.reKey,
trigger: 'blur'
}]
};
loginSubmit() {
const that = this as any;
that.$refs.login.validate((valid) => {
if (valid) {
const param = JSON.parse(JSON.stringify(that.user))
param.key = md5(param.key)
that.$post(that.urls.login, param).then(function(response) {
if (response == true) {
setTimeout(() => {
that.$emit("init");
}, 300)
} else if (response) {
that.updateFlag = true;
}
})
} else {
return false
}
})
}
reset() {
this.user = {
userId: null,
key: null
}
}
update() {
const that = this;
this.$refs['update'].validate((valid) => {
if (valid) {
var param = JSON.parse(JSON.stringify(that.user));
param.key = md5(param.key);
param.newKey = md5(param.newKey);
that.$post(that.urls.update, param).then(function(response) {
if (response) {
that.user.key = that.user.newKey;
that.updateFlag = false;
}
});
} else {
return false;
}
});
}
init(b) {
this.$store.commit('updateState', {
prop: 'showHeader',
value: b
})
this.$store.commit('initSizes')
}
reKey(rule, value, callback) {
if (!value) {
callback(new Error('请重复输入新密码'));
} else if (value != this.user.newKey) {
callback(new Error('两次输入的新密码不一致'));
} else {
callback();
}
}
created() {
this.init(false);
const that = this;
document.onkeydown = function(e) {
let key = e.which;
if (key == 13) {
that.loginSubmit();
}
};
}
}
</script>
<style scoped>
#login {
background-color: #edf2f7;
align-items: center;
}
.loginForm {
background: none;
height: 350px;
width: 500px;
box-shadow: 0 0 25px #cac6c6 !important;
padding: 30px 30px 20px 0px;
}
.login-title {
margin: 0px 70px 20px;
font-size: 1.8rem;
text-align: center;
color: #2d3748;
}
.login-btn {
margin: 0px 30px;
width: 100px;
}
</style>

184
vue/src/views/operator/buffer.vue

@ -0,0 +1,184 @@ @@ -0,0 +1,184 @@
<template>
<div id="buffer">
<el-container>
<el-header class="main-head">
<el-row type="flex" justify="end">
<el-button v-if="$store.state.buttons['admin/memory/buffer/list']" type="primary" icon="el-icon-search"
@click="query">
刷新
</el-button>
<el-button v-if="$store.state.buttons['admin/memory/buffer/clean']" type="success" icon="el-icon-delete"
@click="clean">
清空失效缓存
</el-button>
</el-row>
</el-header>
<el-main class="app-main">
<el-table :data="result" :height="$store.state.sizes.tableHei" border style="width: 100%" stripe>
<el-table-column type="expand">
<template slot-scope="props">
<el-form v-if="!isObj(props.row.value)" label-position="left" inline class="demo-table-expand">
<el-form-item label="缓存值">
<span>{{ props.row.value }}</span>
</el-form-item>
</el-form>
<el-form v-if="isObj(props.row.value)" label-position="left" inline class="demo-table-expand">
<el-form-item v-for="(val, key, i) in props.row.value" :key="key" :label="key" label-width="180px">
<span>{{ val }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
<el-table-column prop="key" label="唯一键" min-width="200" />
<el-table-column prop="effective" label="是否有效" min-width="100" :formatter="booleanFmt" />
<el-table-column prop="loseTime" label="失效时间" min-width="180" />
<el-table-column label="操作" min-width="200" fixed="right">
<template slot-scope="scope">
<el-button type="success" size="mini" @click="delay(scope.$index, scope.row)">
修改有效期
</el-button>
<el-button v-if="$store.state.buttons['admin/memory/buffer/delete']" type="danger" size="mini" @click="delate(scope.$index, scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
</el-container>
</div>
</template>
<script>
import {
Component,
Prop,
Vue
} from 'vue-property-decorator'
@Component
export default class Buffer extends Vue {
urls = {
list: 'admin/memory/buffer/list',
clean: 'admin/memory/buffer/clean',
delay: 'admin/memory/buffer/delay',
del: 'admin/memory/buffer/delete'
}
result = [];
query() {
const that = this
this.$post(this.urls.list).then(function(response) {
that.result = []
if (response) {
that.result = JSON.parse(JSON.stringify(response))
}
})
}
clean() {
const that = this
this.$post(this.urls.clean).then(function(response) {
if (response) {
that.query()
}
})
}
delay(index, row) {
const that = this
this.$prompt('请输入失效时间(yyyy-MM-dd HH:mm:ss)', '修改', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s((([0-1][0-9])|(2?[0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/,
inputErrorMessage: '时间格式不正确',
distinguishCancelAndClose: true,
showClose: false,
beforeClose: (action, instance, done) => {
if (action === 'close') {
return
}
done()
}
}).then(({
value
}) => {
that.$post(that.urls.delay, {
key: row.key,
loseTime: value
}).then(function(response) {
if (response) {
that.query()
}
})
}).catch(() => {
this.$showMessage('info', '已取消修改')
})
}
delate(index, row) {
const that = this
this.$confirm('确定要删除此条缓存吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'danger'
}).then(() => {
this.$post(this.urls.del, row).then(function(response) {
if (response) {
that.query()
}
})
}).catch(() => {
this.$showMessage('info', '已取消删除')
})
}
booleanFmt(row, column, cellValue, index) {
if (cellValue) {
return '是'
}
return '否'
}
isObj(data) {
return typeof data === 'object'
}
created() {
this.query()
this.$store.commit('getActionPers', 'buffer')
}
mounted() {
// - 访DOM
}
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style>
#buffer {
padding: 20px 20px 0px 20px;
}
.demo-table-expand {
font-size: 0;
}
.demo-table-expand label {
width: 90px;
color: #99a9bf;
}
.demo-table-expand .el-form-item {
margin-right: 0;
margin-bottom: 0;
width: 50%;
}
</style>

252
vue/src/views/operator/dictionary.vue

@ -0,0 +1,252 @@ @@ -0,0 +1,252 @@
<template>
<div id="dictionary">
<el-container>
<el-header class="main-head">
<el-row type="flex" justify="end">
<el-input v-model="example.name" class="query-medium" placeholder="字典类型名称(模糊查询)" clearable />
<el-input v-model="example.code" class="query-medium" placeholder="字典类型编码" clearable />
<el-select v-if="$store.state.buttons['admin/dict/save']" v-model="example.status" class="query-short" placeholder="状态" clearable>
<el-option value="A" label="启用" />
<el-option value="I" label="禁用" />
</el-select>
<el-button type="primary" icon="el-icon-search" @click="queryList(1)"> 查询 </el-button>
<el-button type="success" icon="el-icon-plus" @click="add()"> 添加字典类型 </el-button>
</el-row>
</el-header>
<el-main class="app-main">
<el-table :data="result.rows" :height="$store.state.sizes.pTableHei" :row-class-name="rowClass" row-key="key"
border :tree-props="{children: 'children'}">
<el-table-column prop="name" label="字典名称" min-width="180" fixed="left" />
<el-table-column prop="code" label="字典编码" min-width="180" />
<el-table-column prop="desc" label="字典说明" min-width="300" />
<el-table-column label="状态" min-width="120">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if="scope.row.status=='A'" size="medium">
启用
</el-tag>
<el-tag v-else size="medium" type="danger">
禁用
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="300" fixed="right">
<template slot-scope="scope">
<el-button v-if="$store.state.buttons['admin/dict/update']" size="mini" type="primary" @click="modify(scope.row)">
修改
</el-button>
<el-button v-if="$store.state.buttons['admin/dict/delete']" size="mini" type="danger" @click="delate(scope.row)">
删除
</el-button>
<el-button v-if="$store.state.buttons['admin/dict/save'] && scope.row.parent == null" size="mini" type="success"
@click="add(scope.row)">
添加字典
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination :current-page="example.page" :page-sizes="[10, 20, 50, 100]" :page-size="example.size" layout="total, sizes, prev, pager, next, jumper"
:total="result.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</el-main>
</el-container>
<el-dialog title="修改类型/字典" :visible.sync="flag.modify" :close-on-click-modal="false" top="15vh" width="40%" @keydown.enter.native="confirm()">
<el-form ref="update" class="full-item-form" label-width="100px" :rules="rules" :model="param">
<el-form-item label="字典编号" prop="code">
<el-input v-model="param.code" :disabled="!flag.add" />
</el-form-item>
<el-form-item label="字典名称" prop="name">
<el-input v-model="param.name" />
</el-form-item>
<el-form-item label="字典说明">
<el-input v-model="param.desc" />
</el-form-item>
<el-form-item label="字典状态" prop="status">
<el-select v-model="param.status" placeholder="请选择">
<el-option value="A" label="启用">
启用
</el-option>
<el-option value="I" label="禁用">
禁用
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="flag.modify = false"> Esc </el-button>
<el-button type="primary" @click="confirm"> Enter </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
Vue,
Component,
Prop
} from 'vue-property-decorator'
@Component
export default class Dictionary extends Vue {
urls = {
list: 'admin/dict/list',
save: 'admin/dict/save',
update: 'admin/dict/update',
del: 'admin/dict/delete'
};
rules = {
code: [{
required: true,
message: '请输入字典编号',
trigger: 'blur'
}],
name: [{
required: true,
message: '请输入字典名称',
trigger: 'blur'
}],
status: [{
required: true,
message: '请选择字典状态',
trigger: 'blur'
}]
};
example = {
page: 1,
size: 10
};
param = {};
result = {
rows: [],
total: 0
};
flag = {
add: false,
modify: false
}
handleSizeChange(val) {
this.example.size = val
this.queryList()
}
handleCurrentChange(val) {
this.example.page = val
this.queryList()
}
queryList(page) {
const that = this
if (page != null) {
this.example.page = page
}
this.$get(this.urls.list, that.example).then(function(response) {
if (response) {
that.result = response
} else {
that.result = {
rows: [],
total: 0
}
}
})
}
rowClass(data) {
if (data.row.parent == null) {
return ''
}
return 'child-row'
}
modify(row) {
if (this.$refs.update != null) {
this.$refs.update.clearValidate()
}
this.flag.add = false
this.param = JSON.parse(JSON.stringify(row))
this.flag.modify = true
}
add(row) {
if (this.$refs.update != null) {
this.$refs.update.clearValidate()
}
this.flag.add = true
this.param = {
status: 'A'
}
if (row != null) {
this.param.parent = row.code
}
this.flag.modify = true
}
delate(row) {
const that = this
this.$confirm('确定要字典权限‘' + row.name + '’吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$post(this.urls.del, row).then(function(response) {
if (response) {
that.queryList()
}
})
}).catch(() => {
showMessage('info', '已取消删除')
})
}
confirm() {
const that = this
this.$refs.update.validate((valid) => {
if (valid) {
let url = that.urls.update
if (that.flag.add) {
url = that.urls.save
}
const param = JSON.parse(JSON.stringify(that.param))
delete param.children;
that.$post(url, param).then(function(response) {
if (response) {
that.queryList()
that.flag.modify = false
}
})
} else {
return false
}
})
}
created() {
this.queryList()
this.$store.commit('getActionPers', 'dictionary')
}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style scoped>
#dictionary {
padding: 20px 20px 0px 20px;
}
.child-row {
background: #f0f9eb !important;
}
</style>

268
vue/src/views/operator/permission.vue

@ -0,0 +1,268 @@ @@ -0,0 +1,268 @@
<template>
<div id="permission">
<el-header class="main-head">
<el-row type="flex" class="row-bg" justify="end">
<el-button v-if="$store.state.buttons['admin/per/save']" type="primary" icon="el-icon-plus" @click="add()">
添加菜单组
</el-button>
<el-button v-if="$store.state.buttons['admin/per/list']" type="info" icon="el-icon-refresh" @click="queryList(1)">
刷新
</el-button>
</el-row>
</el-header>
<el-main class="app-main">
<el-table :data="result" :height="$store.state.sizes.tableHei" :row-class-name="rowClass" row-key="id" border
:tree-props="{children: 'children'}">
<el-table-column prop="name" label="权限名称" min-width="200" fixed="left" />
<el-table-column prop="id" label="权限编号" min-width="220" />
<el-table-column label="菜单图标" min-width="80">
<template slot-scope="scope">
<i :class="scope.row.desc" />
</template>
</el-table-column>
<el-table-column prop="perLevel" label="权限级别" min-width="80" :formatter="(row,column,value) => getValue('per_level',value)" />
<el-table-column prop="perOrder" label="排序优先级" min-width="80" />
<el-table-column label="权限状态" min-width="80">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if="scope.row.perStatus=='A'" size="medium">
启用
</el-tag>
<el-tag v-if="scope.row.perStatus=='H'" size="medium" type="info">
专用
</el-tag>
<el-tag v-if="scope.row.perStatus=='I'" size="medium" type="danger">
禁用
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column prop="perContent" label="权限内容" min-width="230" />
<el-table-column label="操作" width="270" fixed="right">
<template slot-scope="scope">
<el-button v-if="$store.state.buttons['admin/per/update']" size="mini" type="primary" @click="modify(scope.row)">
修改
</el-button>
<el-button v-if="$store.state.buttons['admin/per/delete']" size="mini" type="danger" @click="delate(scope.row)">
删除
</el-button>
<el-button v-if="$store.state.buttons['admin/per/save'] && scope.row.perLevel != 'action'" size="mini" type="success"
@click="add(scope.row)">
添加子权限
</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
<el-dialog :title="(flag.add ? '添加':'修改')+'权限'" :visible.sync="flag.modify" :close-on-click-modal="false" top="15vh"
width="30%" @keydown.enter.native="confirm()">
<el-form ref="update" class="full-item-form" label-width="100px" :rules="rules" :model="param">
<el-form-item label="权限编号" prop="id">
<el-input v-model="param.id" :disabled="!flag.add" />
</el-form-item>
<el-form-item label="父权限">
<el-input v-model="param.perParent" disabled="disabled" />
</el-form-item>
<el-form-item label="权限级别">
<el-select v-model="param.perLevel" placeholder="请选择" disabled>
<el-option v-for="(val, key, i) in $store.state.dict.per_level" :key="key" :value="key" :label="val" />
</el-select>
</el-form-item>
<el-form-item label="权限名称" prop="name">
<el-input v-model="param.name" />
</el-form-item>
<el-form-item label="权限内容">
<el-input v-model="param.perContent" />
</el-form-item>
<el-form-item label="菜单图标">
<el-select v-model="param.desc" placeholder="请选择">
<el-option v-for="item in iconsArr" :key="item" :value="item">
<span style="float: left; color: #8492a6; font-size: 16px; margin-right:20px;">
<i :class="item" />
</span>
<span style="float: left">{{ item }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="排序优先级">
<el-select v-model="param.perOrder" placeholder="请选择">
<el-option v-for="index in order" :key="index" :value="index" />
</el-select>
</el-form-item>
<el-form-item label="权限状态" prop="dictStatus">
<el-select v-model="param.perStatus" placeholder="请选择">
<el-option v-for="(val, key, i) in $store.state.dict.active_status" :key="key" :value="key" :label="val" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="flag.modify = false"> Esc </el-button>
<el-button type="primary" @click="confirm"> Enter </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
Vue,
Component,
Prop,
Watch
} from 'vue-property-decorator'
import element from '@/static/plugins/element'
@Component
export default class Permission extends Vue {
urls = {
list: 'admin/per/list',
save: 'admin/per/save',
update: 'admin/per/update',
del: 'admin/per/delete'
};
rules = {
id: [{required: true,message:'请输入权限编号',trigger: 'blur'}],
name: [{required: true,message:'请输入权限名称',trigger: 'blur'}]
};
iconsArr = element.icons;
order = 99;
nodeLevel = {
module: 'group',
group: 'view',
view: 'action'
};
example = {page:1,size:10};
result = [];
param = {};
flag = {
modify: false,
add: false
};
queryList(page) {
if (page != null) {
this.example.page = page
}
const that = this
this.$get(this.urls.list, this.example).then(rsp => {
that.result = rsp
})
}
rowClass(data) {
return data.row.perLevel + '-row'
}
modify(row) {
if (this.$refs.update != null) {
this.$refs.update.clearValidate()
}
this.flag.add = false
this.param = JSON.parse(JSON.stringify(row))
this.flag.modify = true
}
add(row) {
if (this.$refs.update != null) {
this.$refs.update.clearValidate()
}
this.flag.add = true
this.param = {
perStatus: 'A'
}
if (row == null) {
this.param.perLevel = 'group'
} else {
this.param.perParent = row.id
this.param.perLevel = this.nodeLevel[row.perLevel]
}
this.flag.modify = true
}
delate(row) {
const that = this
this.$confirm('确定要删除权限‘' + row.name + '’吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
that.$post(that.urls.del, row).then(function(response) {
if (response) {
that.queryList()
}
})
}).catch(() => {
showMessage('info', '已取消删除')
})
}
confirm() {
const that = this
this.$refs.update.validate((valid) => {
if (valid) {
let url = that.urls.update
if (that.flag.add) {
url = that.urls.save
}
delete that.param.children
that.$post(url, that.param).then(function(response) {
if (response) {
that.queryList()
that.flag.modify = false
}
})
} else {
return false
}
})
}
getValue(dictKey, value) {
const dict = this.$store.state.dict[dictKey]
if (dict == null) {
return ''
}
return dict[value] == null ? value : dict[value]
}
created() {
this.queryList()
this.$store.commit('getDictMap', ['per_level', 'active_status'])
this.$store.commit('getActionPers', 'permission')
}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style>
#permission {
padding: 20px 20px 0px 20px;
}
.module-row {
background-color: #ecf5ff !important;
}
.group-row {
background-color: #f0f9eb !important;
}
.view-row {
background-color: oldlace !important;
}
.action-row {
background-color: #c5f9e6 !important;
}
</style>

159
vue/src/views/operator/status.vue

@ -0,0 +1,159 @@ @@ -0,0 +1,159 @@
<template>
<div id="buffer">
<div id="main">
<el-tabs v-model="type">
<el-tab-pane v-for="item in typeList" :label="item.name + '状态管理'" :name="item.type">
<el-table :data="result.rows" :height="$store.state.sizes.pTableHei - 20" border style="width: 100%" stripe>
<el-table-column v-for="cl in item.columns" :prop="cl.code" :label="cl.name" min-width="150"></el-table-column>
<el-table-column prop="status" label="状态" min-width="100" :formatter="getValue"></el-table-column>
<el-table-column label="操作" :width="450" fixed="right">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="edit(scope.row)">修改</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="example.page"
:page-sizes="[10, 20, 50, 100]" :page-size="example.size" layout="total, sizes, prev, pager, next, jumper"
:total="result.total">
</el-pagination>
</el-tab-pane>
</el-tabs>
</div>
<el-dialog title="修改状态" :visible.sync="showEdit" :close-on-click-modal="false" top="15vh" width="30%" @keydown.enter.native="confirm()">
<el-form class="full-item-form" label-width="100px" :model="param">
<el-form-item label="状态">
<el-select v-model="param.status" placeholder="请选择">
<el-option v-for="(val, key, i) in status" :key="key" :value="key" :label="val"></el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="showEdit = false"> Esc</el-button>
<el-button type="primary" @click="confirm"> Enter</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
Component,
Prop,
Vue,
Watch
} from 'vue-property-decorator'
@Component
export default class Buffer extends Vue {
example = {
page: 1,
size: 10
};
param = {};
result = [];
type = 'role';
typeList = [{
type: 'role',
name: '角色',
columns: [{
code: 'code',
name: '角色编号'
},
{
code: 'name',
name: '角色名称'
}
]
}, {
type: 'user',
name: '用户',
columns: [{
code: 'userId',
name: '用户名'
},
{
code: 'name',
name: '用户姓名'
}
]
}];
status = {};
showEdit = false;
handleSizeChange(val) {
this.example.size = val;
this.query();
}
handleCurrentChange(val) {
this.example.page = val;
this.query();
}
query(page) {
if (page != null) {
this.example.page = page;
}
const that = this;
this.$get('admin/' + this.type + '/list/all', this.example).then(function(response) {
if (response) {
that.result = response;
} else {
that.result = [];
}
});
}
edit(row) {
this.status = this.$store.state.dict[this.type + '_status'];
this.param = JSON.parse(JSON.stringify(row));
this.showEdit = true;
}
confirm() {
const that = this;
this.$post('admin/' + this.type + '/update', this.param).then(function(response) {
if (response) {
that.query();
that.showEdit = false;
}
});
}
getValue(row, column, value, index) {
const dict = this.$store.state.dict[this.type + '_status'];
if (dict == null) {
return value;
}
const val = dict[value];
return val == null ? value : val;
}
@Watch('type', {
immediate: true
})
typeChange(nVal, oVal) {
this.query(1);
}
created() {
const arr = new Array();
for (var i = 0; i < this.typeList.length; i++) {
arr.push(this.typeList[i].type + '_status');
}
this.$store.commit('getDictMap', arr)
this.query();
}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style>
#main {
padding: 10px 100px;
}
</style>

101
vue/src/views/sys/log.vue

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
<template>
<div id="log">
<Template ref="template" name="日志" :urls="urls" :terms="terms" :props="props"></Template>
</div>
</template>
<script>
import {
Vue,
Component,
Prop
} from "vue-property-decorator";
import Template from '@/components/template/manage.vue';
@Component({
components: {
Template
}
})
export default class Log extends Vue {
urls = {
list: 'admin/log/action'
}
terms = [{
code: 'userId',
desc: '操作用户'
}, {
code: 'module',
dict: 'log_module',
desc: '日志模块',
filterable: true
}, {
code: 'type',
dict: 'log_type',
desc: '操作类型',
filterable: true
}, {
code: 'startTime',
datePicker: true,
valueFormat: 'yyyy-MM-dd HH:mm:ss',
type: 'datetime',
desc: '开始时间'
}, {
code: 'endTime',
datePicker: true,
valueFormat: 'yyyy-MM-dd HH:mm:ss',
type: 'datetime',
desc: '结束时间'
}, ];
props = [{
type: 'index',
name: '序号',
width: 80
}, {
code: 'userId',
name: '操作用户',
width: 120
}, {
code: 'module',
name: '日志模块',
dict: 'log_module',
width: 150,
}, {
code: 'type',
name: '操作类型',
dict: 'log_type',
width: 150
}, {
code: 'time',
name: '操作时间',
width: 180
}, {
code: 'loginIp',
name: '登录IP',
width: 180
}, {
code: 'context',
name: '日志信息',
width: 300
}]
created() {
this.$store.commit('getActionPers', 'system_log')
} // - 访this
mounted() {} // - 访DOM
beforeCreate() {
this.$store.commit('getDictMap', ['log_type', 'log_module']);
} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} //keep-alive
}
</script>
<style scoped>
</style>

196
vue/src/views/sys/role.vue

@ -0,0 +1,196 @@ @@ -0,0 +1,196 @@
<template>
<div id="role">
<Template ref="template" name="角色" :urls="urls" :props="props" :rules="rules" :actions="actions" @per="per"
stateProp="status" @change="$store.commit('updateState', {prop:'roles',value:null})"></Template>
<el-dialog title="分配权限" :visible.sync="flag.per" :close-on-click-modal="false" @keydown.enter.native="setPre()">
<el-tree ref="tree" check-strictly :data="perTree" show-checkbox node-key="id" :default-checked-keys="param.permissions"
:props="{ children: 'children',label: 'name'}" render-after-expand @check-change="checkChange" />
<div slot="footer" class="dialog-footer">
<el-button @click="flag.per = false"> </el-button>
<el-button type="primary" @click="setPre()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
Vue,
Component,
Prop,
Watch
} from 'vue-property-decorator';
import Template from '@/components/template/manage.vue';
@Component({
components: {
Template
}
})
export default class Role extends Vue {
urls = {
tree: 'public/per/list',
list: 'admin/role/list',
save: 'admin/role/save',
update: 'admin/role/update',
del: 'admin/role/delete'
};
rules = {
code: [{
required: true,
message: '请输入角色编码',
trigger: 'blur'
},
{
min: 5,
max: 45,
message: '角色编码长度为5-45个字符',
trigger: 'blur'
}
],
name: [{
required: true,
message: '请输入角色名称',
trigger: 'blur'
},
{
min: 2,
max: 15,
message: '角色名称长度为2-15个字符',
trigger: 'blur'
}
],
desc: [{
required: true,
message: '请输入备注',
trigger: 'blur'
},
{
max: 100,
message: '备注最多可包含100个字符',
trigger: 'blur'
}
]
};
props = [
{
code: 'code',
name: '角色编码',
readOnly: true,
width: 120
}, {
code: 'name',
name: '角色名称',
width: 120
}, {
code: 'desc',
name: '备注',
width: 180
}, {
code: 'status',
name: '角色状态',
dict: 'role_status',
width: 100,
hide: true
},
]
actions = [{
type: 'success',
name: '分配权限',
width: 170,
emit: 'per',
url: this.urls.update
}];
param = {};
perTree = [];
flag = {
per: false
};
queryPerTree() {
const that = this
this.$get(this.urls.tree).then(function(response) {
if (response) {
that.perTree = response
} else {
that.perTree = []
}
})
}
per(row) {
this.param = JSON.parse(JSON.stringify(row))
this.param.flag = true
this.flag.per = true
if (this.$refs.tree != null) {
this.$refs.tree.setCheckedNodes(row.permissions)
}
}
setPre() {
const that = this
const param = JSON.parse(JSON.stringify(that.param))
param.permissions = that.$refs.tree.getCheckedKeys()
this.$post(this.urls.update, param).then(function(response) {
if (response) {
that.$refs.template.query(1);
that.flag.per = false
}
})
}
checkChange(data, checked) {
const child = this.$refs.tree.getNode(data).childNodes
if (child != null && child.length > 0) {
for (let i = 0; i < child.length; i++) {
child[i].checked = checked
this.checkChange(data.children[i], checked)
}
}
}
created() {
this.queryPerTree()
this.$store.commit('getActionPers', 'role')
}
mounted() {} // - 访DOM
beforeCreate() {
this.$store.commit('getDictMap', ['role_status'])
} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style>
#role {
padding: 20px 20px 0px 20px;
}
.module-row {
background-color: #ecf5ff !important;
}
.group-row {
background-color: #f0f9eb !important;
}
.view-row {
background-color: oldlace !important;
}
.action-row {
background-color: #c5f9e6 !important;
}
</style>

189
vue/src/views/sys/user.vue

@ -0,0 +1,189 @@ @@ -0,0 +1,189 @@
<template>
<div id="user">
<Template ref="template" name="用户" :urls="urls" :terms="terms" :props="props" :rules="rules" :actions="actions"
@reset="reset" stateProp="status"></Template>
</div>
</template>
<script>
import {
Vue,
Component,
Prop,
Watch
} from 'vue-property-decorator';
import md5 from 'js-md5';
import {
userName,
password,
name,
idCard,
phone,
email
} from '@/static/tool/validate.js';
import Template from '@/components/template/manage.vue';
@Component({
components: {
Template
}
})
export default class User extends Vue {
urls = {
list: 'admin/user/list',
save: 'admin/user/save',
update: 'admin/user/update',
reset: 'admin/user/reset',
del: 'admin/user/delete'
};
rules = {
userId: [{
required: true,
message: '请输入用户名',
trigger: 'blur'
},
{
validator: userName,
trigger: 'blur'
}
],
key: [{
required: true,
message: '请输入密码',
trigger: 'blur'
},
{
validator: password,
trigger: 'blur'
}
],
roles: [{
required: true,
message: '请选择用户角色',
trigger: 'blur'
}],
name: [{
required: true,
message: '请输入用户姓名',
trigger: 'blur'
},
{
validator: name,
trigger: 'blur'
}
],
idCard: [{
validator: idCard,
trigger: 'blur'
}],
phone: [{
required: true,
message: '请输入电话号码',
trigger: 'blur'
},
{
validator: phone,
trigger: 'blur'
}
],
email: [{
validator: email,
trigger: 'blur'
},
{
min: 5,
max: 32,
message: '邮箱长度为5-32位',
trigger: 'blur'
}
]
};
terms = [{
code: 'userId',
desc: '用户名'
}, {
code: 'name',
desc: '姓名'
}, ];
props = [{
code: 'userId',
name: '用户名',
readOnly: true,
width: 120
}, {
code: 'key',
name: '密码',
tableHide: true,
modifyHide: true
}, {
code: 'roles',
name: '用户角色',
tableHide: true,
state: 'roles',
multiple: true
}, {
code: 'name',
name: '姓名',
width: 100
}, {
code: 'phone',
name: '手机号码',
width: 130
}, {
code: 'idCard',
name: '身份证号码',
width: 180
}, {
code: 'email',
name: '邮箱',
width: 180
}]
actions = [{
type: 'warning',
name: '重置密码',
width: 170,
emit: 'reset',
url: this.urls.reset
}];
reset(row) {
const that = this
this.$confirm('确定要重置用户‘' + row.userId + '’的密码吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
that.$post(that.urls.reset, row).then(function(response) {
if (response) {
that.queryList()
}
})
}).catch(() => {
showMessage('info', '已取消重置密码')
})
}
created() {
this.$store.commit('getActionPers', 'user')
this.$store.commit('queryRoleMap')
}
mounted() {} // - 访DOM
beforeCreate() {} // -
beforeMount() {} // -
beforeUpdate() {} // -
updated() {} // -
beforeDestroy() {} // -
destroyed() {} // -
activated() {} // keep-alive
}
</script>
<style>
#user {
padding: 20px 20px 0px 20px;
}
</style>

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

Loading…
Cancel
Save