├── .gitignore ├── README.md ├── pictures ├── admin-home.png ├── after-init.png ├── before-init.png ├── data-list.png ├── form-data.png └── login.png ├── pom.xml └── src ├── main ├── docker │ ├── Dockerfile │ └── run.sh ├── java │ └── com │ │ └── zslin │ │ ├── RootApplication.java │ │ └── basic │ │ ├── annotations │ │ ├── AdminAuth.java │ │ └── Token.java │ │ ├── controller │ │ ├── AdminController.java │ │ ├── AppConfigController.java │ │ ├── AppErrorController.java │ │ ├── GlobalExceptionHandler.java │ │ ├── InitController.java │ │ ├── LoginController.java │ │ ├── MenuController.java │ │ ├── RoleController.java │ │ └── UserController.java │ │ ├── dto │ │ ├── AuthToken.java │ │ ├── MenuDto.java │ │ └── PMenuDto.java │ │ ├── exception │ │ ├── ErrorInfo.java │ │ └── SystemException.java │ │ ├── interceptor │ │ ├── AuthInterceptor.java │ │ ├── MyWebAppConfig.java │ │ ├── SystemInterceptor.java │ │ └── TokenInterceptor.java │ │ ├── model │ │ ├── AppConfig.java │ │ ├── Menu.java │ │ ├── Role.java │ │ ├── RoleMenu.java │ │ ├── User.java │ │ └── UserRole.java │ │ ├── service │ │ ├── AppConfigServiceImpl.java │ │ ├── IAppConfigService.java │ │ ├── IMenuService.java │ │ ├── IRoleMenuService.java │ │ ├── IRoleService.java │ │ ├── IUserRoleService.java │ │ ├── IUserService.java │ │ ├── MenuServiceImpl.java │ │ ├── RoleMenuServiceImpl.java │ │ ├── UserRoleServiceImpl.java │ │ └── UserServiceImpl.java │ │ ├── tools │ │ ├── AuthTools.java │ │ ├── ConfigTools.java │ │ ├── DateTools.java │ │ ├── MyBeanUtils.java │ │ ├── NormalTools.java │ │ ├── PinyinToolkit.java │ │ ├── SecurityUtil.java │ │ └── TokenTools.java │ │ └── utils │ │ ├── BaseSearch.java │ │ ├── PageableUtil.java │ │ ├── ParamFilterUtil.java │ │ ├── SearchDto.java │ │ ├── SearchSpeDto.java │ │ ├── SearchUtil.java │ │ ├── SortDto.java │ │ └── SortUtil.java └── resources │ ├── application-dev.properties │ ├── application-zsl.properties │ ├── application.properties │ ├── static │ ├── admin │ │ └── myself │ │ │ ├── auth.js │ │ │ ├── cms.admin.js │ │ │ ├── delete.js │ │ │ ├── my.sortable.js │ │ │ ├── my_filter.js │ │ │ ├── public.js │ │ │ ├── role_menus.js │ │ │ └── user_roles.js │ ├── basic │ │ ├── admin │ │ │ ├── form-page.css │ │ │ ├── list-page.css │ │ │ ├── main.css │ │ │ ├── main.js │ │ │ ├── myself │ │ │ │ ├── auth.js │ │ │ │ ├── cms.admin.js │ │ │ │ ├── delete.js │ │ │ │ ├── my.sortable.js │ │ │ │ ├── my_filter.js │ │ │ │ ├── public.js │ │ │ │ ├── role_menus.js │ │ │ │ └── user_roles.js │ │ │ └── nav.css │ │ ├── bootstrap3 │ │ │ ├── css │ │ │ │ ├── bootstrap-theme.css │ │ │ │ ├── bootstrap-theme.css.map │ │ │ │ ├── bootstrap-theme.min.css │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ └── bootstrap.min.css │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ └── glyphicons-halflings-regular.woff │ │ │ └── js │ │ │ │ ├── bootstrap.file-input.js │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── npm.js │ │ ├── font-awesome-4.7.0 │ │ │ ├── HELP-US-OUT.txt │ │ │ ├── css │ │ │ │ ├── font-awesome.css │ │ │ │ └── font-awesome.min.css │ │ │ ├── fonts │ │ │ │ ├── FontAwesome.otf │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.svg │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ └── fontawesome-webfont.woff2 │ │ │ ├── less │ │ │ │ ├── animated.less │ │ │ │ ├── bordered-pulled.less │ │ │ │ ├── core.less │ │ │ │ ├── fixed-width.less │ │ │ │ ├── font-awesome.less │ │ │ │ ├── icons.less │ │ │ │ ├── larger.less │ │ │ │ ├── list.less │ │ │ │ ├── mixins.less │ │ │ │ ├── path.less │ │ │ │ ├── rotated-flipped.less │ │ │ │ ├── screen-reader.less │ │ │ │ ├── stacked.less │ │ │ │ └── variables.less │ │ │ └── scss │ │ │ │ ├── _animated.scss │ │ │ │ ├── _bordered-pulled.scss │ │ │ │ ├── _core.scss │ │ │ │ ├── _fixed-width.scss │ │ │ │ ├── _icons.scss │ │ │ │ ├── _larger.scss │ │ │ │ ├── _list.scss │ │ │ │ ├── _mixins.scss │ │ │ │ ├── _path.scss │ │ │ │ ├── _rotated-flipped.scss │ │ │ │ ├── _screen-reader.scss │ │ │ │ ├── _stacked.scss │ │ │ │ ├── _variables.scss │ │ │ │ └── font-awesome.scss │ │ ├── font-awesome │ │ │ ├── css │ │ │ │ ├── font-awesome-ie7.min.css │ │ │ │ ├── font-awesome.css │ │ │ │ └── font-awesome.min.css │ │ │ └── fonts │ │ │ │ ├── FontAwesome.otf │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.svg │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ └── fontawesome-webfont.woff2 │ │ ├── fonts │ │ │ ├── 59ZRklaO5bWGqF5A9baEERJtnKITppOI_IvcXXDNrsc.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTRWV49_lSm1NYrwo-zkhivY.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTT0LW-43aMEzIO6XUTLjad8.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTZX5f-9o1vgP2EXwfjgl7AY.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTa-j2U0lmluP9RWlSytm3ho.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTaaRobkAwv3vxw3jMhVENGA.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTegdm0LZdjqr5-oayXSOefg.woff2 │ │ │ ├── DXI1ORHCpsQm3Vp6mXoaTf8zf_FOSsgRmwsS7Aa9k2w.woff2 │ │ │ ├── K88pR3goAWT7BTt32Z01mxJtnKITppOI_IvcXXDNrsc.woff2 │ │ │ ├── LWCjsQkB6EMdfHrEVqA1KRJtnKITppOI_IvcXXDNrsc.woff2 │ │ │ ├── RjgO7rYTmqiVp7vzi-Q5URJtnKITppOI_IvcXXDNrsc.woff2 │ │ │ ├── cJZKeOuBrn4kERxqtaUH3VtXRa8TVwTICgirnJhmVJw.woff2 │ │ │ ├── u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2 │ │ │ └── xozscpT2726on7jbcb_pAhJtnKITppOI_IvcXXDNrsc.woff2 │ │ ├── init │ │ │ └── css │ │ │ │ ├── main.css │ │ │ │ ├── pattern.jpg │ │ │ │ ├── pattern2.jpg │ │ │ │ └── style.css │ │ ├── js-lib │ │ │ ├── ajaxfileupload.js │ │ │ ├── bootstrap-treeview.min.js │ │ │ ├── images │ │ │ │ ├── input-checked.png │ │ │ │ └── input-unchecked.png │ │ │ ├── jquery-1.12.3.min.js │ │ │ ├── jquery-labelauty.css │ │ │ ├── jquery-labelauty.js │ │ │ ├── jquery.qrcode.min.js │ │ │ └── ui │ │ │ │ ├── jquery.ui.core.js │ │ │ │ ├── jquery.ui.mouse.js │ │ │ │ ├── jquery.ui.sortable.js │ │ │ │ └── jquery.ui.widget.js │ │ ├── login-new │ │ │ ├── images │ │ │ │ └── bg-img.jpg │ │ │ ├── login.css │ │ │ └── login.js │ │ └── validate │ │ │ └── bootstrapValidator.js │ └── favicon.png │ └── templates │ ├── admin │ └── basic │ │ ├── appConfig │ │ └── index.html │ │ ├── errors │ │ ├── 404.html │ │ ├── 500.html │ │ ├── default.html │ │ └── system.html │ │ ├── index.html │ │ ├── init.html │ │ ├── login.html │ │ ├── menu │ │ ├── list.html │ │ ├── nav.html │ │ └── update.html │ │ ├── role │ │ ├── add.html │ │ ├── filter.html │ │ ├── list.html │ │ ├── menus.html │ │ ├── nav.html │ │ └── update.html │ │ ├── updatePwd.html │ │ └── user │ │ ├── add.html │ │ ├── list.html │ │ ├── nav.html │ │ ├── roles.html │ │ └── update.html │ ├── fragments │ ├── adminModel.html │ ├── errorModel.html │ ├── nav.html │ └── page.html │ ├── index.html │ └── test │ └── index.html └── test └── java └── com └── zslin └── MenuTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | .mvn/timing.properties 10 | 11 | *.class 12 | 13 | # Mobile Tools for Java (J2ME) 14 | .mtj.tmp/ 15 | 16 | # Package Files # 17 | *.jar 18 | *.war 19 | *.ear 20 | 21 | *.iml 22 | .idea 23 | target 24 | 25 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 26 | hs_err_pid* 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 网站底层项目 2 | 3 | 此项目为网站最底层的代码,只实现系统权限管理部份: 4 | 5 | 1、用户管理 6 | 7 | 2、角色管理 8 | 9 | 3、菜单管理 10 | 11 | 4、自动生成系统菜单 12 | 13 | 5、为角色授权菜单 14 | 15 | 6、为用户分配角色 16 | 17 | 基本就只实现这些功能,在开发其他项目时可直接将该项目复制一份即可扩展。 -------------------------------------------------------------------------------- /pictures/admin-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/pictures/admin-home.png -------------------------------------------------------------------------------- /pictures/after-init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/pictures/after-init.png -------------------------------------------------------------------------------- /pictures/before-init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/pictures/before-init.png -------------------------------------------------------------------------------- /pictures/data-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/pictures/data-list.png -------------------------------------------------------------------------------- /pictures/form-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/pictures/form-data.png -------------------------------------------------------------------------------- /pictures/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/pictures/login.png -------------------------------------------------------------------------------- /src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | EXPOSE 80 3 | 4 | RUN mkdir -p /usr/upload/ 5 | 6 | VOLUME /usr/upload/ 7 | 8 | ADD run.sh /run.sh 9 | 10 | RUN chmod +x /run.sh 11 | 12 | ADD basic-*.jar /basic.jar 13 | 14 | ENTRYPOINT sh /run.sh -------------------------------------------------------------------------------- /src/main/docker/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | java -jar /basic.jar -------------------------------------------------------------------------------- /src/main/java/com/zslin/RootApplication.java: -------------------------------------------------------------------------------- 1 | package com.zslin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; 6 | import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; 7 | import org.springframework.boot.web.servlet.ErrorPage; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.http.HttpStatus; 10 | 11 | /** 12 | * Created by 钟述林 393156105@qq.com on 2016/10/19 9:51. 13 | */ 14 | @SpringBootApplication 15 | public class RootApplication { 16 | 17 | public static void main(String [] args) { 18 | SpringApplication.run(RootApplication.class, args); 19 | } 20 | 21 | @Bean 22 | public EmbeddedServletContainerCustomizer containerCustomizer() { 23 | return new EmbeddedServletContainerCustomizer(){ 24 | @Override 25 | public void customize(ConfigurableEmbeddedServletContainer container) { 26 | container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400")); 27 | container.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500")); 28 | container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404")); 29 | } 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/annotations/AdminAuth.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.annotations; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | /** 7 | * 后台管理的Annotation对象 8 | * @author zslin.com 20160513 9 | * 10 | */ 11 | //RetentionPolicy.RUNTIME 表示运行时保留 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface AdminAuth { 14 | 15 | /** 资源名称 */ 16 | public String sn() default ""; 17 | /** 父节点SN */ 18 | public String psn() default ""; 19 | /** 资源图标,使用bootstrap */ 20 | public String icon() default "glyphicon glyphicon-tags"; 21 | /** 是否显示 */ 22 | public int display() default 1; 23 | /** 连接地址 */ 24 | public String url() default "#"; 25 | /** 类型,1:导航菜单;2:权限菜单 */ 26 | public String type() default "2"; 27 | /** 资源名称 */ 28 | public String name(); 29 | /** 序号 */ 30 | public int orderNum() ; 31 | 32 | /** 父节点是否是实体,1:是;其他:否,如果不是实体则需要检测是否存在,不存在则添加 */ 33 | public int pentity() default 1; 34 | 35 | /** 父节点的序号 */ 36 | public int porderNum() default 1; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/annotations/Token.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 防止重复提示导致数据重复录入 10 | * - 主要用于数据添加 11 | * - 创建标记Annotation 12 | * @author zslin.com 20160513 13 | * 14 | */ 15 | @Target(ElementType.METHOD) //指定该注释只能应用于方法名上 16 | @Retention(RetentionPolicy.RUNTIME) //指定运行时保留 17 | public @interface Token { 18 | 19 | /** 1:为添加数据前 */ 20 | public static final String READY = "1"; 21 | 22 | /** 2:为添加数据时,需要进行验证 */ 23 | public static final String CHECK = "2"; 24 | 25 | /** 指定验证标记,如果为1:保存防重标记; 2:检查是否为重复提交 */ 26 | public String flag(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import com.zslin.basic.dto.AuthToken; 4 | import com.zslin.basic.service.IUserService; 5 | import com.zslin.basic.model.User; 6 | import com.zslin.basic.tools.SecurityUtil; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | 15 | /** 16 | * Created by zsl-pc on 2016/9/7. 17 | */ 18 | @Controller 19 | @RequestMapping(value = "admin") 20 | public class AdminController { 21 | 22 | @Autowired 23 | private IUserService userService; 24 | 25 | /** 后台首页 */ 26 | @RequestMapping(value={"", "/"}, method= RequestMethod.GET) 27 | public String index(Model model, HttpServletRequest request) { 28 | return "admin/basic/index"; 29 | } 30 | 31 | /** 修改密码 */ 32 | @RequestMapping(value="updatePwd") 33 | public String updatePwd(Model model, Integer flag, String oldPwd, String password, String nickname, HttpServletRequest request) { 34 | String method = request.getMethod(); //获取请求方式,GET、POST 35 | if("get".equalsIgnoreCase(method)) { 36 | model.addAttribute("flag", flag); 37 | return "admin/basic/updatePwd"; 38 | } else if("post".equalsIgnoreCase(method)) { 39 | AuthToken at = (AuthToken) request.getSession().getAttribute(AuthToken.SESSION_NAME); 40 | User user = at.getUser(); 41 | try { 42 | if(password!=null && !"".equals(password)) { //如果没有输入密码,则不修改 43 | if(!SecurityUtil.md5(user.getUsername(), oldPwd).equals(user.getPassword())) { 44 | model.addAttribute("errorMsg", "原始密码输入错误"); 45 | return "admin/basic/updatePwd"; 46 | } 47 | user.setPassword(SecurityUtil.md5(user.getUsername(), password)); 48 | } 49 | user.setNickname(nickname); 50 | userService.save(user); 51 | return "redirect:/admin/updatePwd?flag=1"; 52 | } catch (Exception e) { 53 | //e.printStackTrace(); 54 | return "redirect:/admin/updatePwd?flag=2"; 55 | } 56 | } 57 | return "redirect:/admin/updatePwd"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/AppConfigController.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import com.zslin.basic.annotations.AdminAuth; 4 | import com.zslin.basic.service.IAppConfigService; 5 | import com.zslin.basic.model.AppConfig; 6 | import com.zslin.basic.service.AppConfigServiceImpl; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | 15 | /** 16 | * 系统配置 17 | * @author zslin.com 20160519 18 | * 19 | */ 20 | @Controller 21 | @RequestMapping(value="admin/appConfig") 22 | @AdminAuth(name="系统配置", orderNum=10, psn="系统管理", pentity=0, porderNum=20) 23 | public class AppConfigController { 24 | 25 | @Autowired 26 | private IAppConfigService appConfigService; 27 | 28 | @Autowired 29 | private AppConfigServiceImpl appConfigServiceImpl; 30 | 31 | @AdminAuth(name="系统配置", orderNum=1, icon="glyphicon glyphicon-cog", type="1") 32 | @RequestMapping(value="index", method= RequestMethod.GET) 33 | public String index(Model model, HttpServletRequest request) { 34 | model.addAttribute("appConfig", appConfigService.loadOne()); 35 | return "admin/basic/appConfig/index"; 36 | } 37 | 38 | @RequestMapping(value="index", method=RequestMethod.POST) 39 | public String index(Model model, AppConfig appConfig, HttpServletRequest request) { 40 | appConfigServiceImpl.addOrUpdate(appConfig); 41 | request.getSession().setAttribute("appConfig", appConfig); //修改后需要修改一次Session中的值 42 | return "redirect:/admin/appConfig/index"; 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/AppErrorController.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | /** 10 | * Created by 钟述林 393156105@qq.com on 2016/10/27 9:37. 11 | */ 12 | @Controller 13 | public class AppErrorController { 14 | 15 | @RequestMapping(value = "404") 16 | public String error404(Model model, HttpServletRequest request) { 17 | return "admin/basic/errors/404"; 18 | } 19 | 20 | @RequestMapping(value = "400") 21 | public String error400(Model model, HttpServletRequest request) { 22 | return "admin/basic/errors/400"; 23 | } 24 | 25 | @RequestMapping(value = "500") 26 | public String error500(Model model, HttpServletRequest request) { 27 | return "admin/basic/errors/500"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import com.zslin.basic.exception.ErrorInfo; 4 | import com.zslin.basic.exception.SystemException; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.ControllerAdvice; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | 11 | /** 12 | * Created by zsl-pc on 2016/9/8. 13 | */ 14 | @ControllerAdvice 15 | public class GlobalExceptionHandler { 16 | 17 | @ExceptionHandler(value = SystemException.class) 18 | public String systemExceptionHandler(Model model, HttpServletRequest req, SystemException e) { 19 | ErrorInfo er = new ErrorInfo<>(); 20 | er.setCode(ErrorInfo.ERROR); 21 | er.setMessage(e.getMessage()); 22 | er.setUrl(req.getRequestURL().toString()); 23 | er.setParams(req.getQueryString()); 24 | er.setDatas("发生系统异常,无法继续进行!"); 25 | model.addAttribute("errorInfo", er); 26 | // e.printStackTrace(); 27 | return "admin/basic/errors/system"; 28 | } 29 | 30 | @ExceptionHandler(value = Exception.class) 31 | public String defaultExceptionHandler(Model model, HttpServletRequest req, Exception e) { 32 | ErrorInfo er = new ErrorInfo<>(); 33 | er.setCode(ErrorInfo.ERROR); 34 | er.setMessage(e.getMessage()); 35 | er.setUrl(req.getRequestURL().toString()); 36 | er.setParams(req.getQueryString()); 37 | er.setDatas("发生异常,无法继续进行!"); 38 | model.addAttribute("errorInfo", er); 39 | // e.printStackTrace(); 40 | return "admin/basic/errors/default"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/InitController.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import com.zslin.basic.annotations.Token; 4 | import com.zslin.basic.service.IUserService; 5 | import com.zslin.basic.model.User; 6 | import com.zslin.basic.service.UserServiceImpl; 7 | import com.zslin.basic.tools.TokenTools; 8 | import com.zslin.basic.service.IAppConfigService; 9 | import com.zslin.basic.model.AppConfig; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.ui.Model; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | 16 | import javax.servlet.http.HttpServletRequest; 17 | 18 | /** 19 | * 系统初始化Controller 20 | * @author zslin.com 20160520 21 | * 22 | */ 23 | @Controller 24 | @RequestMapping 25 | public class InitController { 26 | 27 | @Autowired 28 | private IAppConfigService appConfigService; 29 | 30 | @Autowired 31 | private IUserService userService; 32 | 33 | @Autowired 34 | private UserServiceImpl userServiceImpl; 35 | 36 | /** 初始化GET */ 37 | @RequestMapping(value="init", method=RequestMethod.GET) 38 | @Token(flag= Token.READY) 39 | public String init(Model model, HttpServletRequest request) { 40 | AppConfig appConfig = appConfigService.loadOne(); 41 | if(appConfig==null || appConfig.getInitFlag()==null || "0".equals(appConfig.getInitFlag())) { 42 | //表示可以初始化 43 | User user = new User(); 44 | user.setStatus(1); 45 | model.addAttribute("user", user); 46 | model.addAttribute("initFlag", true); 47 | } else { 48 | //表示不可以初始化 49 | model.addAttribute("initFlag", false); 50 | } 51 | return "admin/basic/init"; 52 | } 53 | 54 | /** 初始化POST */ 55 | @Token(flag=Token.CHECK) 56 | @RequestMapping(value="init", method=RequestMethod.POST) 57 | public String init(Model model, User user, HttpServletRequest request) { 58 | if(TokenTools.isNoRepeat(request)) { 59 | AppConfig appConfig = appConfigService.loadOne(); 60 | if(appConfig==null || appConfig.getInitFlag()==null || "0".equals(appConfig.getInitFlag())) { 61 | userServiceImpl.initBaseUser(user); 62 | } else { 63 | //表示不可以初始化,不可以初始化,则直接返回 64 | } 65 | } 66 | return "redirect:/init"; 67 | } 68 | 69 | /** 系统首页 */ 70 | @RequestMapping(value={"index"}, method=RequestMethod.GET) 71 | public String index(Model model, HttpServletRequest request) { 72 | AppConfig appConfig = appConfigService.loadOne(); 73 | if(appConfig==null || appConfig.getInitFlag()==null || "0".equals(appConfig.getInitFlag())) { 74 | //表示可以初始化 75 | return "redirect:/init"; 76 | } else { 77 | //表示不可以初始化,不可以初始化,则直接返回 78 | String indexPage = appConfig.getIndexPage(); 79 | if(indexPage==null) {indexPage = "/admin";} 80 | return "redirect:"+indexPage; 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import com.zslin.basic.dto.AuthToken; 4 | import com.zslin.basic.service.IMenuService; 5 | import com.zslin.basic.service.IUserService; 6 | import com.zslin.basic.model.User; 7 | import com.zslin.basic.service.MenuServiceImpl; 8 | import com.zslin.basic.tools.SecurityUtil; 9 | import com.zslin.basic.exception.SystemException; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.ui.Model; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import javax.servlet.http.HttpServletRequest; 18 | import javax.servlet.http.HttpSession; 19 | import java.security.NoSuchAlgorithmException; 20 | import java.util.Date; 21 | import java.util.List; 22 | 23 | /** 24 | * Created by zsl-pc on 2016/9/7. 25 | */ 26 | @Controller 27 | public class LoginController { 28 | @Autowired 29 | private IUserService userService; 30 | @Autowired 31 | private IMenuService menuService; 32 | 33 | @Autowired 34 | private MenuServiceImpl menuServiceImpl; 35 | 36 | /** 登陆 */ 37 | @RequestMapping(value="login") 38 | public String login(Model model, HttpServletRequest request) { 39 | String method = request.getMethod(); //获取请求方式,GET或POST 40 | try { 41 | if("get".equalsIgnoreCase(method)) { 42 | return "admin/basic/login"; 43 | } else if("post".equalsIgnoreCase(method)) { 44 | String errMsg = null; 45 | String username = request.getParameter("username"); //用户名 46 | String password = request.getParameter("password"); //密码 47 | User u = userService.findByUsername(username); 48 | if(u==null || u.getStatus()==null || u.getStatus()!=1) {errMsg = username+"不存在或已停用";} 49 | else if(!u.getPassword().equals(SecurityUtil.md5(username, password))) {errMsg = "密码输入不正确";} 50 | else { 51 | AuthToken at = new AuthToken(); 52 | at.setLogin_ip(request.getRemoteAddr()); 53 | at.setLogin_time(new Date()); 54 | at.setUser(u); 55 | at.setAuthMenu(menuServiceImpl.queryMenuDtoNew(u.getId())); 56 | List authList = menuService.listAuthByUser(u.getId()); 57 | authList.add("AdminController.index"); 58 | authList.add("AdminController.updatePwd"); 59 | at.setAuthList(authList); 60 | request.getSession().setAttribute(AuthToken.SESSION_NAME, at); 61 | // request.getSession().setAttribute("login_user", u); 62 | } 63 | if(errMsg!=null && !"".equals(errMsg)) { 64 | model.addAttribute("errMsg", errMsg); 65 | return "admin/basic/login"; 66 | } else { 67 | return "redirect:/admin"; 68 | } 69 | } 70 | } catch (NoSuchAlgorithmException e) { 71 | throw new SystemException("登陆异常!"); 72 | } 73 | return "admin/login"; 74 | } 75 | 76 | /** 设置当前的菜单Id */ 77 | @RequestMapping(value="setCurrentMenuId", method= RequestMethod.POST) 78 | public @ResponseBody 79 | String setCurrentMenuId(Integer pmId, Integer mid, HttpServletRequest request) { 80 | HttpSession session = request.getSession(); 81 | session.setAttribute("pmId", pmId); 82 | session.setAttribute("mid", mid); 83 | return "1"; 84 | } 85 | 86 | /** 退出 */ 87 | @RequestMapping(value="logout", method=RequestMethod.POST) 88 | public @ResponseBody String logout(HttpServletRequest request) { 89 | HttpSession session = request.getSession(); 90 | session.removeAttribute(AuthToken.SESSION_NAME); 91 | return "1"; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/controller/MenuController.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.controller; 2 | 3 | import com.zslin.basic.annotations.AdminAuth; 4 | import com.zslin.basic.annotations.Token; 5 | import com.zslin.basic.model.Menu; 6 | import com.zslin.basic.service.IMenuService; 7 | import com.zslin.basic.service.MenuServiceImpl; 8 | import com.zslin.basic.tools.AuthTools; 9 | import com.zslin.basic.tools.TokenTools; 10 | import com.zslin.basic.utils.BaseSearch; 11 | import com.zslin.basic.utils.PageableUtil; 12 | import com.zslin.basic.utils.SearchDto; 13 | import com.zslin.basic.utils.SortDto; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.data.domain.Page; 16 | import org.springframework.data.jpa.domain.Specifications; 17 | import org.springframework.stereotype.Controller; 18 | import org.springframework.ui.Model; 19 | import org.springframework.web.bind.annotation.PathVariable; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RequestMethod; 22 | import org.springframework.web.bind.annotation.ResponseBody; 23 | 24 | import javax.servlet.http.HttpServletRequest; 25 | 26 | /** 27 | * 菜单管理Controller 28 | * @author zsl-pc 20160511 29 | * 30 | */ 31 | @Controller 32 | @RequestMapping(value="admin/menu") 33 | @AdminAuth(name = "菜单管理", psn="权限管理", orderNum = 1, pentity=0, porderNum=2) 34 | public class MenuController { 35 | 36 | @Autowired 37 | private IMenuService menuService; 38 | 39 | @Autowired 40 | private MenuServiceImpl menuServiceImpl; 41 | 42 | @Autowired 43 | private AuthTools authTools; 44 | 45 | /** 列表 */ 46 | @AdminAuth(name = "菜单管理", orderNum = 1, icon="icon-list", type="1") 47 | @RequestMapping(value="list", method= RequestMethod.GET) 48 | public String list(Model model, Integer pid, Integer page, HttpServletRequest request) { 49 | String treeJson = menuServiceImpl.queryTreeJson("1"); 50 | Page datas ; 51 | if(pid==null || pid<=0) { 52 | BaseSearch spec = new BaseSearch<>(new SearchDto("pid", "isnull", "")); 53 | datas = menuService.findAll(Specifications.where(spec).and(new BaseSearch<>(new SearchDto("type", "eq", "1"))), PageableUtil.basicPage(page, 15, new SortDto("asc", "orderNum"))); 54 | } else { 55 | BaseSearch spec = new BaseSearch<>(new SearchDto("pid", "eq", pid)); 56 | datas = menuService.findAll(Specifications.where(spec).and(new BaseSearch<>(new SearchDto("type", "eq", "1"))), PageableUtil.basicPage(page, 15, new SortDto("asc", "orderNum"))); 57 | } 58 | model.addAttribute("treeJson", treeJson); 59 | model.addAttribute("datas", datas); 60 | return "admin/basic/menu/list"; 61 | } 62 | 63 | @AdminAuth(name="重构菜单", orderNum=3) 64 | @RequestMapping(value="rebuildMenus", method=RequestMethod.POST) 65 | public @ResponseBody String rebuildMenus(Model model, HttpServletRequest request) { 66 | authTools.buildSystemMenu(); 67 | return "1"; 68 | } 69 | 70 | @Token(flag=Token.READY) 71 | @AdminAuth(name="修改菜单", orderNum=3) 72 | @RequestMapping(value="update/{id}", method=RequestMethod.GET) 73 | public String update(Model model, @PathVariable Integer id, HttpServletRequest request) { 74 | Menu m = menuService.findOne(id); 75 | model.addAttribute("menu", m); 76 | return "admin/basic/menu/update"; 77 | } 78 | 79 | @Token(flag=Token.CHECK) 80 | @RequestMapping(value="update/{id}", method=RequestMethod.POST) 81 | public String update(Model model, @PathVariable Integer id, Menu menu, HttpServletRequest request) { 82 | if(TokenTools.isNoRepeat(request)) { 83 | Menu m = menuService.findOne(id); 84 | m.setIcon(menu.getIcon()); 85 | menuService.save(m); 86 | } 87 | return "redirect:/admin/menu/list"; 88 | } 89 | 90 | @RequestMapping("updateSort") 91 | @AdminAuth(name="菜单排序", orderNum=4) 92 | public @ResponseBody String updateSort(Integer[] ids) { 93 | try { 94 | menuServiceImpl.updateSort(ids); 95 | } catch (Exception e) { 96 | return "0"; 97 | } 98 | return "1"; 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/dto/AuthToken.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.dto; 2 | 3 | import com.zslin.basic.model.User; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 登陆令牌对象DTO 10 | * @author zslin.com 20160514 11 | * 12 | */ 13 | public class AuthToken { 14 | 15 | //登陆放在Session中的名称 16 | public static final String SESSION_NAME = "LOGIN_USER"; 17 | 18 | //登陆用户 19 | private User user; 20 | 21 | //用户权限范围内的菜单 22 | // private Map>> authMenu; 23 | private List authMenu; 24 | 25 | //用户权限范围内的sn列表 26 | private List authList; 27 | 28 | //登录时间 29 | private Date login_time; 30 | 31 | //登录IP 32 | private String login_ip; 33 | 34 | public List getAuthList() { 35 | return authList; 36 | } 37 | 38 | public void setAuthList(List authList) { 39 | this.authList = authList; 40 | } 41 | 42 | public User getUser() { 43 | return user; 44 | } 45 | 46 | public void setUser(User user) { 47 | this.user = user; 48 | } 49 | 50 | public List getAuthMenu() { 51 | return authMenu; 52 | } 53 | 54 | public void setAuthMenu(List authMenu) { 55 | this.authMenu = authMenu; 56 | } 57 | 58 | public Date getLogin_time() { 59 | return login_time; 60 | } 61 | 62 | public void setLogin_time(Date login_time) { 63 | this.login_time = login_time; 64 | } 65 | 66 | public String getLogin_ip() { 67 | return login_ip; 68 | } 69 | 70 | public void setLogin_ip(String login_ip) { 71 | this.login_ip = login_ip; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/dto/MenuDto.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.dto; 2 | 3 | import com.zslin.basic.model.Menu; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 菜单DTO对象 9 | * @author zslin.com 20160514 10 | * 11 | */ 12 | public class MenuDto implements Comparable { 13 | 14 | /** 15 | * 父节点Id 16 | */ 17 | private Integer pid; 18 | 19 | /** 20 | * 父菜单节点 21 | */ 22 | private Menu pm; 23 | 24 | /** 对应的子菜单 */ 25 | private List children; 26 | 27 | /** 28 | * 父菜单节点 29 | */ 30 | public Menu getPm() { 31 | return pm; 32 | } 33 | 34 | /** 35 | * 父菜单节点 36 | */ 37 | public void setPm(Menu pm) { 38 | this.pm = pm; 39 | } 40 | 41 | /** 对应的子菜单 */ 42 | public List getChildren() { 43 | return children; 44 | } 45 | 46 | /** 对应的子菜单 */ 47 | public void setChildren(List children) { 48 | this.children = children; 49 | } 50 | 51 | public Integer getPid() { 52 | return pid; 53 | } 54 | 55 | public void setPid(Integer pid) { 56 | this.pid = pid; 57 | } 58 | 59 | @Override 60 | public boolean equals(Object obj) { 61 | MenuDto md = (MenuDto)obj; 62 | return md.getPid()==this.getPid(); 63 | } 64 | 65 | public int compareTo(MenuDto o) { 66 | int tp = this.pm.getOrderNum(); 67 | int op = o.getPm().getOrderNum(); 68 | 69 | return tp>op?1:(tp==op?0:-1); 70 | } 71 | 72 | public MenuDto(Integer pid, Menu pm, List children) { 73 | this.pid = pid; this.pm = pm; this.children = children; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/dto/PMenuDto.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.dto; 2 | 3 | import com.zslin.basic.model.Menu; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 父级菜单DTO对象 9 | * 10 | * @author zslin.com 20160514 11 | * 12 | */ 13 | public class PMenuDto implements Comparable { 14 | 15 | /** 16 | * 父节点Id 17 | */ 18 | private Integer pid; 19 | 20 | /** 21 | * 父菜单节点 22 | */ 23 | private Menu pm; 24 | 25 | /** 对应的子菜单 */ 26 | private List children; 27 | 28 | /** 29 | * 父菜单节点 30 | */ 31 | public Menu getPm() { 32 | return pm; 33 | } 34 | 35 | /** 36 | * 父菜单节点 37 | */ 38 | public void setPm(Menu pm) { 39 | this.pm = pm; 40 | } 41 | 42 | /** 对应的子菜单 */ 43 | public List getChildren() { 44 | return children; 45 | } 46 | 47 | /** 对应的子菜单 */ 48 | public void setChildren(List children) { 49 | this.children = children; 50 | } 51 | 52 | public Integer getPid() { 53 | return pid; 54 | } 55 | 56 | public void setPid(Integer pid) { 57 | this.pid = pid; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object obj) { 62 | PMenuDto md = (PMenuDto)obj; 63 | return md.getPid()==this.getPid(); 64 | } 65 | 66 | public int compareTo(PMenuDto o) { 67 | int tp = this.pm.getOrderNum(); 68 | int op = o.getPm().getOrderNum(); 69 | 70 | return tp>op?1:(tp==op?0:-1); 71 | } 72 | 73 | public PMenuDto(Integer pid, Menu pm, List children) { 74 | this.pid = pid; this.pm = pm; this.children = children; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/exception/ErrorInfo.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.exception; 2 | 3 | /** 4 | * Created by zsl-pc on 2016/9/8. 5 | */ 6 | public class ErrorInfo { 7 | public static final String OK = "0"; 8 | public static final String ERROR = "-1"; 9 | 10 | private String code; 11 | private String message; 12 | private String url; 13 | private String params; 14 | private T datas; 15 | 16 | public String getCode() { 17 | return code; 18 | } 19 | 20 | public String getParams() { 21 | return params; 22 | } 23 | 24 | public String getMessage() { 25 | return message; 26 | } 27 | 28 | public String getUrl() { 29 | return url; 30 | } 31 | 32 | public T getDatas() { 33 | return datas; 34 | } 35 | 36 | public void setCode(String code) { 37 | this.code = code; 38 | } 39 | 40 | public void setDatas(T datas) { 41 | this.datas = datas; 42 | } 43 | 44 | public void setMessage(String message) { 45 | this.message = message; 46 | } 47 | 48 | public void setParams(String params) { 49 | this.params = params; 50 | } 51 | 52 | public void setUrl(String url) { 53 | this.url = url; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/exception/SystemException.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.exception; 2 | 3 | /** 4 | * 系统异常 5 | * @author zslin.com 20160514 6 | * 7 | */ 8 | public class SystemException extends RuntimeException { 9 | 10 | private static final long serialVersionUID = -4555331337009026323L; 11 | 12 | public SystemException() { 13 | super(); 14 | } 15 | 16 | public SystemException(String msg, Throwable throwable) { 17 | super(msg, throwable); 18 | } 19 | 20 | public SystemException(String msg) { 21 | super(msg); 22 | } 23 | 24 | public SystemException(Throwable throwable) { 25 | super(throwable); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/interceptor/AuthInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.interceptor; 2 | 3 | import com.zslin.basic.dto.AuthToken; 4 | import com.zslin.basic.exception.SystemException; 5 | import org.springframework.web.method.HandlerMethod; 6 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.util.List; 12 | 13 | public class AuthInterceptor extends HandlerInterceptorAdapter { 14 | 15 | @Override 16 | public boolean preHandle(HttpServletRequest request, 17 | HttpServletResponse response, Object handler) throws Exception { 18 | HttpSession session = request.getSession(); 19 | AuthToken at = (AuthToken)session.getAttribute(AuthToken.SESSION_NAME); 20 | HandlerMethod hm = (HandlerMethod)handler; 21 | if(at==null||at.getUser()==null) { 22 | response.sendRedirect(request.getContextPath()+"/login"); 23 | return false; 24 | } else { 25 | boolean isAdmin = false; 26 | try { 27 | isAdmin = at.getUser().getIsAdmin()==1; //是否为超级管理员 28 | } catch (Exception e) { 29 | } 30 | // System.out.println(isAdmin); 31 | if(!isAdmin) { 32 | //不是超级管理人员,就需要判断是否有权限访问某些功能 33 | String className = hm.getBean().getClass().getName(); 34 | String methodName = hm.getMethod().getName(); 35 | String curUrl = className.substring(className.lastIndexOf(".")+1, className.length())+"."+methodName; 36 | List authList = at.getAuthList(); 37 | if(!authList.contains(curUrl)) {throw new SystemException("无权限访问,请与管理员联系!");} 38 | } 39 | } 40 | return super.preHandle(request, response, handler); 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/interceptor/MyWebAppConfig.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.interceptor; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 6 | 7 | /** 8 | * Created by zsl-pc on 2016/9/7. 9 | */ 10 | @Configuration 11 | public class MyWebAppConfig extends WebMvcConfigurerAdapter { 12 | @Override 13 | public void addInterceptors(InterceptorRegistry registry) { 14 | registry.addInterceptor(new SystemInterceptor()).addPathPatterns("/**"); 15 | registry.addInterceptor(new TokenInterceptor()).addPathPatterns("/**"); 16 | registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/admin/**"); 17 | super.addInterceptors(registry); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/interceptor/SystemInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.interceptor; 2 | 3 | import com.zslin.basic.service.IAppConfigService; 4 | import com.zslin.basic.model.AppConfig; 5 | import org.springframework.beans.factory.BeanFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.web.context.support.WebApplicationContextUtils; 9 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | 15 | @Configuration 16 | public class SystemInterceptor extends HandlerInterceptorAdapter { 17 | 18 | @Autowired 19 | private IAppConfigService appConfigService; 20 | 21 | @Override 22 | public boolean preHandle(HttpServletRequest request, 23 | HttpServletResponse response, Object handler) throws Exception { 24 | HttpSession session = request.getSession(); 25 | //将系统配置文件存入Session中 26 | AppConfig appConfig = (AppConfig) session.getAttribute("appConfig"); 27 | if(appConfigService==null) { 28 | BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext()); 29 | appConfigService = (IAppConfigService) factory.getBean("appConfigService"); 30 | } 31 | if(appConfig==null) { 32 | appConfig = appConfigService.loadOne(); 33 | session.setAttribute("appConfig", appConfig); 34 | } 35 | 36 | return super.preHandle(request, response, handler); 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/interceptor/TokenInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.interceptor; 2 | 3 | import com.zslin.basic.annotations.Token; 4 | import com.zslin.basic.tools.TokenTools; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.method.HandlerMethod; 7 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.lang.reflect.Method; 12 | import java.util.UUID; 13 | 14 | /** 15 | * Created by zsl-pc on 2016/9/7. 16 | */ 17 | @Configuration 18 | public class TokenInterceptor extends HandlerInterceptorAdapter { 19 | 20 | @Override 21 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 22 | if (handler instanceof HandlerMethod) { 23 | try { 24 | HandlerMethod handlerMethod = (HandlerMethod) handler; 25 | Method method = handlerMethod.getMethod(); 26 | //获取自定义的注释 27 | Token annotation = method.getAnnotation(Token.class); 28 | if (annotation != null) { 29 | //如果标记为准备工作,则创建防重标记存入到session中 30 | if (annotation.flag().equals(Token.READY)) { 31 | request.getSession(false).setAttribute("token", UUID.randomUUID().toString()); 32 | } 33 | //如果标记为检查,则判断是否为重复提交 34 | if (annotation.flag().equals(Token.CHECK)) { 35 | if (isRepeatSubmit(request)) { 36 | request.setAttribute(TokenTools.REP_SESSION_NAME, true); 37 | } 38 | request.getSession(false).removeAttribute("token"); 39 | } 40 | } 41 | } catch (Exception e) { 42 | } 43 | return true; 44 | } else { 45 | return super.preHandle(request, response, handler); 46 | } 47 | } 48 | 49 | /** 50 | * 判断是否为重复提交 51 | * @param request 52 | * @return 53 | */ 54 | private boolean isRepeatSubmit(HttpServletRequest request) { 55 | //获取session中保存的防重标记 56 | String serverToken = (String) request.getSession(false).getAttribute("token"); 57 | //如果session中的标记为空,则判断为重复提交 58 | if (serverToken == null) { 59 | return true; 60 | } 61 | //获取请求中传入的防重标记 62 | String clinetToken = request.getParameter("token"); 63 | //如果请求中传入的标记为空,也判断为重复提交 64 | if (clinetToken == null) { 65 | return true; 66 | } 67 | //如果session中的标记与请求中的标记不同,也判断为重复提交 68 | if (!serverToken.equals(clinetToken)) { 69 | return true; 70 | } 71 | return false; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/model/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.model; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * 系统配置 7 | * @author zslin.com 20160519 8 | * 9 | */ 10 | @Entity 11 | @Table(name="a_app_config") 12 | public class AppConfig { 13 | 14 | @Id 15 | @GeneratedValue(strategy=GenerationType.AUTO) 16 | private Integer id; 17 | 18 | /** 系统名称 */ 19 | @Column(name="app_name") 20 | private String appName; 21 | 22 | /** 当前版本 */ 23 | @Column(name="app_version") 24 | private String appVersion; 25 | 26 | /** 创建日期 */ 27 | @Column(name="create_date") 28 | private String createDate; 29 | 30 | /** 初始化标记,如果为空或为0,表示都可以初始化 */ 31 | @Column(name="init_flag") 32 | private String initFlag; 33 | 34 | /** 首页路径 */ 35 | @Column(name="index_page") 36 | private String indexPage; 37 | 38 | /** 页末联系人 */ 39 | private String contant; 40 | 41 | /** 管理员邮箱 */ 42 | @Column(name = "admin_email") 43 | private String adminEmail; 44 | 45 | public String getAdminEmail() { 46 | return adminEmail; 47 | } 48 | 49 | public void setAdminEmail(String adminEmail) { 50 | this.adminEmail = adminEmail; 51 | } 52 | 53 | public String getContant() { 54 | return contant; 55 | } 56 | 57 | public void setContant(String contant) { 58 | this.contant = contant; 59 | } 60 | 61 | /** 首页路径 */ 62 | public String getIndexPage() { 63 | return indexPage; 64 | } 65 | 66 | /** 首页路径 */ 67 | public void setIndexPage(String indexPage) { 68 | this.indexPage = indexPage; 69 | } 70 | 71 | /** 初始化标记,如果为空或为0,表示都可以初始化 */ 72 | public String getInitFlag() { 73 | return initFlag; 74 | } 75 | 76 | /** 初始化标记,如果为空或为0,表示都可以初始化 */ 77 | public void setInitFlag(String initFlag) { 78 | this.initFlag = initFlag; 79 | } 80 | 81 | public String getCreateDate() { 82 | return createDate; 83 | } 84 | 85 | public void setCreateDate(String createDate) { 86 | this.createDate = createDate; 87 | } 88 | 89 | public Integer getId() { 90 | return id; 91 | } 92 | 93 | public void setId(Integer id) { 94 | this.id = id; 95 | } 96 | 97 | public String getAppName() { 98 | return appName; 99 | } 100 | 101 | public void setAppName(String appName) { 102 | this.appName = appName; 103 | } 104 | 105 | public String getAppVersion() { 106 | return appVersion; 107 | } 108 | 109 | public void setAppVersion(String appVersion) { 110 | this.appVersion = appVersion; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/model/Menu.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.model; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by zsl-pc on 2016/9/1. 7 | */ 8 | @Entity 9 | @Table(name="a_menu") 10 | public class Menu { 11 | 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.AUTO) 14 | private Integer id; 15 | /** 16 | * 菜单的名称,中文显示名称 17 | */ 18 | private String name; 19 | /** 20 | * 菜单的唯一英文标识,如:user,auth等 21 | */ 22 | private String sn; 23 | 24 | /** 25 | * 菜单的顺序 26 | */ 27 | @Column(name="order_num") 28 | private int orderNum; 29 | /** 30 | * 是否显示,0表示不显示,1表示显示 31 | */ 32 | private int display; 33 | 34 | /** 35 | * 菜单的链接地址 36 | */ 37 | private String href; 38 | /** 39 | * 上一级菜单 40 | */ 41 | private Integer pid; 42 | 43 | private String pname; 44 | /** 45 | * 父类的sn 46 | */ 47 | private String psn; 48 | 49 | /** 50 | * 菜单的图标 51 | */ 52 | private String icon; 53 | 54 | /** 菜单类型,1:导航菜单;2:权限菜单 */ 55 | private String type; 56 | 57 | public Integer getId() { 58 | return id; 59 | } 60 | 61 | public void setId(Integer id) { 62 | this.id = id; 63 | } 64 | 65 | public String getName() { 66 | return name; 67 | } 68 | 69 | public void setName(String name) { 70 | this.name = name; 71 | } 72 | 73 | public String getSn() { 74 | return sn; 75 | } 76 | 77 | public void setSn(String sn) { 78 | this.sn = sn; 79 | } 80 | 81 | public int getOrderNum() { 82 | return orderNum; 83 | } 84 | 85 | public void setOrderNum(int orderNum) { 86 | this.orderNum = orderNum; 87 | } 88 | 89 | public int getDisplay() { 90 | return display; 91 | } 92 | 93 | public void setDisplay(int display) { 94 | this.display = display; 95 | } 96 | 97 | public String getHref() { 98 | return href; 99 | } 100 | 101 | public void setHref(String href) { 102 | this.href = href; 103 | } 104 | 105 | public Integer getPid() { 106 | return pid; 107 | } 108 | 109 | public void setPid(Integer pid) { 110 | this.pid = pid; 111 | } 112 | 113 | public String getPname() { 114 | return pname; 115 | } 116 | 117 | public void setPname(String pname) { 118 | this.pname = pname; 119 | } 120 | 121 | public String getPsn() { 122 | return psn; 123 | } 124 | 125 | public void setPsn(String psn) { 126 | this.psn = psn; 127 | } 128 | 129 | public String getIcon() { 130 | return icon; 131 | } 132 | 133 | public void setIcon(String icon) { 134 | this.icon = icon; 135 | } 136 | 137 | public String getType() { 138 | return type; 139 | } 140 | 141 | public void setType(String type) { 142 | this.type = type; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.model; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by zsl-pc on 2016/9/1. 7 | */ 8 | @Entity 9 | @Table(name="a_role") 10 | public class Role { 11 | 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.AUTO) 14 | private Integer id; 15 | 16 | private String name; 17 | 18 | private String sn; 19 | 20 | public Integer getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Integer id) { 25 | this.id = id; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getSn() { 37 | return sn; 38 | } 39 | 40 | public void setSn(String sn) { 41 | this.sn = sn; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/model/RoleMenu.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.model; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by zsl-pc on 2016/9/1. 7 | */ 8 | @Entity 9 | @Table(name="a_role_menu") 10 | public class RoleMenu { 11 | 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.AUTO) 14 | private Integer id; 15 | 16 | /** 角色Id */ 17 | private Integer rid; 18 | 19 | /** 菜单Id */ 20 | private Integer mid; 21 | 22 | public Integer getId() { 23 | return id; 24 | } 25 | 26 | public Integer getMid() { 27 | return mid; 28 | } 29 | 30 | public Integer getRid() { 31 | return rid; 32 | } 33 | 34 | public void setId(Integer id) { 35 | this.id = id; 36 | } 37 | 38 | public void setMid(Integer mid) { 39 | this.mid = mid; 40 | } 41 | 42 | public void setRid(Integer rid) { 43 | this.rid = rid; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by zsl-pc on 2016/8/31. 8 | */ 9 | @Entity 10 | @Table(name="a_user") 11 | public class User { 12 | 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.AUTO) 15 | private Integer id; 16 | 17 | private String username; 18 | private String password; 19 | private Integer status; 20 | @Column(name="create_date") 21 | private Date createDate; 22 | /** 用户昵称 */ 23 | private String nickname; 24 | 25 | @Column(name="is_admin") 26 | private Integer isAdmin; 27 | 28 | public Integer getIsAdmin() { 29 | return isAdmin; 30 | } 31 | 32 | public void setIsAdmin(Integer isAdmin) { 33 | this.isAdmin = isAdmin; 34 | } 35 | 36 | public Integer getId() { 37 | return id; 38 | } 39 | 40 | public void setId(Integer id) { 41 | this.id = id; 42 | } 43 | 44 | public String getUsername() { 45 | return username; 46 | } 47 | 48 | public void setUsername(String username) { 49 | this.username = username; 50 | } 51 | 52 | public String getPassword() { 53 | return password; 54 | } 55 | 56 | public void setPassword(String password) { 57 | this.password = password; 58 | } 59 | 60 | public Integer getStatus() { 61 | return status; 62 | } 63 | 64 | public void setStatus(Integer status) { 65 | this.status = status; 66 | } 67 | 68 | public Date getCreateDate() { 69 | return createDate; 70 | } 71 | 72 | public void setCreateDate(Date createDate) { 73 | this.createDate = createDate; 74 | } 75 | 76 | public String getNickname() { 77 | return nickname; 78 | } 79 | 80 | public void setNickname(String nickname) { 81 | this.nickname = nickname; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/model/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.model; 2 | 3 | import javax.persistence.*; 4 | 5 | /** 6 | * Created by zsl-pc on 2016/9/1. 7 | */ 8 | @Entity 9 | @Table(name="a_user_role") 10 | public class UserRole { 11 | 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.AUTO) 14 | private Integer id; 15 | 16 | /** 用户Id */ 17 | private Integer uid; 18 | 19 | /** 角色Id */ 20 | private Integer rid; 21 | 22 | public void setRid(Integer rid) { 23 | this.rid = rid; 24 | } 25 | 26 | public void setId(Integer id) { 27 | this.id = id; 28 | } 29 | 30 | public void setUid(Integer uid) { 31 | this.uid = uid; 32 | } 33 | 34 | public Integer getRid() { 35 | return rid; 36 | } 37 | 38 | public Integer getId() { 39 | return id; 40 | } 41 | 42 | public Integer getUid() { 43 | return uid; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/AppConfigServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.AppConfig; 4 | import com.zslin.basic.tools.MyBeanUtils; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.persistence.EntityManager; 9 | import javax.persistence.PersistenceContext; 10 | 11 | /** 12 | * Created by zsl-pc on 2016/9/7. 13 | */ 14 | @Component 15 | public class AppConfigServiceImpl { 16 | 17 | @PersistenceContext 18 | EntityManager em; 19 | 20 | @Autowired 21 | private IAppConfigService appConfigService; 22 | 23 | public void addOrUpdate(AppConfig ac) { 24 | AppConfig a = appConfigService.loadOne(); 25 | if(a==null) { 26 | appConfigService.save(ac); 27 | } else { 28 | MyBeanUtils.copyProperties(ac, a, new String[]{"id"}); 29 | appConfigService.save(a); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/IAppConfigService.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.AppConfig; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * Created by zsl-pc on 2016/9/7. 10 | */ 11 | @Service("appConfigService") 12 | public interface IAppConfigService extends JpaRepository { 13 | 14 | @Query("FROM AppConfig ") 15 | public AppConfig loadOne(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/IMenuService.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.Menu; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 6 | import org.springframework.data.jpa.repository.Query; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zsl-pc on 2016/9/1. 12 | */ 13 | public interface IMenuService extends JpaRepository, JpaSpecificationExecutor { 14 | 15 | @Query("SELECT m FROM Menu m WHERE m.display=1 AND m.type='1' AND m.id in (SELECT rm.mid FROM RoleMenu rm WHERE rm.rid IN (SELECT ur.rid FROM UserRole ur where ur.uid=?1))") 16 | List findByUser(Integer userId); 17 | 18 | Menu findBySn(String sn); 19 | 20 | @Query("SELECT m.sn FROM Menu m WHERE m.display=1 AND m.id in (SELECT rm.mid FROM RoleMenu rm WHERE rm.rid IN (SELECT ur.rid FROM UserRole ur where ur.uid=?1))") 21 | List listAuthByUser(Integer userId); 22 | 23 | @Query("FROM Menu m WHERE m.href is not null AND m.href!='' AND m.href!='#' ") 24 | List listAllUrlMenu(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/IRoleMenuService.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.Role; 4 | import com.zslin.basic.model.RoleMenu; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by zsl-pc on 2016/9/1. 14 | */ 15 | public interface IRoleMenuService extends JpaRepository, JpaSpecificationExecutor { 16 | 17 | @Query("SELECT rm.mid FROM RoleMenu rm WHERE rm.rid=:roleId") 18 | List queryMenuIds(@Param("roleId") Integer roleId); 19 | 20 | RoleMenu queryByRidAndMid(Integer rid, Integer mid); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/IRoleService.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.Role; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.domain.Specifications; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 8 | import org.springframework.data.jpa.repository.Query; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by 钟述林 393156105@qq.com on 2016/10/19 9:59. 14 | */ 15 | public interface IRoleService extends JpaRepository, JpaSpecificationExecutor { 16 | 17 | @Query("SELECT rm.mid FROM RoleMenu rm WHERE rm.rid=?1") 18 | List listRoleMenuIds(Integer roleId); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/IUserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.UserRole; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zsl-pc on 2016/9/1. 12 | */ 13 | public interface IUserRoleService extends JpaRepository { 14 | 15 | @Query("SELECT ur.rid FROM UserRole ur WHERE ur.uid=:userId") 16 | List queryRoleIds(@Param("userId") Integer userId); 17 | 18 | UserRole findByUidAndRid(Integer uid, Integer rid); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 6 | import org.springframework.data.jpa.repository.Query; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by 钟述林 393156105@qq.com on 2016/10/19 10:00. 12 | */ 13 | public interface IUserService extends JpaRepository, JpaSpecificationExecutor { 14 | 15 | User findByUsername(String username); 16 | 17 | @Query("SELECT ur.rid FROM UserRole ur WHERE ur.uid=?1") 18 | List listUserRoleIds(Integer userId); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/RoleMenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.RoleMenu; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * Created by zsl-pc on 2016/9/7. 9 | */ 10 | @Component 11 | public class RoleMenuServiceImpl { 12 | 13 | @Autowired 14 | private IRoleMenuService roleMenuService; 15 | 16 | /** 17 | * 添加或删除对象,如果存在则删除,如果不存在则添加 18 | * @param roleId 角色Id 19 | * @param menuId 菜单Id 20 | */ 21 | public void addOrDelete(Integer roleId, Integer menuId) { 22 | RoleMenu rm = roleMenuService.queryByRidAndMid(roleId, menuId); 23 | if(rm==null) { 24 | rm = new RoleMenu(); 25 | rm.setMid(menuId); rm.setRid(roleId); 26 | roleMenuService.save(rm); 27 | } else { 28 | roleMenuService.delete(rm); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/UserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.UserRole; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * Created by zsl-pc on 2016/9/7. 9 | */ 10 | @Component 11 | public class UserRoleServiceImpl { 12 | 13 | @Autowired 14 | private IUserRoleService userRoleService; 15 | 16 | /** 17 | * 添加或删除用户角色对应关系,如果存在则删除,如果不存在则添加 18 | * @param userId 用户Id 19 | * @param roleId 角色Id 20 | */ 21 | public void addOrDelete(Integer userId, Integer roleId) { 22 | UserRole ur = userRoleService.findByUidAndRid(userId, roleId); 23 | if(ur==null) { 24 | ur = new UserRole(); 25 | ur.setRid(roleId); ur.setUid(userId); 26 | userRoleService.save(ur); 27 | } else { 28 | userRoleService.delete(ur); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.service; 2 | 3 | import com.zslin.basic.model.AppConfig; 4 | import com.zslin.basic.model.Menu; 5 | import com.zslin.basic.model.Role; 6 | import com.zslin.basic.model.User; 7 | import com.zslin.basic.tools.AuthTools; 8 | import com.zslin.basic.tools.SecurityUtil; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by zsl-pc on 2016/9/7. 18 | */ 19 | @Component 20 | public class UserServiceImpl { 21 | 22 | @Autowired 23 | private IMenuService menuService; 24 | 25 | @Autowired 26 | private IUserService userService; 27 | 28 | @Autowired 29 | private IRoleService roleService; 30 | 31 | @Autowired 32 | private RoleMenuServiceImpl roleMenuServiceImpl; 33 | 34 | @Autowired 35 | private UserRoleServiceImpl userRoleServiceImpl; 36 | 37 | @Autowired 38 | private IAppConfigService appConfigService; 39 | 40 | @Autowired 41 | private AuthTools authTools; 42 | 43 | /** 44 | * 初始化基础用户数据 45 | * - 1、初始化菜单 46 | * - 2、初始化角色 47 | * - 3、为角色分配所有菜单 48 | * - 4、添加用户 49 | * - 5、为用户分配角色 50 | * @param user 51 | */ 52 | public void initBaseUser(User user) { 53 | try { 54 | authTools.buildSystemMenu("com/zslin/basic/controller/*Controller.class"); 55 | Role role = new Role(); 56 | role.setName("超级管理员角色"); role.setSn("ROLE_SUPER_ADMIN"); 57 | roleService.save(role); 58 | // List menuList = menuService.listAllUrlMenu(); 59 | List menuList = menuService.findAll(); 60 | for(Menu m : menuList) { 61 | roleMenuServiceImpl.addOrDelete(role.getId(), m.getId()); 62 | } 63 | 64 | user.setPassword(SecurityUtil.md5(user.getUsername(), user.getPassword())); 65 | user.setStatus(1); user.setIsAdmin(1); user.setCreateDate(new Date()); 66 | userService.save(user); 67 | userRoleServiceImpl.addOrDelete(user.getId(), role.getId()); 68 | 69 | AppConfig ac = appConfigService.loadOne(); 70 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 71 | if(ac==null) { 72 | ac = new AppConfig(); 73 | ac.setCreateDate(sdf.format(new Date())); 74 | ac.setAppVersion("V 1.0"); 75 | ac.setAppName("系统名称"); 76 | ac.setIndexPage("/"); 77 | ac.setAdminEmail("zsl131@qq.com"); 78 | ac.setInitFlag("1"); appConfigService.save(ac); 79 | } else { 80 | ac.setCreateDate(sdf.format(new Date())); 81 | ac.setInitFlag("1"); appConfigService.save(ac); 82 | } 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/AuthTools.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import com.zslin.basic.annotations.AdminAuth; 4 | import com.zslin.basic.model.Menu; 5 | import com.zslin.basic.service.MenuServiceImpl; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.core.io.Resource; 8 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 9 | import org.springframework.core.io.support.ResourcePatternResolver; 10 | import org.springframework.core.type.AnnotationMetadata; 11 | import org.springframework.core.type.MethodMetadata; 12 | import org.springframework.core.type.classreading.CachingMetadataReaderFactory; 13 | import org.springframework.core.type.classreading.MetadataReader; 14 | import org.springframework.core.type.classreading.MetadataReaderFactory; 15 | import org.springframework.stereotype.Component; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | 18 | import java.io.IOException; 19 | import java.util.Map; 20 | import java.util.Set; 21 | 22 | /** 23 | * 权限管理工具类 24 | * - 主要用于通过Annotation自动生成菜单 25 | * @author zslin.com 20160513 26 | * 27 | */ 28 | @Component 29 | public class AuthTools { 30 | 31 | @Autowired 32 | private MenuServiceImpl menuServiceImpl; 33 | 34 | /** 35 | * 遍历系统中的所有指定(AdminAuth)的资源 36 | */ 37 | public void buildSystemMenu() { 38 | String pn = "com/zslin/*/controller/**Controller.class"; 39 | buildSystemMenu(pn); 40 | } 41 | 42 | /** 43 | * 遍历系统中的所有指定(AdminAuth)的资源 44 | * @param pn Controller所在路径,支持通配符 45 | */ 46 | public void buildSystemMenu(String pn) { 47 | try { 48 | //指定需要检索Annotation的路径,可以使用通配符 49 | // String pn = "com/zslin/*/controller/*/*Controller.class"; 50 | //1、创建ResourcePatternResolver资源对象 51 | ResourcePatternResolver rpr = new PathMatchingResourcePatternResolver(); 52 | //2、获取路径中的所有资源对象 53 | Resource [] ress = rpr.getResources(pn); 54 | //3、创建MetadataReaderFactory来获取工程 55 | MetadataReaderFactory fac = new CachingMetadataReaderFactory(); 56 | //4、遍历资源 57 | for(Resource res:ress) { 58 | MetadataReader mr = fac.getMetadataReader(res); 59 | String cname = mr.getClassMetadata().getClassName(); 60 | AnnotationMetadata am = mr.getAnnotationMetadata(); 61 | if(am.hasAnnotation(AdminAuth.class.getName())) { 62 | addMenu(am, cname, menuServiceImpl); 63 | } 64 | } 65 | } catch (IOException e) { 66 | e.printStackTrace(); 67 | } 68 | } 69 | 70 | /** 71 | * 添加系统菜单 72 | * - 如果存在则修改 73 | * @param am 74 | * @param pck 75 | * @param menuServiceImpl 76 | */ 77 | private void addMenu(AnnotationMetadata am, String pck, MenuServiceImpl menuServiceImpl) { 78 | // Menu menu = new Menu(); 79 | Map classRes = am.getAnnotationAttributes(AdminAuth.class.getName()); 80 | Map mapp = am.getAnnotationAttributes(RequestMapping.class.getName()); 81 | // String pack = pck.substring(0, pck.lastIndexOf(".")); 82 | String cName = pck.substring(pck.lastIndexOf(".")+1, pck.length()); 83 | 84 | String pUrl = ((String[]) mapp.get("value"))[0]; 85 | if(!pUrl.endsWith("/")) {pUrl = pUrl + "/";} 86 | if(!pUrl.startsWith("/")) {pUrl = "/" + pUrl;} 87 | 88 | String resUrl = (String) classRes.get("url"); 89 | if(resUrl!=null && !"#".equals(resUrl)) {resUrl = pUrl + resUrl;} 90 | 91 | String psn = (String) classRes.get("psn"); 92 | 93 | /*menu.setDisplay((Integer)classRes.get("display")); 94 | menu.setIcon((String)classRes.get("icon")); 95 | menu.setName((String)classRes.get("name")); 96 | menu.setOrderNum((Integer) classRes.get("orderNum")); 97 | menu.setPsn(psn); 98 | menu.setType((String) classRes.get("type")); 99 | menu.setHref(resUrl); 100 | menu.setSn(cName); 101 | 102 | menuServiceImpl.addOrUpdate(menu);*/ 103 | 104 | Set set = am.getAnnotatedMethods(AdminAuth.class.getName()); 105 | for(MethodMetadata mm : set) { 106 | Menu resMethod = new Menu(); 107 | 108 | classRes = mm.getAnnotationAttributes(AdminAuth.class.getName()); 109 | 110 | resMethod.setDisplay((Integer)classRes.get("display")); 111 | resMethod.setIcon((String)classRes.get("icon")); 112 | resMethod.setName((String)classRes.get("name")); 113 | resMethod.setOrderNum((Integer) classRes.get("orderNum")); 114 | // resMethod.setPsn(cName); 115 | // resMethod.setPid(menu.getId()); 116 | resMethod.setPsn(psn); 117 | resMethod.setType((String) classRes.get("type")); 118 | String url = (String) classRes.get("url"); 119 | if(url==null || "".equals(url.trim()) || "#".equals(url.trim())) { 120 | url = pUrl; 121 | Map meMapp = mm.getAnnotationAttributes(RequestMapping.class.getName()); 122 | String temp = ((String[]) meMapp.get("value"))[0]; 123 | if(temp.indexOf("{")>=0) {temp = temp.substring(0, temp.lastIndexOf("{"));} 124 | if(temp.startsWith("/")) {temp = temp.substring(1, temp.length());} 125 | if(temp.endsWith("/")) {temp = temp.substring(0, temp.length()-1);} 126 | url = url + temp; 127 | } 128 | resMethod.setHref(url); 129 | resMethod.setSn(cName+"."+mm.getMethodName()); 130 | menuServiceImpl.addOrUpdate(resMethod); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/ConfigTools.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.io.File; 8 | 9 | /** 10 | * Created by zsl-pc on 2016/9/11. 11 | */ 12 | @Configuration 13 | @Component 14 | public class ConfigTools { // extends WebMvcConfigurerAdapter 15 | 16 | @Value("${web.upload-path}") 17 | private String uploadPath; 18 | 19 | public String getUploadPath() { 20 | return getUploadPath(""); 21 | } 22 | 23 | public String getUploadPath(String basePath) { 24 | File f = new File(uploadPath+basePath); 25 | if(!f.exists()) {f.mkdirs();} 26 | return f.getAbsolutePath(); 27 | } 28 | 29 | public void setUploadPath(String uploadPath) { 30 | this.uploadPath = uploadPath; 31 | } 32 | 33 | /*@Override 34 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 35 | //设置静态资源路径 36 | registry.addResourceHandler("*//**") 37 | .addResourceLocations("classpath:/", "classpath:/static/", "classpath:/public/", "file:"+File.separator+uploadPath); 38 | // super.addResourceHandlers(registry); 39 | }*/ 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/DateTools.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | 7 | /** 8 | * 日期工具类 9 | * Created by zsl-pc on 2016/9/21. 10 | */ 11 | public class DateTools { 12 | 13 | public static Date plusDay(Integer days) { 14 | Calendar cal = Calendar.getInstance(); 15 | cal.add(Calendar.DAY_OF_MONTH, days); 16 | return cal.getTime(); 17 | } 18 | 19 | /** 20 | * 21 | * @param days 22 | * @param pattern 23 | * @return 24 | */ 25 | public static String plusDay(Integer days, String pattern) { 26 | Date date = plusDay(days); 27 | if(pattern==null || "".equalsIgnoreCase(pattern)) {pattern = "yyyy-MM-dd";} 28 | SimpleDateFormat sdf = new SimpleDateFormat(pattern); 29 | return sdf.format(date); 30 | } 31 | 32 | public static Long plusDayByLong(Integer days) { 33 | Date date = plusDay(days); 34 | return date.getTime(); 35 | } 36 | 37 | /** 38 | * 判断是否逾期 39 | * @param startDate 开始日期 40 | * @param amount 出租天数 41 | * @return 42 | */ 43 | public static boolean isOverdue(Date startDate, Integer amount) { 44 | Calendar needCal = Calendar.getInstance(); 45 | needCal.setTime(startDate); 46 | needCal.add(Calendar.DAY_OF_MONTH, amount); 47 | 48 | Calendar nowCal = Calendar.getInstance(); 49 | 50 | return !needCal.getTime().after(nowCal.getTime()); 51 | } 52 | 53 | public static String date2Str(Date date, String pattern) { 54 | SimpleDateFormat sdf = new SimpleDateFormat(pattern); 55 | return sdf.format(date); 56 | } 57 | 58 | public static String date2Str(Date date) { 59 | return date2Str(date, "yyyy-MM-dd"); 60 | } 61 | 62 | public static String formatDate(Date date) { 63 | return date2Str(date, "yyyy-MM-dd HH:mm:ss") ; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/MyBeanUtils.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import org.springframework.beans.BeanUtils; 4 | import org.springframework.beans.BeanWrapper; 5 | import org.springframework.beans.BeanWrapperImpl; 6 | import org.springframework.beans.BeansException; 7 | 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | /** 12 | * 重写Spring下BeanUtils的copyProperties方法 13 | * @author zslin.com 20160522 14 | */ 15 | public class MyBeanUtils extends BeanUtils { 16 | 17 | public static void copyProperties(Object source, Object target, String [] ignoreFields) 18 | throws BeansException { 19 | BeanUtils.copyProperties(source, target, concat(ignoreFields, getNullPropertyNames(source))); 20 | } 21 | 22 | private static String[] concat(String[] a, String[] b) { 23 | String[] c= new String[a.length+b.length]; 24 | System.arraycopy(a, 0, c, 0, a.length); 25 | System.arraycopy(b, 0, c, a.length, b.length); 26 | return c; 27 | } 28 | 29 | public static String[] getNullPropertyNames (Object source) { 30 | final BeanWrapper src = new BeanWrapperImpl(source); 31 | java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); 32 | 33 | Set emptyNames = new HashSet(); 34 | for(java.beans.PropertyDescriptor pd : pds) { 35 | Object srcValue = src.getPropertyValue(pd.getName()); 36 | if (srcValue == null) emptyNames.add(pd.getName()); 37 | } 38 | String[] result = new String[emptyNames.size()]; 39 | return emptyNames.toArray(result); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/NormalTools.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by zsl-pc on 2016/9/14. 8 | */ 9 | public class NormalTools { 10 | 11 | public static String getFileType(String fileName) { 12 | if(fileName!=null && fileName.indexOf(".")>=0) { 13 | return fileName.substring(fileName.lastIndexOf("."), fileName.length()); 14 | } 15 | return ""; 16 | } 17 | 18 | /** 19 | * 判断文件是否为图片文件 20 | * @param fileName 21 | * @return 22 | */ 23 | public static Boolean isImageFile(String fileName) { 24 | String [] img_type = new String[]{".jpg", ".jpeg", ".png", ".gif", ".bmp"}; 25 | if(fileName==null) {return false;} 26 | fileName = fileName.toLowerCase(); 27 | for(String type : img_type) { 28 | if(fileName.endsWith(type)) {return true;} 29 | } 30 | return false; 31 | } 32 | 33 | public static String curDate(String pattern) { 34 | SimpleDateFormat sdf = new SimpleDateFormat(pattern); 35 | return sdf.format(new Date()); 36 | } 37 | 38 | public static String curDate() { 39 | return curDate("yyyy-MM-dd HH:mm:ss"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/PinyinToolkit.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import net.sourceforge.pinyin4j.PinyinHelper; 4 | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; 5 | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; 6 | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; 7 | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; 8 | 9 | public class PinyinToolkit { 10 | 11 | /** 12 | * 获取汉字串拼音首字母,英文字符不变 13 | * 14 | * @param chinese 15 | * 汉字串 16 | * @return 汉语拼音首字母 17 | */ 18 | public static String cn2FirstSpell(String chinese) { 19 | StringBuffer pybf = new StringBuffer(); 20 | char[] arr = chinese.toCharArray(); 21 | HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); 22 | defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); 23 | defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); 24 | for (int i = 0; i < arr.length; i++) { 25 | if (arr[i] > 128) { 26 | try { 27 | String[] _t = PinyinHelper.toHanyuPinyinStringArray(arr[i], 28 | defaultFormat); 29 | if (_t != null) { 30 | pybf.append(_t[0].charAt(0)); 31 | } 32 | } catch (BadHanyuPinyinOutputFormatCombination e) { 33 | //e.printStackTrace(); 34 | // System.out.println("PinyinToolkit.java 37 BadHanyuPinyinOutputFormatCombination"); 35 | } 36 | } else { 37 | pybf.append(arr[i]); 38 | } 39 | } 40 | return pybf.toString().replaceAll("\\W", "").trim(); 41 | } 42 | 43 | /** 44 | * 获取汉字串拼音,英文字符不变 45 | * 46 | * @param chinese 47 | * 汉字串 48 | * @return 汉语拼音 49 | */ 50 | public static String cn2Spell(String chinese,String split) { 51 | StringBuffer pybf = new StringBuffer(); 52 | char[] arr = chinese.toCharArray(); 53 | HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); 54 | defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); 55 | defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); 56 | for (int i = 0; i < arr.length; i++) { 57 | try { 58 | if(isChinese(arr[i])) 59 | pybf.append(PinyinHelper.toHanyuPinyinStringArray(arr[i], 60 | defaultFormat)[0]).append(split); 61 | else 62 | pybf.append(arr[i]); 63 | } catch (BadHanyuPinyinOutputFormatCombination e) { 64 | //e.printStackTrace(); 65 | } 66 | } 67 | return pybf.toString(); 68 | } 69 | 70 | /** 71 | * 判断是否为汉字 72 | * @param c 73 | * @return 74 | */ 75 | private static boolean isChinese(char c) { 76 | if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) 77 | return true; 78 | return false; 79 | } 80 | } -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/SecurityUtil.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import java.math.BigInteger; 4 | import java.security.MessageDigest; 5 | import java.security.NoSuchAlgorithmException; 6 | 7 | /** 8 | * 安全工具类,可以进行数据的加密和解密,并且可以完成对象的加密和解密 9 | * @author KongHao 10 | * 11 | */ 12 | @SuppressWarnings("rawtypes") 13 | public class SecurityUtil { 14 | public static String md5(String password) throws NoSuchAlgorithmException { 15 | MessageDigest md = MessageDigest.getInstance("MD5"); 16 | md.update(password.getBytes()); 17 | return new BigInteger(1,md.digest()).toString(16); 18 | } 19 | 20 | public static String md5(String username,String password) throws NoSuchAlgorithmException { 21 | MessageDigest md = MessageDigest.getInstance("MD5"); 22 | md.update(username.getBytes()); 23 | md.update(password.getBytes()); 24 | return new BigInteger(1,md.digest()).toString(16); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/tools/TokenTools.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.tools; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * 防重复提交的工具类 7 | * @author zslin.com 20160520 8 | * 9 | */ 10 | public class TokenTools { 11 | public static final String REP_SESSION_NAME = "isRepeat"; 12 | 13 | /** 14 | * 检查是否为重复提交 15 | * - 返回true表示没有重复提交 16 | * @param request 17 | * @return 18 | */ 19 | public static boolean isNoRepeat(HttpServletRequest request) { 20 | Boolean isRepeat = (Boolean) request.getSession().getAttribute(REP_SESSION_NAME); 21 | return (isRepeat==null || !isRepeat); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/BaseSearch.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | import org.springframework.data.jpa.domain.Specification; 4 | 5 | import javax.persistence.criteria.CriteriaBuilder; 6 | import javax.persistence.criteria.CriteriaQuery; 7 | import javax.persistence.criteria.Predicate; 8 | import javax.persistence.criteria.Root; 9 | 10 | /** 11 | * Created by 钟述林 393156105@qq.com on 2016/10/21 17:16. 12 | */ 13 | public class BaseSearch implements Specification { 14 | 15 | public static final String GRATE_EQUAL = "ge"; //大于等于 16 | public static final String GRATE_THEN = "gt"; //大于 17 | public static final String LESS_EQUAL = "le"; //小于等于 18 | public static final String LESS_THEN = "lt"; //小于 19 | public static final String LIKE_BEGIN = "likeb"; // like '%?' 20 | public static final String LIKE_END = "likee"; //like '?%' 21 | public static final String LIKE = "like"; //like '%?%' 22 | public static final String LIKE_BEGIN_END = "likebe"; //like '%?%' 23 | public static final String NOT_LIKE_BEGIN = "nlikeb"; //not like '%?' 24 | public static final String NOT_LIKE_END = "nlikee"; //not like '?%' 25 | public static final String NOT_LIKE = "nlike"; //not like '%?%' 26 | public static final String NOT_LIKE_BEGIN_END = "nlikebe"; // not like '%?%' 27 | public static final String EQUAL = "eq"; //equal = 28 | public static final String NOT_EQUAL = "neq"; // not equal != 29 | public static final String IS_NULL = "isnull"; //is null 30 | 31 | private SearchDto criteria; 32 | public BaseSearch(SearchDto criteria) { 33 | this.criteria = criteria; 34 | } 35 | 36 | @Override 37 | public Predicate toPredicate 38 | (Root root, CriteriaQuery query, CriteriaBuilder builder) { 39 | String opt = criteria.getOperation(); 40 | String key = criteria.getKey(); 41 | String value = criteria.getValue().toString(); 42 | if (opt.equalsIgnoreCase(GRATE_EQUAL)) { //大于等于 43 | return builder.greaterThanOrEqualTo( 44 | root. get(key), value); 45 | } else if(opt.equalsIgnoreCase(GRATE_THEN)) { //大于 46 | return builder.greaterThan(root. get(key), value); 47 | } else if(opt.equalsIgnoreCase(LESS_EQUAL)) { //小于等于 48 | return builder.lessThanOrEqualTo(root.get(key), value); 49 | } else if(opt.equalsIgnoreCase(LESS_THEN)) { //小于 50 | return builder.lessThan(root.get(key), value); 51 | } else if(opt.equalsIgnoreCase(LIKE_BEGIN)) { // like '%?' 52 | return builder.like(root.get(key), "%"+value); 53 | } else if(opt.equalsIgnoreCase(LIKE_END)) { // like '?%' 54 | return builder.like(root.get(key), value+"%"); 55 | } else if(opt.equalsIgnoreCase(LIKE) || opt.equalsIgnoreCase(LIKE_BEGIN_END)) { //like '%?%' 56 | return builder.like(root.get(key), "%"+value+"%"); 57 | } else if(opt.equalsIgnoreCase(NOT_LIKE_BEGIN)) { // not like '%?' 58 | return builder.notLike(root.get(key), "%"+value); 59 | } else if(opt.equalsIgnoreCase(NOT_LIKE_END)) { // not like '?%' 60 | return builder.notLike(root. get(key), value + "%"); 61 | } else if(opt.equalsIgnoreCase(NOT_LIKE) || opt.equalsIgnoreCase(NOT_LIKE_BEGIN_END)) { //not like '%?%' 62 | return builder.notLike(root. get(key), "%"+value+"%"); 63 | } else if(opt.equalsIgnoreCase(EQUAL)) { //equal 64 | return builder.equal(root.get(key), value); 65 | } else if(opt.equalsIgnoreCase(NOT_EQUAL)) { //not equal 66 | return builder.notEqual(root.get(key), value); 67 | } else if(opt.equalsIgnoreCase(IS_NULL)) { // is null 68 | return builder.isNull(root.get(key)); 69 | } 70 | return null; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/PageableUtil.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | import org.springframework.data.domain.PageRequest; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.domain.Sort; 6 | 7 | /** 8 | * Created by 钟述林 393156105@qq.com on 2016/10/21 15:45. 9 | */ 10 | public class PageableUtil { 11 | 12 | /** 13 | * 获取基础分页对象 14 | * @param page 获取第几页 15 | * @param size 每页条数 16 | * @param dtos 排序对象数组 17 | * @return 18 | */ 19 | public static Pageable basicPage(Integer page, Integer size, SortDto... dtos) { 20 | Sort sort = SortUtil.basicSort(dtos); 21 | page = (page==null || page<0)?0:page; 22 | size = (size==null || size<=0)?15:size; 23 | Pageable pageable = new PageRequest(page, size, sort); 24 | return pageable; 25 | } 26 | 27 | /** 28 | * 获取基础分页对象,每页条数默认15条 29 | * - 默认以id降序排序 30 | * @param page 获取第几页 31 | * @return 32 | */ 33 | public static Pageable basicPage(Integer page) { 34 | return basicPage(page, 0, new SortDto("desc", "id")); 35 | } 36 | 37 | /** 38 | * 获取基础分页对象,每页条数默认15条 39 | * @param page 获取第几页 40 | * @param dtos 排序对象数组 41 | * @return 42 | */ 43 | public static Pageable basicPage(Integer page, SortDto... dtos) { 44 | return basicPage(page, 0, dtos); 45 | } 46 | 47 | /** 48 | * 获取基础分页对象,排序方式默认降序 49 | * @param page 获取第几页 50 | * @param size 每页条数 51 | * @param orderField 排序字段 52 | * @return 53 | */ 54 | public static Pageable basicPage(Integer page, Integer size, String orderField) { 55 | return basicPage(page, size, new SortDto("desc", orderField)); 56 | } 57 | 58 | /** 59 | * 获取基础分页对象 60 | * - 每页条数默认15条 61 | * - 排序方式默认降序 62 | * @param page 获取第几页 63 | * @param orderField 排序字段 64 | * @return 65 | */ 66 | public static Pageable basicPage(Integer page, String orderField) { 67 | return basicPage(page, 0, new SortDto("desc", orderField)); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/ParamFilterUtil.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | import org.springframework.data.jpa.domain.Specifications; 4 | import org.springframework.ui.Model; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by zsl-pc on 2016/9/16. 12 | */ 13 | public class ParamFilterUtil { 14 | 15 | //参数名前缀 16 | private static final String PARAM_PRE = "filter_"; 17 | private static final String PARAM_SPE = "-"; 18 | 19 | public Specifications buildSearch(Model model, HttpServletRequest request, Specifications result) { 20 | Map args = new HashMap<>(); 21 | // Specifications result = null; 22 | Map paramMap = request.getParameterMap(); 23 | for(String key : paramMap.keySet()) { 24 | //这个参数是需要进行过虑的 25 | if(key.startsWith(PARAM_PRE)) { 26 | try { 27 | String field = key.replaceFirst(PARAM_PRE, ""); //获取出字段名称 28 | String parVal = paramMap.get(key)[0]; 29 | String [] val_array = parVal.split(PARAM_SPE); 30 | String operate = val_array[0]; //比较符号 31 | String fieldVal = val_array[1]; //对应值 32 | BaseSearch spec = new BaseSearch<>(new SearchDto(field, operate, fieldVal)); 33 | if(result==null) { 34 | result = Specifications.where(spec); 35 | } else { 36 | result = result.and(spec); 37 | } 38 | args.put(key, fieldVal); 39 | } catch (Exception e) { 40 | // e.printStackTrace(); 41 | } 42 | } 43 | } 44 | model.addAttribute("args", args); 45 | return result; 46 | } 47 | 48 | public Specifications buildSearch(Model model, HttpServletRequest request) { 49 | return buildSearch(model, request, null); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/SearchDto.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | /** 4 | * Created by 钟述林 393156105@qq.com on 2016/10/21 17:12. 5 | */ 6 | public class SearchDto { 7 | 8 | /** 拼接类型,and或者or */ 9 | private String type; 10 | private String key; 11 | private String operation; 12 | private Object value; 13 | 14 | public SearchDto(String key, String operation, Object value) { 15 | this.key = key; 16 | this.operation = operation; 17 | this.value = value; 18 | } 19 | 20 | public SearchDto(String type, String key, String operation, Object value) { 21 | this.type = type; 22 | this.key = key; 23 | this.operation = operation; 24 | this.value = value; 25 | } 26 | 27 | public String getType() { 28 | return type; 29 | } 30 | 31 | public void setType(String type) { 32 | this.type = type; 33 | } 34 | 35 | public Object getValue() { 36 | return value; 37 | } 38 | 39 | public String getKey() { 40 | return key; 41 | } 42 | 43 | public String getOperation() { 44 | return operation; 45 | } 46 | 47 | public void setKey(String key) { 48 | this.key = key; 49 | } 50 | 51 | public void setOperation(String operation) { 52 | this.operation = operation; 53 | } 54 | 55 | public void setValue(Object value) { 56 | this.value = value; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/SearchSpeDto.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | import org.springframework.data.jpa.domain.Specifications; 4 | 5 | /** 6 | * Created by 钟述林 393156105@qq.com on 2016/10/22 1:04. 7 | */ 8 | public class SearchSpeDto { 9 | 10 | /** 类型,and或者or */ 11 | private String type; 12 | 13 | public SearchSpeDto(String type, Specifications spes) { 14 | this.type = type; 15 | this.spes = spes; 16 | } 17 | 18 | private Specifications spes; 19 | 20 | public Specifications getSpes() { 21 | return spes; 22 | } 23 | 24 | public String getType() { 25 | return type; 26 | } 27 | 28 | public void setSpes(Specifications spes) { 29 | this.spes = spes; 30 | } 31 | 32 | public void setType(String type) { 33 | this.type = type; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/SearchUtil.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | import org.springframework.data.jpa.domain.Specification; 4 | import org.springframework.data.jpa.domain.Specifications; 5 | 6 | /** 7 | * Created by 钟述林 393156105@qq.com on 2016/10/22 0:50. 8 | */ 9 | public class SearchUtil { 10 | 11 | public static Specification buildSpecification(SearchSpeDto... speDtos) { 12 | Specifications result = null; 13 | for(SearchSpeDto dto : speDtos) { 14 | if(result==null) { 15 | result = Specifications.where(dto.getSpes()); 16 | } else { 17 | if("and".equalsIgnoreCase(dto.getType())) { 18 | result = result.and(dto.getSpes()); 19 | } else { 20 | result = result.or(dto.getSpes()); 21 | } 22 | } 23 | } 24 | return result; 25 | } 26 | 27 | public static SearchSpeDto buildSpeDto(String type, SearchDto... searchDtos) { 28 | SearchSpeDto speDtos = null; 29 | 30 | Specifications result = null; 31 | for(SearchDto dto : searchDtos) { 32 | if(result==null) { 33 | result = Specifications.where(new BaseSearch(dto)); 34 | } else { 35 | if("and".equalsIgnoreCase(dto.getType())) { 36 | result = result.and(new BaseSearch(dto)); 37 | } else { 38 | result = result.or(new BaseSearch(dto)); 39 | } 40 | } 41 | } 42 | speDtos = new SearchSpeDto(type, result); 43 | return speDtos; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/SortDto.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | /** 4 | * Created by 钟述林 393156105@qq.com on 2016/10/21 11:41. 5 | */ 6 | public class SortDto { 7 | 8 | //排序方式 9 | private String orderType; 10 | 11 | //排序字段 12 | private String orderField; 13 | 14 | public String getOrderField() { 15 | return orderField; 16 | } 17 | 18 | public void setOrderField(String orderField) { 19 | this.orderField = orderField; 20 | } 21 | 22 | public String getOrderType() { 23 | return orderType; 24 | } 25 | 26 | public void setOrderType(String orderType) { 27 | this.orderType = orderType; 28 | } 29 | 30 | public SortDto(String orderType, String orderField) { 31 | orderField = orderField==null||"".equalsIgnoreCase(orderField)?"id":orderField; 32 | orderType = orderType==null||"".equalsIgnoreCase(orderType)?"desc":orderType; 33 | this.orderType = orderType; 34 | this.orderField = orderField; 35 | } 36 | 37 | //默认为DESC排序 38 | public SortDto(String orderField) { 39 | orderField = orderField==null||"".equalsIgnoreCase(orderField)?"id":orderField; 40 | this.orderField = orderField; 41 | this.orderType = "desc"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/zslin/basic/utils/SortUtil.java: -------------------------------------------------------------------------------- 1 | package com.zslin.basic.utils; 2 | 3 | import org.springframework.data.domain.Sort; 4 | 5 | /** 6 | * Created by 钟述林 393156105@qq.com on 2016/10/21 11:25. 7 | */ 8 | public class SortUtil { 9 | 10 | public static Sort basicSort() { 11 | return basicSort("desc", "id"); 12 | } 13 | 14 | public static Sort basicSort(String orderType, String orderField) { 15 | Sort sort = new Sort(Sort.Direction.fromString(orderType), orderField); 16 | return sort; 17 | } 18 | 19 | public static Sort basicSort(SortDto... dtos) { 20 | Sort result = null; 21 | for(int i=0; i=0) { 5 | return data.substr(0,data.indexOf("?")); 6 | } 7 | return data; 8 | }; 9 | })(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/admin/myself/delete.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | $.fn.deleteFun = function(opts) { 3 | var _config = { 4 | title:"操作提示", 5 | msg:'' 6 | }; 7 | var _event = { 8 | click:_click, 9 | init:_init 10 | }; 11 | $.extend(_config, _event); 12 | 13 | var that = this; 14 | var settings = $.extend(_config, opts||{}); 15 | function _click(event) { 16 | var href = $(this).attr("href"); 17 | var tempMsg = settings.msg; 18 | if(!tempMsg) { 19 | tempMsg = $(this).attr("title"); 20 | if(!tempMsg) { 21 | tempMsg = $(this).html(); 22 | } 23 | } 24 | //alert(tempMsg); 25 | 26 | var modalDiv = ''; 42 | 43 | $(modalDiv).modal({keyboard:false, backdrop:'static'}); 44 | event.preventDefault(); 45 | } 46 | 47 | function _init() { 48 | $(that).on("click", settings.click); 49 | } 50 | 51 | settings.init(); 52 | 53 | return this; 54 | } 55 | })(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/admin/myself/my.sortable.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | $.fn.sorttable = function(opts) { 3 | var _isSort = false; 4 | var sortEle = $(this).find("tbody"); 5 | var _that = this; 6 | var _cfg = { 7 | url:null, 8 | sn:"show", 9 | idIndex:0 10 | }; 11 | var settings = $.extend(_cfg,opts||{}); 12 | function _init() { 13 | $(_that).find("tfoot").append("" + 14 | "开始排序 " + 15 | "请拖动数据行进行排序  " + 16 | "取消排序 存储排序 " + 17 | ""); 18 | _setBeginBtn(false); 19 | $(_that).find("tbody tr").each(function(){ 20 | $(this).attr("id","id_"+$(this).find("td:eq("+settings.idIndex+")").html()); 21 | }); 22 | sortEle.sortable({ 23 | axis:"y", 24 | helper:function(e,ele) { 25 | //原始元素的td对象 26 | var _original = ele.children(); 27 | var _helper = ele.clone(); 28 | _helper.children().each(function(index){ 29 | $(this).width(_original.eq(index).width()); 30 | }); 31 | _helper.css("background","#888"); 32 | _helper.addClass("white"); 33 | return _helper; 34 | }, 35 | update:function(e,ui) { 36 | _setOrder(); 37 | } 38 | }); 39 | sortEle.sortable("disable"); 40 | $("#beginOrder").click(_beginOrder); 41 | $("#saveOrder").click(_saveOrder); 42 | $("#cancelOrder").click(_cancelOrder); 43 | return sortEle; 44 | } 45 | function _setBeginBtn(isBegin) { 46 | if(isBegin) { 47 | $(_that).find("tfoot").find("a[id='beginOrder']").css("display","none"); 48 | $(_that).find("tfoot").find("a[id='saveOrder']").css("display","inline"); 49 | $(_that).find("tfoot").find("a[id='cancelOrder']").css("display","inline"); 50 | $(_that).find("tfoot").find("span[id='sortRemind']").css("display","inline"); 51 | } else { 52 | $(_that).find("tfoot").find("a[id='beginOrder']").css("display","inline"); 53 | $(_that).find("tfoot").find("a[id='saveOrder']").css("display","none"); 54 | $(_that).find("tfoot").find("a[id='cancelOrder']").css("display","none"); 55 | $(_that).find("tfoot").find("span[id='sortRemind']").css("display","none"); 56 | } 57 | } 58 | function _beginOrder(event) { 59 | event.preventDefault(); 60 | if(!_isSort) { 61 | $(_that).find("thead tr").append("序号"); 62 | _setOrder(); 63 | sortEle.sortable("enable"); 64 | _isSort = true; 65 | _setBeginBtn(true); 66 | } else { 67 | alert("已经处于排序状态"); 68 | } 69 | } 70 | 71 | function _cancelOrder() { 72 | _isSort = false; 73 | $(_that).find("thead tr th:last-child").remove(); 74 | $(_that).find("tbody tr td:last-child").remove(); 75 | _setBeginBtn(false); 76 | sortEle.sortable("disable"); 77 | 78 | } 79 | 80 | function _saveOrder(event) { 81 | event.preventDefault(); 82 | if(_isSort) { 83 | var idArg = sortEle.sortable("serialize",{key:"ids"}); 84 | //alert(settings.url+"?"+idArg); 85 | $.post(settings.url+"?"+idArg,function(data){ 86 | //if($.ajaxCheck(data)) { 87 | if(data=='1') { 88 | _cancelOrder(); 89 | _setBeginBtn(false); 90 | } 91 | //} 92 | }); 93 | } else { 94 | alert("还不是排序状态"); 95 | } 96 | } 97 | 98 | function _setOrder() { 99 | $(_that).find("tbody tr").each(function(index){ 100 | if(_isSort) { 101 | $(this).find("td:last").html((index+1)); 102 | } else 103 | $(this).append(""+(index+1)+""); 104 | }); 105 | } 106 | return _init(); 107 | }; 108 | })(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/admin/myself/my_filter.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("#beginFilter").click(function() { 3 | var location = window.location.href; 4 | location = $.getBaseHref(location); 5 | var params = "?"; 6 | $(".filter_element").each(function(){ 7 | var val = $(this).val(); 8 | var n = $(this).attr("name"); 9 | var opt = $(this).attr("opt"); 10 | if(val!=""&&val!=-1) { 11 | params+=n+"="+opt+"-"+val+"&"; 12 | } 13 | }); 14 | window.location.href=location+params; 15 | }); 16 | 17 | $(".filter_element").each(function() { 18 | var thisObj = $(this); 19 | var id = $(thisObj).attr("name"); 20 | var val = $("input[targetId="+id+"]").val(); 21 | if (typeof(val) != "undefined") { 22 | $(thisObj).val(val); 23 | } 24 | }); 25 | }); -------------------------------------------------------------------------------- /src/main/resources/static/admin/myself/public.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $(".need_skip_url").click(function() { 3 | var targetUrl = $(this).attr("targetUrl"); 4 | if(targetUrl!=null && $.trim(targetUrl)!='') { 5 | window.location.href = targetUrl; 6 | } 7 | }); 8 | 9 | $(".file-size-show").each(function() { 10 | var size = parseInt($(this).html()); 11 | var html ; 12 | if(size<1024) {html = size+"B";} 13 | else if(size>=1024 && size<1024*1024) {html = parseInt(size/1024) + "KB";} 14 | else if(size>=1024*1024 && size<1024*1024*1024) {html = parseInt(size/1024/1024) + "MB";} 15 | else {html = parseInt(size/1024/1024/1024) + "GB";} 16 | $(this).html(html); 17 | }); 18 | }); 19 | /** bootstrap modal */ 20 | function showDialog(msg, title) { 21 | var idStr = "myModal_"+parseInt(Math.random()*100000000); 22 | if($.trim(title)=='') {title = "系统提示";} 23 | var html = ''; 24 | html += ''; 35 | 36 | $(html).appendTo("body"); 37 | $(("#"+idStr)).modal({keyboard:true, show:true}); 38 | $(("#"+idStr)).on('hidden.bs.modal', function (e) { 39 | $(("#"+idStr)).remove(); 40 | }); 41 | return $(("#"+idStr)); 42 | } 43 | 44 | /** bootstrap 提示框 */ 45 | function confirmDialog(msg, title, okfn) { 46 | var idStr = "myConfirmDialog_"+parseInt(Math.random()*100000000); 47 | if($.trim(title)=='') {title = "系统提示";} 48 | var html = ''; 49 | html += ''; 61 | 62 | $(html).appendTo("body"); 63 | $(("#"+idStr)).modal({keyboard:true, show:true}); 64 | $(("#"+idStr)).find(".dialog-ok-btn").click(okfn); 65 | $(("#"+idStr)).on('hidden.bs.modal', function (e) { 66 | $(("#"+idStr)).remove(); 67 | }); 68 | return $(("#"+idStr)); 69 | } -------------------------------------------------------------------------------- /src/main/resources/static/admin/myself/role_menus.js: -------------------------------------------------------------------------------- 1 | var curAuth_array; 2 | $(function() { 3 | var defaultData = $("#treeJson").val(); 4 | //alert(defaultData); 5 | defaultData = eval('(' + defaultData + ')'); //JSON.parse(defaultData); 6 | 7 | //alert(defaultData); 8 | var myMenuTree = $('#tree1').treeview({ 9 | data: defaultData, 10 | showIcon: true, 11 | showCheckbox: true, 12 | showTags: true, 13 | state:'', 14 | multiSelect: false, 15 | //levels: 99, //展开99级,基本也就是全部展开了 16 | onNodeChecked: function(event, node) { 17 | operate(node.text, "1"); 18 | }, 19 | onNodeUnchecked: function (event, node) { 20 | operate(node.text, "2"); 21 | } 22 | }); 23 | 24 | curAuth_array = $("#curAuth").val().split(","); 25 | for(var i=0; i")); 28 | } 29 | }); 30 | 31 | //alert(curAuth_array.length); 32 | 33 | //添加或删除数据 34 | function operate(name, flag) { 35 | var objId = $(name).attr("title"); //获取菜单Id 36 | //alert(objId+"=="+$.inArray(objId, curAuth_array)>=0); 37 | if(flag=='1' && $.inArray(objId, curAuth_array)>=0) {} //初始化时不作任何操作 38 | else { 39 | var roleId = $("#objId").val(); 40 | 41 | $.post("/admin/role/addOrDelRoleMenu", {roleId : roleId, menuId : objId}, function(res) { 42 | if(res!='1') {alert("授权资源菜单失败!");} 43 | }, "json"); 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/resources/static/admin/myself/user_roles.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $(".single-role-box").click(function() { 3 | var objId = $(this).attr("id"); //角色Id 4 | objId = objId.split("_")[1]; 5 | var userId = $("#curUserId").val(); //用户Id 6 | 7 | $.post("/admin/user/addOrDelUserRole", {userId : userId, roleId : objId}, function(datas) { 8 | if(datas=='1') { 9 | alert("设置成功!"); 10 | } 11 | }, "json"); 12 | }); 13 | var curAuth_array = $("#curRoles").val().split(","); 14 | for(var i=0; i=0) { 5 | return data.substr(0,data.indexOf("?")); 6 | } 7 | return data; 8 | }; 9 | })(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/basic/admin/myself/delete.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | $.fn.deleteFun = function(opts) { 3 | var _config = { 4 | title:"操作提示", 5 | msg:'' 6 | }; 7 | var _event = { 8 | click:_click, 9 | init:_init 10 | }; 11 | $.extend(_config, _event); 12 | 13 | var that = this; 14 | var settings = $.extend(_config, opts||{}); 15 | function _click(event) { 16 | var href = $(this).attr("href"); 17 | var tempMsg = settings.msg; 18 | if(!tempMsg) { 19 | tempMsg = $(this).attr("title"); 20 | if(!tempMsg) { 21 | tempMsg = $(this).html(); 22 | } 23 | } 24 | //alert(tempMsg); 25 | 26 | var modalDiv = ''; 42 | 43 | $(modalDiv).modal({keyboard:false, backdrop:'static'}); 44 | event.preventDefault(); 45 | } 46 | 47 | function _init() { 48 | $(that).on("click", settings.click); 49 | } 50 | 51 | settings.init(); 52 | 53 | return this; 54 | } 55 | })(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/basic/admin/myself/my.sortable.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | $.fn.sorttable = function(opts) { 3 | var _isSort = false; 4 | var sortEle = $(this).find("tbody"); 5 | var _that = this; 6 | var _cfg = { 7 | url:null, 8 | sn:"show", 9 | idIndex:0 10 | }; 11 | var settings = $.extend(_cfg,opts||{}); 12 | function _init() { 13 | $(_that).find("tfoot").append("" + 14 | "开始排序 " + 15 | "请拖动数据行进行排序  " + 16 | "取消排序 存储排序 " + 17 | ""); 18 | _setBeginBtn(false); 19 | $(_that).find("tbody tr").each(function(){ 20 | $(this).attr("id","id_"+$(this).find("td:eq("+settings.idIndex+")").html()); 21 | }); 22 | sortEle.sortable({ 23 | axis:"y", 24 | helper:function(e,ele) { 25 | //原始元素的td对象 26 | var _original = ele.children(); 27 | var _helper = ele.clone(); 28 | _helper.children().each(function(index){ 29 | $(this).width(_original.eq(index).width()); 30 | }); 31 | _helper.css("background","#888"); 32 | _helper.addClass("white"); 33 | return _helper; 34 | }, 35 | update:function(e,ui) { 36 | _setOrder(); 37 | } 38 | }); 39 | sortEle.sortable("disable"); 40 | $("#beginOrder").click(_beginOrder); 41 | $("#saveOrder").click(_saveOrder); 42 | $("#cancelOrder").click(_cancelOrder); 43 | return sortEle; 44 | } 45 | function _setBeginBtn(isBegin) { 46 | if(isBegin) { 47 | $(_that).find("tfoot").find("a[id='beginOrder']").css("display","none"); 48 | $(_that).find("tfoot").find("a[id='saveOrder']").css("display","inline"); 49 | $(_that).find("tfoot").find("a[id='cancelOrder']").css("display","inline"); 50 | $(_that).find("tfoot").find("span[id='sortRemind']").css("display","inline"); 51 | } else { 52 | $(_that).find("tfoot").find("a[id='beginOrder']").css("display","inline"); 53 | $(_that).find("tfoot").find("a[id='saveOrder']").css("display","none"); 54 | $(_that).find("tfoot").find("a[id='cancelOrder']").css("display","none"); 55 | $(_that).find("tfoot").find("span[id='sortRemind']").css("display","none"); 56 | } 57 | } 58 | function _beginOrder(event) { 59 | event.preventDefault(); 60 | if(!_isSort) { 61 | $(_that).find("thead tr").append("序号"); 62 | _setOrder(); 63 | sortEle.sortable("enable"); 64 | _isSort = true; 65 | _setBeginBtn(true); 66 | } else { 67 | alert("已经处于排序状态"); 68 | } 69 | } 70 | 71 | function _cancelOrder() { 72 | _isSort = false; 73 | $(_that).find("thead tr th:last-child").remove(); 74 | $(_that).find("tbody tr td:last-child").remove(); 75 | _setBeginBtn(false); 76 | sortEle.sortable("disable"); 77 | 78 | } 79 | 80 | function _saveOrder(event) { 81 | event.preventDefault(); 82 | if(_isSort) { 83 | var idArg = sortEle.sortable("serialize",{key:"ids"}); 84 | //alert(settings.url+"?"+idArg); 85 | $.post(settings.url+"?"+idArg,function(data){ 86 | //if($.ajaxCheck(data)) { 87 | if(data=='1') { 88 | _cancelOrder(); 89 | _setBeginBtn(false); 90 | } 91 | //} 92 | }); 93 | } else { 94 | alert("还不是排序状态"); 95 | } 96 | } 97 | 98 | function _setOrder() { 99 | $(_that).find("tbody tr").each(function(index){ 100 | if(_isSort) { 101 | $(this).find("td:last").html((index+1)); 102 | } else 103 | $(this).append(""+(index+1)+""); 104 | }); 105 | } 106 | return _init(); 107 | }; 108 | })(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/basic/admin/myself/my_filter.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("#beginFilter").click(function() { 3 | var location = window.location.href; 4 | location = $.getBaseHref(location); 5 | var params = "?"; 6 | $(".filter_element").each(function(){ 7 | var val = $(this).val(); 8 | var n = $(this).attr("name"); 9 | var opt = $(this).attr("opt"); 10 | if(val!=""&&val!=-1) { 11 | params+=n+"="+opt+"-"+val+"&"; 12 | } 13 | }); 14 | window.location.href=location+params; 15 | }); 16 | 17 | $(".filter_element").each(function() { 18 | var thisObj = $(this); 19 | var id = $(thisObj).attr("name"); 20 | var val = $("input[targetId="+id+"]").val(); 21 | if (typeof(val) != "undefined") { 22 | $(thisObj).val(val); 23 | } 24 | }); 25 | }); -------------------------------------------------------------------------------- /src/main/resources/static/basic/admin/myself/public.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $(".need_skip_url").click(function() { 3 | var targetUrl = $(this).attr("targetUrl"); 4 | if(targetUrl!=null && $.trim(targetUrl)!='') { 5 | window.location.href = targetUrl; 6 | } 7 | }); 8 | 9 | $(".file-size-show").each(function() { 10 | var size = parseInt($(this).html()); 11 | var html ; 12 | if(size<1024) {html = size+"B";} 13 | else if(size>=1024 && size<1024*1024) {html = parseInt(size/1024) + "KB";} 14 | else if(size>=1024*1024 && size<1024*1024*1024) {html = parseInt(size/1024/1024) + "MB";} 15 | else {html = parseInt(size/1024/1024/1024) + "GB";} 16 | $(this).html(html); 17 | }); 18 | }); 19 | /** bootstrap modal */ 20 | function showDialog(msg, title) { 21 | var idStr = "myModal_"+parseInt(Math.random()*100000000); 22 | if($.trim(title)=='') {title = "系统提示";} 23 | var html = ''; 24 | html += ''; 35 | 36 | $(html).appendTo("body"); 37 | $(("#"+idStr)).modal({keyboard:true, show:true}); 38 | $(("#"+idStr)).on('hidden.bs.modal', function (e) { 39 | $(("#"+idStr)).remove(); 40 | }); 41 | return $(("#"+idStr)); 42 | } 43 | 44 | /** bootstrap 提示框 */ 45 | function confirmDialog(msg, title, okfn) { 46 | var idStr = "myConfirmDialog_"+parseInt(Math.random()*100000000); 47 | if($.trim(title)=='') {title = "系统提示";} 48 | var html = ''; 49 | html += ''; 61 | 62 | $(html).appendTo("body"); 63 | $(("#"+idStr)).modal({keyboard:true, show:true}); 64 | $(("#"+idStr)).find(".dialog-ok-btn").click(okfn); 65 | $(("#"+idStr)).on('hidden.bs.modal', function (e) { 66 | $(("#"+idStr)).remove(); 67 | }); 68 | return $(("#"+idStr)); 69 | } -------------------------------------------------------------------------------- /src/main/resources/static/basic/admin/myself/role_menus.js: -------------------------------------------------------------------------------- 1 | var curAuth_array; 2 | $(function() { 3 | var defaultData = $("#treeJson").val(); 4 | //alert(defaultData); 5 | defaultData = eval('(' + defaultData + ')'); //JSON.parse(defaultData); 6 | 7 | //alert(defaultData); 8 | var myMenuTree = $('#tree1').treeview({ 9 | data: defaultData, 10 | showIcon: true, 11 | showCheckbox: true, 12 | showTags: true, 13 | state:'', 14 | multiSelect: false, 15 | //levels: 99, //展开99级,基本也就是全部展开了 16 | onNodeChecked: function(event, node) { 17 | operate(node.text, "1"); 18 | }, 19 | onNodeUnchecked: function (event, node) { 20 | operate(node.text, "2"); 21 | } 22 | }); 23 | 24 | curAuth_array = $("#curAuth").val().split(","); 25 | for(var i=0; i")); 28 | } 29 | }); 30 | 31 | //alert(curAuth_array.length); 32 | 33 | //添加或删除数据 34 | function operate(name, flag) { 35 | var objId = $(name).attr("title"); //获取菜单Id 36 | //alert(objId+"=="+$.inArray(objId, curAuth_array)>=0); 37 | if(flag=='1' && $.inArray(objId, curAuth_array)>=0) {} //初始化时不作任何操作 38 | else { 39 | var roleId = $("#objId").val(); 40 | 41 | $.post("/admin/role/addOrDelRoleMenu", {roleId : roleId, menuId : objId}, function(res) { 42 | if(res!='1') {alert("授权资源菜单失败!");} 43 | }, "json"); 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/resources/static/basic/admin/myself/user_roles.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $(".single-role-box").click(function() { 3 | var objId = $(this).attr("id"); //角色Id 4 | objId = objId.split("_")[1]; 5 | var userId = $("#curUserId").val(); //用户Id 6 | 7 | $.post("/admin/user/addOrDelUserRole", {userId : userId, roleId : objId}, function(datas) { 8 | if(datas=='1') { 9 | alert("设置成功!"); 10 | } 11 | }, "json"); 12 | }); 13 | var curAuth_array = $("#curRoles").val().split(","); 14 | for(var i=0; i li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/@fa-line-height-base FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | 14 | .fa-icon-rotate(@degrees, @rotation) { 15 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=@{rotation})"; 16 | -webkit-transform: rotate(@degrees); 17 | -ms-transform: rotate(@degrees); 18 | transform: rotate(@degrees); 19 | } 20 | 21 | .fa-icon-flip(@horiz, @vert, @rotation) { 22 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=@{rotation}, mirror=1)"; 23 | -webkit-transform: scale(@horiz, @vert); 24 | -ms-transform: scale(@horiz, @vert); 25 | transform: scale(@horiz, @vert); 26 | } 27 | 28 | 29 | // Only display content to screen readers. A la Bootstrap 4. 30 | // 31 | // See: http://a11yproject.com/posts/how-to-hide-content/ 32 | 33 | .sr-only() { 34 | position: absolute; 35 | width: 1px; 36 | height: 1px; 37 | padding: 0; 38 | margin: -1px; 39 | overflow: hidden; 40 | clip: rect(0,0,0,0); 41 | border: 0; 42 | } 43 | 44 | // Use in conjunction with .sr-only to only display content when it's focused. 45 | // 46 | // Useful for "Skip to main content" links; see http://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1 47 | // 48 | // Credit: HTML5 Boilerplate 49 | 50 | .sr-only-focusable() { 51 | &:active, 52 | &:focus { 53 | position: static; 54 | width: auto; 55 | height: auto; 56 | margin: 0; 57 | overflow: visible; 58 | clip: auto; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/less/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .@{fa-css-prefix}-rotate-90, 15 | :root .@{fa-css-prefix}-rotate-180, 16 | :root .@{fa-css-prefix}-rotate-270, 17 | :root .@{fa-css-prefix}-flip-horizontal, 18 | :root .@{fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/less/screen-reader.less: -------------------------------------------------------------------------------- 1 | // Screen Readers 2 | // ------------------------- 3 | 4 | .sr-only { .sr-only(); } 5 | .sr-only-focusable { .sr-only-focusable(); } 6 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_animated.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .#{$fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_bordered-pulled.scss: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em $fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .#{$fa-css-prefix}-pull-left { float: left; } 11 | .#{$fa-css-prefix}-pull-right { float: right; } 12 | 13 | .#{$fa-css-prefix} { 14 | &.#{$fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.#{$fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .#{$fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_larger.scss: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .#{$fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .#{$fa-css-prefix}-2x { font-size: 2em; } 11 | .#{$fa-css-prefix}-3x { font-size: 3em; } 12 | .#{$fa-css-prefix}-4x { font-size: 4em; } 13 | .#{$fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | 14 | @mixin fa-icon-rotate($degrees, $rotation) { 15 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation})"; 16 | -webkit-transform: rotate($degrees); 17 | -ms-transform: rotate($degrees); 18 | transform: rotate($degrees); 19 | } 20 | 21 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 22 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}, mirror=1)"; 23 | -webkit-transform: scale($horiz, $vert); 24 | -ms-transform: scale($horiz, $vert); 25 | transform: scale($horiz, $vert); 26 | } 27 | 28 | 29 | // Only display content to screen readers. A la Bootstrap 4. 30 | // 31 | // See: http://a11yproject.com/posts/how-to-hide-content/ 32 | 33 | @mixin sr-only { 34 | position: absolute; 35 | width: 1px; 36 | height: 1px; 37 | padding: 0; 38 | margin: -1px; 39 | overflow: hidden; 40 | clip: rect(0,0,0,0); 41 | border: 0; 42 | } 43 | 44 | // Use in conjunction with .sr-only to only display content when it's focused. 45 | // 46 | // Useful for "Skip to main content" links; see http://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1 47 | // 48 | // Credit: HTML5 Boilerplate 49 | 50 | @mixin sr-only-focusable { 51 | &:active, 52 | &:focus { 53 | position: static; 54 | width: auto; 55 | height: auto; 56 | margin: 0; 57 | overflow: visible; 58 | clip: auto; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_screen-reader.scss: -------------------------------------------------------------------------------- 1 | // Screen Readers 2 | // ------------------------- 3 | 4 | .sr-only { @include sr-only(); } 5 | .sr-only-focusable { @include sr-only-focusable(); } 6 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome-4.7.0/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "animated"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | @import "screen-reader"; 19 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/font-awesome/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/font-awesome/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/59ZRklaO5bWGqF5A9baEERJtnKITppOI_IvcXXDNrsc.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/59ZRklaO5bWGqF5A9baEERJtnKITppOI_IvcXXDNrsc.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTRWV49_lSm1NYrwo-zkhivY.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTRWV49_lSm1NYrwo-zkhivY.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTT0LW-43aMEzIO6XUTLjad8.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTT0LW-43aMEzIO6XUTLjad8.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTZX5f-9o1vgP2EXwfjgl7AY.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTZX5f-9o1vgP2EXwfjgl7AY.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTa-j2U0lmluP9RWlSytm3ho.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTa-j2U0lmluP9RWlSytm3ho.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTaaRobkAwv3vxw3jMhVENGA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTaaRobkAwv3vxw3jMhVENGA.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTegdm0LZdjqr5-oayXSOefg.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTegdm0LZdjqr5-oayXSOefg.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTf8zf_FOSsgRmwsS7Aa9k2w.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/DXI1ORHCpsQm3Vp6mXoaTf8zf_FOSsgRmwsS7Aa9k2w.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/K88pR3goAWT7BTt32Z01mxJtnKITppOI_IvcXXDNrsc.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/K88pR3goAWT7BTt32Z01mxJtnKITppOI_IvcXXDNrsc.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/LWCjsQkB6EMdfHrEVqA1KRJtnKITppOI_IvcXXDNrsc.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/LWCjsQkB6EMdfHrEVqA1KRJtnKITppOI_IvcXXDNrsc.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/RjgO7rYTmqiVp7vzi-Q5URJtnKITppOI_IvcXXDNrsc.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/RjgO7rYTmqiVp7vzi-Q5URJtnKITppOI_IvcXXDNrsc.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/cJZKeOuBrn4kERxqtaUH3VtXRa8TVwTICgirnJhmVJw.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/cJZKeOuBrn4kERxqtaUH3VtXRa8TVwTICgirnJhmVJw.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/fonts/xozscpT2726on7jbcb_pAhJtnKITppOI_IvcXXDNrsc.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/fonts/xozscpT2726on7jbcb_pAhJtnKITppOI_IvcXXDNrsc.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/basic/init/css/main.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | background:url("./pattern.jpg"); 3 | } 4 | .my-top-header { 5 | background: url("./pattern2.jpg"); 6 | } -------------------------------------------------------------------------------- /src/main/resources/static/basic/init/css/pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/init/css/pattern.jpg -------------------------------------------------------------------------------- /src/main/resources/static/basic/init/css/pattern2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/init/css/pattern2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/basic/init/css/style.css: -------------------------------------------------------------------------------- 1 | .m-t-1 { 2 | margin-top: 10px; 3 | } 4 | 5 | .input-icon { 6 | display: inline-block; 7 | position: relative; 8 | } 9 | 10 | .input-icon .btn{ 11 | height: 28px!important; 12 | margin-top: -3px; 13 | font-size: 13px; 14 | line-height: 1.3; 15 | padding-top: 2px; 16 | padding-bottom: 2px; 17 | } 18 | 19 | .input-icon .search-input { 20 | border: 1px solid #6FB3E0; 21 | height: 28px!important; 22 | padding-top: 2px; 23 | padding-bottom: 2px; 24 | border-radius: 4px!important; 25 | font-size: 13px; 26 | line-height: 1.3; 27 | color: #666!important; 28 | z-index: 11; 29 | transition: width ease .15s; 30 | } 31 | 32 | .input-icon .ace-icon { 33 | z-index: 2; 34 | position: absolute; 35 | top: 1px; 36 | bottom: 1px; 37 | left: 3px; 38 | display: inline-block; 39 | line-height: 24px; 40 | color: #6FB3E0!important; 41 | } 42 | 43 | 44 | .ace-settings-container .pagination { 45 | margin:0px; margin-top:8px; margin-right:12px; 46 | } 47 | 48 | .remind-red { 49 | color:#F00; padding:0px 8px; 50 | } 51 | 52 | .remind-gray { 53 | color:#888; margin:5px 0px; 54 | } 55 | 56 | .upload-info-div { 57 | border:1px #ddd solid; height:280px; margin:5px; vertical-align: middle; line-height:280px; 58 | border-radius: 5px; 59 | } 60 | 61 | 62 | a.upload-img-href { 63 | border:none; border-radius:5px; 64 | } 65 | a.upload-img-href img { 66 | width:100%; height:100%; border-radius:5px; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/js-lib/images/input-checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/js-lib/images/input-checked.png -------------------------------------------------------------------------------- /src/main/resources/static/basic/js-lib/images/input-unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/js-lib/images/input-unchecked.png -------------------------------------------------------------------------------- /src/main/resources/static/basic/js-lib/jquery-labelauty.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * LABELAUTY jQuery Plugin Styles 3 | * 4 | * @file: jquery-labelauty.css 5 | * @author: Francisco Neves (@fntneves) 6 | * @site: www.francisconeves.com 7 | * @license: MIT License 8 | */ 9 | 10 | /* Prevent text and blocks selection */ 11 | input.labelauty + label ::selection { background-color: rgba(255, 255, 255, 0); } 12 | input.labelauty + label ::-moz-selection { background-color: rgba(255, 255, 255, 0); } 13 | 14 | /* Hide original checkboxes. They are ugly! */ 15 | input.labelauty { display: none !important; } 16 | 17 | /* 18 | * Let's style the input 19 | * Feel free to work with it as you wish! 20 | */ 21 | input.labelauty + label 22 | { 23 | display: inline; 24 | font-size: 14px; 25 | padding: 10px 6px; 26 | background-color: #efefef; 27 | color: #b3b3b3; 28 | cursor: pointer; 29 | 30 | border-radius: 3px 3px 3px 3px; 31 | -moz-border-radius: 3px 3px 3px 3px; 32 | -webkit-border-radius: 3px 3px 3px 3px; 33 | 34 | transition: background-color 0.25s; 35 | -moz-transition: background-color 0.25s; 36 | -webkit-transition: background-color 0.25s; 37 | -o-transition: background-color 0.25s; 38 | 39 | -moz-user-select: none; 40 | -khtml-user-select: none; 41 | -webkit-user-select: none; 42 | -o-user-select: none; 43 | } 44 | 45 | /* Stylish text inside label */ 46 | 47 | input.labelauty + label > span.labelauty-unchecked, 48 | input.labelauty + label > span.labelauty-checked 49 | { 50 | display: inline-block; 51 | line-height: 16px; 52 | vertical-align: bottom; 53 | } 54 | 55 | /* Stylish icons inside label */ 56 | 57 | input.labelauty + label > span.labelauty-unchecked-image, 58 | input.labelauty + label > span.labelauty-checked-image 59 | { 60 | display: inline-block; 61 | width: 16px; 62 | height: 16px; 63 | vertical-align: bottom; 64 | background-repeat: no-repeat; 65 | background-position: left center; 66 | 67 | transition: background-image 0.5s linear; 68 | -moz-transition: background-image 0.5s linear; 69 | -webkit-transition: background-image 0.5s linear; 70 | -o-transition: background-image 0.5s linear; 71 | } 72 | 73 | /* When there's a label, add a little margin to the left */ 74 | input.labelauty + label > span.labelauty-unchecked-image + span.labelauty-unchecked, 75 | input.labelauty + label > span.labelauty-checked-image + span.labelauty-checked 76 | { 77 | margin-left: 7px; 78 | } 79 | 80 | /* When not Checked */ 81 | input.labelauty:not(:checked):not([disabled]) + label:hover 82 | { 83 | background-color: #eaeaea; 84 | color: #a7a7a7; 85 | } 86 | input.labelauty:not(:checked) + label > span.labelauty-checked-image 87 | { 88 | display: none; 89 | } 90 | 91 | input.labelauty:not(:checked) + label > span.labelauty-checked 92 | { 93 | display: none; 94 | } 95 | 96 | /* When Checked */ 97 | input.labelauty:checked + label 98 | { 99 | background-color: #3498db; 100 | color: #ffffff; 101 | } 102 | 103 | input.labelauty:checked:not([disabled]) + label:hover 104 | { 105 | background-color: #72c5fd; 106 | } 107 | input.labelauty:checked + label > span.labelauty-unchecked-image 108 | { 109 | display: none; 110 | } 111 | 112 | input.labelauty:checked + label > span.labelauty-unchecked 113 | { 114 | display: none; 115 | } 116 | 117 | input.labelauty:checked + label > span.labelauty-checked 118 | { 119 | display: inline-block; 120 | } 121 | 122 | input.labelauty.no-label:checked + label > span.labelauty-checked 123 | { 124 | display: block; 125 | } 126 | 127 | /* When Disabled */ 128 | input.labelauty[disabled] + label 129 | { 130 | opacity: 0.5; 131 | } 132 | 133 | /* Add a background to (un)checked images */ 134 | input.labelauty + label > span.labelauty-unchecked-image 135 | { 136 | background-image: url( images/input-unchecked.png ); 137 | } 138 | 139 | input.labelauty + label > span.labelauty-checked-image 140 | { 141 | background-image: url( images/input-checked.png ); 142 | } 143 | .dowebok{ margin-top:-20px;} 144 | .dowebok li{ float:left; margin:5px;} 145 | .x10{height:1px; width:100%; float:left;} 146 | -------------------------------------------------------------------------------- /src/main/resources/static/basic/login-new/images/bg-img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/basic/login-new/images/bg-img.jpg -------------------------------------------------------------------------------- /src/main/resources/static/basic/login-new/login.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | background:url("images/bg-img.jpg"); 3 | } 4 | 5 | .head-part { 6 | height:80px; background:#FFF; padding:10px 0px; 7 | 8 | -webkit-box-shadow:0 0 10px #777; 9 | -moz-box-shadow:0 0 10px #777; 10 | box-shadow:0 0 10px #777; 11 | } 12 | 13 | .login-icon { 14 | font-size:55px; color:#3b8cff; 15 | } 16 | .login-title { 17 | font-size:30px; color:#3b8cff; font-family:'微软雅黑'; 18 | } 19 | 20 | 21 | .login-main { 22 | width:70%; text-align:center; margin-left:15%; margin-top:50px; 23 | } 24 | .login-main .title { 25 | text-align:left; margin-bottom:15px; 26 | } 27 | .login-main .title b { 28 | text-align:left; color:#3b8cff; font-size:16px; margin-left:10px; 29 | } 30 | 31 | .login-main .title a { 32 | float:right; color:#555; margin-right:10px; 33 | } 34 | 35 | .login-main .login-box { 36 | border:1px #c0d0e7 solid; border-radius:5px; background:#f0f4fa; padding:15px 0px; 37 | } 38 | 39 | .login-main .login-box label { 40 | margin-top:30px; color:#888; 41 | } 42 | 43 | .login-main .login-box div.col-md-6 { 44 | padding:0px 20px; 45 | } 46 | 47 | .login-main .login-box div.col-md-6:first-child { 48 | border-right:1px #ddd solid; 49 | } 50 | 51 | .login-main .login-box div.col-md-6:last-child { 52 | border-left:1px #FFF solid; 53 | } 54 | 55 | .login-main .login-box div.col-md-6 p.remind { 56 | font-size:15px; margin-top:25px; text-align:left; color:#40aaef; font-family:'微软雅黑'; 57 | } 58 | .login-main .login-box div.col-md-6 p.remind:first-child { 59 | margin-top:35px; color:#fba848; 60 | } 61 | .login-main .login-box div.col-md-6 p.remind i { 62 | font-size:50px; width:60px; text-align:center; 63 | } 64 | .login-main .login-box div.col-md-6 p.remind:last-child { 65 | color:#58be89; 66 | } 67 | 68 | 69 | .show-year { 70 | padding:0px 10px 0px 5px; 71 | } 72 | 73 | .login-bottom { 74 | line-height:50px; color:#999; 75 | } -------------------------------------------------------------------------------- /src/main/resources/static/basic/login-new/login.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | var date = new Date(); 3 | var year = date.getFullYear(); 4 | $(".show-year").html(year+"-"+(year+1)); 5 | 6 | //设置高度 7 | var leftHeight = $(".login-box div.col-md-6:first-child").height(); 8 | $(".login-box div.col-md-6:last-child").height(leftHeight); 9 | }); -------------------------------------------------------------------------------- /src/main/resources/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsl131/web-basic/998134ebccf67c3338cc0e6a457b0dc800ce2432/src/main/resources/static/favicon.png -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/appConfig/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 网站配置管理 10 | 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 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/errors/404.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 404错误 10 | 11 | 12 |
13 |
14 | 出现错误 15 | 前台首页 16 |
17 | 29 |
30 | 31 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/errors/500.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 500错误 10 | 11 | 12 |
13 |
14 | 出现错误 15 | 前台首页 16 |
17 | 29 |
30 | 31 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/errors/default.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 系统异常 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 34 |
35 |

