├── .gitignore ├── README.md ├── common ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── weisi │ └── common │ ├── JsonResult.java │ └── ZtreeView.java ├── pom.xml ├── veems.iml └── web ├── pom.xml └── src └── main ├── java └── com │ └── weisi │ └── veems │ ├── Application.java │ ├── controller │ ├── login │ │ └── LoginController.java │ ├── mpcv │ │ └── MpCvController.java │ ├── permission │ │ └── PermissionController.java │ ├── role │ │ └── RoleController.java │ ├── test │ │ └── TestController.java │ └── user │ │ └── UserController.java │ ├── frame │ ├── constants │ │ ├── PageConstants.java │ │ ├── SysPermissionConstants.java │ │ └── UserPasswordConstants.java │ ├── druid │ │ ├── configuration │ │ │ └── DruidConfiguration.java │ │ ├── filter │ │ │ └── DruidWebStatFilter.java │ │ └── servlet │ │ │ └── DruidStatViewServlet.java │ ├── init │ │ ├── FreeMarkerConfig.java │ │ └── TkMapper.java │ └── shiro │ │ ├── ShiroConfig.java │ │ ├── ShiroManager.java │ │ └── ShiroRealm.java │ ├── mapper │ └── sys │ │ ├── SysMapRolePermissionMapper.java │ │ ├── SysMapUserRoleMapper.java │ │ ├── SysPermissionMapper.java │ │ ├── SysRoleMapper.java │ │ └── SysUserMapper.java │ ├── models │ ├── elasticsearch │ │ └── Mpcv.java │ └── sys │ │ ├── SysMapRolePermission.java │ │ ├── SysMapUserRole.java │ │ ├── SysPermission.java │ │ ├── SysRole.java │ │ └── SysUser.java │ ├── repository │ └── ElasticSearchRepository.java │ └── services │ ├── base │ ├── BaseService.java │ └── impl │ │ └── BaseServiceImpl.java │ ├── mpcv │ ├── MpCvService.java │ └── impl │ │ └── MpCvServiceImpl.java │ ├── permission │ ├── SysPermissonService.java │ └── impl │ │ └── SysPermissionImpl.java │ ├── role │ ├── SysRoleService.java │ └── impl │ │ └── SysRoleServiceImpl.java │ └── user │ ├── SysUserService.java │ └── impl │ └── SysUserServiceImpl.java └── resources ├── application.properties ├── biaozhunhua_init.sql ├── druid-bean.xml ├── ehcache-shiro.xml ├── logback-spring.xml ├── mybatis ├── mapper │ ├── SysMapRolePermissionMapper.xml │ ├── SysMapUserRoleMapper.xml │ ├── SysPermissionMapper.xml │ ├── SysRoleMapper.xml │ └── SysUserMapper.xml └── mybatis-config.xml ├── static └── assets │ ├── img │ ├── permission │ │ └── unauthorized.png │ ├── screenshot │ │ ├── home.png │ │ ├── permission.png │ │ ├── role.png │ │ └── user.png │ └── user │ │ └── avatar.png │ └── js │ ├── test │ ├── bootstrap.js │ └── myChart.js │ └── user │ └── test.js └── web └── bzh ├── index.ftl ├── layout ├── layout.ftl └── macro.ftl ├── login.ftl ├── permission ├── form.ftl ├── index.ftl └── unauthorized.ftl ├── role ├── form.ftl ├── grant.ftl └── index.ftl ├── test ├── bootstrap.ftl └── myChart.ftl └── user ├── form.ftl ├── grant.ftl ├── index.ftl └── updatePwd.ftl /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | .idea 3 | */*.iml 4 | .idea/ 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpringBoot-veems 2 | ##### 技术选型 3 | ###### 后台选型 4 | * SpringBoot 1.5.9.RELEASE 5 | * mybatis 1.3.2 6 | * 通用Mapper 2.0.1 7 | * Shiro 8 | * logback 9 | * druid 10 | 11 | ###### 前台选型 12 | * AdminLTE 13 | * Freemarker 14 | * Bootstrap 15 | * Echarts 16 | * Jquery 17 | 18 | 19 | ##### 结构 20 | * common中包含帮助类 21 | * web中包含基本模块(权限、角色、用户) 22 | * resources\static\assets\ 静态资源 23 | * resources\static\webjars\ 通过http://www.webjars.org/添加maven jar的外部资源 24 | * resources\static\assets\plugins 外部引用js、css 25 | * resources\static\assets\js 项目中模块定制的js,按照功能模块划分 26 | * resources\static\assets\css 项目中模块定制的css,按照功能模块划分 27 | * resources\web\bzh 项目中模块ftl,按照功能模块划分 28 | 29 | 30 | ##### 测试地址 31 | * 初始化sql:biaozhunhua_init.sql 32 | * Bootstrap:http://localhost:8080/test/bootstrap 33 | * echarts:http://localhost:8080/test/echarts 34 | * Druid:http://localhost:8080/druid/ 用户名:admin 密码:admin 35 | * shiro 账号登录测试:http://localhost:8080/login 账号lisi 密码111111 36 | * 完成模块:用户管理、角色管理、权限管理 37 | * 演示图片: 38 | ![输入图片说明](https://github.com/luomouren/veems/blob/master/web/src/main/resources/static/assets/img/screenshot/login.png "登录") 39 | ![输入图片说明](https://github.com/luomouren/veems/blob/master/web/src/main/resources/static/assets/img/screenshot/home.png "主页") 40 | ![输入图片说明](https://github.com/luomouren/veems/blob/master/web/src/main/resources/static/assets/img/screenshot/user.png "用户") 41 | ![输入图片说明](https://github.com/luomouren/veems/blob/master/web/src/main/resources/static/assets/img/screenshot/role.png "角色") 42 | ![输入图片说明](https://github.com/luomouren/veems/blob/master/web/src/main/resources/static/assets/img/screenshot/permission.png "权限") -------------------------------------------------------------------------------- /common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | veems 7 | org.weisi 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | common 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /common/src/main/java/com/weisi/common/JsonResult.java: -------------------------------------------------------------------------------- 1 | package com.weisi.common; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Json 统一返回消息类 7 | * 8 | * @author SPPan 9 | */ 10 | public class JsonResult implements Serializable { 11 | private static final long serialVersionUID = -1491499610244557029L; 12 | public static int CODE_SUCCESS = 0; 13 | public static int CODE_FAILURED = -1; 14 | public static String[] NOOP = new String[]{}; 15 | 16 | private int code; // 处理状态:0: 成功 17 | private String message; 18 | private Object data; // 返回数据 19 | 20 | private JsonResult(int code, String message, Object data) { 21 | this.code = code; 22 | this.message = message; 23 | this.data = data; 24 | } 25 | 26 | /** 27 | * 处理成功,并返回数据 28 | * 29 | * @param data 数据对象 30 | * @return data 31 | */ 32 | public static final JsonResult success(Object data) { 33 | return new JsonResult(CODE_SUCCESS, "操作成功", data); 34 | } 35 | 36 | /** 37 | * 处理成功 38 | * 39 | * @return data 40 | */ 41 | public static final JsonResult success() { 42 | return new JsonResult(CODE_SUCCESS, "操作成功", NOOP); 43 | } 44 | 45 | /** 46 | * 处理成功 47 | * 48 | * @param message 消息 49 | * @return data 50 | */ 51 | public static final JsonResult success(String message) { 52 | return new JsonResult(CODE_SUCCESS, message, NOOP); 53 | } 54 | 55 | /** 56 | * 处理成功 57 | * 58 | * @param message 消息 59 | * @param data 数据对象 60 | * @return data 61 | */ 62 | public static final JsonResult success(String message, Object data) { 63 | return new JsonResult(CODE_SUCCESS, message, data); 64 | } 65 | 66 | /** 67 | * 处理失败,并返回数据(一般为错误信息) 68 | * 69 | * @param code 错误代码 70 | * @param message 消息 71 | * @return data 72 | */ 73 | public static final JsonResult failure(int code, String message) { 74 | return new JsonResult(code, message, NOOP); 75 | } 76 | 77 | /** 78 | * 处理失败 79 | * 80 | * @param message 消息 81 | * @return data 82 | */ 83 | public static final JsonResult failure(String message) { 84 | return failure(CODE_FAILURED, message); 85 | } 86 | 87 | public int getCode() { 88 | return code; 89 | } 90 | 91 | public void setCode(int code) { 92 | this.code = code; 93 | } 94 | 95 | public String getMessage() { 96 | return message; 97 | } 98 | 99 | public void setMessage(String message) { 100 | this.message = message; 101 | } 102 | 103 | public Object getData() { 104 | return data; 105 | } 106 | 107 | public void setData(Object data) { 108 | this.data = data; 109 | } 110 | 111 | @Override 112 | public String toString() { 113 | return "JsonResult [code=" + code + ", message=" + message + ", data=" 114 | + data + "]"; 115 | } 116 | 117 | 118 | } 119 | -------------------------------------------------------------------------------- /common/src/main/java/com/weisi/common/ZtreeView.java: -------------------------------------------------------------------------------- 1 | package com.weisi.common; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * ztree树 9 | * 10 | * @author luomouren 11 | */ 12 | @Data 13 | public class ZtreeView implements Serializable { 14 | private static final long serialVersionUID = 6237809780035784312L; 15 | 16 | private String id; 17 | 18 | private String pId; 19 | 20 | private String name; 21 | 22 | private boolean open; 23 | 24 | private boolean checked = false; 25 | 26 | public ZtreeView() { 27 | } 28 | 29 | public ZtreeView(String id, String pId, String name, boolean open) { 30 | super(); 31 | this.id = id; 32 | this.pId = pId; 33 | this.name = name; 34 | this.open = open; 35 | } 36 | 37 | 38 | public ZtreeView(String id, String pId, String name, boolean open, boolean checked) { 39 | this.id = id; 40 | this.pId = pId; 41 | this.name = name; 42 | this.open = open; 43 | this.checked = checked; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.weisi 8 | veems 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | common 13 | web 14 | 15 | 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-starter-parent 21 | 1.5.9.RELEASE 22 | 23 | 24 | 25 | UTF-8 26 | UTF-8 27 | 1.8 28 | 1.3.2 29 | 1.2.27 30 | 4.0.1 31 | 1.2.4 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-web 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-data-jpa 51 | 52 | 53 | 54 | 55 | junit 56 | junit 57 | 4.12 58 | 59 | 60 | 61 | 62 | com.alibaba 63 | fastjson 64 | ${fastjson} 65 | 66 | 67 | 68 | 69 | mysql 70 | mysql-connector-java 71 | 72 | 73 | 74 | 75 | org.mybatis.spring.boot 76 | mybatis-spring-boot-starter 77 | ${mybatis-spring-boot} 78 | 79 | 80 | 81 | 82 | com.github.pagehelper 83 | pagehelper-spring-boot-starter 84 | ${pagehelper} 85 | 86 | 87 | 88 | 89 | tk.mybatis 90 | mapper-spring-boot-starter 91 | 2.0.1 92 | 93 | 94 | 95 | 96 | org.springframework.boot 97 | spring-boot-devtools 98 | 99 | 100 | 101 | 102 | org.springframework.boot 103 | spring-boot-starter-freemarker 104 | 105 | 106 | 107 | 108 | org.projectlombok 109 | lombok 110 | 1.16.20 111 | provided 112 | 113 | 114 | 115 | com.alibaba 116 | druid-spring-boot-starter 117 | 1.1.9 118 | 119 | 120 | org.springframework.boot 121 | spring-boot-starter-data-elasticsearch 122 | 123 | 124 | 125 | io.searchbox 126 | jest 127 | 128 | 129 | net.java.dev.jna 130 | jna 131 | 132 | 133 | -------------------------------------------------------------------------------- /veems.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | veems 7 | org.weisi 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | web 13 | 14 | 15 | UTF-8 16 | UTF-8 17 | 1.8 18 | 1.0-SNAPSHOT 19 | 1.4.0 20 | 0.33 21 | 3.3.7 22 | 3.3.1-1 23 | 4.0.4 24 | 2.4.0 25 | 4.7.0 26 | 4.0.0-9 27 | 1.0.2 28 | 3.1.1 29 | 1.0.6 30 | 1.3.8 31 | 32 | 33 | 34 | 35 | 36 | org.weisi 37 | common 38 | 1.0-SNAPSHOT 39 | 40 | 41 | 42 | 43 | org.apache.shiro 44 | shiro-ehcache 45 | ${shiro.version} 46 | 47 | 48 | org.apache.shiro 49 | shiro-spring 50 | ${shiro.version} 51 | 52 | 53 | org.apache.shiro 54 | shiro-core 55 | ${shiro.version} 56 | 57 | 58 | 59 | 60 | net.mingsoft 61 | shiro-freemarker-tags 62 | 0.1 63 | 64 | 65 | 66 | 67 | 68 | org.webjars 69 | webjars-locator 70 | ${webjars-locator} 71 | 72 | 73 | 74 | 75 | org.webjars 76 | jquery 77 | ${jquery} 78 | 79 | 80 | 81 | 82 | org.webjars.bower 83 | bootstrap 84 | ${bootstrap} 85 | 86 | 87 | 88 | 89 | org.webjars.bower 90 | echarts 91 | ${echarts} 92 | 93 | 94 | 95 | org.webjars 96 | AdminLTE 97 | ${adminlte} 98 | 99 | 100 | 101 | 102 | org.webjars.bower 103 | font-awesome 104 | ${font-awesome} 105 | 106 | 107 | 108 | 109 | org.webjars.npm 110 | ionicons 111 | ${ionicons} 112 | 113 | 114 | 115 | 116 | org.webjars.bower 117 | iCheck 118 | ${iCheck} 119 | 120 | 121 | 122 | 123 | org.webjars 124 | jQuery-slimScroll 125 | ${jQuery-slimScroll} 126 | 127 | 128 | 129 | 130 | org.webjars.bower 131 | fastclick 132 | ${fastclick} 133 | 134 | 135 | 136 | org.webjars.bower 137 | layer 138 | ${layer} 139 | 140 | 141 | 142 | 143 | org.webjars.bower 144 | bootstrapValidator 145 | 0.5.2 146 | 147 | 148 | 149 | 150 | org.webjars 151 | zTree 152 | 3.5.28 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/Application.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.ServletComponentScan; 6 | import org.springframework.context.annotation.ImportResource; 7 | import tk.mybatis.spring.annotation.MapperScan; 8 | 9 | /** 10 | * 按照官方的建议放在root目录下,这样才能扫描到Service和dao,不然还会引起,扫描不到注解的问题 11 | * @author luomouren 12 | */ 13 | 14 | @ServletComponentScan 15 | @SpringBootApplication 16 | // mapper.java扫描 17 | @MapperScan("com.weisi.veems.mapper") 18 | @ImportResource(locations = { "classpath:druid-bean.xml" }) 19 | public class Application { 20 | public static void main(String[] args) { 21 | SpringApplication.run(Application.class, args); 22 | } 23 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/controller/login/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.controller.login; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.authc.AuthenticationException; 5 | import org.apache.shiro.authc.UsernamePasswordToken; 6 | import org.apache.shiro.subject.Subject; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.ui.ModelMap; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | 16 | /** 17 | * @author:luomouren 18 | * @description:用户登录 19 | * @dateTime: created in 2018-04-10 16:38 20 | * @modified by: 21 | **/ 22 | @Controller 23 | public class LoginController{ 24 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 25 | 26 | @RequestMapping(value = {"/login"}, method = RequestMethod.GET) 27 | public String login() { 28 | return "bzh/login"; 29 | } 30 | 31 | @RequestMapping("/index") 32 | public String list(Model model) { 33 | return "bzh/index"; 34 | } 35 | 36 | @RequestMapping(value = "/login", method = RequestMethod.POST) 37 | public String login( 38 | @RequestParam(value = "username", required = true) String username, 39 | @RequestParam(value = "password", required = true) String password,ModelMap model) { 40 | Subject subject = SecurityUtils.getSubject(); 41 | UsernamePasswordToken token = new UsernamePasswordToken(username, password); 42 | try { 43 | subject.login(token); 44 | return "redirect:index"; 45 | } catch (AuthenticationException e) { 46 | model.put("message", e.getMessage()); 47 | } 48 | return "bzh/login"; 49 | } 50 | 51 | @RequestMapping(value = {"/logout"}, method = RequestMethod.GET) 52 | public String logout() { 53 | Subject subject = SecurityUtils.getSubject(); 54 | subject.logout(); 55 | // url重定向 56 | return "redirect:bzh/login"; 57 | } 58 | 59 | 60 | 61 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/controller/mpcv/MpCvController.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.controller.mpcv; 2 | import com.github.pagehelper.PageInfo; 3 | import com.weisi.common.JsonResult; 4 | import com.weisi.veems.models.elasticsearch.Mpcv; 5 | import com.weisi.veems.services.mpcv.MpCvService; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.ui.ModelMap; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.util.Date; 13 | import java.util.UUID; 14 | 15 | /** 16 | * @description:历史抄表示数 17 | * @author:@luomouren. 18 | * @Date:2018-04-09 16:53 19 | */ 20 | @RestController 21 | @RequestMapping({"/mpcv"}) 22 | public class MpCvController { 23 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 24 | @Autowired 25 | private MpCvService mpCvService; 26 | private static String PAGE_FILE_NAME = "bzh/mpcv/"; 27 | 28 | @RequestMapping(value = {"/index"}) 29 | public String index(@RequestParam(value = "cvId", required = true) String cvId, 30 | @RequestParam(value = "pageNum", required = true, defaultValue = "1") int pageNum, 31 | @RequestParam(value = "pageSize", required = true, defaultValue = "2") int pageSize, 32 | ModelMap model) { 33 | PageInfo pageInfo = mpCvService.searchMpCv(cvId); 34 | //获得当前页 35 | model.addAttribute("pageNum", pageInfo.getPageNum()); 36 | //获得一页显示的条数 37 | model.addAttribute("pageSize", pageInfo.getPageSize()); 38 | //是否是第一页 39 | model.addAttribute("isFirstPage", pageInfo.isIsFirstPage()); 40 | //获得总页数 41 | model.addAttribute("totalPages", pageInfo.getPages()); 42 | //是否是最后一页 43 | model.addAttribute("isLastPage", pageInfo.isIsLastPage()); 44 | model.addAttribute("users", pageInfo.getList()); 45 | 46 | model.put("pageInfo", pageInfo); 47 | return PAGE_FILE_NAME + "index"; 48 | } 49 | 50 | @RequestMapping(value = "/add", method = RequestMethod.GET) 51 | @ResponseBody 52 | public String add() { 53 | String cvId = "cvId"; 54 | String mpId = "mpId"; 55 | Double value = 12.1230; 56 | Date dataTime = new Date(); 57 | Date samTime = new Date(); 58 | Mpcv mpcv = new Mpcv(UUID.randomUUID() + "", cvId, mpId, value, dataTime, samTime); 59 | mpCvService.save(mpcv); 60 | return PAGE_FILE_NAME+"form"; 61 | } 62 | 63 | @RequestMapping(value = "/edit", method = RequestMethod.GET) 64 | public String edit(@RequestParam(value = "cvId", required = true) String cvId) { 65 | Mpcv mpcv = new Mpcv(); 66 | mpcv.setId("sLPruWIB64xKF3zA_woz"); 67 | mpcv.setCvId(cvId); 68 | mpcv.setDataTime(new Date()); 69 | mpcv.setValue(new Double("123")); 70 | mpCvService.update(mpcv); 71 | return PAGE_FILE_NAME+"form"; 72 | } 73 | 74 | @RequestMapping(value = "/delete", method = RequestMethod.GET) 75 | @ResponseBody 76 | public JsonResult delete(@RequestParam(value = "cvId", required = true) String cvId) { 77 | mpCvService.deleteByPrimaryKey(cvId); 78 | try { 79 | mpCvService.deleteByPrimaryKey(cvId); 80 | } catch (Exception e) { 81 | logger.error(e.toString()); 82 | return JsonResult.failure(e.getMessage()); 83 | } 84 | return JsonResult.success(); 85 | } 86 | 87 | @RequestMapping(value = {"/searchMpCv"}, method = RequestMethod.GET) 88 | public String searchMpCv(@RequestParam(value = "cvId", required = true) String cvId){ 89 | PageInfo pageInfo = mpCvService.searchMpCv(cvId); 90 | return PAGE_FILE_NAME + "index"; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/controller/permission/PermissionController.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.controller.permission; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.weisi.common.JsonResult; 5 | import com.weisi.common.ZtreeView; 6 | import com.weisi.veems.frame.constants.PageConstants; 7 | import com.weisi.veems.models.sys.SysPermission; 8 | import com.weisi.veems.services.permission.SysPermissonService; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.ui.ModelMap; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import java.util.List; 17 | import java.util.UUID; 18 | 19 | /** 20 | * 权限信息 21 | * 22 | * @author luomouren 23 | */ 24 | @Controller 25 | @RequestMapping({"/permission"}) 26 | public class PermissionController { 27 | private static String PAGE_FILE_NAME = "bzh/permission/"; 28 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 29 | 30 | @Autowired 31 | private SysPermissonService permissionService; 32 | 33 | @RequestMapping("/tree/{permissionId}") 34 | @ResponseBody 35 | public List tree(@PathVariable String permissionId) { 36 | List list = permissionService.tree(permissionId); 37 | return list; 38 | } 39 | 40 | @RequestMapping("/index") 41 | public String index(@RequestParam(value = "pageNum", required = true, defaultValue = PageConstants.PAGE_NUM+"") int pageNum, 42 | @RequestParam(value = "pageSize", required = true, defaultValue = PageConstants.PAGE_SIZE+"") int pageSize, 43 | @RequestParam(value = "sortOrder", required = true, defaultValue = " PERMISSION_NAME asc ") String sortOrder, 44 | ModelMap map) { 45 | PageInfo pageInfo = permissionService.findAll(pageNum, pageSize,sortOrder); 46 | // pageInfo.list 保存所有的SysPermission 47 | map.put("pageInfo", pageInfo); 48 | return PAGE_FILE_NAME +"index"; 49 | } 50 | 51 | @RequestMapping(value = "/add", method = RequestMethod.GET) 52 | public String add(ModelMap map) { 53 | SysPermission permission = new SysPermission(); 54 | permission.setIsAvailable(true); 55 | permission.setPermissionType(1); 56 | map.put("permissionInfo", permission); 57 | map.put("isAdd", true); 58 | return PAGE_FILE_NAME +"form"; 59 | } 60 | 61 | 62 | @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) 63 | public String edit(@PathVariable String id, ModelMap map) { 64 | SysPermission permission = permissionService.selectByPrimaryKey(id); 65 | map.put("permissionInfo", permission); 66 | map.put("isAdd", false); 67 | return PAGE_FILE_NAME +"form"; 68 | } 69 | 70 | @RequestMapping(value = {"/edit"}, method = RequestMethod.POST) 71 | @ResponseBody 72 | public JsonResult edit(SysPermission permission, Boolean isAdd, ModelMap map) { 73 | try { 74 | if(isAdd){ 75 | // 新建保存 76 | permission.setPermissionId(UUID.randomUUID()+""); 77 | permissionService.insert(permission); 78 | }else{ 79 | // 编辑保存用户 80 | permissionService.updateByPrimaryKey(permission); 81 | } 82 | } catch (Exception e) { 83 | return JsonResult.failure(e.getMessage()); 84 | } 85 | return JsonResult.success(); 86 | } 87 | 88 | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) 89 | @ResponseBody 90 | public JsonResult delete(@PathVariable String id) { 91 | try { 92 | permissionService.deleteById(id); 93 | } catch (Exception e) { 94 | e.printStackTrace(); 95 | return JsonResult.failure(e.getMessage()); 96 | } 97 | return JsonResult.success(); 98 | } 99 | 100 | /** 101 | * 无权访问页面时 102 | * @return 103 | */ 104 | @RequestMapping("/unauthorized") 105 | public String unauthorized() { 106 | return PAGE_FILE_NAME +"unauthorized"; 107 | } 108 | 109 | } 110 | 111 | 112 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/controller/role/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.controller.role; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.weisi.common.JsonResult; 5 | import com.weisi.veems.frame.constants.PageConstants; 6 | import com.weisi.veems.models.sys.SysRole; 7 | import com.weisi.veems.services.role.SysRoleService; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.ui.ModelMap; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.UUID; 16 | 17 | /** 18 | * 角色信息 19 | * 20 | * @author luomouren 21 | */ 22 | @Controller 23 | @RequestMapping({"/role"}) 24 | public class RoleController { 25 | private static String PAGE_FILE_NAME = "bzh/role/"; 26 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 27 | 28 | @Autowired 29 | private SysRoleService sysRoleService; 30 | 31 | @RequestMapping(value = {"/index"}) 32 | public String index(@RequestParam(value = "pageNum", required = true, defaultValue = PageConstants.PAGE_NUM + "") int pageNum, 33 | @RequestParam(value = "pageSize", required = true, defaultValue = PageConstants.PAGE_SIZE + "") int pageSize, 34 | ModelMap modelMap) { 35 | PageInfo pageInfo = sysRoleService.findAll(pageNum, pageSize); 36 | modelMap.put("pageInfo", pageInfo); 37 | return PAGE_FILE_NAME + "index"; 38 | } 39 | 40 | @RequestMapping(value = "/add", method = RequestMethod.GET) 41 | public String add(ModelMap map) { 42 | SysRole role = new SysRole(); 43 | role.setIsAvailable(true); 44 | map.put("role", role); 45 | map.put("isAdd", true); 46 | return PAGE_FILE_NAME + "form"; 47 | } 48 | 49 | 50 | @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) 51 | public String edit(@PathVariable String id, ModelMap map) { 52 | SysRole role = sysRoleService.selectByPrimaryKey(id); 53 | map.put("role", role); 54 | map.put("isAdd", false); 55 | return PAGE_FILE_NAME + "form"; 56 | } 57 | 58 | 59 | @RequestMapping(value = {"/edit"}, method = RequestMethod.POST) 60 | @ResponseBody 61 | public JsonResult edit(SysRole role,Boolean isAdd, ModelMap map) { 62 | try { 63 | if(isAdd){ 64 | // 新增角色 65 | role.setRoleId(UUID.randomUUID()+""); 66 | sysRoleService.insert(role); 67 | }else{ 68 | // 编辑保存角色 69 | sysRoleService.updateByPrimaryKey(role); 70 | } 71 | } catch (Exception e) { 72 | return JsonResult.failure(e.getMessage()); 73 | } 74 | return JsonResult.success(); 75 | } 76 | 77 | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) 78 | @ResponseBody 79 | public JsonResult delete(@PathVariable String id, ModelMap map) { 80 | try { 81 | sysRoleService.deleteById(id); 82 | } catch (Exception e) { 83 | e.printStackTrace(); 84 | return JsonResult.failure(e.getMessage()); 85 | } 86 | return JsonResult.success(); 87 | } 88 | 89 | @RequestMapping(value = "/grant/{id}", method = RequestMethod.GET) 90 | public String grant(@PathVariable String id, ModelMap map) { 91 | SysRole role = sysRoleService.selectByPrimaryKey(id); 92 | map.put("role", role); 93 | return PAGE_FILE_NAME + "grant"; 94 | } 95 | 96 | @RequestMapping(value = "/grant/{id}", method = RequestMethod.POST) 97 | @ResponseBody 98 | public JsonResult grant(@PathVariable String id, 99 | @RequestParam(required = false) String[] permissionIds, ModelMap map) { 100 | try { 101 | sysRoleService.grant(id, permissionIds); 102 | } catch (Exception e) { 103 | e.printStackTrace(); 104 | return JsonResult.failure(e.getMessage()); 105 | } 106 | return JsonResult.success(); 107 | } 108 | 109 | } 110 | 111 | 112 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/controller/test/TestController.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.controller.test; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.ModelMap; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | /** 10 | * @description: 11 | * @author:@luomouren. 12 | * @Date:2017-12-31 18:43 13 | */ 14 | @Controller 15 | @RequestMapping("/test") 16 | public class TestController { 17 | private static String PAGE_FILE_NAME = "bzh/test/"; 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | 21 | @RequestMapping(value = "/bootstrap") 22 | public String bootstrap(ModelMap map) { 23 | map.put("host","xxxSpringBootDemo bootstrap"); 24 | return PAGE_FILE_NAME+"bootstrap"; 25 | } 26 | 27 | @RequestMapping(value = "/echarts") 28 | public String testEcharts(ModelMap map) { 29 | return PAGE_FILE_NAME+"myChart"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/controller/user/UserController.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.controller.user; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.weisi.common.JsonResult; 5 | import com.weisi.veems.frame.constants.PageConstants; 6 | import com.weisi.veems.models.sys.SysRole; 7 | import com.weisi.veems.models.sys.SysUser; 8 | import com.weisi.veems.services.role.SysRoleService; 9 | import com.weisi.veems.services.user.SysUserService; 10 | import org.apache.shiro.SecurityUtils; 11 | import org.apache.shiro.subject.Subject; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.ui.ModelMap; 17 | import org.springframework.web.bind.annotation.*; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | import java.util.Set; 22 | 23 | /** 24 | * 用户信息 25 | * 26 | * @author luomouren 27 | * @date 2017/6/4 28 | */ 29 | @Controller 30 | @RequestMapping({"/user"}) 31 | public class UserController { 32 | private static String PAGE_FILE_NAME = "bzh/user/"; 33 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 34 | @Autowired 35 | private SysUserService sysUserServices; 36 | @Autowired 37 | private SysRoleService sysRoleService; 38 | 39 | 40 | @RequestMapping(value = {"/index"}) 41 | public String index(@RequestParam(value = "pageNum", required = true, defaultValue = PageConstants.PAGE_NUM+"") int pageNum, 42 | @RequestParam(value = "pageSize", required = true, defaultValue = PageConstants.PAGE_SIZE+"") int pageSize, 43 | ModelMap model) { 44 | PageInfo pageInfo = sysUserServices.findAll(pageNum, pageSize); 45 | // pageInfo.list 保存所有的sysUser 46 | model.put("pageInfo", pageInfo); 47 | return PAGE_FILE_NAME + "index"; 48 | } 49 | 50 | @RequestMapping(value = "/add", method = RequestMethod.GET) 51 | public String add(ModelMap map) { 52 | SysUser user = new SysUser(); 53 | user.setUserCategory(1); 54 | user.setIsLocked(false); 55 | map.put("user", user); 56 | map.put("isAdd", true); 57 | return PAGE_FILE_NAME+"form"; 58 | } 59 | 60 | @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) 61 | public String edit(@PathVariable String id, ModelMap map) { 62 | SysUser user = sysUserServices.selectByPrimaryKey(id); 63 | map.put("user", user); 64 | map.put("isAdd", false); 65 | return PAGE_FILE_NAME+"form"; 66 | } 67 | 68 | @RequestMapping(value = {"/edit"}, method = RequestMethod.POST) 69 | @ResponseBody 70 | public JsonResult edit(SysUser user, Boolean isAdd,ModelMap map) { 71 | try { 72 | if(isAdd){ 73 | // 新建保存 74 | sysUserServices.save(user); 75 | }else{ 76 | // 编辑保存用户 77 | sysUserServices.updateByPrimaryKey(user); 78 | } 79 | } catch (Exception e) { 80 | logger.error(e.toString()); 81 | return JsonResult.failure(e.getMessage()); 82 | } 83 | return JsonResult.success(); 84 | } 85 | 86 | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) 87 | @ResponseBody 88 | public JsonResult delete(@PathVariable String id, ModelMap map) { 89 | try { 90 | sysUserServices.deleteById(id); 91 | } catch (Exception e) { 92 | logger.error(e.toString()); 93 | return JsonResult.failure(e.getMessage()); 94 | } 95 | return JsonResult.success(); 96 | } 97 | 98 | 99 | @RequestMapping(value = "/grant/{id}", method = RequestMethod.GET) 100 | public String grant(@PathVariable String id, ModelMap map) { 101 | SysUser user = sysUserServices.selectByPrimaryKey(id); 102 | map.put("user", user); 103 | List roleIds = sysUserServices.findRoleIdsByUserId(id); 104 | map.put("roleIds", roleIds); 105 | List roles = sysRoleService.selectAll(); 106 | map.put("roles", roles); 107 | return PAGE_FILE_NAME+"grant"; 108 | } 109 | 110 | @ResponseBody 111 | @RequestMapping(value = "/grant/{id}", method = RequestMethod.POST) 112 | public JsonResult grant(@PathVariable String id, String[] roleIds) { 113 | try { 114 | sysUserServices.grant(id, roleIds); 115 | } catch (Exception e) { 116 | e.printStackTrace(); 117 | return JsonResult.failure(e.getMessage()); 118 | } 119 | return JsonResult.success(); 120 | } 121 | 122 | @RequestMapping(value = "/updatePwd", method = RequestMethod.GET) 123 | public String updatePwd() { 124 | return PAGE_FILE_NAME+"updatePwd"; 125 | } 126 | 127 | 128 | @RequestMapping(value = "/updatePwd", method = RequestMethod.POST) 129 | @ResponseBody 130 | public JsonResult updatePwd(String oldPassword, String password1, String password2) { 131 | try { 132 | Subject subject = SecurityUtils.getSubject(); 133 | Object principal = subject.getPrincipal(); 134 | if (principal == null) { 135 | return JsonResult.failure("您尚未登录"); 136 | } 137 | sysUserServices.updatePwd((SysUser) principal, oldPassword, password1, password2); 138 | } catch (Exception e) { 139 | e.printStackTrace(); 140 | return JsonResult.failure(e.getMessage()); 141 | } 142 | return JsonResult.success(); 143 | } 144 | 145 | } 146 | 147 | 148 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/constants/PageConstants.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.constants; 2 | 3 | /** 4 | * @author:luomouren 5 | * @description:与分页相关的Constants 6 | * @dateTime: created in 2018-04-13 10:48 7 | * @modified by: 8 | **/ 9 | public class PageConstants { 10 | /** 11 | * 当前页码,默认从1开始 12 | */ 13 | public static final int PAGE_NUM = 1; 14 | /** 15 | * 一页显示多少条数据,默认显示10条 16 | */ 17 | public static final int PAGE_SIZE = 10; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/constants/SysPermissionConstants.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.constants; 2 | 3 | /** 4 | * @author:luomouren 5 | * @description:与权限相关的Constants 6 | * @dateTime: created in 2018-04-14 14:53 7 | * @modified by: 8 | **/ 9 | public class SysPermissionConstants { 10 | /** 11 | * 一级导航权限 12 | */ 13 | public static final int FIST_MENU = 1; 14 | /** 15 | * 二级导航权限 16 | */ 17 | public static final int SECOND_MENU = 2; 18 | /** 19 | * 按钮操作权限 20 | */ 21 | public static final int OPERATE_MENU = 3; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/constants/UserPasswordConstants.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.constants; 2 | 3 | /** 4 | * @author:luomouren 5 | * @description:用户密码相关的Constants 6 | * @dateTime: created in 2018-04-12 18:50 7 | * @modified by: 8 | **/ 9 | public class UserPasswordConstants { 10 | /** 11 | * 加密次数 12 | */ 13 | public static final int HASHITERATIONS = 1; 14 | /** 15 | * 加密方式 16 | */ 17 | public static final String HASHALGORITHM_NAME = "md5"; 18 | } 19 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/druid/configuration/DruidConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.druid.configuration; 2 | 3 | import com.alibaba.druid.pool.DruidDataSource; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.boot.jdbc.DatabaseDriver; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Configuration 13 | public class DruidConfiguration { 14 | 15 | @ConditionalOnClass(DruidDataSource.class) 16 | @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.alibaba.druid.pool.DruidDataSource", matchIfMissing = true) 17 | static class Druid extends DruidConfiguration { 18 | @Bean 19 | @ConfigurationProperties("spring.datasource.druid") 20 | public DruidDataSource dataSource(DataSourceProperties properties) { 21 | DruidDataSource druidDataSource = (DruidDataSource) properties.initializeDataSourceBuilder().type(DruidDataSource.class).build(); 22 | DatabaseDriver databaseDriver = DatabaseDriver.fromJdbcUrl(properties.determineUrl()); 23 | String validationQuery = databaseDriver.getValidationQuery(); 24 | if (validationQuery != null) { 25 | druidDataSource.setValidationQuery(validationQuery); 26 | } 27 | return druidDataSource; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/druid/filter/DruidWebStatFilter.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.druid.filter; 2 | 3 | import com.alibaba.druid.support.http.WebStatFilter; 4 | 5 | import javax.servlet.annotation.WebFilter; 6 | import javax.servlet.annotation.WebInitParam; 7 | 8 | /** 9 | * @author wujing 10 | */ 11 | @WebFilter(filterName = "druidWebStatFilter", urlPatterns = "/*", initParams = { @WebInitParam(name = "exclusions", value = "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*") }) 12 | public class DruidWebStatFilter extends WebStatFilter { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/druid/servlet/DruidStatViewServlet.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.druid.servlet; 2 | 3 | import com.alibaba.druid.support.http.StatViewServlet; 4 | 5 | import javax.servlet.annotation.WebInitParam; 6 | import javax.servlet.annotation.WebServlet; 7 | 8 | /** 9 | * 10 | * @author wujing 11 | */ 12 | @WebServlet(urlPatterns = { "/druid/*" }, initParams = { @WebInitParam(name = "loginUsername", value = "admin"), @WebInitParam(name = "loginPassword", value = "admin") }) 13 | public class DruidStatViewServlet extends StatViewServlet { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/init/FreeMarkerConfig.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.init; 2 | 3 | import com.jagregory.shiro.freemarker.ShiroTags; 4 | import freemarker.template.TemplateModelException; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | /** 12 | * Freemarker + shiro 权限控制文件 13 | * 14 | * @author luomouren 15 | */ 16 | @Component 17 | public class FreeMarkerConfig { 18 | @Autowired 19 | private FreeMarkerConfigurer freeMarkerConfigurer; 20 | 21 | @PostConstruct 22 | public void setSharedVariable() throws TemplateModelException { 23 | freeMarkerConfigurer.getConfiguration().setSharedVariable("shiro", new ShiroTags()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/init/TkMapper.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.init; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @author:luomouren 8 | * @description:通用Mapper接口 9 | * @dateTime: created in 2018-04-09 17:06 10 | * @modified by: 11 | **/ 12 | public interface TkMapper extends Mapper, MySqlMapper { 13 | //TODO 14 | //FIXME 特别注意,该接口不能被扫描到,否则会出错 15 | } 16 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/shiro/ShiroConfig.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.shiro; 2 | 3 | import com.weisi.veems.frame.constants.UserPasswordConstants; 4 | import com.weisi.veems.models.sys.SysPermission; 5 | import com.weisi.veems.services.permission.SysPermissonService; 6 | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; 7 | import org.apache.shiro.cache.CacheManager; 8 | import org.apache.shiro.cache.MemoryConstrainedCacheManager; 9 | import org.apache.shiro.mgt.DefaultSecurityManager; 10 | import org.apache.shiro.realm.Realm; 11 | import org.apache.shiro.spring.web.ShiroFilterFactoryBean; 12 | import org.apache.shiro.web.mgt.DefaultWebSecurityManager; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 15 | import org.springframework.context.annotation.Bean; 16 | import org.springframework.context.annotation.Configuration; 17 | import org.springframework.context.annotation.DependsOn; 18 | import org.springframework.context.annotation.Import; 19 | 20 | import java.util.LinkedHashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * shiro config配置项 26 | * 27 | * @author luomouren 28 | */ 29 | @Configuration 30 | @Import(ShiroManager.class) 31 | public class ShiroConfig { 32 | 33 | @Autowired 34 | private SysPermissonService sysPermissonService; 35 | 36 | @Bean(name = "realm") 37 | @DependsOn("lifecycleBeanPostProcessor") 38 | @ConditionalOnMissingBean 39 | public Realm realm() { 40 | ShiroRealm realm = new ShiroRealm(); 41 | // 告诉realm,使用credentialsMatcher加密算法类来验证密文 42 | realm.setCredentialsMatcher(hashedCredentialsMatcher()); 43 | return realm; 44 | } 45 | 46 | /** 47 | * 用户授权信息Cache 48 | */ 49 | @Bean(name = "shiroCacheManager") 50 | @ConditionalOnMissingBean 51 | public CacheManager cacheManager() { 52 | return new MemoryConstrainedCacheManager(); 53 | } 54 | 55 | /** 56 | * 将缓存对象注入到SecurityManager中 57 | * @return 58 | */ 59 | @Bean(name = "securityManager") 60 | @ConditionalOnMissingBean 61 | public DefaultSecurityManager securityManager() { 62 | 63 | 64 | DefaultSecurityManager sm = new DefaultWebSecurityManager(); 65 | sm.setCacheManager(cacheManager()); 66 | return sm; 67 | } 68 | 69 | /** 70 | * 处理认证匹配处理器:如果自定义需要实现继承HashedCredentialsMatcher 71 | * 指定加密方式方式,也可以在这里加入缓存,当用户超过五次登陆错误就锁定该用户禁止不断尝试登陆 72 | * @return 73 | */ 74 | @Bean(name = "hashedCredentialsMatcher") 75 | public HashedCredentialsMatcher hashedCredentialsMatcher() { 76 | HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); 77 | // 散列算法:这里指md5 78 | credentialsMatcher.setHashAlgorithmName(UserPasswordConstants.HASHALGORITHM_NAME); 79 | // 散列的次数:比如散列两次,相当于 md5(md5("")); 80 | credentialsMatcher.setHashIterations(UserPasswordConstants.HASHITERATIONS); 81 | credentialsMatcher.setStoredCredentialsHexEncoded(true); 82 | return credentialsMatcher; 83 | } 84 | 85 | 86 | /** 87 | * 配置地址 88 | * @param securityManager 89 | * @return 90 | */ 91 | @Bean(name = "shiroFilter") 92 | @DependsOn("securityManager") 93 | @ConditionalOnMissingBean 94 | public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultSecurityManager securityManager, Realm realm) { 95 | securityManager.setRealm(realm); 96 | 97 | ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean(); 98 | shiroFilter.setSecurityManager(securityManager); 99 | // 登录地址 100 | shiroFilter.setLoginUrl("/login"); 101 | // 登录成功后跳转的地址 102 | shiroFilter.setSuccessUrl("/index"); 103 | // 没有权限则跳转到该页面 104 | shiroFilter.setUnauthorizedUrl("/permission/unauthorized"); 105 | Map filterChainDefinitionMap = new LinkedHashMap<>(); 106 | //静态资源不拦截 107 | filterChainDefinitionMap.put("/assets/**", "anon"); 108 | filterChainDefinitionMap.put("/webjars/**", "anon"); 109 | //登录不拦截,anon 可以理解为不拦截 110 | filterChainDefinitionMap.put("/login", "anon"); 111 | 112 | List list = sysPermissonService.selectAll(); 113 | for (SysPermission permission: list) { 114 | // org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter 115 | filterChainDefinitionMap.put(permission.getUrl(), "perms[" + permission.getPercode() + "]"); 116 | } 117 | // 其他资源全部拦截 118 | filterChainDefinitionMap.put("/**", "authc"); 119 | shiroFilter.setFilterChainDefinitionMap(filterChainDefinitionMap); 120 | return shiroFilter; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/shiro/ShiroManager.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.shiro; 2 | 3 | import org.apache.shiro.mgt.DefaultSecurityManager; 4 | import org.apache.shiro.spring.LifecycleBeanPostProcessor; 5 | import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; 6 | import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.DependsOn; 10 | 11 | /** 12 | * Shiro Config Manager. 13 | * 因为shiroConfig中要注入service查询数据库,需要分离开shiro配置,否则会注入失败 14 | * 15 | * @author luomouren 16 | */ 17 | public class ShiroManager { 18 | 19 | /** 20 | * 保证实现了Shiro内部lifecycle函数的bean执行 21 | */ 22 | @Bean(name = "lifecycleBeanPostProcessor") 23 | @ConditionalOnMissingBean 24 | public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { 25 | return new LifecycleBeanPostProcessor(); 26 | } 27 | 28 | /** 29 | * 开启注解控制权限的方式,AOP式方法级权限检查 30 | * 31 | * @return 32 | */ 33 | @Bean(name = "defaultAdvisorAutoProxyCreator") 34 | @ConditionalOnMissingBean 35 | @DependsOn("lifecycleBeanPostProcessor") 36 | public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { 37 | DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator(); 38 | defaultAdvisorAutoProxyCreator.setProxyTargetClass(true); 39 | return defaultAdvisorAutoProxyCreator; 40 | } 41 | 42 | /** 43 | * 开启注解控制权限的方式 44 | * 45 | * @param securityManager 46 | * @return 47 | */ 48 | @Bean 49 | @ConditionalOnMissingBean 50 | public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultSecurityManager securityManager) { 51 | AuthorizationAttributeSourceAdvisor aasa = new AuthorizationAttributeSourceAdvisor(); 52 | aasa.setSecurityManager(securityManager); 53 | return aasa; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/frame/shiro/ShiroRealm.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.frame.shiro; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.weisi.veems.models.sys.SysPermission; 6 | import com.weisi.veems.models.sys.SysUser; 7 | import com.weisi.veems.services.permission.SysPermissonService; 8 | import com.weisi.veems.services.user.SysUserService; 9 | import org.apache.shiro.SecurityUtils; 10 | import org.apache.shiro.authc.*; 11 | import org.apache.shiro.authz.AuthorizationInfo; 12 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 13 | import org.apache.shiro.crypto.hash.SimpleHash; 14 | import org.apache.shiro.realm.AuthorizingRealm; 15 | import org.apache.shiro.subject.PrincipalCollection; 16 | import org.apache.shiro.util.ByteSource; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | /** 25 | * Shiro Realm 26 | * 27 | * @author luomouren 28 | */ 29 | public class ShiroRealm extends AuthorizingRealm { 30 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 31 | 32 | @Autowired 33 | private SysUserService sysUserService; 34 | 35 | @Autowired 36 | private SysPermissonService sysPermissonService; 37 | 38 | /** 39 | * 设置realm的名称 40 | * 41 | * @param name 42 | */ 43 | @Override 44 | public void setName(String name) { 45 | super.setName("customRealm"); 46 | } 47 | 48 | /** 49 | * realm的认证方法,从数据库查询用户信息 50 | * 51 | * @param token 52 | * @return 53 | * @throws AuthenticationException 54 | */ 55 | @Override 56 | protected AuthenticationInfo doGetAuthenticationInfo( 57 | AuthenticationToken token) throws AuthenticationException { 58 | // token是用户输入的用户名和密码 59 | // 第一步从token中取出用户名 60 | String userName = (String) token.getPrincipal(); 61 | 62 | // 第二步:根据用户输入的userCode从数据库查询 63 | SysUser sysUser = sysUserService.findByUserName(userName); 64 | 65 | // 如果查询不到返回null 66 | if (sysUser == null) { 67 | return null; 68 | } else { 69 | // 判断帐号是否锁定 70 | if (Boolean.TRUE.equals(sysUser.getIsLocked())) { 71 | // 抛出 帐号锁定异常 72 | throw new LockedAccountException(); 73 | } 74 | // 从数据库查询到密码 75 | String password = sysUser.getPassword(); 76 | //盐 77 | String salt = sysUser.getSalt(); 78 | 79 | // 查询用户对应的导航模块信息 80 | List menulList = sysPermissonService.findMenuListByUserId(sysUser.getUserId()); 81 | // 组装导航权限父子关系 82 | menulList = sysPermissonService.formatChildPermission(menulList); 83 | sysUser.setMenuJson(JSON.toJSONString(menulList)); 84 | 85 | // 将sysUser设置simpleAuthenticationInfo 86 | SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo( 87 | sysUser, password, ByteSource.Util.bytes(salt), this.getName()); 88 | return simpleAuthenticationInfo; 89 | } 90 | 91 | } 92 | 93 | 94 | 95 | 96 | /** 97 | * 用于授权 98 | * 99 | * @param principals 100 | * @return 101 | */ 102 | @Override 103 | protected AuthorizationInfo doGetAuthorizationInfo( 104 | PrincipalCollection principals) { 105 | 106 | //从 principals获取主身份信息 107 | //将getPrimaryPrincipal方法返回值转为真实身份类型(在上边的doGetAuthenticationInfo认证通过填充到SimpleAuthenticationInfo中身份类型), 108 | SysUser activeUser = (SysUser) principals.getPrimaryPrincipal(); 109 | 110 | //根据身份信息获取权限信息 111 | //从数据库获取到权限数据 112 | List permissionList = sysPermissonService.findPermissionListByUserId(activeUser.getUserId()); 113 | 114 | //单独定一个集合对象 115 | List permissions = new ArrayList(); 116 | if (permissionList != null) { 117 | for (SysPermission sysPermission : permissionList) { 118 | //将数据库中的权限标签 符放入集合 119 | permissions.add(sysPermission.getPercode()); 120 | } 121 | } 122 | 123 | //查到权限数据,返回授权信息(要包括 上边的permissions) 124 | SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(); 125 | //将上边查询到授权信息填充到simpleAuthorizationInfo对象中 126 | simpleAuthorizationInfo.addStringPermissions(permissions); 127 | 128 | return simpleAuthorizationInfo; 129 | } 130 | 131 | //清除缓存 132 | public void clearCached() { 133 | PrincipalCollection principals = SecurityUtils.getSubject().getPrincipals(); 134 | super.clearCache(principals); 135 | } 136 | 137 | /** 138 | * 明文密码进行加密 139 | * 140 | * @param args 141 | */ 142 | public static void main(String[] args) { 143 | int hashIterations = 1;//加密的次数 144 | Object salt = "eteokues";//盐值 145 | Object credentials = "111111";//密码 146 | String hashAlgorithmName = "MD5";//加密方式 147 | Object simpleHash = new SimpleHash(hashAlgorithmName, credentials, 148 | salt, hashIterations); 149 | // cb571f7bd7a6f73ab004a70322b963d5 150 | System.out.println("加密后的值----->" + simpleHash); 151 | } 152 | 153 | 154 | } 155 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/mapper/sys/SysMapRolePermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.mapper.sys; 2 | 3 | import com.weisi.veems.frame.init.TkMapper; 4 | import com.weisi.veems.models.sys.SysMapRolePermission; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 用户角色map信息 11 | * 12 | * @author luomouren 13 | */ 14 | public interface SysMapRolePermissionMapper extends TkMapper { 15 | 16 | /** 17 | * 给角色分配权限 18 | * 19 | * @param roleId 角色ID 20 | * @param permissionIds 权限ids 21 | */ 22 | void grant(@Param("roleId") String roleId, @Param("permissionIds") String[] permissionIds); 23 | 24 | /** 25 | * 根据角色id查找其所有的权限id 26 | * @param roleId 27 | * @return 28 | */ 29 | List findAllPermissionIds(@Param("roleId")String roleId); 30 | } 31 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/mapper/sys/SysMapUserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.mapper.sys; 2 | 3 | import com.weisi.veems.frame.init.TkMapper; 4 | import com.weisi.veems.models.sys.SysMapUserRole; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 用户角色map信息 11 | * 12 | * @author luomouren 13 | */ 14 | public interface SysMapUserRoleMapper extends TkMapper { 15 | 16 | /** 17 | * 根据用户id查找roleIds 18 | * 19 | * @param userId 用户id 20 | * @return 21 | */ 22 | List findRoleIdsByUserId(@Param("userId") String userId); 23 | 24 | /** 25 | * 分配角色 26 | * 27 | * @param userId 用户id 28 | * @param roleIds 角色id 29 | */ 30 | void grant(@Param("userId") String userId, @Param("roleIds") String[] roleIds); 31 | } 32 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/mapper/sys/SysPermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.mapper.sys; 2 | 3 | import com.weisi.veems.frame.init.TkMapper; 4 | import com.weisi.veems.models.sys.SysPermission; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author:luomouren 10 | * @description:权限mapper 11 | * @dateTime: created in 2018-04-10 12:11 12 | * @modified by: 13 | **/ 14 | public interface SysPermissionMapper extends TkMapper { 15 | /** 16 | * 根据用户id查询权限url 17 | * 18 | * @param userId 19 | * @return 20 | */ 21 | List findPermissionListByUserId(String userId); 22 | 23 | /** 24 | * 根据用户主键,获取其权限下所有的menu,按照sort asc排序 25 | * @param userId 26 | * @return 27 | */ 28 | List findMenuListByUserId(String userId); 29 | 30 | /** 31 | * 根据父节点asc/排序值asc 查询所有的权限 32 | * 33 | * @return 34 | */ 35 | List findAllByOrderByParentAscIdAscSortAsc(); 36 | } 37 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/mapper/sys/SysRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.mapper.sys; 2 | 3 | import com.weisi.veems.frame.init.TkMapper; 4 | import com.weisi.veems.models.sys.SysRole; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | /** 8 | * @author:luomouren 9 | * @description:角色mapper 10 | * @dateTime: created in 2018-04-10 12:11 11 | * @modified by: 12 | **/ 13 | public interface SysRoleMapper extends TkMapper { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/mapper/sys/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.mapper.sys; 2 | 3 | import com.weisi.veems.frame.init.TkMapper; 4 | import com.weisi.veems.models.sys.SysUser; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | /** 8 | * 用户信息 9 | * 10 | * @author luomouren 11 | */ 12 | public interface SysUserMapper extends TkMapper { 13 | 14 | /** 15 | * 根据用户名查找用户 16 | * 17 | * @param userName 用户名 18 | * @return 19 | */ 20 | SysUser findByUserName(@Param("userName") String userName); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/models/elasticsearch/Mpcv.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.models.elasticsearch; 2 | import org.springframework.data.elasticsearch.annotations.Document; 3 | 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * @author luomouren 10 | * 测点cv值-与数据库mongodb表mpcv对应 11 | */ 12 | @Document(indexName="mpcv",type="mpcv") 13 | public class Mpcv implements Serializable { 14 | 15 | public static String INDEX_NAME ="mpcv"; 16 | 17 | public static String TYPE ="mpcv"; 18 | 19 | private static final long serialVersionUID = 1L; 20 | private String id; 21 | private String cvId; 22 | private String mpId; 23 | private Double value; 24 | // 示数对应时间 25 | private Date dataTime; 26 | // 数据采集时间 27 | private Date samTime; 28 | 29 | public Mpcv() { 30 | super(); 31 | } 32 | 33 | public Mpcv(String _id, String cvId, String mpId, Double value, Date dataTime, Date samTime) { 34 | super(); 35 | this.id = id; 36 | this.cvId = cvId; 37 | this.mpId = mpId; 38 | this.value = value; 39 | this.dataTime = dataTime; 40 | this.samTime = samTime; 41 | } 42 | 43 | public String getCvId() { 44 | return cvId; 45 | } 46 | 47 | public void setCvId(String cvId) { 48 | this.cvId = cvId; 49 | } 50 | 51 | public String getMpId() { 52 | return mpId; 53 | } 54 | 55 | public void setMpId(String mpId) { 56 | this.mpId = mpId; 57 | } 58 | 59 | public Double getValue() { 60 | return value; 61 | } 62 | 63 | public void setValue(Double value) { 64 | this.value = value; 65 | } 66 | 67 | public Date getDataTime() { 68 | return dataTime; 69 | } 70 | 71 | public void setDataTime(Date dataTime) { 72 | this.dataTime = dataTime; 73 | } 74 | 75 | public Date getSamTime() { 76 | return samTime; 77 | } 78 | 79 | public void setSamTime(Date samTime) { 80 | this.samTime = samTime; 81 | } 82 | 83 | public String getId() { 84 | return id; 85 | } 86 | 87 | public void setId(String id) { 88 | this.id = id; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/models/sys/SysMapRolePermission.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.models.sys; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 角色权限表 7 | * 8 | * @author luomouren 9 | */ 10 | @Data 11 | public class SysMapRolePermission implements java.io.Serializable { 12 | private String roleId; 13 | private String permissionId; 14 | 15 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/models/sys/SysMapUserRole.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.models.sys; 2 | 3 | import lombok.Data; 4 | import org.hibernate.validator.constraints.NotEmpty; 5 | 6 | import javax.persistence.Id; 7 | 8 | /** 9 | * 用户角色表 10 | * 11 | * @author luomouren 12 | */ 13 | @Data 14 | public class SysMapUserRole implements java.io.Serializable { 15 | private String userId; 16 | private String roleId; 17 | 18 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/models/sys/SysPermission.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.models.sys; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | import javax.persistence.Transient; 9 | import java.util.List; 10 | 11 | /** 12 | * 权限 13 | * @author luomouren 14 | */ 15 | @Data 16 | @Table(name = "sys_permission") 17 | public class SysPermission implements java.io.Serializable { 18 | @Id 19 | private String permissionId; 20 | 21 | private String permissionName; 22 | 23 | private Integer permissionType; 24 | 25 | private String url; 26 | 27 | private String percode; 28 | 29 | private String parentPermissionId; 30 | 31 | private Integer sort; 32 | 33 | private Boolean isAvailable; 34 | 35 | private String icon; 36 | 37 | /** 38 | * 该权限下所有子权限 39 | */ 40 | @Transient 41 | private List childList; 42 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/models/sys/SysRole.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.models.sys; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | 7 | /** 8 | * 角色 9 | * @author luomouren 10 | */ 11 | @Data 12 | public class SysRole implements java.io.Serializable { 13 | @Id 14 | private String roleId; 15 | 16 | private String roleName; 17 | 18 | private Boolean isAvailable; 19 | 20 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/models/sys/SysUser.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.models.sys; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import lombok.Data; 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | 7 | import javax.persistence.Id; 8 | import javax.persistence.Transient; 9 | import java.util.List; 10 | 11 | /** 12 | * 用户表 13 | * 14 | * @author luomouren 15 | */ 16 | @Data 17 | public class SysUser implements java.io.Serializable { 18 | @Id 19 | private String userId; 20 | 21 | private String realName; 22 | 23 | private String userName; 24 | 25 | private String password; 26 | 27 | private Integer userCategory; 28 | 29 | private String positionJob; 30 | 31 | private String email; 32 | 33 | private String cellphone; 34 | 35 | private String tel; 36 | 37 | private String salt; 38 | 39 | private Boolean isLocked; 40 | 41 | /** 42 | * 用户权限下所有的导航权限 43 | */ 44 | @Transient 45 | private String menuJson; 46 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/repository/ElasticSearchRepository.java: -------------------------------------------------------------------------------- 1 | // 2 | // Source code recreated from a .class file by IntelliJ IDEA 3 | // (powered by Fernflower decompiler) 4 | // 5 | 6 | package com.weisi.veems.repository; 7 | 8 | import com.alibaba.fastjson.JSON; 9 | import com.google.gson.JsonObject; 10 | import com.google.gson.JsonParser; 11 | import io.searchbox.client.JestClient; 12 | import io.searchbox.client.JestResult; 13 | import io.searchbox.cluster.Health; 14 | import io.searchbox.cluster.NodesInfo; 15 | import io.searchbox.cluster.NodesStats; 16 | import io.searchbox.core.Bulk; 17 | import io.searchbox.core.Delete; 18 | import io.searchbox.core.DeleteByQuery; 19 | import io.searchbox.core.Get; 20 | import io.searchbox.core.Index; 21 | import io.searchbox.core.Search; 22 | import io.searchbox.core.SearchResult; 23 | import io.searchbox.core.Suggest; 24 | import io.searchbox.core.SuggestResult; 25 | import io.searchbox.core.Update; 26 | import io.searchbox.core.SearchResult.Hit; 27 | import io.searchbox.core.SuggestResult.Suggestion; 28 | import io.searchbox.indices.ClearCache; 29 | import io.searchbox.indices.CloseIndex; 30 | import io.searchbox.indices.DeleteIndex; 31 | import io.searchbox.indices.Flush; 32 | import io.searchbox.indices.IndicesExists; 33 | import io.searchbox.indices.Optimize; 34 | import io.searchbox.indices.DeleteIndex.Builder; 35 | import io.searchbox.params.SearchType; 36 | import java.io.IOException; 37 | import java.util.Arrays; 38 | import java.util.Iterator; 39 | import java.util.List; 40 | import org.apache.commons.logging.Log; 41 | import org.apache.commons.logging.LogFactory; 42 | import org.elasticsearch.index.query.QueryBuilders; 43 | import org.elasticsearch.search.builder.SearchSourceBuilder; 44 | import org.elasticsearch.search.highlight.HighlightBuilder; 45 | import org.springframework.beans.factory.annotation.Autowired; 46 | 47 | public abstract class ElasticSearchRepository { 48 | protected static final Log log = LogFactory.getLog(ElasticSearchRepository.class.getName()); 49 | @Autowired 50 | private JestClient client; 51 | 52 | public ElasticSearchRepository() { 53 | } 54 | /** 55 | * 删除索引 56 | * @param type :当前删除document名称 57 | * @return 58 | */ 59 | public JestResult deleteIndex(String type) { 60 | DeleteIndex deleteIndex = (new Builder(type)).build(); 61 | JestResult result = null; 62 | 63 | try { 64 | result = this.client.execute(deleteIndex); 65 | log.info("deleteIndex == " + result.getJsonString()); 66 | } catch (IOException var5) { 67 | var5.printStackTrace(); 68 | } 69 | 70 | return result; 71 | } 72 | /** 73 | * 清除缓存 74 | */ 75 | public JestResult clearCache() { 76 | ClearCache closeIndex = (new io.searchbox.indices.ClearCache.Builder()).build(); 77 | JestResult result = null; 78 | 79 | try { 80 | result = this.client.execute(closeIndex); 81 | log.info("clearCache == " + result.getJsonString()); 82 | } catch (IOException var4) { 83 | var4.printStackTrace(); 84 | } 85 | 86 | return result; 87 | } 88 | 89 | /** 90 | * 关闭索引 91 | * @param type :文档表示的对象类别 92 | * @return 93 | */ 94 | public JestResult closeIndex(String type) { 95 | CloseIndex closeIndex = (new io.searchbox.indices.CloseIndex.Builder(type)).build(); 96 | JestResult result = null; 97 | 98 | try { 99 | result = this.client.execute(closeIndex); 100 | log.info("closeIndex == " + result.getJsonString()); 101 | } catch (IOException var5) { 102 | var5.printStackTrace(); 103 | } 104 | 105 | return result; 106 | } 107 | 108 | /** 109 | *优化索引 110 | */ 111 | public JestResult optimizeIndex() { 112 | Optimize optimize = (new io.searchbox.indices.Optimize.Builder()).build(); 113 | JestResult result = null; 114 | 115 | try { 116 | result = this.client.execute(optimize); 117 | log.info("optimizeIndex == " + result.getJsonString()); 118 | } catch (IOException var4) { 119 | var4.printStackTrace(); 120 | } 121 | 122 | return result; 123 | } 124 | 125 | /** 126 | *刷新索引 127 | */ 128 | public JestResult flushIndex() { 129 | Flush flush = (new io.searchbox.indices.Flush.Builder()).build(); 130 | JestResult result = null; 131 | 132 | try { 133 | result = this.client.execute(flush); 134 | log.info("flushIndex == " + result.getJsonString()); 135 | } catch (IOException var4) { 136 | var4.printStackTrace(); 137 | } 138 | 139 | return result; 140 | } 141 | 142 | /** 143 | *判断索引是否存在 144 | */ 145 | public JestResult indicesExists() { 146 | IndicesExists indicesExists = (new io.searchbox.indices.IndicesExists.Builder("article")).build(); 147 | JestResult result = null; 148 | try { 149 | result = this.client.execute(indicesExists); 150 | log.info("indicesExists == " + result.getJsonString()); 151 | } catch (IOException var4) { 152 | var4.printStackTrace(); 153 | } 154 | 155 | return result; 156 | } 157 | 158 | /** 159 | *查看节点信息 160 | */ 161 | public JestResult nodesInfo() { 162 | NodesInfo nodesInfo = (new io.searchbox.cluster.NodesInfo.Builder()).build(); 163 | JestResult result = null; 164 | 165 | try { 166 | result = this.client.execute(nodesInfo); 167 | log.info("nodesInfo == " + result.getJsonString()); 168 | } catch (IOException var4) { 169 | var4.printStackTrace(); 170 | } 171 | 172 | return result; 173 | } 174 | 175 | /** 176 | * 查看集群健康信息 177 | * @return 178 | */ 179 | public JestResult health() { 180 | Health health = (new io.searchbox.cluster.Health.Builder()).build(); 181 | JestResult result = null; 182 | 183 | try { 184 | result = this.client.execute(health); 185 | log.info("health == " + result.getJsonString()); 186 | } catch (IOException var4) { 187 | var4.printStackTrace(); 188 | } 189 | 190 | return result; 191 | } 192 | 193 | /** 194 | * 节点状态 195 | * @return 196 | */ 197 | public JestResult nodesStats() { 198 | NodesStats nodesStats = (new io.searchbox.cluster.NodesStats.Builder()).build(); 199 | JestResult result = null; 200 | 201 | try { 202 | result = this.client.execute(nodesStats); 203 | log.info("nodesStats == " + result.getJsonString()); 204 | } catch (IOException var4) { 205 | var4.printStackTrace(); 206 | } 207 | 208 | return result; 209 | } 210 | 211 | /** 212 | * 更新Document 213 | * @param index :文档在哪存放 214 | * @param type : 文档表示的对象类别 215 | * @param id :文档唯一标识 216 | */ 217 | public void updateDocument(Object o, String index, String type, String id) { 218 | String jsonString = JSON.toJSONString(o); 219 | Update update = ((io.searchbox.core.Update.Builder)((io.searchbox.core.Update.Builder)((io.searchbox.core.Update.Builder)(new io.searchbox.core.Update.Builder(jsonString)).index(index)).type(type)).id(id)).build(); 220 | JestResult result = null; 221 | 222 | try { 223 | result = this.client.execute(update); 224 | log.info("updateDocument == " + result.getJsonString()); 225 | } catch (IOException var9) { 226 | var9.printStackTrace(); 227 | } 228 | 229 | } 230 | 231 | /** 232 | * 删除Document 233 | * @param index :文档在哪存放 234 | * @param type : 文档表示的对象类别 235 | * @param id :文档唯一标识 236 | * @return 237 | */ 238 | public JestResult deleteDocument(String index, String type, String id) { 239 | Delete delete = ((io.searchbox.core.Delete.Builder)((io.searchbox.core.Delete.Builder)(new io.searchbox.core.Delete.Builder(id)).index(index)).type(type)).build(); 240 | JestResult result = null; 241 | 242 | try { 243 | result = this.client.execute(delete); 244 | log.info("deleteDocument == " + result.getJsonString()); 245 | } catch (IOException var7) { 246 | var7.printStackTrace(); 247 | } 248 | 249 | return result; 250 | } 251 | 252 | /** 253 | * 根据条件删除 254 | * @param index 255 | * @param type 256 | * @param params 257 | */ 258 | public JestResult deleteDocumentByQuery(String index, String type, String params) { 259 | DeleteByQuery db = ((io.searchbox.core.DeleteByQuery.Builder)((io.searchbox.core.DeleteByQuery.Builder)(new io.searchbox.core.DeleteByQuery.Builder(params)).addIndex(index)).addType(type)).build(); 260 | JestResult result = null; 261 | 262 | try { 263 | result = this.client.execute(db); 264 | log.info("deleteDocument == " + result.getJsonString()); 265 | } catch (IOException var7) { 266 | var7.printStackTrace(); 267 | } 268 | 269 | return result; 270 | } 271 | 272 | /** 273 | * 获取Document 274 | * @param o :返回对象 275 | * @param index :文档在哪存放 276 | * @param type : 文档表示的对象类别 277 | * @param id :文档唯一标识 278 | * @return 279 | */ 280 | public Object getDocument(T object, String index, String type, String id) { 281 | Get get = ((io.searchbox.core.Get.Builder)(new io.searchbox.core.Get.Builder(index, id)).type(type)).build(); 282 | JestResult result = null; 283 | 284 | try { 285 | result = this.client.execute(get); 286 | } catch (IOException var8) { 287 | var8.printStackTrace(); 288 | } 289 | 290 | return result.getSourceAsObject(object.getClass()); 291 | } 292 | 293 | /** 294 | * Suggestion 295 | * @return 296 | */ 297 | public List suggest() { 298 | String suggestionName = "my-suggestion"; 299 | Suggest suggest = (new io.searchbox.core.Suggest.Builder("{ \"" + suggestionName + "\" : { \"text\" : \"the amsterdma meetpu\", \"term\" : { \"field\" : \"body\" } }}")).build(); 300 | SuggestResult suggestResult = null; 301 | List suggestionList = null; 302 | 303 | try { 304 | suggestResult = (SuggestResult)this.client.execute(suggest); 305 | log.info("suggestResult.isSucceeded() == " + suggestResult.isSucceeded()); 306 | suggestionList = suggestResult.getSuggestions(suggestionName); 307 | log.info("suggestionList.size() == " + suggestionList.size()); 308 | Iterator var5 = suggestionList.iterator(); 309 | 310 | while(var5.hasNext()) { 311 | Suggestion suggestion = (Suggestion)var5.next(); 312 | System.out.println(suggestion.text); 313 | } 314 | } catch (IOException var7) { 315 | var7.printStackTrace(); 316 | } 317 | 318 | return suggestionList; 319 | } 320 | 321 | /** 322 | * 查询全部 323 | * @param index :文档在哪存放 324 | * @return 325 | */ 326 | public List> searchAll(String index, T o) { 327 | SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); 328 | searchSourceBuilder.query(QueryBuilders.matchAllQuery()); 329 | Search search = ((io.searchbox.core.Search.Builder)(new io.searchbox.core.Search.Builder(searchSourceBuilder.toString())).addIndex(index)).build(); 330 | SearchResult result = null; 331 | List hits = null; 332 | 333 | try { 334 | result = (SearchResult)this.client.execute(search); 335 | log.info("本次查询共查到:" + result.getTotal() + "个关键字!"); 336 | hits = result.getHits(o.getClass()); 337 | } catch (IOException var8) { 338 | var8.printStackTrace(); 339 | } 340 | 341 | return hits; 342 | } 343 | 344 | /** 345 | * 搜索 346 | * @param keyWord :搜索关键字 347 | * @return 348 | */ 349 | public List createSearch(String keyWord, String index, String type, T o, String field) { 350 | SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); 351 | searchSourceBuilder.query(QueryBuilders.termQuery(field, keyWord)); 352 | HighlightBuilder highlightBuilder = new HighlightBuilder(); 353 | highlightBuilder.preTags(new String[]{""}).postTags(new String[]{""}); 354 | highlightBuilder.fragmentSize(200); 355 | Search search = ((io.searchbox.core.Search.Builder)((io.searchbox.core.Search.Builder)(new io.searchbox.core.Search.Builder(searchSourceBuilder.toString())).addIndex(index)).addType(type)).setSearchType(SearchType.DFS_QUERY_THEN_FETCH).build(); 356 | SearchResult result = null; 357 | List resultList = null; 358 | 359 | try { 360 | result = (SearchResult)this.client.execute(search); 361 | log.info("本次查询共查到:" + result.getTotal() + "个结果!"); 362 | resultList = result.getSourceAsObjectList(o.getClass()); 363 | } catch (IOException var12) { 364 | var12.printStackTrace(); 365 | } 366 | 367 | return resultList; 368 | } 369 | 370 | /** 371 | * bulkIndex操作 372 | * @param index 373 | * @param type 374 | * @param o 375 | * @param 376 | */ 377 | public void bulkIndex(String index, String type, T o) { 378 | Bulk bulk = (new io.searchbox.core.Bulk.Builder()).defaultIndex(index).defaultType(type).addAction(Arrays.asList((new io.searchbox.core.Index.Builder(o)).build())).build(); 379 | 380 | try { 381 | this.client.execute(bulk); 382 | } catch (IOException var6) { 383 | var6.printStackTrace(); 384 | } 385 | 386 | } 387 | 388 | /** 389 | * 创建索引 390 | * @param o :返回对象 391 | * @param index :文档在哪存放 392 | * @param type : 文档表示的对象类别 393 | * @return 394 | */ 395 | public JestResult createIndex(T o, String index, String type) { 396 | Index index1 = ((io.searchbox.core.Index.Builder)((io.searchbox.core.Index.Builder)(new io.searchbox.core.Index.Builder(o)).index(index)).type(type)).build(); 397 | JestResult jestResult = null; 398 | 399 | try { 400 | jestResult = this.client.execute(index1); 401 | } catch (IOException var7) { 402 | var7.printStackTrace(); 403 | } 404 | 405 | return jestResult; 406 | } 407 | 408 | 409 | /** 410 | * 搜索事件流图表数据 411 | * @param param 412 | * @return 413 | */ 414 | public JsonObject searchEvent(String param) { 415 | JsonObject returnData = (new JsonParser()).parse(param).getAsJsonObject(); 416 | Search search = ((io.searchbox.core.Search.Builder)((io.searchbox.core.Search.Builder)(new io.searchbox.core.Search.Builder(returnData.toString())).addType("event")).addIndex("pi")).build(); 417 | SearchResult result = null; 418 | 419 | try { 420 | result = (SearchResult)this.client.execute(search); 421 | } catch (IOException var6) { 422 | var6.printStackTrace(); 423 | } 424 | 425 | return result.getJsonObject(); 426 | } 427 | 428 | public void save(T o, String index, String type) { 429 | try { 430 | JestResult var4 = this.client.execute(((io.searchbox.core.Index.Builder)((io.searchbox.core.Index.Builder)(new io.searchbox.core.Index.Builder(o)).index(index)).type(type)).build()); 431 | } catch (Exception var5) { 432 | var5.printStackTrace(); 433 | } 434 | 435 | } 436 | } 437 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/base/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * @author:luomouren 10 | * @description:BaseService,能够根据泛型自动注入dao,并定义常用的CURD方法,每一个service再继承它 11 | * @dateTime: created in 2018-04-11 16:54 12 | * @modified by: 13 | **/ 14 | public interface BaseService, T extends Serializable> { 15 | /** 16 | * 通过id查询 实体 17 | * 18 | * @param id id 19 | * @return 实体 20 | */ 21 | T selectByPrimaryKey(String id); 22 | 23 | /** 24 | * 保存 25 | * 26 | * @param t 27 | */ 28 | void insert(T t); 29 | 30 | 31 | /** 32 | * 根据主键保存更新 33 | * 34 | * @param t 35 | */ 36 | void updateByPrimaryKey(T t); 37 | 38 | /** 39 | * 查询所有 40 | * 41 | * @return 42 | */ 43 | List selectAll(); 44 | 45 | 46 | /** 47 | * 通过id删除实体 48 | * 49 | * @param id id 50 | * @return 提示信息 51 | */ 52 | Integer deleteById(String id); 53 | 54 | /** 55 | * 删除实体 56 | * 57 | * @param t 58 | */ 59 | void delete(T t); 60 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/base/impl/BaseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.base.impl; 2 | 3 | import com.weisi.veems.services.base.BaseService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | /** 11 | * @author:luomouren 12 | * @description:BaseService,能够根据泛型自动注入dao,并定义常用的CURD方法,每一个service再继承它 13 | * @dateTime: created in 2018-04-11 16:54 14 | * @modified by: 15 | **/ 16 | public abstract class BaseServiceImpl, T extends Serializable> implements BaseService { 17 | @Autowired 18 | protected M mapper; 19 | 20 | /** 21 | * 通过id查询 实体 22 | * 23 | * @param id id 24 | * @return 实体 25 | */ 26 | @Override 27 | public T selectByPrimaryKey(String id) { 28 | return mapper.selectByPrimaryKey(id); 29 | } 30 | 31 | /** 32 | * 保存 33 | * 34 | * @param t 35 | */ 36 | @Override 37 | public void insert(T t) { 38 | mapper.insert(t); 39 | } 40 | 41 | 42 | /** 43 | * 根据主键保存更新 44 | * 45 | * @param t 46 | */ 47 | @Override 48 | public void updateByPrimaryKey(T t) { 49 | mapper.updateByPrimaryKey(t); 50 | } 51 | 52 | /** 53 | * 查询所有 54 | * 55 | * @return 56 | */ 57 | @Override 58 | public List selectAll() { 59 | return mapper.selectAll(); 60 | } 61 | 62 | 63 | /** 64 | * 通过id删除实体 65 | * 66 | * @param id id 67 | * @return 提示信息 68 | */ 69 | @Override 70 | public Integer deleteById(String id) { 71 | return mapper.deleteByPrimaryKey(id); 72 | } 73 | 74 | /** 75 | * 删除实体 76 | * 77 | * @param t 78 | */ 79 | @Override 80 | public void delete(T t) { 81 | mapper.delete(t); 82 | } 83 | 84 | 85 | public M getMapper() { 86 | return mapper; 87 | } 88 | 89 | public void setMapper(M mapper) { 90 | this.mapper = mapper; 91 | } 92 | } -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/mpcv/MpCvService.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.mpcv; 2 | import com.github.pagehelper.PageInfo; 3 | import com.weisi.veems.models.elasticsearch.Mpcv; 4 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.io.IOException; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * @description:查询历史抄表记录 13 | * @author:@luomouren. 14 | * @Date:2017-12-03 15:17 15 | */ 16 | @Repository 17 | public interface MpCvService{ 18 | /** 19 | * 保存历史抄表示数 20 | * @param mpcv 历史抄表示数 21 | */ 22 | void save(Mpcv mpcv) ; 23 | 24 | /** 25 | * 更新抄表示数 26 | */ 27 | void update(Mpcv mpcv); 28 | 29 | /** 30 | * 查询表计示数 31 | * @param cvId 表计cvId 32 | */ 33 | PageInfo searchMpCv(String cvId); 34 | 35 | /** 36 | * 根据CVID查询表计示数信息 37 | */ 38 | Mpcv selectByPrimaryKey(String id); 39 | 40 | /** 41 | * 根据ID删除对象 42 | * @param id 43 | */ 44 | void deleteByPrimaryKey(String id); 45 | } 46 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/mpcv/impl/MpCvServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.mpcv.impl; 2 | import com.github.pagehelper.PageInfo; 3 | import com.weisi.veems.models.elasticsearch.Mpcv; 4 | import com.weisi.veems.repository.ElasticSearchRepository; 5 | import com.weisi.veems.services.mpcv.MpCvService; 6 | import io.searchbox.client.JestClient; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import java.util.List; 12 | 13 | /** 14 | * @description:保存历史抄表示数 15 | * @author:@luomouren. 16 | * @Date:2017-12-03 16:45 17 | */ 18 | @Service 19 | public class MpCvServiceImpl extends ElasticSearchRepository implements MpCvService { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(MpCvServiceImpl.class); 22 | 23 | @Override 24 | public void save(Mpcv mpcv) { 25 | super.save(mpcv,Mpcv.INDEX_NAME,Mpcv.TYPE); 26 | } 27 | 28 | @Override 29 | public void update(Mpcv mpcv) { 30 | super.updateDocument(mpcv,Mpcv.INDEX_NAME,Mpcv.TYPE,mpcv.getId()); 31 | } 32 | 33 | /** 34 | * 分页查询测点的cv信息 35 | * @param searchContent 36 | * @return 37 | */ 38 | @Override 39 | public PageInfo searchMpCv(String searchContent) { 40 | List cvList = super.createSearch(searchContent,Mpcv.INDEX_NAME,Mpcv.TYPE,new Mpcv(),"cvId"); 41 | return new PageInfo(cvList); 42 | } 43 | 44 | @Override 45 | public Mpcv selectByPrimaryKey(String id) { 46 | Mpcv mpcv = (Mpcv) super.getDocument(new Mpcv(), Mpcv.INDEX_NAME,Mpcv.TYPE,id); 47 | return mpcv; 48 | } 49 | 50 | @Override 51 | public void deleteByPrimaryKey(String id) { 52 | deleteDocument(Mpcv.INDEX_NAME,Mpcv.TYPE,id); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/permission/SysPermissonService.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.permission; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.weisi.common.ZtreeView; 5 | import com.weisi.veems.mapper.sys.SysPermissionMapper; 6 | import com.weisi.veems.models.sys.SysPermission; 7 | import com.weisi.veems.services.base.BaseService; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author:luomouren 13 | * @description:系统所有权限 14 | * @dateTime: created in 2018-04-10 20:14 15 | * @modified by: 16 | **/ 17 | public interface SysPermissonService extends BaseService { 18 | 19 | /** 20 | * 根据用户查询其下面所有权限 21 | * 22 | * @param userId 23 | * @return 24 | */ 25 | List findPermissionListByUserId(String userId); 26 | 27 | /** 28 | * 传入所有权限list,将其按照父子关系组装 29 | * @param permiissionList 30 | * @return 31 | */ 32 | List formatChildPermission(List permiissionList); 33 | 34 | /** 35 | * 根据用户主键,获取其权限下所有的menu,按照sort asc排序 36 | * @param userId 37 | * @return 38 | */ 39 | List findMenuListByUserId(String userId); 40 | 41 | /** 42 | * 分页查找所有的用户 43 | * @param pageNum 当前页码,从1开始 44 | * @param pageSize 一页显示多少行 45 | * @param orderBy 排序字段+排序方式 46 | * @return 47 | */ 48 | PageInfo findAll(int pageNum, int pageSize,String orderBy); 49 | 50 | /** 51 | * 获取角色的权限树 52 | * 53 | * @param roleId 54 | * @return 55 | */ 56 | List tree(String roleId); 57 | } 58 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/permission/impl/SysPermissionImpl.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.permission.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.weisi.common.ZtreeView; 6 | import com.weisi.veems.frame.constants.SysPermissionConstants; 7 | import com.weisi.veems.mapper.sys.SysMapRolePermissionMapper; 8 | import com.weisi.veems.mapper.sys.SysPermissionMapper; 9 | import com.weisi.veems.mapper.sys.SysRoleMapper; 10 | import com.weisi.veems.models.sys.SysPermission; 11 | import com.weisi.veems.services.base.impl.BaseServiceImpl; 12 | import com.weisi.veems.services.permission.SysPermissonService; 13 | import org.apache.commons.lang.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * @author:luomouren 22 | * @description:系统所有操作权限 23 | * @dateTime: created in 2018-04-10 20:15 24 | * @modified by: 25 | **/ 26 | @Service 27 | public class SysPermissionImpl extends BaseServiceImpl implements SysPermissonService { 28 | 29 | @Autowired 30 | private SysPermissionMapper sysPermissionMapper; 31 | @Autowired 32 | private SysRoleMapper sysRoleMapper; 33 | @Autowired 34 | private SysMapRolePermissionMapper sysMapRolePermissionMapper; 35 | 36 | @Override 37 | public List findPermissionListByUserId(String userId) { 38 | return sysPermissionMapper.findPermissionListByUserId(userId); 39 | } 40 | 41 | @Override 42 | public List findMenuListByUserId(String userId) { 43 | return sysPermissionMapper.findMenuListByUserId(userId); 44 | } 45 | 46 | @Override 47 | public List formatChildPermission(List permiissionList) { 48 | // 最后的结果 49 | List menuList = new ArrayList(); 50 | // 先找到所有的一级菜单 51 | for(SysPermission permission:permiissionList){ 52 | if(SysPermissionConstants.FIST_MENU == permission.getPermissionType()){ 53 | menuList.add(permission); 54 | } 55 | } 56 | // 为一级菜单设置子菜单,getChild是递归调用的 57 | for (SysPermission menu : menuList) { 58 | menu.setChildList(getChild(menu.getPermissionId(), permiissionList)); 59 | } 60 | 61 | return menuList; 62 | } 63 | 64 | /** 65 | * 递归查找子菜单 66 | * 67 | * @param id 68 | * 当前菜单id 69 | * @param rootMenu 70 | * 要查找的列表 71 | * @return 72 | */ 73 | private List getChild(String id, List rootMenu) { 74 | // 子菜单 75 | List childList = new ArrayList<>(); 76 | for (SysPermission menu : rootMenu) { 77 | // 遍历所有节点,将父菜单id与传过来的id比较 78 | if (StringUtils.isNotBlank(menu.getPermissionId())) { 79 | if ( menu.getParentPermissionId() !=null && id.equals(menu.getParentPermissionId()) ) { 80 | childList.add(menu); 81 | } 82 | } 83 | } 84 | // 把子菜单的子菜单再循环一遍 85 | for (SysPermission menu : childList) { 86 | // 没有url子菜单还有子菜单 87 | if ("javascript:void(0);".equalsIgnoreCase(menu.getUrl())) { 88 | // 递归 89 | menu.setChildList(getChild(menu.getPermissionId(), rootMenu)); 90 | } 91 | } 92 | // 递归退出条件 93 | if (childList.size() == 0) { 94 | return null; 95 | } 96 | return childList; 97 | } 98 | 99 | 100 | @Override 101 | public PageInfo findAll(int pageNum, int pageSize,String sortOrder) { 102 | PageHelper.startPage(pageNum, pageSize); 103 | PageHelper.orderBy(sortOrder); 104 | List results = sysPermissionMapper.selectAll(); 105 | return new PageInfo(results); 106 | } 107 | 108 | @Override 109 | public List tree(String roleId) { 110 | List resulTreeNodes = new ArrayList(); 111 | List permissionIds = sysMapRolePermissionMapper.findAllPermissionIds(roleId); 112 | ZtreeView node; 113 | List allPermissions = sysPermissionMapper.findAllByOrderByParentAscIdAscSortAsc(); 114 | for (SysPermission resource : allPermissions) { 115 | node = new ZtreeView(); 116 | node.setId(resource.getPermissionId()); 117 | if (resource.getParentPermissionId() == null) { 118 | node.setId(resource.getPermissionId()); 119 | } else { 120 | node.setPId(resource.getParentPermissionId()); 121 | } 122 | node.setName(resource.getPermissionName()); 123 | if (permissionIds != null && permissionIds.contains(resource.getPermissionId())) { 124 | node.setChecked(true); 125 | } 126 | resulTreeNodes.add(node); 127 | } 128 | return resulTreeNodes; 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/role/SysRoleService.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.role; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.weisi.veems.mapper.sys.SysRoleMapper; 5 | import com.weisi.veems.models.sys.SysRole; 6 | import com.weisi.veems.services.base.BaseService; 7 | 8 | /** 9 | * 角色信息 10 | * 11 | * @author luomouren 12 | */ 13 | public interface SysRoleService extends BaseService { 14 | 15 | /** 16 | * 分页查找所有的角色 17 | * 18 | * @param pageNum 当前页码,从1开始 19 | * @param pageSize 一页显示多少行 20 | * @return 21 | */ 22 | PageInfo findAll(int pageNum, int pageSize); 23 | 24 | /** 25 | * 给角色分配权限 26 | * 27 | * @param id 角色ID 28 | * @param permissionIds 权限ids 29 | */ 30 | void grant(String id, String[] permissionIds); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/role/impl/SysRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.role.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.weisi.veems.mapper.sys.SysMapRolePermissionMapper; 6 | import com.weisi.veems.mapper.sys.SysRoleMapper; 7 | import com.weisi.veems.models.sys.SysRole; 8 | import com.weisi.veems.services.base.impl.BaseServiceImpl; 9 | import com.weisi.veems.services.role.SysRoleService; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * 系统角色service 19 | * 20 | * @author luomouren 21 | */ 22 | @Service 23 | public class SysRoleServiceImpl extends BaseServiceImpl implements SysRoleService { 24 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 25 | 26 | @Autowired 27 | private SysRoleMapper sysRoleMapper; 28 | @Autowired 29 | private SysMapRolePermissionMapper sysMapRolePermissionMapper; 30 | 31 | @Override 32 | public PageInfo findAll(int pageNum, int pageSize) { 33 | PageHelper.startPage(pageNum, pageSize); 34 | List roles = sysRoleMapper.selectAll(); 35 | return new PageInfo(roles); 36 | } 37 | 38 | @Override 39 | public void grant(String id, String[] permissionIds) { 40 | sysMapRolePermissionMapper.grant(id,permissionIds); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/user/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.user; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.weisi.veems.mapper.sys.SysUserMapper; 5 | import com.weisi.veems.models.sys.SysUser; 6 | import com.weisi.veems.services.base.BaseService; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 用户信息 12 | * 13 | * @author luomouren 14 | */ 15 | public interface SysUserService extends BaseService { 16 | 17 | /** 18 | * 根据用户名查找用户 19 | * 20 | * @param userName 用户名 21 | * @return 22 | */ 23 | SysUser findByUserName(String userName); 24 | 25 | 26 | /** 27 | * 分页查找所有的用户 28 | * @param pageNum 当前页码,从1开始 29 | * @param pageSize 一页显示多少行 30 | * @return 31 | */ 32 | PageInfo findAll(int pageNum, int pageSize); 33 | 34 | /** 35 | * 分配角色 36 | * @param id 用户id 37 | * @param roleIds 角色id 38 | */ 39 | void grant(String id, String[] roleIds); 40 | 41 | /** 42 | * 修改用户密码 43 | * 44 | * @param user 45 | * @param oldPassword 46 | * @param password1 47 | * @param password2 48 | */ 49 | void updatePwd(SysUser user, String oldPassword, String password1, String password2); 50 | 51 | /** 52 | * 根据用户id查找roleIds 53 | * 54 | * @param userId 用户id 55 | * @return 56 | */ 57 | List findRoleIdsByUserId(String userId); 58 | 59 | /** 60 | * 新建保存用户,自动生成salt盐,加密password保存 61 | * @param user 62 | */ 63 | void save(SysUser user); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /web/src/main/java/com/weisi/veems/services/user/impl/SysUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.weisi.veems.services.user.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.weisi.veems.frame.constants.UserPasswordConstants; 6 | import com.weisi.veems.mapper.sys.SysMapUserRoleMapper; 7 | import com.weisi.veems.mapper.sys.SysUserMapper; 8 | import com.weisi.veems.models.sys.SysUser; 9 | import com.weisi.veems.services.base.impl.BaseServiceImpl; 10 | import com.weisi.veems.services.user.SysUserService; 11 | import org.apache.commons.codec.binary.Base64; 12 | import org.apache.shiro.crypto.hash.SimpleHash; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.util.Assert; 18 | 19 | import java.security.SecureRandom; 20 | import java.util.List; 21 | import java.util.UUID; 22 | 23 | /** 24 | * 系统用户service 25 | * 26 | * @author luomouren 27 | */ 28 | @Service 29 | public class SysUserServiceImpl extends BaseServiceImpl implements SysUserService { 30 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 31 | 32 | @Autowired 33 | private SysUserMapper sysUserMapper; 34 | @Autowired 35 | private SysMapUserRoleMapper sysMapUserRoleMapper; 36 | 37 | @Override 38 | public SysUser findByUserName(String userName) { 39 | return sysUserMapper.findByUserName(userName); 40 | } 41 | 42 | @Override 43 | public PageInfo findAll(int pageNum, int pageSize) { 44 | PageHelper.startPage(pageNum, pageSize); 45 | List users = sysUserMapper.selectAll(); 46 | return new PageInfo(users); 47 | } 48 | 49 | @Override 50 | public void grant(String id, String[] roleIds) { 51 | sysMapUserRoleMapper.grant(id, roleIds); 52 | } 53 | 54 | @Override 55 | public List findRoleIdsByUserId(String userId) { 56 | return sysMapUserRoleMapper.findRoleIdsByUserId(userId); 57 | } 58 | 59 | @Override 60 | public void updatePwd(SysUser user, String oldPassword, String password1, String password2) { 61 | Assert.notNull(user, "用户不能为空"); 62 | Assert.notNull(oldPassword, "原始密码不能为空"); 63 | Assert.notNull(password1, "新密码不能为空"); 64 | Assert.notNull(password2, "重复密码不能为空"); 65 | 66 | SysUser dbUser = sysUserMapper.findByUserName(user.getUserName()); 67 | Assert.notNull(dbUser, "用户不存在"); 68 | 69 | String salt = dbUser.getSalt(); 70 | // 旧密码加密后与数据库中的原密码比较是否一致 71 | String oldPasswordEncrypt = new SimpleHash(UserPasswordConstants.HASHALGORITHM_NAME, oldPassword, 72 | salt, UserPasswordConstants.HASHITERATIONS).toString(); 73 | Assert.isTrue(user.getPassword().equals(oldPasswordEncrypt), "原始密码不正确"); 74 | Assert.isTrue(password1.equals(password2), "两次密码不一致"); 75 | String password1Encrypt = new SimpleHash(UserPasswordConstants.HASHALGORITHM_NAME, password1, 76 | salt, UserPasswordConstants.HASHITERATIONS).toString(); 77 | dbUser.setPassword(password1Encrypt); 78 | sysUserMapper.updateByPrimaryKey(dbUser); 79 | } 80 | 81 | @Override 82 | public void save(SysUser user) { 83 | if (null != user) { 84 | String password = user.getPassword(); 85 | user.setUserId(UUID.randomUUID() + ""); 86 | 87 | // 生成随机salt 88 | SecureRandom random = new SecureRandom(); 89 | byte bytes[] = new byte[16]; 90 | random.nextBytes(bytes); 91 | String salt = Base64.encodeBase64String(bytes); 92 | user.setSalt(salt); 93 | 94 | // 加密密码 95 | String passwordEncrypt = new SimpleHash(UserPasswordConstants.HASHALGORITHM_NAME, password, 96 | salt, UserPasswordConstants.HASHITERATIONS).toString(); 97 | user.setPassword(passwordEncrypt); 98 | 99 | this.insert(user); 100 | } 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #MySQL配置 2 | spring.datasource.url=jdbc:mysql://localhost:3306/biaozhunhua?useSSL=false 3 | spring.datasource.username=root 4 | spring.datasource.password=123456 5 | 6 | #ELASTICSEARCH配置 7 | spring.elasticsearch.jest.uris=http://192.168.1.162:9200 8 | spring.elasticsearch.jest.read-timeout=5000 9 | 10 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 11 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 12 | #初始化连接大小 13 | spring.datasource.druid.initial-size=8 14 | #最小空闲连接数 15 | spring.datasource.druid.min-idle=5 16 | #最大连接数 17 | spring.datasource.druid.max-active=10 18 | #查询超时时间 19 | spring.datasource.druid.query-timeout=6000 20 | #事务查询超时时间 21 | spring.datasource.druid.transaction-query-timeout=6000 22 | #关闭空闲连接超时时间 23 | spring.datasource.druid.remove-abandoned-timeout=1800 24 | spring.datasource.druid.filter-class-names=stat 25 | spring.datasource.druid.filters=stat,config 26 | 27 | #mybatis通用Mapper 28 | mapper.mappers=com.weisi.veems.frame.init.TkMapper 29 | mapper.not-empty=false 30 | mapper.identity=MYSQL 31 | 32 | #myBatis的配置路径 33 | mybatis.config-locations=classpath:mybatis/mybatis-config.xml 34 | #myBatis model的查询sql.xml 35 | mybatis.mapper-locations=classpath*:mybatis/mapper/*.xml 36 | #自动扫描需要定义类别名的包,将包内的JAVA类的类名作为类别名,对应models 37 | mybatis.type-aliases-package=com.weisi.veems.models 38 | 39 | #当前是开发环境dev还是正式环境prod,在日志文件logback-spring.xml中用到 40 | spring.profiles.active=prod 41 | 42 | ## Freemarker 配置 43 | ## 文件配置路径 44 | spring.freemarker.template-loader-path=classpath:/web/ 45 | spring.freemarker.cache=false 46 | spring.freemarker.charset=UTF-8 47 | spring.freemarker.check-template-location=true 48 | spring.freemarker.content-type=text/html 49 | spring.freemarker.expose-request-attributes=true 50 | spring.freemarker.expose-session-attributes=true 51 | spring.freemarker.request-context-attribute=request 52 | spring.freemarker.suffix=.ftl 53 | 54 | 55 | #设定静态文件路径,js,css等 56 | spring.mvc.static-path-pattern=/** 57 | 58 | #设置热部署 59 | #开启热部署 60 | spring.devtools.restart.enabled=true 61 | #重启范围 62 | spring.devtools.restart.additional-paths=web/src/main/java -------------------------------------------------------------------------------- /web/src/main/resources/biaozhunhua_init.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog Professional v12.08 (64 bit) 3 | MySQL - 5.7.17 : Database - biaozhunhua 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`biaozhunhua` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `biaozhunhua`; 18 | 19 | /*Table structure for table `sys_log` */ 20 | 21 | DROP TABLE IF EXISTS `sys_log`; 22 | 23 | CREATE TABLE `sys_log` ( 24 | `LOG_ID` varchar(36) NOT NULL, 25 | `USER_ID` varchar(36) DEFAULT NULL, 26 | `OPERATION_NAME` varchar(30) NOT NULL, 27 | `LOG_TIME` datetime NOT NULL, 28 | `RESULT` tinyint(1) DEFAULT NULL, 29 | `RESULT_DESCRIPTION` varchar(200) DEFAULT NULL, 30 | PRIMARY KEY (`LOG_ID`), 31 | KEY `FK_SYS_LOG_USER` (`USER_ID`), 32 | CONSTRAINT `FK_SYS_LOG_USER` FOREIGN KEY (`USER_ID`) REFERENCES `sys_user` (`USER_ID`) 33 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 34 | 35 | /*Data for the table `sys_log` */ 36 | 37 | /*Table structure for table `sys_map_role_permission` */ 38 | 39 | DROP TABLE IF EXISTS `sys_map_role_permission`; 40 | 41 | CREATE TABLE `sys_map_role_permission` ( 42 | `ROLE_ID` varchar(36) NOT NULL, 43 | `PERMISSION_ID` varchar(36) NOT NULL, 44 | PRIMARY KEY (`ROLE_ID`,`PERMISSION_ID`), 45 | KEY `FK_SYS_MAP_ROLE_PERMISSION` (`PERMISSION_ID`), 46 | CONSTRAINT `FK_SYS_MAP_ROLE_PERMISSION` FOREIGN KEY (`PERMISSION_ID`) REFERENCES `sys_permission` (`PERMISSION_ID`), 47 | CONSTRAINT `FK_SYS_MAP_ROME_PERMISSION_ROLE` FOREIGN KEY (`ROLE_ID`) REFERENCES `sys_role` (`ROLE_ID`) 48 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 49 | 50 | /*Data for the table `sys_map_role_permission` */ 51 | 52 | insert into `sys_map_role_permission`(`ROLE_ID`,`PERMISSION_ID`) values ('admin','111111111112'),('admin','111111111132'),('admin','111111111133'),('admin','111111111134'),('admin','111111111135'),('admin','111111111136'),('admin','111111111137'),('admin','111111111142'),('admin','111111111143'),('admin','111111111144'),('admin','111111111145'),('admin','111111111146'),('admin','111111111147'),('admin','111111111152'),('admin','111111111153'),('admin','111111111154'),('admin','111111111155'),('admin','22222222222220'),('admin','22222222222221'); 53 | 54 | /*Table structure for table `sys_map_user_role` */ 55 | 56 | DROP TABLE IF EXISTS `sys_map_user_role`; 57 | 58 | CREATE TABLE `sys_map_user_role` ( 59 | `USER_ID` varchar(36) NOT NULL, 60 | `ROLE_ID` varchar(36) NOT NULL, 61 | PRIMARY KEY (`USER_ID`,`ROLE_ID`), 62 | KEY `FK_SYS_USER_ROLE_SYS_ROLE` (`ROLE_ID`), 63 | CONSTRAINT `FK_SYS_USER_ROLE_SYS_ROLE` FOREIGN KEY (`ROLE_ID`) REFERENCES `sys_role` (`ROLE_ID`), 64 | CONSTRAINT `FK_SYS_USER_ROLE_SYS_USER` FOREIGN KEY (`USER_ID`) REFERENCES `sys_user` (`USER_ID`) 65 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 66 | 67 | /*Data for the table `sys_map_user_role` */ 68 | 69 | insert into `sys_map_user_role`(`USER_ID`,`ROLE_ID`) values ('admin','admin'),('ceshi','admin'); 70 | 71 | /*Table structure for table `sys_permission` */ 72 | 73 | DROP TABLE IF EXISTS `sys_permission`; 74 | 75 | CREATE TABLE `sys_permission` ( 76 | `PERMISSION_ID` varchar(36) NOT NULL, 77 | `PERMISSION_NAME` varchar(128) NOT NULL, 78 | `PERMISSION_TYPE` int(1) NOT NULL, 79 | `URL` varchar(128) NOT NULL, 80 | `PERCODE` varchar(128) NOT NULL, 81 | `PARENT_PERMISSION_ID` varchar(36) DEFAULT NULL, 82 | `SORT` int(2) NOT NULL, 83 | `IS_AVAILABLE` tinyint(1) NOT NULL DEFAULT '1', 84 | `ICON` varchar(30) DEFAULT NULL, 85 | PRIMARY KEY (`PERMISSION_ID`), 86 | KEY `FK_SYS_MAP_PERMISSION_PERMISSION` (`PARENT_PERMISSION_ID`), 87 | CONSTRAINT `FK_SYS_MAP_PERMISSION_PERMISSION` FOREIGN KEY (`PARENT_PERMISSION_ID`) REFERENCES `sys_permission` (`PERMISSION_ID`) 88 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 89 | 90 | /*Data for the table `sys_permission` */ 91 | 92 | insert into `sys_permission`(`PERMISSION_ID`,`PERMISSION_NAME`,`PERMISSION_TYPE`,`URL`,`PERCODE`,`PARENT_PERMISSION_ID`,`SORT`,`IS_AVAILABLE`,`ICON`) values ('111111111112','配置管理',1,'javascript:void(0);','system1',NULL,1,1,'fa-cog'),('111111111132','用户管理',2,'/user/index','system:user:index','111111111112',10,1,'fa-user-o'),('111111111133','用户新增',3,'/user/add','system:user:add','111111111132',0,1,NULL),('111111111134','用户修改',3,'/user/edit','system:user:edit','111111111132',0,1,NULL),('111111111135','用户删除',3,'/user/delete','system:user:delete','111111111132',0,1,NULL),('111111111136','用户角色分配',3,'/user/grant','system:user:grant','111111111132',0,1,NULL),('111111111137','用户密码修改',3,'/user/updatePwd','system:user:updatePwd','111111111132',0,1,NULL),('111111111142','角色管理',2,'/role/index','system:role:index','111111111112',20,1,'fa-user-circle-o'),('111111111143','角色新增',3,'/role/add','system:role:add','111111111142',0,1,NULL),('111111111144','角色修改',3,'/role/edit','system:role:edit','111111111142',0,1,NULL),('111111111145','角色删除',3,'/role/delete','system:role:delete','111111111142',0,1,NULL),('111111111146','角色角色分配',3,'/role/grant','system:role:grant','111111111142',0,1,NULL),('111111111147','角色密码修改',3,'/role/updatePwd','system:role:updatePwd','111111111142',0,1,NULL),('111111111152','权限管理',2,'/permission/index','system:permission:index','111111111112',30,1,'fa-file-o'),('111111111153','权限新增',3,'/permission/add','system:permission:add','111111111152',0,1,NULL),('111111111154','权限修改',3,'/permission/edit','system:permission:edit','111111111152',0,1,NULL),('111111111155','权限删除',3,'/permission/delete','system:permission:delete','111111111152',0,1,NULL),('22222222222220','数据查询',1,'javascript:void(0);','dataSearch','22333333333331',100,1,'fa-search'),('22222222222221','历史数据查询',2,'/mpcv/index','dataSearch:mpcv:index','22222222222220',110,1,'fa-star'); 93 | 94 | /*Table structure for table `sys_role` */ 95 | 96 | DROP TABLE IF EXISTS `sys_role`; 97 | 98 | CREATE TABLE `sys_role` ( 99 | `ROLE_ID` varchar(36) NOT NULL, 100 | `ROLE_NAME` varchar(30) DEFAULT NULL, 101 | `IS_AVAILABLE` tinyint(1) DEFAULT '1', 102 | PRIMARY KEY (`ROLE_ID`) 103 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 104 | 105 | /*Data for the table `sys_role` */ 106 | 107 | insert into `sys_role`(`ROLE_ID`,`ROLE_NAME`,`IS_AVAILABLE`) values ('1a3388b2-6eaa-4c39-b6df-a497ebb8eff1','北京广元科技',1),('6a2e077e-d544-4740-b41e-7556c7027022','呜呜呜',1),('admin','admin',1); 108 | 109 | /*Table structure for table `sys_user` */ 110 | 111 | DROP TABLE IF EXISTS `sys_user`; 112 | 113 | CREATE TABLE `sys_user` ( 114 | `USER_ID` varchar(36) NOT NULL, 115 | `CUSTOMER_ID` varchar(36) DEFAULT NULL, 116 | `USER_NAME` varchar(30) NOT NULL, 117 | `REAL_NAME` varchar(30) NOT NULL, 118 | `PASSWORD` varchar(32) NOT NULL, 119 | `USER_CATEGORY` int(1) NOT NULL, 120 | `POSITION_JOB` varchar(30) DEFAULT NULL, 121 | `EMAIL` varchar(50) DEFAULT NULL, 122 | `CELLPHONE` varchar(15) DEFAULT NULL, 123 | `TEL` varchar(15) DEFAULT NULL, 124 | `SALT` varchar(24) NOT NULL, 125 | `IS_LOCKED` tinyint(1) NOT NULL DEFAULT '0', 126 | PRIMARY KEY (`USER_ID`), 127 | KEY `FK_SYS_USER_CUSTOMER_USER` (`CUSTOMER_ID`), 128 | CONSTRAINT `FK_SYS_USER_CUSTOMER_USER` FOREIGN KEY (`CUSTOMER_ID`) REFERENCES `bzh_customer_user` (`CUSTOMER_ID`) 129 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 130 | 131 | /*Data for the table `sys_user` */ 132 | 133 | insert into `sys_user`(`USER_ID`,`CUSTOMER_ID`,`USER_NAME`,`REAL_NAME`,`PASSWORD`,`USER_CATEGORY`,`POSITION_JOB`,`EMAIL`,`CELLPHONE`,`TEL`,`SALT`,`IS_LOCKED`) values ('83930a16-f610-4707-9217-701291311e18',NULL,'guangyuan','广元科技','204514a72406943d960dc00f471455b6',1,'测试账号','guangyuan@guangyuanbj.com','100010','18810378647','YoGpm/yje1xmw7EFQo3UUg==',0),('admin',NULL,'lisi','李四','cb571f7bd7a6f73ab004a70322b963d5',1,'经理','test@qq.com','100865','18810378647','eteokues',0),('b6750c5e-c2ca-4954-9fa6-43d960f7823c',NULL,'zhangsan','张三','f63c861a8adfef47f5064993d73779c3',1,'测试人员','11','11','11','VJIessf8PKAteb2VFHInhA==',0),('c9848dd9-acd7-4a84-9548-5c3016e14486',NULL,'liming','李明','0e2c4189fbc769ce528ba09763088d23',1,'','','','','R/iZWeiLFGILxnAVEiZAeg==',0),('ceshi',NULL,'ceshi','测试test','cb571f7bd7a6f73ab004a70322b963d5',1,'测试经理','test@163.com','100865','18810378647','eteokues',0),('d014c03e-7c09-471e-ac21-4fe4577549d0',NULL,'cesaaa','测试账号','23798a0002015eed63a366003fc4d47f',1,'','','','','suJsNaqGBGX6fUga502hIA==',0),('d6922280-fbb6-4aca-b5c8-d823555e0788',NULL,'wangwu','王五','4ed126748f829c370d9fe4ff9023ce72',1,'测试','','','','VJlqjxnoLFz891XETB/0bg==',0),('test',NULL,'test','测试','cb571f7bd7a6f73ab004a70322b963d5',1,'初级测试用户','test@foxmail.com','100865','18810378647','eteokues',0); 134 | 135 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 136 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 137 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 138 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 139 | -------------------------------------------------------------------------------- /web/src/main/resources/druid-bean.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | com.weisi.veems.mapper.* 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /web/src/main/resources/ehcache-shiro.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 32 | 33 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /web/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | logback 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | true 14 | 15 | 16 | log/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log 17 | 18 | 19 | 20 | 21 | %d{yyyy-MM-dd HH:mm:ss} -%msg%n 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /web/src/main/resources/mybatis/mapper/SysMapRolePermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | insert into sys_map_role_permission(ROLE_ID, PERMISSION_ID) values 10 | 11 | (#{roleId}, #{permission}) 12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /web/src/main/resources/mybatis/mapper/SysMapUserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | insert into sys_map_user_role(user_id, role_id) values 14 | 15 | (#{userId}, #{role}) 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /web/src/main/resources/mybatis/mapper/SysPermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 34 | 35 | 36 | 53 | 54 | 55 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /web/src/main/resources/mybatis/mapper/SysRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /web/src/main/resources/mybatis/mapper/SysUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | sys_user 27 | 28 | 29 | 30 | USER_ID, USER_NAME, REAL_NAME, PASSWORD, 31 | USER_CATEGORY,POSITION_JOB,EMAIL,CELLPHONE,TEL,SALT,IS_LOCKED 32 | 33 | 34 | 35 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /web/src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/img/permission/unauthorized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luomouren/veems/2ee0fefeabc6e92605b27e4812ad429340823d0c/web/src/main/resources/static/assets/img/permission/unauthorized.png -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/img/screenshot/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luomouren/veems/2ee0fefeabc6e92605b27e4812ad429340823d0c/web/src/main/resources/static/assets/img/screenshot/home.png -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/img/screenshot/permission.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luomouren/veems/2ee0fefeabc6e92605b27e4812ad429340823d0c/web/src/main/resources/static/assets/img/screenshot/permission.png -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/img/screenshot/role.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luomouren/veems/2ee0fefeabc6e92605b27e4812ad429340823d0c/web/src/main/resources/static/assets/img/screenshot/role.png -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/img/screenshot/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luomouren/veems/2ee0fefeabc6e92605b27e4812ad429340823d0c/web/src/main/resources/static/assets/img/screenshot/user.png -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/img/user/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luomouren/veems/2ee0fefeabc6e92605b27e4812ad429340823d0c/web/src/main/resources/static/assets/img/user/avatar.png -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/js/test/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by luomouren on 2018-01-28. 3 | */ 4 | 5 | function clickTestBotton(){ 6 | alert(1); 7 | } -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/js/test/myChart.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Created by luomouren on 2018-01-28. 4 | */ 5 | 6 | function initEcharts(){ 7 | var myChart = echarts.init(document.getElementById('myChart')); 8 | var option = { 9 | title: { 10 | text: '堆叠区域图' 11 | }, 12 | tooltip : { 13 | trigger: 'axis', 14 | axisPointer: { 15 | type: 'cross', 16 | label: { 17 | backgroundColor: '#6a7985' 18 | } 19 | } 20 | }, 21 | legend: { 22 | data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎'] 23 | }, 24 | toolbox: { 25 | feature: { 26 | saveAsImage: {} 27 | } 28 | }, 29 | grid: { 30 | left: '3%', 31 | right: '4%', 32 | bottom: '3%', 33 | containLabel: true 34 | }, 35 | xAxis : [ 36 | { 37 | type : 'category', 38 | boundaryGap : false, 39 | data : ['周一','周二','周三','周四','周五','周六','周日'] 40 | } 41 | ], 42 | yAxis : [ 43 | { 44 | type : 'value' 45 | } 46 | ], 47 | series : [ 48 | { 49 | name:'邮件营销', 50 | type:'line', 51 | stack: '总量', 52 | areaStyle: {normal: {}}, 53 | data:[120, 132, 101, 134, 90, 230, 210] 54 | }, 55 | { 56 | name:'联盟广告', 57 | type:'line', 58 | stack: '总量', 59 | areaStyle: {normal: {}}, 60 | data:[220, 182, 191, 234, 290, 330, 310] 61 | }, 62 | { 63 | name:'视频广告', 64 | type:'line', 65 | stack: '总量', 66 | areaStyle: {normal: {}}, 67 | data:[150, 232, 201, 154, 190, 330, 410] 68 | }, 69 | { 70 | name:'直接访问', 71 | type:'line', 72 | stack: '总量', 73 | areaStyle: {normal: {}}, 74 | data:[320, 332, 301, 334, 390, 330, 320] 75 | }, 76 | { 77 | name:'搜索引擎', 78 | type:'line', 79 | stack: '总量', 80 | label: { 81 | normal: { 82 | show: true, 83 | position: 'top' 84 | } 85 | }, 86 | areaStyle: {normal: {}}, 87 | data:[820, 932, 901, 934, 1290, 1330, 1320] 88 | } 89 | ] 90 | }; 91 | 92 | // 使用刚指定的配置项和数据显示图表。 93 | myChart.setOption(option); 94 | 95 | } 96 | 97 | initEcharts(); -------------------------------------------------------------------------------- /web/src/main/resources/static/assets/js/user/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by luomouren on 2018-01-28. 3 | */ 4 | 5 | function findUserInfoByUsername(){ 6 | var url = "getByUserName"; 7 | // 用户名 8 | var username=$("#username").val(); 9 | var param={}; 10 | param["username"] = username; 11 | $.ajax({ 12 | url:url, 13 | type:"GET", 14 | dataType:'json', 15 | data:param, 16 | success:function(data) { 17 | console.log("data",data); 18 | // {"userId":"e5792c05-fa1c-4ffa-9adb-aa66f2cd8863","userName":"bzh","realName":"管理员","userPassword":"25d55ad283aa400af464c76d713c07ad","email":"","cellphone":"","createdTime":"2013-04-03T16:00:00.000+0000","description":null,"deleted":false,"firstLogin":false,"showStartPage":true,"enable":true} 19 | var returnMsg = '

userId:' + data.userId + '

' 20 | +'

userName:' + data.userName + '

' 21 | +'

realName:' + data.realName + '

'; 22 | $("#userInfo").html(returnMsg); 23 | }, 24 | error:function(e){ 25 | console.log("login error",e) 26 | } 27 | }); 28 | } -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/index.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <@layout title="主页" active="home"> 3 | 4 |
5 |

6 | 首页 7 | 一切从这里开始 8 |

9 | 13 |
14 | 15 | 16 |
17 | 18 |
19 |
20 | 欢迎使用 21 |
22 | 23 |
24 | 25 | 26 |
27 | 28 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/layout/layout.ftl: -------------------------------------------------------------------------------- 1 | <#macro layout title="" active=""> 2 | 3 | 4 | 5 | 6 | 7 | GEM-View - ${title!} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ${css!}<#--具体ftl中用到的css--> 29 | 30 | 31 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | <#--其中class为skin-blue表示用AdminLTE中蓝肤色--> 42 | 43 | 44 |
45 | 46 |
47 | 48 | 54 | 55 | 97 |
98 | 99 | 100 | 131 | 132 | 133 | 134 | 135 |
136 | <#nested > 137 |
138 | 139 | 140 |
141 | 144 | Copyright © 2018 Guangyuan. All rights 145 | reserved. 146 |
147 |
148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 208 | 209 | 210 | 211 | <#--具体ftl中用到的js--> 212 | ${js!} 213 | 214 | 215 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/layout/macro.ftl: -------------------------------------------------------------------------------- 1 | <#macro page pageInfo url> 2 | <#--当前页--> 3 | <#local pageNo = pageInfo.pageNum> 4 | <#--总共有多少页--> 5 | <#local totalPage = pageInfo.pages> 6 | <#--获得一页显示的条数--> 7 | <#local pageSize = pageInfo.pageSize> 8 | <#--是否是第一页--> 9 | <#local isFirstPage = pageInfo.isFirstPage> 10 | <#--是否是最后一页--> 11 | <#local isLastPage = pageInfo.isLastPage> 12 | 13 | 14 | <#local showPages = 6> 15 |
    16 | <#if pageNo!=1 && totalPage gt 1> 17 |
  • 首页
  • 18 |
  • 上一页
  • 19 | 20 | <#if pageNo-showPages/2 gt 0> 21 | <#assign start = pageNo-(showPages-1)/2/> 22 | <#if showPages gt totalPage> 23 | <#assign start = 1/> 24 | 25 | <#else> 26 | <#assign start = 1/> 27 | 28 | <#if totalPage gt showPages> 29 | <#assign end = (start+showPages-1)/> 30 | <#if end gt totalPage> 31 | <#assign start = totalPage-showPages+1/> 32 | <#assign end = totalPage/> 33 | 34 | <#else> 35 | <#assign end = totalPage/> 36 | 37 | <#assign pages=start..end/> 38 | <#list pages as page> 39 | <#if page==pageNo> 40 |
  • ${page}
  • 41 | <#else> 42 |
  • ${page}
  • 43 | 44 | 45 | <#if pageNo!=totalPage && pageNo lt totalPage> 46 |
  • 下一页
  • 47 |
  • 尾页
  • 48 | 49 |
50 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/login.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | GEM-View | 登录 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/permission/form.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 5 | 6 | <#assign js> 7 | 40 | 41 | <@layout title="权限编辑" active="permission"> 42 | 43 |
44 |

45 | 权限编辑 46 | 编辑权限详细信息 47 |

48 | 53 |
54 | 55 |
56 |
57 |
58 | 59 |
60 |
61 |
62 | 63 | 64 | 65 | 66 |
67 | 68 |
69 | 70 |
71 |
72 | 73 |
74 | 75 |
76 | 81 |
82 |
83 | 84 |
85 | 86 |
87 | 88 |
89 |
90 | 91 |
92 | 93 |
94 | 95 |
96 |
97 | 98 |
99 | 100 |
101 | 102 |
103 |
104 | 105 |
106 | 107 |
108 | 112 |
113 |
114 | 115 |
116 | 120 |
121 |
122 | 123 |
124 |
125 |
126 | 127 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/permission/index.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 6 | 7 | <#assign js> 8 | 24 | 25 | <@layout title="权限管理" active="permission"> 26 | 27 |
28 |

29 | 权限列表 30 | 31 |

32 | 37 |
38 | 39 | 40 |
41 | 42 |
43 |
44 | <@shiro.hasPermission name="system:permission:add"> 45 | 新增 46 | 47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | <#list pageInfo.list as permissionInfo> 60 | 61 | 62 | 71 | 72 | 73 | 74 | 81 | 89 | 90 | 91 |
权限名称类型权限url权限code排序状态操作
${permissionInfo.permissionName!} 63 | <#if permissionInfo.permissionType == 1> 64 | 一级导航 65 | <#elseif permissionInfo.permissionType ==2> 66 | 二级导航 67 | <#elseif permissionInfo.permissionType ==3 > 68 | 操作按钮 69 | 70 | ${permissionInfo.url!}${permissionInfo.percode!}${permissionInfo.sort!} 75 | <#if permissionInfo.isAvailable> 76 | 显示 77 | <#else> 78 | 隐藏 79 | 80 | 82 | <@shiro.hasPermission name="system:permission:edit"> 83 | 编辑 84 | 85 | <@shiro.hasPermission name="system:permission:delete"> 86 | 87 | 88 |
92 |
93 | 94 | 97 |
98 | 99 | 100 |
101 | 102 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/permission/unauthorized.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | GEM-View | 无权限访问 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |
36 |
37 |
38 | 39 |
40 |
41 | 42 |

咦?

43 |

什么?

44 |

为什么?

45 |

怎么可能?

46 |

我竟然没有权限!

47 |

请联系管理员分配权限访问!

48 |
49 |
50 |
51 |
52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/role/form.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 5 | 6 | <#assign js> 7 | 42 | 43 | <@layout title="角色编辑" active="role"> 44 | 45 |
46 |

47 | 角色编辑 48 | 编辑角色详细信息 49 |

50 | 55 |
56 | 57 |
58 |
59 |
60 | 61 |
62 |
63 |
64 | 65 | 66 | 67 |
68 | 69 |
70 | 71 |
72 |
73 | 74 |
75 | 76 |
77 | 81 |
82 |
83 | 84 |
85 | 89 |
90 |
91 | 92 |
93 |
94 |
95 | 96 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/role/grant.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 5 | 6 | <#assign js> 7 | 8 | 9 | 58 | 59 | <@layout title="资源分配" active="role"> 60 | 61 |
62 |

63 | 资源分配 64 | 分配角色关联资源 65 |

66 | 71 |
72 | 73 |
74 |
75 |
76 | 77 |
78 |
79 |
    80 |
    81 | 85 |
    86 |
    87 |
    88 |
    89 | 90 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/role/index.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 6 | 7 | <#assign js> 8 | 24 | 25 | <@layout title="角色管理" active="role"> 26 | 27 |
    28 |

    29 | 角色列表 30 | 31 |

    32 | 37 |
    38 | 39 | 40 |
    41 | 42 |
    43 |
    44 | <@shiro.hasPermission name="system:role:add"> 45 | 新增 46 | 47 |
    48 |
    49 | 50 | 51 | 52 | 53 | 54 | 55 | <#list pageInfo.list as roleInfo> 56 | 57 | 58 | 65 | 76 | 77 | 78 |
    角色名称状态操作
    ${roleInfo.roleName} 59 | <#if roleInfo.isAvailable > 60 | 正常 61 | <#else> 62 | 已禁用 63 | 64 | 66 | <@shiro.hasPermission name="system:role:edit"> 67 | 编辑 68 | 69 | <@shiro.hasPermission name="system:role:grant"> 70 | 分配资源 71 | 72 | <@shiro.hasPermission name="system:role:delete"> 73 | 74 | 75 |
    79 |
    80 | 81 | 84 |
    85 | 86 | 87 |
    88 | 89 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/test/bootstrap.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Insert title here 13 | 14 | 15 | 16 |

    ${host!}

    17 |
    18 |

    Button

    19 |

    .btn 类是按钮的基本样式:

    20 | 21 |
    22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/test/myChart.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Echarts Test 8 | 9 | 10 | 11 |
    12 |

    Echarts Test

    13 |
    14 |
    15 |
    16 |
    17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/user/form.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | <#--此ftl中用到的css--> 5 | 6 | <#assign js> 7 | <#--此ftl中用到的js--> 8 | 41 | 42 | <@layout title="用户编辑" active="user"> 43 | 44 |
    45 |

    46 | 用户编辑 47 | 编辑用户详细信息 48 |

    49 | 54 |
    55 | 56 |
    57 |
    58 |
    59 | 60 |
    61 |
    62 |
    63 | 64 | 65 | 66 | 67 |
    68 | 69 |
    70 | readonly="readonly" > 71 |
    72 |
    73 | 74 | <#if isAdd> 75 |
    76 | 77 |
    78 | 79 |
    80 |
    81 | <#else> 82 | 83 | 84 | 85 | 86 |
    87 | 88 |
    89 | 93 |
    94 |
    95 | 96 |
    97 | 98 |
    99 | 100 |
    101 |
    102 | 103 |
    104 | 105 |
    106 | 107 |
    108 |
    109 | 110 |
    111 | 112 |
    113 | 114 |
    115 |
    116 | 117 |
    118 | 119 |
    120 | 121 |
    122 |
    123 | 124 |
    125 | 126 |
    127 | 128 |
    129 |
    130 | 131 |
    132 | 133 |
    134 | 138 |
    139 |
    140 | 141 |
    142 | 143 | 147 | 148 |
    149 |
    150 | 151 |
    152 |
    153 |
    154 | 155 | 156 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/user/grant.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 5 | 6 | <#assign js> 7 | 22 | 23 | <@layout title="角色分配" active="user"> 24 | 25 |
    26 |

    27 | 角色分配 28 | 分配用户关联角色 29 |

    30 | 35 |
    36 | 37 |
    38 |
    39 |
    40 | 41 |
    42 |
    43 |
    44 | 45 |
    46 | <#list roles as role> 47 |
    48 |
    49 | 56 |
    57 |
    58 | 59 |
    60 |
    61 | 65 |
    66 |
    67 |
    68 |
    69 |
    70 | 71 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/user/index.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 6 | 7 | <#assign js> 8 | 82 | 83 | <@layout title="用户管理" active="user"> 84 | 85 |
    86 |

    87 | 用户列表 88 |

    89 | 94 |
    95 | 96 | 97 |
    98 | 99 |
    100 |
    101 | <@shiro.hasPermission name="system:user:add"> 102 | 新增 103 | 104 |
    105 |
    106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | <#list pageInfo.list as userInfo> 119 | 120 | 121 | 130 | 131 | 132 | 133 | 134 | 135 | 143 | 154 | 155 | 156 |
    账号用户类别真实姓名职位手机号码联系电话邮箱状态操作
    ${userInfo.userName} 122 | <#if userInfo.userCategory == 1> 123 | 企业用户 124 | <#elseif userInfo.sex == 2> 125 | 个人用户 126 | <#else > 127 | 未知 128 | 129 | ${userInfo.realName}${userInfo.positionJob}${userInfo.tel}${userInfo.cellphone}${userInfo.email} 136 | <#if userInfo.isLocked> 137 | 已禁用 138 | <#else> 139 | 正常 140 | 141 | 142 | 144 | <@shiro.hasPermission name="system:user:edit"> 145 | 编辑 146 | 147 | <@shiro.hasPermission name="system:user:grant"> 148 | 分配角色 149 | 150 | <@shiro.hasPermission name="system:user:delete"> 151 | 152 | 153 |
    157 |
    158 | 159 | 162 |
    163 | 164 | 165 |
    166 | 167 | -------------------------------------------------------------------------------- /web/src/main/resources/web/bzh/user/updatePwd.ftl: -------------------------------------------------------------------------------- 1 | <#include "/bzh/layout/layout.ftl"> 2 | <#import "/bzh/layout/macro.ftl" as macro> 3 | <#assign css> 4 | 5 | <#assign js> 6 | 25 | 26 | 27 | <@layout title="修改密码" active="user"> 28 | 29 |
    30 |

    31 | 修改密码 32 | 修改当前登录用户密码 33 |

    34 | 39 |
    40 | 41 |
    42 |
    43 |
    44 | 45 |
    46 |
    47 |
    48 |
    49 | 50 |
    51 | 52 |
    53 |
    54 |
    55 | 56 |
    57 | 58 |
    59 |
    60 |
    61 | 62 |
    63 | 64 |
    65 |
    66 |
    67 |
    68 | 69 |
    70 |
    71 |
    72 | 76 |
    77 |
    78 | 79 |
    80 |
    81 |
    82 | 83 | --------------------------------------------------------------------------------