36 | 37 |
38 | 异常信息 39 | 40 |

41 |
42 |

43 |

44 |

45 |
46 | 47 | 52 |
53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/errors/system.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 系统异常 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 |
28 | 37 |
38 |

39 | 40 |
41 | 异常信息 42 | 43 |

44 |
45 |

46 |

47 |

48 |
49 | 50 | 55 |
56 |
57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 后台首页 10 | 11 | 12 |
13 | 16 | 17 |
18 | 21 | 22 | 欢迎登陆 23 | 24 | 系统名称 25 | 版本 26 | 27 | ,登陆IP:登陆IP,登陆时间: 28 | 29 |
30 | 31 |
32 |
33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/login.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 用户登陆 9 | 10 | 11 | 12 |
13 |
14 | 用户登陆 15 | 前台首页 16 |
17 | 40 | 41 |
42 | 43 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/menu/nav.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 |
6 |
7 | 11 |
12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/menu/update.html: -------------------------------------------------------------------------------- 1 | 2 | 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 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/role/add.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 添加角色 11 | 12 | 13 |
14 |
15 |

 添加角色

16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 |
24 | 25 | 26 |
27 | 49 |
50 | 51 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/role/filter.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 |
6 |
7 |
8 | 名称 9 | 10 |
11 | 12 | 13 |
14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/role/list.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 角色列表 10 | 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 | 53 | 54 | 55 |
ID名称SN操作
${obj.id}${obj.name}${obj.sn} 42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 |
56 |
57 |
58 |
59 | 60 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/role/menus.html: -------------------------------------------------------------------------------- 1 | 2 | 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 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/role/nav.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 |
6 |
7 | 11 |
12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/role/update.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 修改角色 11 | 12 | 13 |
14 |
15 |

 修改角色

16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 |
24 | 25 | 26 |
27 | 49 |
50 | 51 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/user/add.html: -------------------------------------------------------------------------------- 1 | 2 | 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 | 117 |
118 | 119 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/user/list.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 用户列表 11 | 16 | 17 | 18 | 19 |
20 |
21 |

 用户列表

22 |
23 |
24 | 25 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 49 | 62 | 63 | 64 |
ID名称状态操作
${obj.id}${obj.name} 44 |
45 |

正常

46 |

停用

47 |
48 |
50 |
51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
61 |
65 |
66 |
67 |
68 | 69 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/user/nav.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 |
6 |
7 | 11 |
12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/user/roles.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 为用户授权 12 | 13 | 14 |
15 |
16 |

 为用户授权

17 |
18 |
19 |
20 |
21 |

在角色名前面打钩则表示授权(共有【】个角色)

22 |
23 | 24 | 32 | 33 | 34 |
35 | 36 |
37 | 38 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/basic/user/update.html: -------------------------------------------------------------------------------- 1 | 2 | 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 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragments/adminModel.html: -------------------------------------------------------------------------------- 1 | 2 | 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 | 41 | 42 | 43 |
44 | 48 |
49 | 50 | 51 | 改密 52 | 退出 53 |
54 |
55 | 56 |
57 |
58 |
59 | 60 |
61 |
62 |
63 |
64 |
65 | 66 | 71 |
72 | 73 |
74 | 75 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragments/errorModel.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 用户登陆 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 | 30 | 31 |
32 |
33 | 34 |
35 | 36 |
37 | 40 |
41 | 42 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragments/nav.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 用户管理 9 | 10 | 11 | 66 | 67 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragments/page.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 用户管理 9 | 10 | 11 |
12 |
13 |
    16 | 17 | 18 |
  • 首页
  • 19 |
  • 上一页
  • 20 | 21 | 22 |
    23 |
    24 | 25 |
  • ${pageNumber}
  • 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 | -------------------------------------------------------------------------------- /src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello Spring Boot! 6 | 7 | 8 | 9 |
10 | 22 |
23 | 24 |
25 |
26 | ====+++++==== 27 |
28 |
29 | 30 |
31 |
© 2016 blog.codeleak.pl
32 |
33 | 34 | -------------------------------------------------------------------------------- /src/main/resources/templates/test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 |
20 |
21 |

测试js是否起作用

22 |
23 |
24 |
25 | 27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 | 35 | -------------------------------------------------------------------------------- /src/test/java/com/zslin/MenuTest.java: -------------------------------------------------------------------------------- 1 | package com.zslin; 2 | 3 | import com.zslin.basic.dto.MenuDto; 4 | import com.zslin.basic.model.Menu; 5 | import com.zslin.basic.service.MenuServiceImpl; 6 | import com.zslin.basic.tools.AuthTools; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.ActiveProfiles; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by 钟述林 393156105@qq.com on 2016/10/26 11:30. 18 | */ 19 | @SpringBootTest 20 | @RunWith(SpringRunner.class) 21 | @ActiveProfiles("zsl") 22 | public class MenuTest { 23 | 24 | @Autowired 25 | private AuthTools authTools; 26 | 27 | @Autowired 28 | private MenuServiceImpl menuServiceImpl; 29 | 30 | @Test 31 | public void initMenus() { 32 | //com/zslin/*/controller/**Controller.class 33 | authTools.buildSystemMenu("com/zslin/basic/controller/*Controller.class"); 34 | } 35 | 36 | @Test 37 | public void testQueryMenus() { 38 | List list = menuServiceImpl.queryMenuDtoNew(1); 39 | System.out.println(list.size()); 40 | for(MenuDto md : list) { 41 | System.out.println("==========="+md.getPm().getName()); 42 | for(Menu m : md.getChildren()) { 43 | System.out.println(" ++" + m.getName()); 44 | } 45 | } 46 | } 47 | } 48 | --------------------------------------------------------------------------------