Commit 774fd11e3f3ec07a73c8c5f7b52c1ce144360e6b

Authored by 王通
1 parent ca0c3273

1.CSP header

2.密码验证、强制更新弱密码,管理员重置密码,解锁账号
3.白名单套装
4.密码错误多次锁定账号
Showing 42 changed files with 5924 additions and 3297 deletions
src/main/java/com/bsth/Application.java
1   -package com.bsth;
2   -
3   -import com.fasterxml.jackson.databind.ObjectMapper;
4   -import com.fasterxml.jackson.databind.SerializationFeature;
5   -import org.springframework.boot.SpringApplication;
6   -import org.springframework.boot.autoconfigure.SpringBootApplication;
7   -import org.springframework.boot.builder.SpringApplicationBuilder;
8   -import org.springframework.boot.context.web.SpringBootServletInitializer;
9   -import org.springframework.context.annotation.Bean;
10   -import org.springframework.context.annotation.Primary;
11   -import org.springframework.transaction.annotation.EnableTransactionManagement;
12   -
13   -import java.util.concurrent.Executors;
14   -import java.util.concurrent.ScheduledExecutorService;
15   -
16   -@EnableTransactionManagement
17   -@SpringBootApplication
18   -public class Application extends SpringBootServletInitializer {
19   -
20   - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18);
21   -
22   - @Override
23   - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
24   - return application.sources(Application.class);
25   - }
26   -
27   - @Bean
28   - @Primary
29   - public ObjectMapper objectMapper() {
30   - ObjectMapper objectMapper = new ObjectMapper();
31   - objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
32   -
33   - return objectMapper;
34   - }
35   -
36   - public static void main(String[] args) throws Exception {
37   - SpringApplication.run(Application.class, args);
38   - }
  1 +package com.bsth;
  2 +
  3 +import com.bsth.data.SystemParamCache;
  4 +import com.fasterxml.jackson.databind.ObjectMapper;
  5 +import com.fasterxml.jackson.databind.SerializationFeature;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.boot.SpringApplication;
  8 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  9 +import org.springframework.boot.builder.SpringApplicationBuilder;
  10 +import org.springframework.boot.context.web.SpringBootServletInitializer;
  11 +import org.springframework.context.annotation.Bean;
  12 +import org.springframework.context.annotation.Primary;
  13 +import org.springframework.transaction.annotation.EnableTransactionManagement;
  14 +
  15 +import java.util.concurrent.Executors;
  16 +import java.util.concurrent.ScheduledExecutorService;
  17 +
  18 +@EnableTransactionManagement
  19 +@SpringBootApplication
  20 +public class Application extends SpringBootServletInitializer {
  21 +
  22 + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(21);
  23 +
  24 + @Autowired
  25 + private SystemParamCache systemParamCache;
  26 +
  27 + @Override
  28 + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  29 + return application.sources(Application.class);
  30 + }
  31 +
  32 + @Bean
  33 + @Primary
  34 + public ObjectMapper objectMapper() {
  35 + ObjectMapper objectMapper = new ObjectMapper();
  36 + objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
  37 +
  38 + return objectMapper;
  39 + }
  40 +
  41 + public static void main(String[] args) throws Exception {
  42 + SpringApplication.run(Application.class, args);
  43 + }
39 44 }
40 45 \ No newline at end of file
... ...
src/main/java/com/bsth/common/Constants.java
1   -package com.bsth.common;
2   -
3   -/**
4   - *
5   - * @ClassName: Constants
6   - * @Description: TODO(常量类)
7   - * @author PanZhao
8   - * @date 2016年3月18日 下午11:06:53
9   - *
10   - */
11   -public class Constants {
12   -
13   - /**
14   - * 不需要拦截的资源
15   - */
16   - public static final String LOGIN = "/user/login/**";
17   - public static final String LOGIN_PAGE = "/login.html";
18   - public static final String ASSETS_URL = "/assets/**";
19   - public static final String FAVICON_URL = "/favicon.ico";
20   - public static final String METRONIC_URL = "/metronic_v4.5.4/**";
21   - public static final String LOGIN_FAILURE = "/user/loginFailure";
22   - public static final String CAPTCHA = "/captcha.jpg";
23   - public static final String XIANDIAO_LOGIN = "/xdlogin.html";
24   - public static final String IPAD_IMG_URL = "/apple-touch-icon-72x72.png";
25   -
26   - //对外的营运数据接口
27   - public static final String SERVICE_INTERFACE = "/companyService/**";
28   -
29   - /**
30   - * 线调部分子页面不做拦截,便于浏览器缓存
31   - */
32   - public static final String XD_CHILD_PAGES = "/real_control_v2/**";
33   - public static final String XD_REAL_GPS = "/gps/real/line";
34   - //public static final String XD_TEMPS = "/pages/control/line/temps/**";
35   -
36   - //车载网关上行接口
37   - public static final String UPSTREAM_URL = "/control/upstream";
38   - //rfid 上传入口
39   - public static final String UP_RFID_URL = "/rfid/**";
40   -
41   - public static final String SESSION_USERNAME = "sessionUserName";
42   - public static final String COMPANY_AUTHORITYS = "cmyAuths";
43   - public static final String STATION_AND_SECTION_COUNT = "/station/updateStationAndSectionCode";
44   -
45   - /**
46   - * 解除调度指令和班次的外键约束
47   - */
48   - public static final String REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch=?";
49   -
50   - /**
51   - * 批量解除调度指令和班次的外键约束
52   - */
53   - public static final String MULTI_REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch in ";
54   -}
  1 +package com.bsth.common;
  2 +
  3 +/**
  4 + *
  5 + * @ClassName: Constants
  6 + * @Description: TODO(常量类)
  7 + * @author PanZhao
  8 + * @date 2016年3月18日 下午11:06:53
  9 + *
  10 + */
  11 +public class Constants {
  12 +
  13 + /**
  14 + * 不需要拦截的资源
  15 + */
  16 + public static final String LOGIN = "/user/login/**";
  17 + public static final String ORIGINAL_LOGIN_PAGE = "/login.html";
  18 + public static String LOGIN_PAGE = "/login.html";
  19 + public static final String ASSETS_URL = "/assets/**";
  20 + public static final String FAVICON_URL = "/favicon.ico";
  21 + public static final String METRONIC_URL = "/metronic_v4.5.4/**";
  22 + public static final String LOGIN_FAILURE = "/user/loginFailure";
  23 + public static final String CAPTCHA = "/captcha.jpg";
  24 + public static final String XIANDIAO_LOGIN = "/xdlogin.html";
  25 + public static final String IPAD_IMG_URL = "/apple-touch-icon-72x72.png";
  26 +
  27 + //对外的营运数据接口
  28 + public static final String SERVICE_INTERFACE = "/companyService/**";
  29 +
  30 + /**
  31 + * 线调部分子页面不做拦截,便于浏览器缓存
  32 + */
  33 + public static final String XD_CHILD_PAGES = "/real_control_v2/**";
  34 + public static final String XD_REAL_GPS = "/gps/real/line";
  35 + //public static final String XD_TEMPS = "/pages/control/line/temps/**";
  36 +
  37 + //车载网关上行接口
  38 + public static final String UPSTREAM_URL = "/control/upstream";
  39 + //rfid 上传入口
  40 + public static final String UP_RFID_URL = "/rfid/**";
  41 +
  42 + public static final String SESSION_USERNAME = "sessionUserName";
  43 + public static final String COMPANY_AUTHORITYS = "cmyAuths";
  44 + public static final String STATION_AND_SECTION_COUNT = "/station/updateStationAndSectionCode";
  45 +
  46 + /**
  47 + * 解除调度指令和班次的外键约束
  48 + */
  49 + public static final String REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch=?";
  50 +
  51 + /**
  52 + * 批量解除调度指令和班次的外键约束
  53 + */
  54 + public static final String MULTI_REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch in ";
  55 +
  56 + /**
  57 + * 批量解除子任务和班次的外键约束
  58 + */
  59 + public static final String MULTI_REMOVE_CHILDTASK_SCH_FK = "update bsth_c_s_child_task set schedule=NULL where schedule in ";
  60 +
  61 + public static final String WEAK_CIPHER = "weakCipher";
  62 +
  63 + public static final String FILE_AUTH = "/.well-known/pki-validation/fileauth.txt";
  64 +
  65 + public static final String SSO_TOKEN = "ssoToken";
  66 +
  67 + public static final String RESOURCE_AUTHORITYS = "resourceAuthoritys";
  68 +}
... ...
src/main/java/com/bsth/common/SystemParamKeys.java 0 → 100644
  1 +package com.bsth.common;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public class SystemParamKeys {
  7 +
  8 + public static final String SPECIAL_ROLES = "special.roles";
  9 +
  10 + public static final String SPECIAL_DAYS = "special.days";
  11 +
  12 + public static final String URL_HTTP_GPS_REAL_CACHE = "url.http.gps.real.cache";
  13 +
  14 + public static final String URL_HTTP_GPS_REAL = "url.http.gps.real";
  15 +
  16 + public static final String URL_HTTP_DIRECTIVE = "url.http.directive";
  17 +
  18 + public static final String URL_HTTP_RFID = "url.http.rfid";
  19 +
  20 + public static final String URL_HTTP_REPORT = "url.http.report.%s";
  21 +
  22 + public static final String URL_HTTP_TICKETING = "url.http.ticketing";
  23 +
  24 + public static final String URL_HTTP_DSM_ACK = "url.http.dsm.ack";
  25 +
  26 + public static final String URL_HTTP_CP_ACK = "url.http.cp.ack";
  27 +
  28 + public static final String MAIL_ADMIN = "mail.admin";
  29 +
  30 + public static final String MAIL_WAYBILL = "mail.waybill";
  31 +
  32 + public static final String ENABLED_FIRST_LAST_GENERATION = "enabled.first.last.generation";
  33 +
  34 + public static final String ENABLED_FILTER_SQL_INJECTION = "enabled.filter.sql.injection";
  35 +
  36 + public static final String ENABLED_SSO = "enabled.sso";
  37 +
  38 + public static final String SSO_SYSTEM_CODE = "sso.system.code";
  39 +
  40 + public static final String URL_HTTP_SSO_LOGIN = "url.http.sso.login";
  41 +
  42 + public static final String URL_HTTP_SSO_LOGOUT = "url.http.sso.logout";
  43 +
  44 + public static final String URL_HTTP_SSO_AUTH = "url.http.sso.auth";
  45 +
  46 + public static final String URL_HTTP_MAINTENANCE = "url.http.maintenance";
  47 +
  48 + public static final String ENABLED_WHITE_IP = "enabled.white.ip";
  49 +
  50 + public static final String ENABLED_FILTER_AUTHORITY = "enabled.filter.authority";
  51 +
  52 + public static final String URL_HTTP_DVR = "url.http.dvr";
  53 +
  54 + public static final String URL_HTTP_DVR_PWD = "url.http.dvr.pwd";
  55 +}
0 56 \ No newline at end of file
... ...
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import ch.qos.logback.classic.Level;
4   -import ch.qos.logback.classic.LoggerContext;
  3 +import java.util.*;
  4 +
5 5 import com.bsth.data.BasicData;
  6 +import com.bsth.service.SectionService;
  7 +import com.bsth.service.StationService;
6 8 import com.bsth.data.directive.DayOfDirectives;
7 9 import com.bsth.data.directive.DirectivesPstThread;
  10 +import com.bsth.data.directive.GatewayHttpUtils;
8 11 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
9 12 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
  13 +import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader;
  14 +import com.bsth.data.gpsdata_v2.load.SocketClientLoader;
10 15 import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
11 16 import com.bsth.data.msg_queue.DirectivePushQueue;
12 17 import com.bsth.data.msg_queue.WebSocketPushQueue;
13 18 import com.bsth.data.pilot80.PilotReport;
14 19 import com.bsth.data.schedule.DayOfSchedule;
15 20 import com.bsth.entity.realcontrol.ScheduleRealInfo;
16   -import com.bsth.websocket.handler.SendUtils;
  21 +import com.bsth.service.SystemParamService;
  22 +import com.bsth.util.MailUtils;
17 23 import com.fasterxml.jackson.databind.ObjectMapper;
18 24 import org.slf4j.Logger;
19 25 import org.slf4j.LoggerFactory;
... ... @@ -22,10 +28,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
22 28 import org.springframework.web.bind.annotation.RequestParam;
23 29 import org.springframework.web.bind.annotation.RestController;
24 30  
25   -import java.util.HashMap;
26   -import java.util.List;
27   -import java.util.Map;
28   -import java.util.Set;
  31 +import com.bsth.websocket.handler.SendUtils;
  32 +
  33 +import ch.qos.logback.classic.Level;
  34 +import ch.qos.logback.classic.LoggerContext;
29 35  
30 36 /**
31 37 * Created by panzhao on 2017/4/14.
... ... @@ -56,8 +62,29 @@ public class AdminUtilsController {
56 62 PilotReport pilotReport;
57 63  
58 64 @Autowired
  65 + private MailUtils mailUtils;
  66 +
  67 + @Autowired
59 68 private BasicData.BasicDataLoader basicDataLoader;
60 69  
  70 + @Autowired
  71 + private SectionService sectionService;
  72 +
  73 + @Autowired
  74 + private StationService stationService;
  75 +
  76 + @Autowired
  77 + private SystemParamService systemParamService;
  78 +
  79 + @Autowired
  80 + private SocketClientLoader socketClientLoader;
  81 +
  82 + @Autowired
  83 + private GatewayHttpLoader gatewayHttpLoader;
  84 +
  85 + @Autowired
  86 + private GatewayHttpUtils gatewayHttpUtils;
  87 +
61 88 /**
62 89 * 出现重复班次的车辆
63 90 *
... ... @@ -218,9 +245,71 @@ public class AdminUtilsController {
218 245  
219 246 @RequestMapping("/reloadSystemParam")
220 247 public String reloadSystemParam() {
  248 + try {
  249 + systemParamService.refresh();
  250 +
  251 + return "success";
  252 + } catch (Exception e) {
  253 + e.printStackTrace();
  254 + }
  255 +
  256 + return "error";
  257 + }
  258 +
  259 + @RequestMapping("/applySystemParam")
  260 + public String applySystemParam() {
  261 + try {
  262 + socketClientLoader.afterPropertiesSet();
  263 + gatewayHttpLoader.afterPropertiesSet();
  264 + gatewayHttpUtils.afterPropertiesSet();
  265 + //rfidHttpLoader.afterPropertiesSet();
  266 + //ssoConfig.afterPropertiesSet();
  267 +
  268 + return "success";
  269 + } catch (Exception e) {
  270 + e.printStackTrace();
  271 + }
  272 +
  273 + return "error";
  274 + }
  275 +
  276 + @RequestMapping("/reloadAndApplySystemParam")
  277 + public String reloadAndApplySystemParam() {
  278 + try {
  279 + systemParamService.refresh();
  280 +
  281 + socketClientLoader.afterPropertiesSet();
  282 + gatewayHttpLoader.afterPropertiesSet();
  283 + gatewayHttpUtils.afterPropertiesSet();
  284 + //rfidHttpLoader.afterPropertiesSet();
  285 + //ssoConfig.afterPropertiesSet();
  286 +
  287 + return "success";
  288 + } catch (Exception e) {
  289 + e.printStackTrace();
  290 + }
  291 +
  292 + return "error";
  293 + }
  294 +
  295 + @RequestMapping("/section/translateWgs2Bd")
  296 + public String translateWgs2Bd1() {
  297 + Map<String, Object> result = new HashMap<>();
  298 + try {
  299 + //sectionService.translateWgs2Bd();
  300 + return "success";
  301 + } catch (Exception e) {
  302 + e.printStackTrace();
  303 + }
  304 +
  305 + return "error";
  306 + }
  307 +
  308 + @RequestMapping("/station/translateWgs2Bd")
  309 + public String translateWgs2Bd2() {
221 310 Map<String, Object> result = new HashMap<>();
222 311 try {
223   - basicDataLoader.loadSystemParam();
  312 + //stationService.translateWgs2Bd();
224 313 return "success";
225 314 } catch (Exception e) {
226 315 e.printStackTrace();
... ...
src/main/java/com/bsth/controller/sys/RoleController.java
1   -package com.bsth.controller.sys;
2   -
3   -import java.util.Map;
4   -
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestMethod;
8   -import org.springframework.web.bind.annotation.RequestParam;
9   -import org.springframework.web.bind.annotation.RestController;
10   -
11   -import com.bsth.controller.BaseController;
12   -import com.bsth.entity.sys.Role;
13   -import com.bsth.service.sys.RoleService;
14   -
15   -@RestController
16   -@RequestMapping("role")
17   -public class RoleController extends BaseController<Role, Integer>{
18   -
19   -
20   - @Autowired
21   - RoleService roleService;
22   -
23   - /**
24   - *
25   - * @Title: settRoleModules
26   - * @Description: TODO(为角色设置模块,全量覆盖)
27   - * @param @param roleId 角色ID
28   - * @param @param mIds 模块ID字符串(1,2,3,4)
29   - * @throws
30   - */
31   - @RequestMapping(value = "/settModules", method = RequestMethod.POST)
32   - public Map<String, Object> settRoleModules(@RequestParam Integer roleId,@RequestParam String mIds){
33   - return roleService.settRoleModules(roleId, mIds);
34   - }
35   -
36   - /**
37   - *
38   - * @Title: roleInfo
39   - * @Description: TODO(角色信息)
40   - * @param @param id 角色ID
41   - * @throws
42   - */
43   - @RequestMapping(value = "/roleInfo")
44   - public Map<String, Object> roleInfo(@RequestParam Integer id){
45   - return roleService.roleInfo(id);
46   - }
47   -}
  1 +package com.bsth.controller.sys;
  2 +
  3 +import java.util.Map;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import com.bsth.controller.BaseController;
  12 +import com.bsth.entity.sys.Role;
  13 +import com.bsth.service.sys.RoleService;
  14 +
  15 +@RestController
  16 +@RequestMapping("role")
  17 +public class RoleController extends BaseController<Role, Integer>{
  18 +
  19 +
  20 + @Autowired
  21 + RoleService roleService;
  22 +
  23 + /**
  24 + * @param @param map
  25 + * @throws
  26 + * @Title: list
  27 + * @Description: TODO(查询下级)
  28 + */
  29 + @RequestMapping(value = "/findSubordinate", method = RequestMethod.GET)
  30 + public Map<String, Object> findSubordinate() {
  31 + return roleService.findSubordinate();
  32 + }
  33 +
  34 + /**
  35 + * @param @param map
  36 + * @Description: TODO(添加角色)
  37 + * @return
  38 + */
  39 + @RequestMapping(value = "/add", method = RequestMethod.POST)
  40 + public Map<String, Object> add(Role role){
  41 + return roleService.add(role);
  42 + }
  43 +
  44 + /**
  45 + *
  46 + * @Title: settRoleModules
  47 + * @Description: TODO(为角色设置模块,全量覆盖)
  48 + * @param @param roleId 角色ID
  49 + * @param @param mIds 模块ID字符串(1,2,3,4)
  50 + * @throws
  51 + */
  52 + @RequestMapping(value = "/settModules", method = RequestMethod.POST)
  53 + public Map<String, Object> settRoleModules(@RequestParam Integer roleId,@RequestParam String mIds){
  54 + return roleService.settRoleModules(roleId, mIds);
  55 + }
  56 +
  57 + /**
  58 + *
  59 + * @Title: roleInfo
  60 + * @Description: TODO(角色信息)
  61 + * @param @param id 角色ID
  62 + * @throws
  63 + */
  64 + @RequestMapping(value = "/roleInfo")
  65 + public Map<String, Object> roleInfo(@RequestParam Integer id){
  66 + return roleService.roleInfo(id);
  67 + }
  68 +
  69 + /**
  70 + * 检查操作合法性 操作的是否是下级角色
  71 + * @param operationRoleId 下级角色Id
  72 + * @return
  73 + */
  74 + @RequestMapping(value = "/checkOperationLegality")
  75 + public boolean checkOperationLegality(@RequestParam Integer operationRoleId){
  76 + return roleService.checkOperationLegality(operationRoleId);
  77 + }
  78 +}
... ...
src/main/java/com/bsth/controller/sys/UserController.java
1   -package com.bsth.controller.sys;
2   -
3   -import com.bsth.common.Constants;
4   -import com.bsth.common.ResponseCode;
5   -import com.bsth.controller.BaseController;
6   -import com.bsth.controller.sys.dto.CompanyData;
7   -import com.bsth.controller.sys.util.RSAUtils;
8   -import com.bsth.entity.sys.CompanyAuthority;
9   -import com.bsth.entity.sys.SysUser;
10   -import com.bsth.security.util.SecurityUtils;
11   -import com.bsth.service.logger.UserSignService;
12   -import com.bsth.service.sys.CompanyAuthorityService;
13   -import com.bsth.service.sys.SysUserService;
14   -import com.google.common.collect.ArrayListMultimap;
15   -import org.apache.commons.lang3.StringUtils;
16   -import org.slf4j.Logger;
17   -import org.slf4j.LoggerFactory;
18   -import org.springframework.beans.factory.annotation.Autowired;
19   -import org.springframework.security.authentication.BadCredentialsException;
20   -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
21   -import org.springframework.security.web.authentication.session.SessionAuthenticationException;
22   -import org.springframework.web.bind.annotation.RequestMapping;
23   -import org.springframework.web.bind.annotation.RequestMethod;
24   -import org.springframework.web.bind.annotation.RequestParam;
25   -import org.springframework.web.bind.annotation.RestController;
26   -
27   -import javax.servlet.http.HttpServletRequest;
28   -import javax.servlet.http.HttpSession;
29   -import java.util.*;
30   -
31   -@RestController
32   -@RequestMapping("user")
33   -public class UserController extends BaseController<SysUser, Integer> {
34   -
35   - Logger logger = LoggerFactory.getLogger(this.getClass());
36   -
37   - @Autowired
38   - SysUserService sysUserService;
39   -
40   - @Autowired
41   - CompanyAuthorityService companyAuthorityService;
42   -
43   - @Autowired
44   - UserSignService userLogInoutService;
45   -
46   - @RequestMapping(value = "/login/jCryptionKey")
47   - public Map<String, Object> jCryptionKey(HttpServletRequest request) {
48   - //公匙返回页面
49   - Map<String, Object> rs = new HashMap<>();
50   - rs.put("publickey", RSAUtils.generateBase64PublicKey());
51   - return rs;
52   - }
53   -
54   - //需要验证码的账号
55   - public static Map<String, Integer> captchaMap = new HashMap<>();
56   -
57   - @RequestMapping(value = "/login", method = RequestMethod.POST)
58   - public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
59   - @RequestParam String password, String captcha) {
60   -
61   - Map<String, Object> rs = new HashMap<>();
62   - rs.put("status", ResponseCode.ERROR);
63   - try {
64   - HttpSession session = request.getSession();
65   - rs.put("captcha", session.getAttribute("captcha"));
66   -
67   - if (captchaMap.get(userName) != null && captchaMap.get(userName) >= 3) {
68   - //校验验证码
69   - String verCode = (String) session
70   - .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
71   -
72   - if (StringUtils.isBlank(captcha))
73   - return put(rs, "msg", "请输入验证码");
74   -
75   - if (!verCode.equals(captcha))
76   - return put(rs, "msg", "验证码有误,请刷新后重新输入");
77   - }
78   -
79   - //解密RSA
80   - try {
81   - userName = RSAUtils.decryptBase64(userName);
82   - password = RSAUtils.decryptBase64(password);
83   - } catch (RuntimeException e) {
84   - return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。");
85   - }
86   -
87   - SysUser user = sysUserService.findByUserName(userName);
88   - if (null == user)
89   - return put(rs, "msg", "不存在的用户");
90   -
91   - if (!user.isEnabled())
92   - return put(rs, "msg", "该用户已被锁定,请联系管理员");
93   -
94   - // 校验密码
95   - boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
96   - if (!matchStatus) {
97   - rs.put("msg", "密码有误");
98   -
99   - Integer captchSize = captchaMap.get(userName);
100   - if (null == captchSize)
101   - captchSize = 0;
102   -
103   - captchSize++;
104   - captchaMap.put(userName, captchSize);
105   - return rs;
106   - }
107   -
108   - // 登录
109   - SecurityUtils.login(user, request);
110   - //session里写入用户名,webSocket连接时标识身份用
111   - session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
112   -
113   - //获取公司权限数据
114   - List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
115   - session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
116   -
117   - captchaMap.remove(userName);
118   - rs.put("status", ResponseCode.SUCCESS);
119   -
120   - // 记录登录日志
121   - userLogInoutService.userLogIn(user.getUserName(), session.getId(), new Date());
122   - } catch (Exception e) {
123   - logger.error("", e);
124   - rs.put("msg", "服务器出现异常,请联系管理员");
125   - }
126   - return rs;
127   - }
128   -
129   - @RequestMapping(value = "/change_user", method = RequestMethod.POST)
130   - public Map<String, Object> changeUser(HttpServletRequest request, @RequestParam String userName,
131   - @RequestParam String password) {
132   -
133   - Map<String, Object> rs = new HashMap<>();
134   - rs.put("status", ResponseCode.ERROR);
135   - try {
136   - HttpSession session = request.getSession();
137   -
138   - SysUser user = sysUserService.findByUserName(userName);
139   - if (null == user)
140   - return put(rs, "msg", "不存在的用户");
141   -
142   - if (!user.isEnabled())
143   - return put(rs, "msg", "该用户已被锁定,请联系管理员");
144   -
145   - // 校验密码
146   - boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
147   - if (!matchStatus)
148   - return put(rs, "msg", "密码有误");
149   -
150   - // 登录
151   - SecurityUtils.login(user, request);
152   - //session里写入用户名,webSocket连接时标识身份用
153   - session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
154   -
155   - //获取公司权限数据
156   - List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
157   - session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
158   - rs.put("status", ResponseCode.SUCCESS);
159   - } catch (Exception e) {
160   - logger.error("", e);
161   - rs.put("msg", "服务器出现异常,请联系管理员");
162   - }
163   - return rs;
164   - }
165   -
166   - /**
167   - * 返回当前用户的公司权限数据,用于构建页面级联下拉框
168   - *
169   - * @return
170   - */
171   - @RequestMapping("companyData")
172   - public List<CompanyData> companyData(HttpServletRequest request) {
173   - List<CompanyData> rs = new ArrayList<>();
174   - CompanyData companyData;
175   -
176   - ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create();
177   - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
178   -
179   - for (CompanyAuthority cAuth : cmyAuths) {
180   - map.put(cAuth.getCompanyCode() + "_" + cAuth.getCompanyName(), cAuth);
181   - }
182   -
183   - Set<String> keys = map.keySet();
184   - String[] temps;
185   - for (String k : keys) {
186   - temps = k.split("_");
187   -
188   - companyData = new CompanyData();
189   - companyData.setCompanyCode(temps[0]);
190   - companyData.setCompanyName(temps[1]);
191   - companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>());
192   -
193   - cmyAuths = map.get(k);
194   - for (CompanyAuthority c : cmyAuths) {
195   - companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName()));
196   - }
197   -
198   - rs.add(companyData);
199   - }
200   -
201   - return rs;
202   - }
203   -
204   - @RequestMapping(value = "/login/captchaStatus")
205   - public int captchaStatus(String userName) {
206   - Integer size = captchaMap.get(userName);
207   - return size == null ? 0 : size;
208   - }
209   -
210   - public Map<String, Object> put(Map<String, Object> rs, String key, Object val) {
211   - rs.put(key, val);
212   - return rs;
213   - }
214   -
215   - /**
216   - * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param
217   - * request @return String 返回类型 @throws
218   - */
219   - @RequestMapping("/loginFailure")
220   - public String loginFailure(HttpServletRequest request) {
221   - String msg = "";
222   - HttpSession session = request.getSession();
223   -
224   - Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
225   -
226   - if (obj instanceof BadCredentialsException)
227   - msg = "登录失败,用户名或密码错误.";
228   - else if (obj instanceof SessionAuthenticationException)
229   - msg = "登录失败,当前策略不允许重复登录.";
230   - session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
231   - return msg;
232   - }
233   -
234   - @RequestMapping("/currentUser")
235   - public SysUser currentUser() {
236   - return SecurityUtils.getCurrentUser();
237   - }
238   -
239   - /**
240   - * @param id 用户ID
241   - * @param enabled 状态
242   - * @return
243   - * @Title changeEnabled
244   - * @Description: TODO(改变用户状态)
245   - */
246   - @RequestMapping("/changeEnabled")
247   - public int changeEnabled(@RequestParam int id, @RequestParam int enabled) {
248   - return sysUserService.changeEnabled(id, enabled);
249   - }
250   -
251   - /**
252   - * @param oldPWD 原始密码
253   - * @param newPWD 新密码
254   - * @param cnewPWD 确认新密码
255   - * @return
256   - * @Title changePWD
257   - * @Description: TODO(修改密码)
258   - */
259   - @RequestMapping(value = "/changePWD", method = RequestMethod.POST)
260   - public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) {
261   - SysUser sysUser = SecurityUtils.getCurrentUser();
262   - String msg = "";
263   - if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) {
264   - if (oldPWD.equals(newPWD)) {
265   - msg = "新密码不能跟原始密码一样!";
266   - } else {
267   - if (newPWD.equals(cnewPWD)) {
268   - sysUserService.changePWD(sysUser.getId(), newPWD);
269   - msg = "修改成功!";
270   - } else {
271   - msg = "新密码两次输入不一致!";
272   - }
273   - }
274   - } else {
275   - msg = "原始密码错误!";
276   - }
277   - return msg;
278   - }
279   -
280   - @RequestMapping(value = "/register", method = RequestMethod.POST)
281   - public Map<String, Object> register(SysUser u) {
282   - return sysUserService.register(u);
283   - }
284   -
285   - @RequestMapping(value = "/all_distinct")
286   - public List<SysUser> findAll_distinct() {
287   - return sysUserService.findAll_distinct();
288   - }
289   -}
  1 +package com.bsth.controller.sys;
  2 +
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.controller.BaseController;
  6 +import com.bsth.controller.sys.dto.CompanyData;
  7 +import com.bsth.controller.sys.util.RSAUtils;
  8 +import com.bsth.entity.sys.CompanyAuthority;
  9 +import com.bsth.entity.sys.Role;
  10 +import com.bsth.entity.sys.SysUser;
  11 +import com.bsth.security.util.SecurityUtils;
  12 +import com.bsth.service.logger.UserSignService;
  13 +import com.bsth.service.sys.CompanyAuthorityService;
  14 +import com.bsth.service.sys.SysUserService;
  15 +import com.google.common.collect.ArrayListMultimap;
  16 +import org.apache.commons.lang3.StringUtils;
  17 +import org.joda.time.DateTime;
  18 +import org.joda.time.Period;
  19 +import org.joda.time.PeriodType;
  20 +import org.slf4j.Logger;
  21 +import org.slf4j.LoggerFactory;
  22 +import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.security.authentication.BadCredentialsException;
  24 +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  25 +import org.springframework.security.web.authentication.session.SessionAuthenticationException;
  26 +import org.springframework.web.bind.annotation.RequestMapping;
  27 +import org.springframework.web.bind.annotation.RequestMethod;
  28 +import org.springframework.web.bind.annotation.RequestParam;
  29 +import org.springframework.web.bind.annotation.RestController;
  30 +
  31 +import javax.servlet.http.HttpServletRequest;
  32 +import javax.servlet.http.HttpSession;
  33 +import java.util.*;
  34 +import java.util.regex.Matcher;
  35 +import java.util.regex.Pattern;
  36 +
  37 +@RestController
  38 +@RequestMapping("user")
  39 +public class UserController extends BaseController<SysUser, Integer> {
  40 +
  41 + Logger logger = LoggerFactory.getLogger(this.getClass());
  42 +
  43 + @Autowired
  44 + SysUserService sysUserService;
  45 +
  46 + @Autowired
  47 + CompanyAuthorityService companyAuthorityService;
  48 +
  49 + @Autowired
  50 + UserSignService userLogInoutService;
  51 +
  52 + private Pattern pattern = Pattern.compile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*?[#?!@$%^&*-.]).{8,16}$");
  53 +
  54 + @RequestMapping(value = "/login/jCryptionKey")
  55 + public Map<String, Object> jCryptionKey(HttpServletRequest request) {
  56 + //公匙返回页面
  57 + Map<String, Object> rs = new HashMap<>();
  58 + rs.put("publickey", RSAUtils.generateBase64PublicKey());
  59 + return rs;
  60 + }
  61 +
  62 + @RequestMapping(value = "/getCurrentUser")
  63 + public SysUser getCurrentUser() {
  64 + SysUser user = SecurityUtils.getCurrentUser();
  65 + return user;
  66 + }
  67 +
  68 + //需要验证码的账号
  69 + public static Map<String, Integer> USER_ERRTIMES = new HashMap<>();
  70 + public static Map<String, Long> USER_LOCKTIME = new HashMap<>();
  71 +
  72 + @RequestMapping(value = "/login", method = RequestMethod.POST)
  73 + public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
  74 + @RequestParam String password, String captcha) {
  75 +
  76 + Map<String, Object> rs = new HashMap<>();
  77 + rs.put("status", ResponseCode.ERROR);
  78 + try {
  79 + HttpSession session = request.getSession();
  80 + rs.put("captcha", session.getAttribute("captcha"));
  81 +
  82 + //解密RSA
  83 + try {
  84 + userName = RSAUtils.decryptBase64(userName);
  85 + password = RSAUtils.decryptBase64(password);
  86 + } catch (RuntimeException e) {
  87 + return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。");
  88 + }
  89 +
  90 + SysUser user = sysUserService.findByUserName(userName);
  91 +
  92 + if (null == user) {
  93 + userOrPasswordInvalid(rs, userName);
  94 +
  95 + return rs;
  96 + }
  97 +
  98 + // 校验用户状态
  99 + if (!user.isEnabled()) {
  100 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
  101 + }
  102 +
  103 + // 校验临时状态
  104 + if (USER_LOCKTIME.get(userName) != null && USER_LOCKTIME.get(userName) >= System.currentTimeMillis()) {
  105 + return put(rs, "msg", "您的账户因密码错误次数过多,处于锁定状态中");
  106 + }
  107 +
  108 + // 校验验证码
  109 + if (USER_ERRTIMES.get(userName) != null && USER_ERRTIMES.get(userName) > 1) {
  110 + String verCode = (String) session.getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
  111 + if (StringUtils.isBlank(captcha)) {
  112 + return put(rs, "msg", "请输入验证码");
  113 + }
  114 + if (!verCode.equals(captcha)) {
  115 + return put(rs, "msg", "验证码有误,请刷新后重新输入");
  116 + }
  117 + }
  118 +
  119 + // 校验密码
  120 + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
  121 + if (!matchStatus) {
  122 + userOrPasswordInvalid(rs, userName);
  123 +
  124 + return rs;
  125 + }
  126 +
  127 + // 检验密码有效期
  128 + Date lastPwdDate = user.getLastPwdDate();
  129 + if (lastPwdDate != null) {
  130 + if (user.getPwdExpiredDate().before(new Date())) {
  131 + return put(rs, "msg", "密码已过期,不能登录,请联系管理员");
  132 + }
  133 +
  134 + Integer validPeriod = user.getPwdValidPeriod();
  135 + if (validPeriod == null) {
  136 + validPeriod = 30;
  137 + }
  138 + Period p = new Period(new DateTime(lastPwdDate), new DateTime(new Date()), PeriodType.days());
  139 + if (p.getDays() > validPeriod) {
  140 + return put(rs, "msg", "天没有修改密码,不能登录,请联系管理员");
  141 + }
  142 + } else {
  143 + return put(rs, "msg", "从未更新过密码,不能登录,请联系管理员");
  144 + }
  145 +
  146 + // 弱密码检查
  147 + Matcher matcher = pattern.matcher(password);
  148 + if (!matcher.matches()) {
  149 + session.setAttribute(Constants.WEAK_CIPHER, 1);
  150 + }
  151 +
  152 + // 登录
  153 + SecurityUtils.login(user, request);
  154 + sysUserService.recordLoginDate(userName);
  155 + //session里写入用户名,webSocket连接时标识身份用
  156 + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
  157 + session.setAttribute(Constants.RESOURCE_AUTHORITYS, user.getLinks());
  158 +
  159 + //获取公司权限数据
  160 + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
  161 + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
  162 +
  163 + USER_ERRTIMES.remove(userName);
  164 + rs.put("status", ResponseCode.SUCCESS);
  165 + logger.error("用户:" + user.getUserName() + "登录");
  166 +
  167 + // 记录登录日志
  168 + userLogInoutService.userLogIn(user.getUserName(), session.getId(), new Date());
  169 + } catch (Exception e) {
  170 + logger.error("", e);
  171 + rs.put("msg", "服务器出现异常,请联系管理员");
  172 + }
  173 + return rs;
  174 + }
  175 +
  176 + private void userOrPasswordInvalid(Map<String, Object> rs, String userName) {
  177 + rs.put("msg", "密码有误");
  178 +
  179 + Integer errTimes = USER_ERRTIMES.get(userName);
  180 + if (null == errTimes) {
  181 + errTimes = 0;
  182 + }
  183 + USER_ERRTIMES.put(userName, ++errTimes);
  184 + if (errTimes > 3) {
  185 + USER_LOCKTIME.put(userName, System.currentTimeMillis() + 600000);
  186 + USER_ERRTIMES.put(userName, 0);
  187 + put(rs, "msg", "密码错误4次,账户将被锁定10分钟");
  188 + }
  189 + }
  190 +
  191 + @RequestMapping(value = "/change_user", method = RequestMethod.POST)
  192 + public Map<String, Object> changeUser(HttpServletRequest request, @RequestParam String userName,
  193 + @RequestParam String password) {
  194 +
  195 + Map<String, Object> rs = new HashMap<>();
  196 + rs.put("status", ResponseCode.ERROR);
  197 + try {
  198 + HttpSession session = request.getSession();
  199 +
  200 + SysUser user = sysUserService.findByUserName(userName);
  201 + if (null == user)
  202 + return put(rs, "msg", "不存在的用户");
  203 +
  204 + if (!user.isEnabled())
  205 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
  206 +
  207 + // 校验密码
  208 + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
  209 + if (!matchStatus)
  210 + return put(rs, "msg", "密码有误");
  211 +
  212 + // 登录
  213 + SecurityUtils.login(user, request);
  214 + //session里写入用户名,webSocket连接时标识身份用
  215 + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
  216 + session.setAttribute(Constants.RESOURCE_AUTHORITYS, user.getLinks());
  217 +
  218 + //获取公司权限数据
  219 + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
  220 + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
  221 + rs.put("status", ResponseCode.SUCCESS);
  222 + } catch (Exception e) {
  223 + logger.error("", e);
  224 + rs.put("msg", "服务器出现异常,请联系管理员");
  225 + }
  226 + return rs;
  227 + }
  228 +
  229 + /**
  230 + * 返回当前用户的公司权限数据,用于构建页面级联下拉框
  231 + *
  232 + * @return
  233 + */
  234 + @RequestMapping("companyData")
  235 + public List<CompanyData> companyData(HttpServletRequest request) {
  236 + List<CompanyData> rs = new ArrayList<>();
  237 + CompanyData companyData;
  238 +
  239 + ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create();
  240 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
  241 +
  242 + for (CompanyAuthority cAuth : cmyAuths) {
  243 + map.put(cAuth.getCompanyCode() + "_" + cAuth.getCompanyName(), cAuth);
  244 + }
  245 +
  246 + Set<String> keys = map.keySet();
  247 + String[] temps;
  248 + for (String k : keys) {
  249 + temps = k.split("_");
  250 +
  251 + companyData = new CompanyData();
  252 + companyData.setCompanyCode(temps[0]);
  253 + companyData.setCompanyName(temps[1]);
  254 + companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>());
  255 +
  256 + cmyAuths = map.get(k);
  257 + for (CompanyAuthority c : cmyAuths) {
  258 + companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName()));
  259 + }
  260 +
  261 + rs.add(companyData);
  262 + }
  263 +
  264 + return rs;
  265 + }
  266 +
  267 + @RequestMapping(value = "/login/captchaStatus")
  268 + public int captchaStatus(String userName) {
  269 + Integer size = USER_ERRTIMES.get(userName);
  270 + return size == null ? 0 : size;
  271 + }
  272 +
  273 + public Map<String, Object> put(Map<String, Object> rs, String key, Object val) {
  274 + rs.put(key, val);
  275 + return rs;
  276 + }
  277 +
  278 + /**
  279 + * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param
  280 + * request @return String 返回类型 @throws
  281 + */
  282 + @RequestMapping("/loginFailure")
  283 + public String loginFailure(HttpServletRequest request) {
  284 + String msg = "";
  285 + HttpSession session = request.getSession();
  286 +
  287 + Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
  288 +
  289 + if (obj instanceof BadCredentialsException)
  290 + msg = "登录失败,用户名或密码错误.";
  291 + else if (obj instanceof SessionAuthenticationException)
  292 + msg = "登录失败,当前策略不允许重复登录.";
  293 + session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
  294 + return msg;
  295 + }
  296 +
  297 + @RequestMapping("/currentUser")
  298 + public SysUser currentUser() {
  299 + return SecurityUtils.getCurrentUser();
  300 + }
  301 +
  302 + /**
  303 + * @param id 用户ID
  304 + * @param enabled 状态
  305 + * @return
  306 + * @Title changeEnabled
  307 + * @Description: TODO(改变用户状态)
  308 + */
  309 + @RequestMapping("/changeEnabled")
  310 + public int changeEnabled(@RequestParam int id, @RequestParam int enabled) {
  311 + return sysUserService.changeEnabled(id, enabled);
  312 + }
  313 +
  314 + /**
  315 + * @param oldPWD 原始密码
  316 + * @param newPWD 新密码
  317 + * @param cnewPWD 确认新密码
  318 + * @return
  319 + * @Title changePWD
  320 + * @Description: TODO(修改密码)
  321 + */
  322 + @RequestMapping(value = "/changePWD", method = RequestMethod.POST)
  323 + public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD, HttpServletRequest request) {
  324 + SysUser sysUser = SecurityUtils.getCurrentUser();
  325 + String msg = "";
  326 +
  327 + //解密RSA
  328 + try{
  329 + oldPWD = (RSAUtils.decryptBase64(oldPWD));
  330 + newPWD = (RSAUtils.decryptBase64(newPWD));
  331 + cnewPWD = (RSAUtils.decryptBase64(cnewPWD));
  332 + }catch (RuntimeException e) {
  333 + return "网络延迟,解密失败,请重新添加!";
  334 + }
  335 + if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) {
  336 + if (oldPWD.equals(newPWD)) {
  337 + msg = "新密码不能跟原始密码一样!";
  338 + } else {
  339 + if (newPWD.equals(cnewPWD)) {
  340 + sysUserService.changePWD(sysUser.getId(), newPWD);
  341 + request.getSession().setAttribute(Constants.WEAK_CIPHER, 0);
  342 + msg = "修改成功!";
  343 + } else {
  344 + msg = "新密码两次输入不一致!";
  345 + }
  346 + }
  347 + } else {
  348 + msg = "原始密码错误!";
  349 + }
  350 + return msg;
  351 + }
  352 +
  353 + @RequestMapping(value = "/validPWDExpired", method = RequestMethod.GET)
  354 + public String validPWDExpired() {
  355 + try {
  356 + SysUser sysUser = SecurityUtils.getCurrentUser();
  357 + this.sysUserService.validPWDExpired(sysUser.getUserName());
  358 + return "ok";
  359 + } catch (Exception exp) {
  360 + exp.printStackTrace();
  361 + return exp.getMessage();
  362 + }
  363 + }
  364 +
  365 + @RequestMapping(value = "/register", method = RequestMethod.POST)
  366 + public Map<String, Object> register(SysUser u) {
  367 + return sysUserService.register(u);
  368 + }
  369 +
  370 + // 查询用户下所有下级角色
  371 + @RequestMapping(value = "/all_distinct")
  372 + public List<SysUser> findAll_distinct() {
  373 + return sysUserService.findAll_distinct();
  374 + }
  375 +
  376 + // 重置密码
  377 + @RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
  378 + public Map<String, Object> resetPassword(@RequestParam Integer id, @RequestParam Integer pwdValidPeriod) {
  379 + return sysUserService.resetPassword(id, pwdValidPeriod);
  380 + }
  381 +
  382 + /**
  383 + * 解除临时锁定
  384 + * @param userName
  385 + * @return
  386 + */
  387 + @RequestMapping(value = "/unlock", method = RequestMethod.POST)
  388 + public Map<String, Object> unlock(@RequestParam String userName) {
  389 + Map<String, Object> result = new HashMap<>();
  390 + // 获取当前用户
  391 + SysUser user = SecurityUtils.getCurrentUser();
  392 + Iterator<Role> itRole = user.getRoles().iterator();
  393 + Role ro = new Role();
  394 + boolean isSuper = false;
  395 + while (itRole.hasNext()) {//判断是否有下一个
  396 + ro = itRole.next();
  397 + if (ro.getLevel() == 1) {
  398 + isSuper = true;
  399 + }
  400 + }
  401 + if (isSuper) {
  402 + USER_LOCKTIME.remove(userName);
  403 + USER_ERRTIMES.remove(userName);
  404 + result.put("status", ResponseCode.SUCCESS);
  405 + result.put("msg", "用户解锁成功!");
  406 + } else {
  407 + result.put("status", ResponseCode.ERROR);
  408 + result.put("msg", "您不是管理员无用户解锁权限");
  409 + }
  410 +
  411 + return result;
  412 + }
  413 +
  414 + /**
  415 + * 弱密码
  416 + * @param request
  417 + * @return
  418 + */
  419 + @RequestMapping(value = "/isWeakCipher", method = RequestMethod.POST)
  420 + public Map<String, Object> isWeakCipher(HttpServletRequest request) {
  421 + Map<String, Object> result = new HashMap<>();
  422 + result.put("status", ResponseCode.SUCCESS);
  423 + result.put("data", request.getSession().getAttribute(Constants.WEAK_CIPHER));
  424 +
  425 + return result;
  426 + }
  427 +
  428 +// /**
  429 +// * 弱密码
  430 +// * @return
  431 +// */
  432 +// @RequestMapping(value = "/isRealName", method = RequestMethod.POST)
  433 +// public Map<String, Object> hasJobCode() {
  434 +// Map<String, Object> result = new HashMap<>();
  435 +// SysUser user = SecurityUtils.getCurrentUser();
  436 +// result.put("status", ResponseCode.SUCCESS);
  437 +// result.put("data", (StringUtils.isBlank(user.getJobCode()) || StringUtils.isBlank(user.getRealName())) ? 0 : 1);
  438 +//
  439 +// return result;
  440 +// }
  441 +//
  442 +// // 重置密码
  443 +// @RequestMapping(value = "/realName", method = RequestMethod.POST)
  444 +// public Map<String, Object> setJobCode(@RequestParam String jobCode, @RequestParam String realName) throws Exception {
  445 +// Map<String, Object> data = new HashMap<>(), result = new HashMap<>();
  446 +// result.put("status", ResponseCode.ERROR);
  447 +// result.put("data", "设置成功");
  448 +//
  449 +// if (jobCode == null || realName == null) {
  450 +// result.put("data", "你跳过验证了是吧");
  451 +// return result;
  452 +// }
  453 +// data.put("account", jobCode);
  454 +// data.put("pageSize", 2);
  455 +// data.put("pageNum", 1);
  456 +// StringBuilder stringBuilder = HttpClientUtils.post("https://112.64.45.51/businessCenter/userInfo/queryUserList", mapper.writeValueAsString(data));
  457 +// if (stringBuilder == null) {
  458 +// result.put("data", "统一平台验证失败1");
  459 +// return result;
  460 +// } else {
  461 +// List<Map<String, Object>> maps = mapper.readValue(mapper.writeValueAsString(((Map) mapper.readValue(stringBuilder.toString(), Map.class).get("data")).get("list")), mapper.getTypeFactory().constructParametricType(List.class, Map.class));
  462 +// if (maps.size() == 0) {
  463 +// result.put("data", "统一平台验证失败2");
  464 +// return result;
  465 +// } else {
  466 +// boolean isAuth = false;
  467 +// for (Map<String, Object> map : maps) {
  468 +// if (realName.equals(map.get("name"))) {
  469 +// isAuth = true;
  470 +// break;
  471 +// }
  472 +// }
  473 +// if (!isAuth) {
  474 +// result.put("data", "统一平台验证失败3");
  475 +// return result;
  476 +// }
  477 +// }
  478 +// }
  479 +//
  480 +// SysUser user = SecurityUtils.getCurrentUser();
  481 +// sysUserService.realName(jobCode, realName, user.getId());
  482 +// user.setJobCode(jobCode);
  483 +// user.setRealName(realName);
  484 +//
  485 +// result.put("status", ResponseCode.SUCCESS);
  486 +// return result;
  487 +// }
  488 +
  489 +}
... ...
src/main/java/com/bsth/data/SystemParamCache.java 0 → 100644
  1 +package com.bsth.data;
  2 +
  3 +import com.bsth.common.SystemParamKeys;
  4 +import com.bsth.service.SystemParamService;
  5 +import org.springframework.beans.factory.InitializingBean;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * @author Hill
  11 + */
  12 +@Component
  13 +public class SystemParamCache implements InitializingBean {
  14 +
  15 + @Autowired
  16 + private SystemParamService systemParamService;
  17 +
  18 + private static SystemParamService systemParamService1;
  19 +
  20 + public static String getSpecialRoles() {
  21 + return systemParamService1.getValue(SystemParamKeys.SPECIAL_ROLES);
  22 + }
  23 +
  24 + public static String getSpecialDays() {
  25 + return systemParamService1.getValue(SystemParamKeys.SPECIAL_DAYS);
  26 + }
  27 +
  28 + public static String getUrlHttpGpsRealCache() {
  29 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_GPS_REAL_CACHE);
  30 + }
  31 +
  32 + public static String getUrlHttpGpsReal() {
  33 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_GPS_REAL);
  34 + }
  35 +
  36 + public static String getUrlHttpDirective() {
  37 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_DIRECTIVE);
  38 + }
  39 +
  40 + public static String getUrlHttpRfid() {
  41 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_RFID);
  42 + }
  43 +
  44 + public static String getUrlHttpReport(String param) {
  45 + return systemParamService1.getValue(String.format(SystemParamKeys.URL_HTTP_REPORT, param));
  46 + }
  47 +
  48 + public static String getUrlHttpTicketing() {
  49 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_TICKETING);
  50 + }
  51 +
  52 + public static String getUrlHttpDsmAck() {
  53 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_DSM_ACK);
  54 + }
  55 +
  56 + public static String getUrlHttpCpAck() {
  57 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_CP_ACK);
  58 + }
  59 +
  60 + public static String getMailAdmin() {
  61 + return systemParamService1.getValue(SystemParamKeys.MAIL_ADMIN);
  62 + }
  63 +
  64 + public static String getMailWaybill() {
  65 + return systemParamService1.getValue(SystemParamKeys.MAIL_WAYBILL);
  66 + }
  67 +
  68 + public static boolean getEnabledFirstLastGeneration() {
  69 + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FIRST_LAST_GENERATION));
  70 + }
  71 +
  72 + public static boolean getEnabledFilterSqlInjection() {
  73 + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FILTER_SQL_INJECTION));
  74 + }
  75 +
  76 + public static boolean getEnabledSso() {
  77 + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_SSO));
  78 + }
  79 +
  80 + public static String getSsoSystemCode() {
  81 + return systemParamService1.getValue(SystemParamKeys.SSO_SYSTEM_CODE);
  82 + }
  83 +
  84 + public static String getUrlHttpSsoLogin() {
  85 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_SSO_LOGIN);
  86 + }
  87 +
  88 + public static String getUrlHttpSsoLogout() {
  89 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_SSO_LOGOUT);
  90 + }
  91 +
  92 + public static String getUrlHttpSsoAuth() {
  93 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_SSO_AUTH);
  94 + }
  95 +
  96 + public static String getUrlHttpMaintenance() {
  97 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_MAINTENANCE);
  98 + }
  99 +
  100 + public static boolean getEnabledWhiteIp() {
  101 + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_WHITE_IP));
  102 + }
  103 +
  104 + public static boolean getEnableFilterAuthority() {
  105 + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FILTER_AUTHORITY));
  106 + }
  107 +
  108 + public static String getUrlHttpDvr() {
  109 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_DVR);
  110 + }
  111 +
  112 + public static String getUrlHttpDvrPwd() {
  113 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_DVR_PWD);
  114 + }
  115 +
  116 + @Override
  117 + public void afterPropertiesSet() throws Exception {
  118 + systemParamService1 = systemParamService;
  119 + systemParamService1.refresh();
  120 + }
  121 +}
0 122 \ No newline at end of file
... ...
src/main/java/com/bsth/data/WhiteIpCache.java 0 → 100644
  1 +package com.bsth.data;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.XDApplication;
  5 +import com.bsth.entity.WhiteIp;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.InitializingBean;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  11 +import org.springframework.jdbc.core.JdbcTemplate;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.List;
  15 +import java.util.concurrent.TimeUnit;
  16 +
  17 +@Component
  18 +public class WhiteIpCache implements InitializingBean {
  19 +
  20 + private final static Logger log = LoggerFactory.getLogger(WhiteIpCache.class);
  21 +
  22 + @Autowired
  23 + private JdbcTemplate jdbcTemplate;
  24 +
  25 + private static List<WhiteIp> whiteIps;
  26 +
  27 + public static List<WhiteIp> getWhiteIps() {
  28 + return whiteIps;
  29 + }
  30 +
  31 + @Override
  32 + public void afterPropertiesSet() throws Exception {
  33 + Application.mainServices.scheduleWithFixedDelay(new WhiteIpDataLoader(), 0, 1, TimeUnit.MINUTES);
  34 + }
  35 +
  36 + class WhiteIpDataLoader extends Thread {
  37 +
  38 + @Override
  39 + public void run() {
  40 + if (SystemParamCache.getEnabledWhiteIp()) {
  41 + loadData();
  42 + }
  43 + }
  44 +
  45 + /**
  46 + * @Title: loadAllData
  47 + * @Description: TODO(加载所有数据)
  48 + */
  49 + public int loadData() {
  50 + try {
  51 + log.info("开始加载IP白名单数据..,");
  52 + loadWhiteIp();
  53 + log.info("加载IP白名单数据成功!,");
  54 + } catch (Exception e) {
  55 + log.error("加载IP白名单数据时出现异常,", e);
  56 + }
  57 + return 0;
  58 + }
  59 +
  60 + /**
  61 + * 加载IP白名单
  62 + */
  63 + public void loadWhiteIp() {
  64 + List<WhiteIp> result = jdbcTemplate.query("select * from control_interface.bsth_c_white_ip where valid_date > now()", BeanPropertyRowMapper.newInstance(WhiteIp.class));
  65 + whiteIps = result;
  66 + }
  67 + }
  68 +}
... ...
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
1   -package com.bsth.data.directive;
2   -
3   -import com.alibaba.fastjson.JSONObject;
4   -import com.bsth.util.ConfigUtil;
5   -import org.apache.http.client.config.RequestConfig;
6   -import org.apache.http.client.methods.CloseableHttpResponse;
7   -import org.apache.http.client.methods.HttpPost;
8   -import org.apache.http.entity.StringEntity;
9   -import org.apache.http.impl.client.CloseableHttpClient;
10   -import org.apache.http.impl.client.HttpClients;
11   -import org.apache.http.util.EntityUtils;
12   -import org.slf4j.Logger;
13   -import org.slf4j.LoggerFactory;
14   -
15   -/**
16   - * @author PanZhao
17   - * @ClassName: GatewayHttpUtils
18   - * @Description: TODO(和网关HTTP通讯工具类)
19   - * @date 2016年8月14日 下午9:50:46
20   - */
21   -public class GatewayHttpUtils {
22   - static Logger logger = LoggerFactory.getLogger(GatewayHttpUtils.class);
23   -
24   - static String url;
25   - static CloseableHttpClient httpClient = null;
26   - static HttpPost post;
27   - static RequestConfig requestConfig;
28   - static CloseableHttpResponse response;
29   -
30   - static {
31   - url = ConfigUtil.get("http.send.directive");
32   - httpClient = HttpClients.createDefault();
33   - post = new HttpPost(url);
34   - requestConfig = RequestConfig.custom()
35   - .setConnectTimeout(3000).setConnectionRequestTimeout(2000)
36   - .setSocketTimeout(3000).build();
37   - post.setConfig(requestConfig);
38   - }
39   -
40   - public static int postJson(String jsonStr) {
41   - logger.info("send : " + jsonStr);
42   -
43   - int code = -1;
44   - try {
45   - post.setEntity(new StringEntity(jsonStr, "utf-8"));
46   -
47   - response = httpClient.execute(post);
48   -
49   - int statusCode = response.getStatusLine().getStatusCode();
50   - if(statusCode != 200){
51   - logger.error("http client status code: " + statusCode);
52   - }
53   -
54   - JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity()));
55   - if (null != json && json.getInteger("errCode") == 0)
56   - code = 0;
57   - else
58   - logger.error("和网关http通讯失败,rs: " + json);
59   -
60   - if (null != response)
61   - response.close();
62   - } catch (Exception e) {
63   - logger.error("", e);
64   - }
65   - return code;
66   - }
67   -}
  1 +package com.bsth.data.directive;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.bsth.data.SystemParamCache;
  5 +import org.apache.http.client.config.RequestConfig;
  6 +import org.apache.http.client.methods.CloseableHttpResponse;
  7 +import org.apache.http.client.methods.HttpPost;
  8 +import org.apache.http.entity.StringEntity;
  9 +import org.apache.http.impl.client.CloseableHttpClient;
  10 +import org.apache.http.impl.client.HttpClients;
  11 +import org.apache.http.util.EntityUtils;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.InitializingBean;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +/**
  18 + * @author PanZhao
  19 + * @ClassName: GatewayHttpUtils
  20 + * @Description: TODO(和网关HTTP通讯工具类)
  21 + * @date 2016年8月14日 下午9:50:46
  22 + */
  23 +@Component
  24 +public class GatewayHttpUtils implements InitializingBean {
  25 + static Logger logger = LoggerFactory.getLogger(GatewayHttpUtils.class);
  26 +
  27 + static String url;
  28 + static CloseableHttpClient httpClient = null;
  29 + static HttpPost post;
  30 + static RequestConfig requestConfig;
  31 + static CloseableHttpResponse response;
  32 +
  33 + public static int postJson(String jsonStr) {
  34 + logger.info("send : " + jsonStr);
  35 +
  36 + int code = -1;
  37 + try {
  38 + post.setEntity(new StringEntity(jsonStr, "utf-8"));
  39 +
  40 + response = httpClient.execute(post);
  41 +
  42 + int statusCode = response.getStatusLine().getStatusCode();
  43 + if(statusCode != 200){
  44 + logger.error("http client status code: " + statusCode);
  45 + }
  46 +
  47 + JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity()));
  48 + if (null != json && json.getInteger("errCode") == 0)
  49 + code = 0;
  50 + else
  51 + logger.error("和网关http通讯失败,rs: " + json);
  52 +
  53 + if (null != response)
  54 + response.close();
  55 + } catch (Exception e) {
  56 + logger.error("", e);
  57 + }
  58 + return code;
  59 + }
  60 +
  61 + @Override
  62 + public void afterPropertiesSet() throws Exception {
  63 + url = SystemParamCache.getUrlHttpDirective();
  64 + httpClient = HttpClients.createDefault();
  65 + post = new HttpPost(url);
  66 + requestConfig = RequestConfig.custom()
  67 + .setConnectTimeout(3000).setConnectionRequestTimeout(2000)
  68 + .setSocketTimeout(3000).build();
  69 + post.setConfig(requestConfig);
  70 + }
  71 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/load/GatewayHttpLoader.java
... ... @@ -2,10 +2,10 @@ package com.bsth.data.gpsdata_v2.load;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.bsth.data.BasicData;
  5 +import com.bsth.data.SystemParamCache;
5 6 import com.bsth.data.gpsdata_v2.GpsRealData;
6 7 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 8 import com.bsth.data.gpsdata_v2.utils.GpsDataUtils;
8   -import com.bsth.util.ConfigUtil;
9 9 import org.apache.commons.lang3.StringUtils;
10 10 import org.apache.http.HttpEntity;
11 11 import org.apache.http.client.config.RequestConfig;
... ... @@ -16,6 +16,7 @@ import org.apache.http.impl.client.HttpClients;
16 16 import org.slf4j.Logger;
17 17 import org.slf4j.LoggerFactory;
18 18 import org.springframework.beans.BeansException;
  19 +import org.springframework.beans.factory.InitializingBean;
19 20 import org.springframework.context.ApplicationContext;
20 21 import org.springframework.context.ApplicationContextAware;
21 22 import org.springframework.stereotype.Component;
... ... @@ -30,7 +31,7 @@ import java.util.List;
30 31 * Created by panzhao on 2017/11/15.
31 32 */
32 33 @Component
33   -public class GatewayHttpLoader implements ApplicationContextAware{
  34 +public class GatewayHttpLoader implements ApplicationContextAware, InitializingBean {
34 35  
35 36 static Logger logger = LoggerFactory.getLogger(GatewayHttpLoader.class);
36 37  
... ... @@ -45,17 +46,6 @@ public class GatewayHttpLoader implements ApplicationContextAware{
45 46  
46 47 static GpsRealData gpsRealData;
47 48  
48   - static{
49   - url = ConfigUtil.get("http.gps.real.url");
50   - list = new ArrayList<>();
51   - httpClient = HttpClients.createDefault();
52   - get = new HttpGet(url);
53   - requestConfig = RequestConfig.custom()
54   - .setConnectTimeout(2500).setConnectionRequestTimeout(2000)
55   - .setSocketTimeout(2500).build();
56   - get.setConfig(requestConfig);
57   - }
58   -
59 49 public static List<GpsEntity> load(){
60 50 try{
61 51 if(list.size() > 0)
... ... @@ -117,4 +107,16 @@ public class GatewayHttpLoader implements ApplicationContextAware{
117 107 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
118 108 gpsRealData = applicationContext.getBean(GpsRealData.class);
119 109 }
  110 +
  111 + @Override
  112 + public void afterPropertiesSet() throws Exception {
  113 + url = SystemParamCache.getUrlHttpGpsReal();
  114 + list = new ArrayList<>();
  115 + httpClient = HttpClients.createDefault();
  116 + get = new HttpGet(url);
  117 + requestConfig = RequestConfig.custom()
  118 + .setConnectTimeout(2500).setConnectionRequestTimeout(2000)
  119 + .setSocketTimeout(2500).build();
  120 + get.setConfig(requestConfig);
  121 + }
120 122 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/load/SocketClientLoader.java
1   -package com.bsth.data.gpsdata_v2.load;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.bsth.data.BasicData;
5   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6   -import com.bsth.data.gpsdata_v2.utils.GpsDataUtils;
7   -import com.bsth.util.ConfigUtil;
8   -import org.apache.http.HttpEntity;
9   -import org.apache.http.client.config.RequestConfig;
10   -import org.apache.http.client.methods.CloseableHttpResponse;
11   -import org.apache.http.client.methods.HttpGet;
12   -import org.apache.http.impl.client.CloseableHttpClient;
13   -import org.apache.http.impl.client.HttpClients;
14   -import org.slf4j.Logger;
15   -import org.slf4j.LoggerFactory;
16   -
17   -import java.io.BufferedReader;
18   -import java.io.InputStreamReader;
19   -import java.util.ArrayList;
20   -import java.util.List;
21   -
22   -/**
23   - * 从专用的socket client 加载数据
24   - * Created by panzhao on 2017/11/15.
25   - */
26   -public class SocketClientLoader {
27   -
28   - static Logger logger = LoggerFactory.getLogger(SocketClientLoader.class);
29   -
30   - static String url;
31   - static List<GpsEntity> list;
32   - static CloseableHttpClient httpClient = null;
33   - static HttpGet get;
34   - static RequestConfig requestConfig;
35   - static CloseableHttpResponse response;
36   - static HttpEntity entity;
37   - static BufferedReader br;
38   -
39   - static {
40   - url = ConfigUtil.get("http.gps.real.cache.url");
41   - list = new ArrayList<>();
42   - httpClient = HttpClients.createDefault();
43   - get = new HttpGet(url);
44   - requestConfig = RequestConfig.custom()
45   - .setConnectTimeout(2500).setConnectionRequestTimeout(2000)
46   - .setSocketTimeout(2500).build();
47   - get.setConfig(requestConfig);
48   - }
49   -
50   - public static List<GpsEntity> load(){
51   - try {
52   - if(list.size() > 0)
53   - list.clear();
54   - logger.info("load start...");
55   - response = httpClient.execute(get);
56   - entity = response.getEntity();
57   - if(null == entity)
58   - return list;
59   -
60   - br = new BufferedReader(new InputStreamReader(entity.getContent()));
61   - StringBuilder sb = new StringBuilder();
62   - String str;
63   - while ((str = br.readLine()) != null)
64   - sb.append(str);
65   -
66   - list = JSON.parseArray(sb.toString(), GpsEntity.class);
67   -
68   - logger.info("load end ! size: " + list.size());
69   - //过滤掉无效的点位
70   - list = GpsDataUtils.clearInvalid(list);
71   -
72   - for (GpsEntity gps : list) {
73   - gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
74   - }
75   -
76   - if (null != response)
77   - response.close();
78   - } catch (Exception e) {
79   - logger.error("", e);
80   - }
81   -
82   - return list;
83   - }
84   -}
  1 +package com.bsth.data.gpsdata_v2.load;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.data.SystemParamCache;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  7 +import com.bsth.data.gpsdata_v2.utils.GpsDataUtils;
  8 +import org.apache.http.HttpEntity;
  9 +import org.apache.http.client.config.RequestConfig;
  10 +import org.apache.http.client.methods.CloseableHttpResponse;
  11 +import org.apache.http.client.methods.HttpGet;
  12 +import org.apache.http.impl.client.CloseableHttpClient;
  13 +import org.apache.http.impl.client.HttpClients;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.beans.factory.InitializingBean;
  17 +import org.springframework.stereotype.Component;
  18 +
  19 +import java.io.BufferedReader;
  20 +import java.io.InputStreamReader;
  21 +import java.util.ArrayList;
  22 +import java.util.List;
  23 +
  24 +/**
  25 + * 从专用的socket client 加载数据
  26 + * Created by panzhao on 2017/11/15.
  27 + */
  28 +@Component
  29 +public class SocketClientLoader implements InitializingBean {
  30 +
  31 + static Logger logger = LoggerFactory.getLogger(SocketClientLoader.class);
  32 +
  33 + static String url;
  34 + static List<GpsEntity> list;
  35 + static CloseableHttpClient httpClient = null;
  36 + static HttpGet get;
  37 + static RequestConfig requestConfig;
  38 + static CloseableHttpResponse response;
  39 + static HttpEntity entity;
  40 + static BufferedReader br;
  41 +
  42 + public static List<GpsEntity> load(){
  43 + try {
  44 + if(list.size() > 0)
  45 + list.clear();
  46 + logger.info("load start...");
  47 + response = httpClient.execute(get);
  48 + entity = response.getEntity();
  49 + if(null == entity)
  50 + return list;
  51 +
  52 + br = new BufferedReader(new InputStreamReader(entity.getContent()));
  53 + StringBuilder sb = new StringBuilder();
  54 + String str;
  55 + while ((str = br.readLine()) != null)
  56 + sb.append(str);
  57 +
  58 + list = JSON.parseArray(sb.toString(), GpsEntity.class);
  59 +
  60 + logger.info("load end ! size: " + list.size());
  61 + //过滤掉无效的点位
  62 + list = GpsDataUtils.clearInvalid(list);
  63 +
  64 + for (GpsEntity gps : list) {
  65 + gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
  66 + }
  67 +
  68 + if (null != response)
  69 + response.close();
  70 + } catch (Exception e) {
  71 + logger.error("", e);
  72 + }
  73 +
  74 + return list;
  75 + }
  76 +
  77 + @Override
  78 + public void afterPropertiesSet() throws Exception {
  79 + url = SystemParamCache.getUrlHttpGpsRealCache();
  80 + list = new ArrayList<>();
  81 + httpClient = HttpClients.createDefault();
  82 + get = new HttpGet(url);
  83 + requestConfig = RequestConfig.custom()
  84 + .setConnectTimeout(2500).setConnectionRequestTimeout(2000)
  85 + .setSocketTimeout(2500).build();
  86 + get.setConfig(requestConfig);
  87 + }
  88 +}
... ...
src/main/java/com/bsth/entity/sys/Role.java
1   -package com.bsth.entity.sys;
2   -
3   -import java.util.Date;
4   -import java.util.LinkedHashSet;
5   -import java.util.Set;
6   -
7   -import javax.persistence.Column;
8   -import javax.persistence.Entity;
9   -import javax.persistence.FetchType;
10   -import javax.persistence.GeneratedValue;
11   -import javax.persistence.GenerationType;
12   -import javax.persistence.Id;
13   -import javax.persistence.ManyToMany;
14   -import javax.persistence.Table;
15   -
16   -import com.fasterxml.jackson.annotation.JsonIgnore;
17   -
18   -@Entity
19   -@Table(name = "bsth_c_sys_role")
20   -public class Role {
21   -
22   - @Id
23   - @GeneratedValue(strategy = GenerationType.IDENTITY)
24   - private Integer id;
25   -
26   - private String codeName;
27   -
28   - private String roleName;
29   -
30   - private String descriptions;
31   -
32   - private boolean isSuperAdmin;
33   -
34   - private boolean enable;
35   -
36   - @JsonIgnore
37   - @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
38   - private Set<SysUser> users = new LinkedHashSet<>();
39   -
40   - @JsonIgnore
41   - @ManyToMany
42   - private Set<Module> modules = new LinkedHashSet<>();
43   -
44   - @JsonIgnore
45   - @ManyToMany(mappedBy = "roles")
46   - private Set<Resource> resources = new LinkedHashSet<>();
47   -
48   - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
49   - private Date createDate;
50   -
51   - @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
52   - private Date updateDate;
53   -
54   - private int pic;
55   -
56   - public Integer getId() {
57   - return id;
58   - }
59   -
60   - public void setId(Integer id) {
61   - this.id = id;
62   - }
63   -
64   - public String getRoleName() {
65   - return roleName;
66   - }
67   -
68   - public String getDescriptions() {
69   - return descriptions;
70   - }
71   -
72   - public void setDescriptions(String descriptions) {
73   - this.descriptions = descriptions;
74   - }
75   -
76   - public void setRoleName(String roleName) {
77   - this.roleName = roleName;
78   - }
79   -
80   - public boolean isEnable() {
81   - return enable;
82   - }
83   -
84   - public void setEnable(boolean enable) {
85   - this.enable = enable;
86   - }
87   -
88   - public Set<SysUser> getUsers() {
89   - return users;
90   - }
91   -
92   - public void setUsers(Set<SysUser> users) {
93   - this.users = users;
94   - }
95   -
96   - public boolean isSuperAdmin() {
97   - return isSuperAdmin;
98   - }
99   -
100   - public void setSuperAdmin(boolean isSuperAdmin) {
101   - this.isSuperAdmin = isSuperAdmin;
102   - }
103   -
104   - public Set<Module> getModules() {
105   - return modules;
106   - }
107   -
108   - public void setModules(Set<Module> modules) {
109   - this.modules = modules;
110   - }
111   -
112   - public Set<Resource> getResources() {
113   - return resources;
114   - }
115   -
116   - public void setResources(Set<Resource> resources) {
117   - this.resources = resources;
118   - }
119   -
120   - public Date getCreateDate() {
121   - return createDate;
122   - }
123   -
124   - public void setCreateDate(Date createDate) {
125   - this.createDate = createDate;
126   - }
127   -
128   - public Date getUpdateDate() {
129   - return updateDate;
130   - }
131   -
132   - public void setUpdateDate(Date updateDate) {
133   - this.updateDate = updateDate;
134   - }
135   -
136   - public String getCodeName() {
137   - return codeName;
138   - }
139   -
140   - public void setCodeName(String codeName) {
141   - this.codeName = codeName;
142   - }
143   -
144   - public int getPic() {
145   - return pic;
146   - }
147   -
148   - public void setPic(int pic) {
149   - this.pic = pic;
150   - }
151   -
152   - @Override
153   - public boolean equals(Object obj) {
154   - return this.id.equals(((Role)obj).getId());
155   - }
156   -
157   - @Override
158   - public int hashCode() {
159   - return this.toString().hashCode();
160   - }
161   -
162   - @Override
163   - public String toString() {
164   - return this.id + "" + this.getCodeName();
165   - }
166   -}
  1 +package com.bsth.entity.sys;
  2 +
  3 +import java.io.Serializable;
  4 +import java.util.Date;
  5 +import java.util.LinkedHashSet;
  6 +import java.util.Set;
  7 +
  8 +import javax.persistence.Column;
  9 +import javax.persistence.Entity;
  10 +import javax.persistence.FetchType;
  11 +import javax.persistence.GeneratedValue;
  12 +import javax.persistence.GenerationType;
  13 +import javax.persistence.Id;
  14 +import javax.persistence.ManyToMany;
  15 +import javax.persistence.Table;
  16 +
  17 +import com.fasterxml.jackson.annotation.JsonIgnore;
  18 +import org.hibernate.annotations.Formula;
  19 +
  20 +@Entity
  21 +@Table(name = "bsth_c_sys_role")
  22 +public class Role implements Serializable {
  23 +
  24 + @Id
  25 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  26 + private Integer id;
  27 +
  28 + private String codeName;
  29 +
  30 + private String roleName;
  31 +
  32 + private String descriptions;
  33 +
  34 + private boolean isSuperAdmin;
  35 +
  36 + private boolean enable;
  37 +
  38 + @JsonIgnore
  39 + @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
  40 + private Set<SysUser> users = new LinkedHashSet<>();
  41 +
  42 + @JsonIgnore
  43 + @ManyToMany
  44 + private Set<Module> modules = new LinkedHashSet<>();
  45 +
  46 + @JsonIgnore
  47 + @ManyToMany(mappedBy = "roles")
  48 + private Set<Resource> resources = new LinkedHashSet<>();
  49 +
  50 + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  51 + private Date createDate;
  52 +
  53 + @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  54 + private Date updateDate;
  55 +
  56 + /**
  57 + * 角色权限
  58 + *
  59 + * 角色树结构 本级只能管理下级角色,不能查看同级和上级的任何数据:这里主要为了规范管理 (管理员)层级的用户
  60 + *
  61 + * 只能看其他角色upCode 等于 本角色roleCode level字段等级比自己小的 其他角色 严格的树形结构,只能看自己分支下级节点
  62 + *
  63 + */
  64 + private int roleCode;
  65 +
  66 + private int upCode;
  67 +
  68 + private int level;
  69 +
  70 + /** 组合自己和父节点编码 */
  71 + @Formula(" concat(up_code, '_', role_code) ")
  72 + private String groupCode;
  73 +
  74 + @Formula(" concat(level, '_',role_code) ")
  75 + private String levelCode;
  76 +
  77 + private int pic;
  78 +
  79 + public Integer getId() {
  80 + return id;
  81 + }
  82 +
  83 + public void setId(Integer id) {
  84 + this.id = id;
  85 + }
  86 +
  87 + public String getRoleName() {
  88 + return roleName;
  89 + }
  90 +
  91 + public String getDescriptions() {
  92 + return descriptions;
  93 + }
  94 +
  95 + public void setDescriptions(String descriptions) {
  96 + this.descriptions = descriptions;
  97 + }
  98 +
  99 + public void setRoleName(String roleName) {
  100 + this.roleName = roleName;
  101 + }
  102 +
  103 + public boolean isEnable() {
  104 + return enable;
  105 + }
  106 +
  107 + public void setEnable(boolean enable) {
  108 + this.enable = enable;
  109 + }
  110 +
  111 + public Set<SysUser> getUsers() {
  112 + return users;
  113 + }
  114 +
  115 + public void setUsers(Set<SysUser> users) {
  116 + this.users = users;
  117 + }
  118 +
  119 + public boolean isSuperAdmin() {
  120 + return isSuperAdmin;
  121 + }
  122 +
  123 + public void setSuperAdmin(boolean isSuperAdmin) {
  124 + this.isSuperAdmin = isSuperAdmin;
  125 + }
  126 +
  127 + public Set<Module> getModules() {
  128 + return modules;
  129 + }
  130 +
  131 + public void setModules(Set<Module> modules) {
  132 + this.modules = modules;
  133 + }
  134 +
  135 + public Set<Resource> getResources() {
  136 + return resources;
  137 + }
  138 +
  139 + public void setResources(Set<Resource> resources) {
  140 + this.resources = resources;
  141 + }
  142 +
  143 + public Date getCreateDate() {
  144 + return createDate;
  145 + }
  146 +
  147 + public void setCreateDate(Date createDate) {
  148 + this.createDate = createDate;
  149 + }
  150 +
  151 + public Date getUpdateDate() {
  152 + return updateDate;
  153 + }
  154 +
  155 + public void setUpdateDate(Date updateDate) {
  156 + this.updateDate = updateDate;
  157 + }
  158 +
  159 + public String getCodeName() {
  160 + return codeName;
  161 + }
  162 +
  163 + public void setCodeName(String codeName) {
  164 + this.codeName = codeName;
  165 + }
  166 +
  167 + public int getRoleCode() {
  168 + return roleCode;
  169 + }
  170 +
  171 + public void setRoleCode(int roleCode) {
  172 + this.roleCode = roleCode;
  173 + }
  174 +
  175 + public int getUpCode() {
  176 + return upCode;
  177 + }
  178 +
  179 + public void setUpCode(int upCode) {
  180 + this.upCode = upCode;
  181 + }
  182 +
  183 + public int getLevel() {
  184 + return level;
  185 + }
  186 +
  187 + public void setLevel(int level) {
  188 + this.level = level;
  189 + }
  190 +
  191 + public String getGroupCode() {
  192 + return groupCode;
  193 + }
  194 +
  195 + public void setGroupCode(String groupCode) {
  196 + this.groupCode = groupCode;
  197 + }
  198 +
  199 +
  200 + public String getLevelCode() {
  201 + return levelCode;
  202 + }
  203 +
  204 + public void setLevelCode(String levelCode) {
  205 + this.levelCode = levelCode;
  206 + }
  207 +
  208 + public int getPic() {
  209 + return pic;
  210 + }
  211 +
  212 + public void setPic(int pic) {
  213 + this.pic = pic;
  214 + }
  215 +
  216 + @Override
  217 + public boolean equals(Object obj) {
  218 + return this.id.equals(((Role)obj).getId());
  219 + }
  220 +
  221 + @Override
  222 + public int hashCode() {
  223 + return this.toString().hashCode();
  224 + }
  225 +
  226 + @Override
  227 + public String toString() {
  228 + return this.id + "" + this.getCodeName();
  229 + }
  230 +}
... ...
src/main/java/com/bsth/entity/sys/SysUser.java
1   -package com.bsth.entity.sys;
2   -
3   -import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4   -
5   -import javax.persistence.*;
6   -import java.util.Date;
7   -import java.util.LinkedHashSet;
8   -import java.util.Set;
9   -
10   -@Entity
11   -@Table(name = "bsth_c_sys_user")
12   -@JsonIgnoreProperties(ignoreUnknown = true)
13   -@NamedEntityGraphs({
14   - @NamedEntityGraph(name = "sysUser_role", attributeNodes = {
15   - @NamedAttributeNode("roles")
16   - })
17   -})
18   -public class SysUser {
19   -
20   - @Id
21   - @GeneratedValue(strategy = GenerationType.IDENTITY)
22   - private Integer id;
23   -
24   - private String userName;
25   -
26   - private String name;
27   -
28   - private String password;
29   -
30   - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
31   - private Date createDate;
32   -
33   - @Column(name = "last_loginDate", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
34   - private Date lastLoginDate;
35   -
36   - private String agencies;
37   -
38   - private boolean enabled;
39   -
40   - @ManyToMany(fetch = FetchType.EAGER)
41   - private Set<Role> roles = new LinkedHashSet<>();
42   -
43   -
44   - public Integer getId() {
45   - return id;
46   - }
47   -
48   - public void setId(Integer id) {
49   - this.id = id;
50   - }
51   -
52   - public String getUserName() {
53   - return userName;
54   - }
55   -
56   - public void setUserName(String userName) {
57   - this.userName = userName;
58   - }
59   -
60   - public String getName() {
61   - return name;
62   - }
63   -
64   - public void setName(String name) {
65   - this.name = name;
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 Date getLastLoginDate() {
77   - return lastLoginDate;
78   - }
79   -
80   - public void setLastLoginDate(Date lastLoginDate) {
81   - this.lastLoginDate = lastLoginDate;
82   - }
83   -
84   - public String getAgencies() {
85   - return agencies;
86   - }
87   -
88   - public void setAgencies(String agencies) {
89   - this.agencies = agencies;
90   - }
91   -
92   - public boolean isEnabled() {
93   - return enabled;
94   - }
95   -
96   - public void setEnabled(boolean enabled) {
97   - this.enabled = enabled;
98   - }
99   -
100   - public String getPassword() {
101   - return password;
102   - }
103   -
104   - public void setPassword(String password) {
105   - this.password = password;
106   - }
107   -
108   - public Set<Role> getRoles() {
109   - return roles;
110   - }
111   -
112   - public void setRoles(Set<Role> roles) {
113   - this.roles = roles;
114   - }
115   -}
  1 +package com.bsth.entity.sys;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnore;
  4 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +import org.springframework.util.StringUtils;
  7 +import org.joda.time.DateTime;
  8 +import javax.persistence.*;
  9 +import java.io.Serializable;
  10 +import java.util.Date;
  11 +import java.util.HashSet;
  12 +import java.util.LinkedHashSet;
  13 +import java.util.Set;
  14 +
  15 +@Entity
  16 +@Table(name = "bsth_c_sys_user")
  17 +@JsonIgnoreProperties(ignoreUnknown = true)
  18 +@NamedEntityGraphs({
  19 + @NamedEntityGraph(name = "sysUser_role", attributeNodes = {
  20 + @NamedAttributeNode("roles")
  21 + })
  22 +})
  23 +public class SysUser implements Serializable {
  24 +
  25 + @Id
  26 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  27 + private Integer id;
  28 +
  29 + private String userName;
  30 +
  31 + private String name;
  32 +
  33 + @JsonIgnore
  34 + private String password;
  35 +
  36 + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  37 + private Date createDate;
  38 +
  39 + @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  40 + private Date updateDate;
  41 +
  42 + @DateTimeFormat(pattern = "yyyy-MM-dd")
  43 + private Date lastLoginDate;
  44 +
  45 + /** 最近密码更新时间 */
  46 + @Column(updatable = false, name = "last_pwd_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  47 + @DateTimeFormat(pattern = "yyyy-MM-dd")
  48 + private Date lastPwdDate;
  49 + /** 密码有效期 */
  50 + private Integer pwdValidPeriod = 30;
  51 +
  52 + private String agencies;
  53 +
  54 + private boolean enabled;
  55 +
  56 + @ManyToMany(fetch = FetchType.EAGER)
  57 + private Set<Role> roles = new LinkedHashSet<>();
  58 +
  59 + private String jobCode;
  60 +
  61 + private String realName;
  62 +
  63 + /**
  64 + * 密码过期时间
  65 + */
  66 + @Transient
  67 + private Date pwdExpiredDate;
  68 +
  69 + public Integer getId() {
  70 + return id;
  71 + }
  72 +
  73 + public void setId(Integer id) {
  74 + this.id = id;
  75 + }
  76 +
  77 + public String getUserName() {
  78 + return userName;
  79 + }
  80 +
  81 + public void setUserName(String userName) {
  82 + this.userName = userName;
  83 + }
  84 +
  85 + public String getName() {
  86 + return name;
  87 + }
  88 +
  89 + public void setName(String name) {
  90 + this.name = name;
  91 + }
  92 +
  93 + public Date getCreateDate() {
  94 + return createDate;
  95 + }
  96 +
  97 + public void setCreateDate(Date createDate) {
  98 + this.createDate = createDate;
  99 + }
  100 +
  101 + public Date getUpdateDate() {
  102 + return updateDate;
  103 + }
  104 +
  105 + public void setUpdateDate(Date updateDate) {
  106 + this.updateDate = updateDate;
  107 + }
  108 +
  109 + public Date getLastLoginDate() {
  110 + return lastLoginDate;
  111 + }
  112 +
  113 + public void setLastLoginDate(Date lastLoginDate) {
  114 + this.lastLoginDate = lastLoginDate;
  115 + }
  116 +
  117 + public String getAgencies() {
  118 + return agencies;
  119 + }
  120 +
  121 + public void setAgencies(String agencies) {
  122 + this.agencies = agencies;
  123 + }
  124 +
  125 + public boolean isEnabled() {
  126 + return enabled;
  127 + }
  128 +
  129 + public void setEnabled(boolean enabled) {
  130 + this.enabled = enabled;
  131 + }
  132 +
  133 + public String getPassword() {
  134 + return password;
  135 + }
  136 +
  137 + public void setPassword(String password) {
  138 + this.password = password;
  139 + }
  140 +
  141 + public Set<Role> getRoles() {
  142 + return roles;
  143 + }
  144 +
  145 + public void setRoles(Set<Role> roles) {
  146 + this.roles = roles;
  147 + }
  148 +
  149 + public String getJobCode() {
  150 + return jobCode;
  151 + }
  152 +
  153 + public void setJobCode(String jobCode) {
  154 + this.jobCode = jobCode;
  155 + }
  156 +
  157 + public String getRealName() {
  158 + return realName;
  159 + }
  160 +
  161 + public void setRealName(String realName) {
  162 + this.realName = realName;
  163 + }
  164 +
  165 + @JsonIgnore
  166 + public Set<String> getLinks() {
  167 + Set<String> links = new HashSet<>();
  168 + if (links.size() == 0) {
  169 + for (Role role : roles) {
  170 + for (Module module : role.getModules()) {
  171 + String symbol = module.getMappSymbol();
  172 + if (!StringUtils.isEmpty(symbol)) {
  173 + String[] symbols = symbol.split(";");
  174 + for (String temp : symbols) {
  175 + if (!StringUtils.isEmpty(temp)) {
  176 + links.add(temp);
  177 + }
  178 + }
  179 + }
  180 + }
  181 + }
  182 + }
  183 +
  184 + return links;
  185 + }
  186 +
  187 + public Date getLastPwdDate() {
  188 + return lastPwdDate;
  189 + }
  190 +
  191 + public void setLastPwdDate(Date lastPwdDate) {
  192 + this.lastPwdDate = lastPwdDate;
  193 + }
  194 +
  195 + public Integer getPwdValidPeriod() {
  196 + return pwdValidPeriod;
  197 + }
  198 +
  199 + public void setPwdValidPeriod(Integer pwdValidPeriod) {
  200 + this.pwdValidPeriod = pwdValidPeriod;
  201 + }
  202 +
  203 + public Date getPwdExpiredDate() {
  204 + DateTime dateTime = new DateTime(getLastPwdDate());
  205 + if (pwdValidPeriod != null) {
  206 + dateTime = dateTime.plusDays(pwdValidPeriod);
  207 + }
  208 +
  209 + return dateTime.toDate();
  210 + }
  211 +
  212 + public void setPwdExpiredDate(Date pwdExpiredDate) {
  213 + this.pwdExpiredDate = pwdExpiredDate;
  214 + }
  215 +}
... ...
src/main/java/com/bsth/filter/AuthorityFilter.java 0 → 100644
  1 +package com.bsth.filter;
  2 +
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.data.SystemParamCache;
  6 +import com.fasterxml.jackson.databind.ObjectMapper;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.util.AntPathMatcher;
  10 +import org.springframework.util.PathMatcher;
  11 +
  12 +import javax.servlet.*;
  13 +import javax.servlet.http.HttpServletRequest;
  14 +import javax.servlet.http.HttpServletResponse;
  15 +import java.io.IOException;
  16 +import java.util.HashMap;
  17 +import java.util.Map;
  18 +import java.util.Set;
  19 +
  20 +/**
  21 + * 权限过滤器
  22 + * @author Hill
  23 + */
  24 +public class AuthorityFilter extends BaseFilter {
  25 +
  26 + Logger logger = LoggerFactory.getLogger(this.getClass());
  27 +
  28 + private ObjectMapper mapper = new ObjectMapper();
  29 +
  30 + private final String rootUri = "/";
  31 +
  32 + private final String scheduleReferer = "/real_control/v2";
  33 +
  34 + private PathMatcher matcher = new AntPathMatcher();
  35 +
  36 + private String[] pubUrls = new String[]{ "/pages/home.html", "/error", "/dictionary/all", "/user/validPWDExpired", "/user/isWeakCipher", "/user/isRealName", "/user/currentUser", "/user/companyData", "/user/changePWD", "/pages/permission/user/changePWD.html", "/module/findByCurrentUser", "/cars_sc/all", "/ee/all_py", "/eci/validate_get_destroy_info", "/business/all", "/personnel/all_py", "/companyAuthority/all", "/line/all", "/basic/refresh_person_data", "/downloadFile/download", "/report/lineList", "/adminUtils/**", "/pages/scheduleApp/module/common/**", "/e10adc3949ba59abbe56e057f20f883e.html", "/8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92.html"};
  37 +
  38 + @Override
  39 + public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
  40 + if (!SystemParamCache.getEnableFilterAuthority()) {
  41 + chain.doFilter(request, response);
  42 + return;
  43 + }
  44 +
  45 + String uri = request.getRequestURI(), referer = request.getHeader("Referer");
  46 + Set<String> links = (Set<String>) request.getSession().getAttribute(Constants.RESOURCE_AUTHORITYS);
  47 + if (rootUri.equals(uri) || (referer != null && referer.indexOf(scheduleReferer) > 0) || isPubURL(uri)) {
  48 + chain.doFilter(request, response);
  49 + return;
  50 + }
  51 + if (links != null) {
  52 + boolean matched = false;
  53 + for (String link : links) {
  54 + if (matcher.match(link, uri)) {
  55 + matched = true;
  56 + break;
  57 + }
  58 + }
  59 + if (!matched) {
  60 + Map<String, Object> result = new HashMap<>();
  61 + result.put("status", ResponseCode.ERROR);
  62 + result.put("msg", "未授权的访问");
  63 + response.setContentType("text/html;charset=utf-8");
  64 + response.getWriter().write(mapper.writeValueAsString(result));
  65 + return;
  66 + }
  67 + }
  68 +
  69 + chain.doFilter(request, response);
  70 + }
  71 +
  72 + protected boolean isPubURL(String uri) {
  73 + for (String pubUrl : pubUrls) {
  74 + if (matcher.match(pubUrl, uri)) {
  75 + return true;
  76 + }
  77 + }
  78 +
  79 + return false;
  80 + }
  81 +}
0 82 \ No newline at end of file
... ...
src/main/java/com/bsth/filter/BaseFilter.java
1   -package com.bsth.filter;
2   -
3   -import com.bsth.common.Constants;
4   -import org.springframework.util.AntPathMatcher;
5   -import org.springframework.util.PathMatcher;
6   -
7   -import javax.servlet.*;
8   -import javax.servlet.http.HttpServletRequest;
9   -import javax.servlet.http.HttpServletResponse;
10   -import java.io.IOException;
11   -
12   -public abstract class BaseFilter implements Filter {
13   -
14   - private final PathMatcher pathMatcher = new AntPathMatcher();
15   -
16   - /**
17   - * 白名单
18   - */
19   - private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
20   - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT,Constants.XIANDIAO_LOGIN ,Constants.IPAD_IMG_URL};
21   -
22   - @Override
23   - public void destroy() {
24   -
25   - }
26   -
27   - @Override
28   - public void doFilter(ServletRequest request, ServletResponse response,
29   - FilterChain chain) throws IOException, ServletException {
30   -
31   - HttpServletRequest httpRequest = (HttpServletRequest) request;
32   - HttpServletResponse httpResponse = (HttpServletResponse) response;
33   -
34   - String currentURL = httpRequest.getServletPath();
35   -
36   - if (isWhiteURL(currentURL)) {
37   - chain.doFilter(request, response);
38   - return;
39   - }
40   -
41   - doFilter(httpRequest, httpResponse, chain);
42   - return;
43   - }
44   -
45   - public void doFilter(HttpServletRequest request,
46   - HttpServletResponse response, FilterChain chain)
47   - throws IOException, ServletException {
48   - chain.doFilter(request, response);
49   - }
50   -
51   - @Override
52   - public void init(FilterConfig arg0) throws ServletException {
53   -
54   - }
55   -
56   - private boolean isWhiteURL(String currentURL) {
57   - for (String whiteURL : whiteListURLs) {
58   - if (pathMatcher.match(whiteURL, currentURL)) {
59   - return true;
60   - }
61   - }
62   - return false;
63   - }
64   -}
  1 +package com.bsth.filter;
  2 +
  3 +import com.bsth.common.Constants;
  4 +import org.springframework.util.AntPathMatcher;
  5 +import org.springframework.util.PathMatcher;
  6 +
  7 +import javax.servlet.*;
  8 +import javax.servlet.http.HttpServletRequest;
  9 +import javax.servlet.http.HttpServletResponse;
  10 +import java.io.IOException;
  11 +
  12 +public abstract class BaseFilter implements Filter {
  13 +
  14 + private final PathMatcher pathMatcher = new AntPathMatcher();
  15 +
  16 + /**
  17 + * 白名单
  18 + */
  19 + private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
  20 + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT,Constants.XIANDIAO_LOGIN ,Constants.IPAD_IMG_URL};
  21 +
  22 + @Override
  23 + public void destroy() {
  24 +
  25 + }
  26 +
  27 + @Override
  28 + public void doFilter(ServletRequest request, ServletResponse response,
  29 + FilterChain chain) throws IOException, ServletException {
  30 +
  31 + HttpServletRequest httpRequest = (HttpServletRequest) request;
  32 + HttpServletResponse httpResponse = (HttpServletResponse) response;
  33 + httpResponse.setHeader("Content-Security-Policy", "script-src 'unsafe-inline' 'unsafe-eval' http: https:; worker-src blob:;");
  34 +
  35 + String currentURL = httpRequest.getServletPath();
  36 +
  37 + if (isWhiteURL(currentURL)) {
  38 + chain.doFilter(request, response);
  39 + return;
  40 + }
  41 +
  42 + doFilter(httpRequest, httpResponse, chain);
  43 + return;
  44 + }
  45 +
  46 + public void doFilter(HttpServletRequest request,
  47 + HttpServletResponse response, FilterChain chain)
  48 + throws IOException, ServletException {
  49 + chain.doFilter(request, response);
  50 + }
  51 +
  52 + @Override
  53 + public void init(FilterConfig arg0) throws ServletException {
  54 +
  55 + }
  56 +
  57 + private boolean isWhiteURL(String currentURL) {
  58 + for (String whiteURL : whiteListURLs) {
  59 + if (pathMatcher.match(whiteURL, currentURL)) {
  60 + return true;
  61 + }
  62 + }
  63 + return false;
  64 + }
  65 +}
... ...
src/main/java/com/bsth/filter/WhiteIpFilter.java
1 1 package com.bsth.filter;
2 2  
3   -import com.bsth.common.Setting;
4   -import com.bsth.data.BasicData;
  3 +import com.bsth.data.SystemParamCache;
  4 +import com.bsth.data.WhiteIpCache;
5 5 import com.bsth.entity.WhiteIp;
6 6 import com.bsth.util.IpUtils;
7 7 import org.slf4j.Logger;
8 8 import org.slf4j.LoggerFactory;
9   -import org.springframework.stereotype.Component;
10 9  
11 10 import javax.servlet.*;
12 11 import javax.servlet.http.HttpServletRequest;
... ... @@ -21,17 +20,7 @@ import java.util.List;
21 20 //@Component
22 21 public class WhiteIpFilter implements Filter {
23 22  
24   - Logger logger = LoggerFactory.getLogger(this.getClass());
25   -
26   - private Setting setting;
27   -
28   - public Setting getSetting() {
29   - return setting;
30   - }
31   -
32   - public void setSetting(Setting setting) {
33   - this.setting = setting;
34   - }
  23 + Logger logger = LoggerFactory.getLogger(this.getClass());
35 24  
36 25 @Override
37 26 public void init(FilterConfig filterConfig) throws ServletException {
... ... @@ -39,29 +28,34 @@ public class WhiteIpFilter implements Filter {
39 28 }
40 29  
41 30 @Override
42   - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
43   - HttpServletRequest req = (HttpServletRequest)request;
44   - HttpServletResponse res = (HttpServletResponse)response;
  31 + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
45 32  
46   - String ip = IpUtils.getIpAddr(req);
47   - boolean isMatch = false;
48   - List<WhiteIp> whiteIps = BasicData.whiteIpList;
49   - if (whiteIps != null) {
50   - for (WhiteIp whiteIp : whiteIps) {
51   - if (ip.equals(whiteIp.getIp())) {
52   - isMatch = true;
53   - break;
54   - }
55   - }
56   - }
57   - if (isMatch || !setting.isWhiteipEnabled()) {
58   - chain.doFilter(request, response);
59   - } else {
60   - logger.info(ip + "未在白名单中,不予访问");
61   - res.setStatus(404);
62   - return;
63   - }
64   - }
  33 + if (!SystemParamCache.getEnabledWhiteIp()) {
  34 + chain.doFilter(request, response);
  35 + return;
  36 + }
  37 +
  38 + HttpServletRequest req = (HttpServletRequest)request;
  39 + HttpServletResponse res = (HttpServletResponse)response;
  40 +
  41 + String ip = IpUtils.getIpAddr(req);
  42 + boolean isMatch = false;
  43 + List<WhiteIp> whiteIps = WhiteIpCache.getWhiteIps();
  44 + if (whiteIps != null) {
  45 + for (WhiteIp whiteIp : whiteIps) {
  46 + if (ip.equals(whiteIp.getIp())) {
  47 + isMatch = true;
  48 + break;
  49 + }
  50 + }
  51 + }
  52 + if (isMatch) {
  53 + chain.doFilter(request, response);
  54 + } else {
  55 + logger.info("{}未在白名单中,不予访问", ip);
  56 + res.setStatus(404);
  57 + }
  58 + }
65 59  
66 60 @Override
67 61 public void destroy() {
... ...
src/main/java/com/bsth/repository/sys/RoleRepository.java
1   -package com.bsth.repository.sys;
2   -
3   -
4   -import javax.transaction.Transactional;
5   -
6   -import org.springframework.data.jpa.repository.Modifying;
7   -import org.springframework.data.jpa.repository.Query;
8   -import org.springframework.stereotype.Repository;
9   -
10   -import com.bsth.entity.sys.Role;
11   -import com.bsth.repository.BaseRepository;
12   -
13   -@Repository
14   -public interface RoleRepository extends BaseRepository<Role, Integer>{
15   -
16   - /**
17   - * @Title: update
18   - * @Description: TODO(简洁版更新(不需要级联的))
19   - */
20   - @Modifying
21   - @Transactional
22   - @Query("update Role r set r.codeName=?1, r.roleName=?2, r.enable=?3, r.descriptions=?4 where r.id=?5")
23   - void update(String codeName, String roleName, boolean enable, String descriptions, Integer id);
24   -}
  1 +package com.bsth.repository.sys;
  2 +
  3 +
  4 +import javax.transaction.Transactional;
  5 +
  6 +import org.springframework.data.jpa.repository.Modifying;
  7 +import org.springframework.data.jpa.repository.Query;
  8 +import org.springframework.stereotype.Repository;
  9 +
  10 +import com.bsth.entity.sys.Role;
  11 +import com.bsth.repository.BaseRepository;
  12 +
  13 +import java.util.List;
  14 +
  15 +@Repository
  16 +public interface RoleRepository extends BaseRepository<Role, Integer>{
  17 +
  18 + // 查询最大ID
  19 + @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_sys_role) k"
  20 + , nativeQuery=true)
  21 + public int roleMaxId();
  22 +
  23 + /**
  24 + * @Title: update
  25 + * @Description: TODO(简洁版更新(不需要级联的))
  26 + */
  27 + @Modifying
  28 + @Transactional
  29 + @Query("update Role r set r.codeName=?1, r.roleName=?2, r.enable=?3, r.descriptions=?4 where r.id=?5")
  30 + void update(String codeName, String roleName, boolean enable, String descriptions, Integer id);
  31 +
  32 + @Query(value = "select * from role where id in(?1)",nativeQuery = true)
  33 + List<Role> findAllById(String ids);
  34 +
  35 +// @Query(value = "select r from Role r where < ?1")
  36 +// List<Role> findSubordinate(Integer pic);
  37 +}
... ...
src/main/java/com/bsth/repository/sys/SysUserRepository.java
1   -package com.bsth.repository.sys;
2   -
3   -import com.bsth.entity.sys.SysUser;
4   -import com.bsth.repository.BaseRepository;
5   -import org.springframework.data.jpa.repository.EntityGraph;
6   -import org.springframework.data.jpa.repository.Modifying;
7   -import org.springframework.data.jpa.repository.Query;
8   -import org.springframework.stereotype.Repository;
9   -import org.springframework.transaction.annotation.Transactional;
10   -
11   -import java.util.List;
12   -
13   -@Repository
14   -public interface SysUserRepository extends BaseRepository<SysUser, Integer>{
15   -
16   - SysUser findByUserName(String userName);
17   -
18   - @Transactional
19   - @Modifying
20   - @Query(value="update bsth_c_sys_user set enabled=?2 where id=?1",nativeQuery=true)
21   - int changeEnabled(int id,int enabled);
22   -
23   - @Transactional
24   - @Modifying
25   - @Query(value="update bsth_c_sys_user set password=?2 where id=?1",nativeQuery=true)
26   - int changePWD(int id,String newPWD);
27   -
28   - @EntityGraph(value = "sysUser_role", type = EntityGraph.EntityGraphType.FETCH)
29   - @Query(value = "select DISTINCT u from SysUser u")
30   - List<SysUser> findAll_distinct();
31   -}
  1 +package com.bsth.repository.sys;
  2 +
  3 +import com.bsth.entity.sys.SysUser;
  4 +import com.bsth.repository.BaseRepository;
  5 +import org.springframework.data.jpa.repository.EntityGraph;
  6 +import org.springframework.data.jpa.repository.Modifying;
  7 +import org.springframework.data.jpa.repository.Query;
  8 +import org.springframework.stereotype.Repository;
  9 +import org.springframework.transaction.annotation.Transactional;
  10 +
  11 +import java.util.List;
  12 +
  13 +@Repository
  14 +public interface SysUserRepository extends BaseRepository<SysUser, Integer>{
  15 +
  16 + SysUser findByUserName(String userName);
  17 +
  18 + @Transactional
  19 + @Modifying
  20 + @Query(value="update bsth_c_sys_user set enabled=?2 where id=?1",nativeQuery=true)
  21 + int changeEnabled(int id,int enabled);
  22 +
  23 + @Transactional
  24 + @Modifying
  25 + @Query(value="update bsth_c_sys_user set password=?2, last_pwd_date = now() where id=?1",nativeQuery=true)
  26 + int changePWD(int id,String newPWD);
  27 +
  28 + @EntityGraph(value = "sysUser_role", type = EntityGraph.EntityGraphType.FETCH)
  29 + @Query(value = "select DISTINCT u from SysUser u")
  30 + List<SysUser> findAll_distinct();
  31 +
  32 + @Modifying
  33 + @Query(value="update bsth_c_sys_user set last_login_date=now() where user_name = ?1",nativeQuery=true)
  34 + void recordLoginDate(String userName);
  35 +
  36 + @Modifying
  37 + @Query(value="update bsth_c_sys_user set job_code = ?1, real_name = ?2 where id = ?3",nativeQuery=true)
  38 + void realName(String jobCode, String realName, int id);
  39 +}
... ...
src/main/java/com/bsth/security/WebSecurityConfig.java
1 1 package com.bsth.security;
2 2  
3   -import com.bsth.common.Setting;
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.filter.AccessLogFilter;
  5 +import com.bsth.filter.AuthorityFilter;
4 6 import com.bsth.filter.WhiteIpFilter;
  7 +import com.bsth.security.filter.LoginInterceptor;
5 8 import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.beans.factory.annotation.Value;
7 9 import org.springframework.boot.context.embedded.ServletListenerRegistrationBean;
8 10 import org.springframework.context.annotation.Bean;
9 11 import org.springframework.context.annotation.Configuration;
... ... @@ -20,9 +22,6 @@ import org.springframework.security.web.firewall.DefaultHttpFirewall;
20 22 import org.springframework.security.web.firewall.HttpFirewall;
21 23 import org.springframework.security.web.session.HttpSessionEventPublisher;
22 24  
23   -import com.bsth.common.Constants;
24   -import com.bsth.security.filter.LoginInterceptor;
25   -
26 25 @Configuration
27 26 @EnableWebSecurity
28 27 public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
... ... @@ -36,15 +35,12 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
36 35 @Autowired
37 36 SecurityMetadataSourceService securityMetadataSourceService;
38 37  
39   - @Autowired
40   - private Setting setting;
41   -
42 38 @Override
43 39 public void configure(WebSecurity web) throws Exception {
44 40 // 白名单
45   - web.ignoring().antMatchers(Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA,
46   - Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL,
47   - Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT);
  41 + web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ORIGINAL_LOGIN_PAGE, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA,
  42 + Constants.SERVICE_INTERFACE, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES,
  43 + Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT, Constants.FILE_AUTH);
48 44 }
49 45  
50 46 @Override
... ... @@ -75,11 +71,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
75 71 .expiredUrl(Constants.LOGIN_PAGE + "?error=true")
76 72 .maxSessionsPreventsLogin(false)
77 73 .sessionRegistry(sessionRegistry());
  74 + //edge游览器地图和轨迹播放不行的问题
  75 +// http.headers().contentSecurityPolicy(
  76 +// "script-src 'unsafe-inline' 'unsafe-eval' http: https:; worker-src blob:;"
  77 +// );
78 78  
79 79 WhiteIpFilter whiteIpFilter = new WhiteIpFilter();
80   - whiteIpFilter.setSetting(setting);
81 80 http.addFilterBefore(whiteIpFilter, FilterSecurityInterceptor.class);
82 81 http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class);
  82 + http.addFilterBefore(new AccessLogFilter(), FilterSecurityInterceptor.class);
  83 + http.addFilterBefore(new AuthorityFilter(), FilterSecurityInterceptor.class);
83 84 http.addFilter(filterSecurityInterceptor());
84 85 }
85 86  
... ...
src/main/java/com/bsth/service/SystemParamService.java
... ... @@ -6,4 +6,8 @@ import com.bsth.entity.SystemParam;
6 6 * @author Hill
7 7 */
8 8 public interface SystemParamService extends BaseService<SystemParam, Integer> {
  9 +
  10 + void refresh();
  11 +
  12 + String getValue(String key);
9 13 }
... ...
src/main/java/com/bsth/service/impl/SystemParamServiceImpl.java
1 1 package com.bsth.service.impl;
2 2  
3 3 import com.bsth.entity.SystemParam;
  4 +import com.bsth.repository.SystemParamRepository;
4 5 import com.bsth.service.SystemParamService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.scheduling.annotation.EnableScheduling;
  8 +import org.springframework.scheduling.annotation.Scheduled;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import java.util.HashMap;
  12 +import java.util.Map;
5 13  
6 14 /**
7 15 * @author Hill
8 16 */
  17 +@Service
  18 +@EnableScheduling
9 19 public class SystemParamServiceImpl extends BaseServiceImpl<SystemParam, Integer> implements SystemParamService {
  20 +
  21 + @Autowired
  22 + private SystemParamRepository systemParamRepository;
  23 +
  24 + private Map<String, String> pairs = new HashMap<>();
  25 +
  26 + @Scheduled(cron = "0 0/30 * * * ?")
  27 + public void refresh() {
  28 + for (SystemParam sp : systemParamRepository.findAll()) {
  29 + pairs.put(sp.getKey(), sp.getValue());
  30 + }
  31 + }
  32 +
  33 + public String getValue(String key) {
  34 + return pairs.get(key);
  35 + }
10 36 }
... ...
src/main/java/com/bsth/service/sys/RoleService.java
1   -package com.bsth.service.sys;
2   -
3   -import java.util.Map;
4   -
5   -import com.bsth.entity.sys.Role;
6   -import com.bsth.service.BaseService;
7   -
8   -public interface RoleService extends BaseService<Role, Integer>{
9   -
10   - Map<String, Object> settRoleModules(Integer roleId, String mIds);
11   -
12   - Map<String, Object> roleInfo(Integer id);
13   -}
  1 +package com.bsth.service.sys;
  2 +
  3 +import com.bsth.entity.sys.Role;
  4 +import com.bsth.service.BaseService;
  5 +
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +public interface RoleService extends BaseService<Role, Integer>{
  10 +
  11 + Map<String, Object> findSubordinate();
  12 +
  13 + Map<String, Object> add(Role role);
  14 +
  15 + Map<String, Object> settRoleModules(Integer roleId, String mIds);
  16 +
  17 + Map<String, Object> roleInfo(Integer id);
  18 +
  19 + List<Role> findAllByIds(String ids);
  20 +
  21 + boolean checkOperationLegality(Integer operationRoleId);
  22 +}
... ...
src/main/java/com/bsth/service/sys/SysUserService.java
1   -package com.bsth.service.sys;
2   -
3   -import com.bsth.entity.sys.SysUser;
4   -import com.bsth.service.BaseService;
5   -
6   -import java.util.List;
7   -import java.util.Map;
8   -
9   -public interface SysUserService extends BaseService<SysUser, Integer>{
10   -
11   - SysUser findByUserName(String name);
12   -
13   - int changeEnabled(int id,int enabled);
14   -
15   - int changePWD(int id,String newPWD);
16   -
17   - Map<String,Object> register(SysUser u);
18   -
19   - List<SysUser> findAll_distinct();
20   -}
  1 +package com.bsth.service.sys;
  2 +
  3 +import com.bsth.entity.sys.SysUser;
  4 +import com.bsth.service.BaseService;
  5 +
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +public interface SysUserService extends BaseService<SysUser, Integer>{
  10 +
  11 + SysUser findByUserName(String name);
  12 +
  13 + int changeEnabled(int id,int enabled);
  14 +
  15 + int changePWD(int id,String newPWD);
  16 +
  17 + /**
  18 + * 检测指定用户密码是否过期
  19 + * @param userName 用户名
  20 + */
  21 + boolean validPWDExpired(String userName);
  22 +
  23 + Map<String,Object> register(SysUser u);
  24 +
  25 + List<SysUser> findAll_distinct();
  26 +
  27 + Map<String, Object> resetPassword(Integer id, Integer pwdValidPeriod);
  28 +
  29 + void recordLoginDate(String userName);
  30 +
  31 + void realName(String jobCode, String realName, int id);
  32 +}
... ...
src/main/java/com/bsth/service/sys/impl/PwdGenerator.java 0 → 100644
  1 +package com.bsth.service.sys.impl;
  2 +
  3 +import java.util.Random;
  4 +
  5 +public class PwdGenerator {
  6 + private static final String SPECIAL_CHARS = "!@#$%^&*_=+-/";
  7 +
  8 + /**
  9 + * 查找一个char数组中还没有填充字符的位置
  10 + */
  11 + private static int nextIndex(char[] chars, Random rnd) {
  12 + int index = rnd.nextInt(chars.length);
  13 + while (chars[index] != 0) {
  14 + index = rnd.nextInt(chars.length);
  15 + }
  16 + return index;
  17 + }
  18 +
  19 + /**
  20 + * 返回一个随机的特殊字符
  21 + */
  22 + private static char nextSpecialChar(Random rnd) {
  23 + return SPECIAL_CHARS.charAt(rnd.nextInt(SPECIAL_CHARS.length()));
  24 + }
  25 +
  26 + /**
  27 + * 返回一个随机的大写字母
  28 + */
  29 + private static char nextUpperLetter(Random rnd) {
  30 + return (char) ('A' + rnd.nextInt(26));
  31 + }
  32 +
  33 + /**
  34 + * 返回一个随机的小写字母
  35 + */
  36 + private static char nextLowerLetter(Random rnd) {
  37 + return (char) ('a' + rnd.nextInt(26));
  38 + }
  39 +
  40 + /**
  41 + * 返回一个随机的数字
  42 + */
  43 + private static char nextNumLetter(Random rnd) {
  44 + return (char) ('0' + rnd.nextInt(10));
  45 + }
  46 +
  47 + /**
  48 + * 返回一个随机的字符
  49 + */
  50 + private static char nextChar(Random rnd) {
  51 + switch (rnd.nextInt(4)) {
  52 + case 0:
  53 + return (char) ('a' + rnd.nextInt(26));
  54 + case 1:
  55 + return (char) ('A' + rnd.nextInt(26));
  56 + case 2:
  57 + return (char) ('0' + rnd.nextInt(10));
  58 + default:
  59 + return SPECIAL_CHARS.charAt(rnd.nextInt(SPECIAL_CHARS.length()));
  60 + }
  61 + }
  62 +
  63 + /**
  64 + * 生成指定位数的随机数
  65 + */
  66 + public static String randomPassword(int length) {
  67 + if(length < 3){
  68 + return "";
  69 + }
  70 + char[] chars = new char[length];
  71 + Random rnd = new Random();
  72 +
  73 + //1. 至少生成一个大写字母、小写字母、特殊字符、数字
  74 + chars[nextIndex(chars, rnd)] = nextUpperLetter(rnd);
  75 + chars[nextIndex(chars, rnd)] = nextLowerLetter(rnd);
  76 + chars[nextIndex(chars, rnd)] = nextNumLetter(rnd);
  77 +
  78 + //2. 填补其他位置的字符
  79 + for (int i = 0; i < length; i++) {
  80 + if (chars[i] == 0) {
  81 + chars[i] = nextChar(rnd);
  82 + }
  83 + }
  84 +
  85 + //3. 返回结果
  86 + return new String(chars);
  87 + }
  88 +
  89 +
  90 + /**
  91 + * 测试代码
  92 + */
  93 + public static void main(String[] args) {
  94 + for (int i = 0; i < 10; i++) {
  95 + System.out.println(randomPassword(16));
  96 + }
  97 +
  98 + }
  99 +
  100 +}
... ...
src/main/java/com/bsth/service/sys/impl/RoleServiceImpl.java
1   -package com.bsth.service.sys.impl;
2   -
3   -import java.text.SimpleDateFormat;
4   -import java.util.ArrayList;
5   -import java.util.HashMap;
6   -import java.util.Iterator;
7   -import java.util.List;
8   -import java.util.Map;
9   -import java.util.Set;
10   -
11   -import org.slf4j.Logger;
12   -import org.slf4j.LoggerFactory;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.stereotype.Service;
15   -
16   -import com.bsth.common.ResponseCode;
17   -import com.bsth.entity.sys.Module;
18   -import com.bsth.entity.sys.Role;
19   -import com.bsth.entity.sys.SysUser;
20   -import com.bsth.repository.sys.ModuleRepository;
21   -import com.bsth.repository.sys.RoleRepository;
22   -import com.bsth.service.impl.BaseServiceImpl;
23   -import com.bsth.service.sys.RoleService;
24   -
25   -@Service
26   -public class RoleServiceImpl extends BaseServiceImpl<Role, Integer> implements
27   - RoleService {
28   -
29   - Logger logger = LoggerFactory.getLogger(this.getClass());
30   -
31   - @Autowired
32   - RoleRepository roleRepository;
33   -
34   - @Autowired
35   - ModuleRepository moduleRepository;
36   -
37   - SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
38   -
39   - @Override
40   - public Map<String, Object> save(Role t) {
41   - if (t.getId() != null) {
42   - // 更新
43   - Map<String, Object> map = new HashMap<>();
44   - try {
45   - roleRepository.update(t.getCodeName(), t.getRoleName(),
46   - t.isEnable(), t.getDescriptions(), t.getId());
47   - map.put("status", ResponseCode.SUCCESS);
48   - } catch (Exception e) {
49   - map.put("status", ResponseCode.ERROR);
50   - }
51   - return map;
52   - }
53   - return super.save(t);
54   - }
55   -
56   - @Override
57   - public Map<String, Object> settRoleModules(Integer roleId, String mIds) {
58   -
59   - Map<String, Object> map = new HashMap<>();
60   - try {
61   - Role role = roleRepository.findOne(roleId);
62   -
63   - List<Integer> idList = new ArrayList<>();
64   - String[] array = mIds.split(",");
65   - for (String id : array) {
66   - if (null == id || id.trim().equals(""))
67   - continue;
68   - idList.add(Integer.parseInt(id));
69   - }
70   -
71   - Set<Module> mList = moduleRepository.findByIds(idList);
72   - role.setModules(mList);
73   - roleRepository.save(role);
74   - map.put("status", ResponseCode.SUCCESS);
75   - } catch (Exception e) {
76   - logger.error("", e);
77   - map.put("status", ResponseCode.ERROR);
78   - }
79   - return map;
80   - }
81   -
82   - @Override
83   - public Map<String, Object> roleInfo(Integer id) {
84   - Map<String, Object> map = new HashMap<>();
85   - Role role = roleRepository.findOne(id);
86   - map.put("codeName", role.getCodeName());
87   - map.put("roleName", role.getRoleName());
88   - map.put("createDate", sdfMinute.format(role.getCreateDate()));
89   - map.put("updateDate", sdfMinute.format(role.getUpdateDate()));
90   - map.put("enable", role.isEnable()==true?1:0);
91   - map.put("descriptions", role.getDescriptions());
92   - map.put("modules", role.getModules().size());
93   - map.put("resources", role.getResources().size());
94   - String userNames = "";
95   - Set<SysUser> users = role.getUsers();
96   - if(!users.isEmpty()){
97   - Iterator<SysUser> it = users.iterator();
98   - while(it.hasNext()){
99   - SysUser user = it.next();
100   - userNames = user.getUserName()+"...";
101   - }
102   - }
103   - map.put("userNames", userNames);
104   - return map;
105   - }
106   -}
  1 +package com.bsth.service.sys.impl;
  2 +
  3 +import java.beans.BeanInfo;
  4 +import java.beans.Introspector;
  5 +import java.beans.PropertyDescriptor;
  6 +import java.lang.reflect.Method;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.*;
  9 +
  10 +import com.bsth.security.util.SecurityUtils;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import com.bsth.common.ResponseCode;
  17 +import com.bsth.entity.sys.Module;
  18 +import com.bsth.entity.sys.Role;
  19 +import com.bsth.entity.sys.SysUser;
  20 +import com.bsth.repository.sys.ModuleRepository;
  21 +import com.bsth.repository.sys.RoleRepository;
  22 +import com.bsth.service.impl.BaseServiceImpl;
  23 +import com.bsth.service.sys.RoleService;
  24 +
  25 +@Service
  26 +public class RoleServiceImpl extends BaseServiceImpl<Role, Integer> implements
  27 + RoleService {
  28 +
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + @Autowired
  32 + RoleRepository roleRepository;
  33 +
  34 + @Autowired
  35 + ModuleRepository moduleRepository;
  36 +
  37 + SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  38 +
  39 + @Override
  40 + public Map<String, Object> findSubordinate() {
  41 + SysUser user = SecurityUtils.getCurrentUser();
  42 + Iterator<Role> itRole = user.getRoles().iterator();
  43 + Role ro = new Role();
  44 + while(itRole.hasNext()){//判断是否有下一个
  45 + ro = itRole.next();
  46 + }
  47 + Map<String, Object> map = new HashMap<>();
  48 + List<Map<String, Object>> rsRoleList = new ArrayList<>();
  49 + try {
  50 + // 读取层次数据结果集列表
  51 + Iterator<Role> roleList = roleRepository.findAll().iterator();
  52 +
  53 + // 节点列表(散列表,用于临时存储节点对象)
  54 + Map<String, Object> nodeList = new HashMap<>();
  55 + // 根节点
  56 + List rootlist = new ArrayList();
  57 + while(roleList.hasNext()){
  58 + Role role = roleList.next();
  59 + HashMap map0 = new HashMap();
  60 + map0.put("id", role.getId());
  61 + map0.put("roleCode", role.getRoleCode());
  62 + map0.put("upCode", role.getUpCode());
  63 + map0.put("roleName", role.getRoleName());
  64 + map0.put("codeName", role.getCodeName());
  65 + map0.put("level", role.getLevel());
  66 + map0.put("levelCode", role.getLevelCode());
  67 + nodeList.put(role.getLevelCode(), map0);
  68 + }
  69 + // 构造无序的多叉树
  70 + Set entrySet = nodeList.entrySet();
  71 + for (Iterator it = entrySet.iterator(); it.hasNext();) {
  72 + Map<String, Object> map1 = (HashMap) ((Map.Entry) it.next()).getValue();
  73 +// Map<String, Object> map1 = objectToMap(it.next());
  74 + if (map1.get("upCode") == null || map1.get("upCode").equals("")
  75 + || Integer.parseInt(map1.get("upCode").toString()) == 0) {
  76 + // root = node;
  77 + rootlist.add(map1);
  78 + } else {
  79 + Map<String, Object> tempmap = ((HashMap)nodeList.get((Integer.parseInt(map1.get("level").toString())-1)+"_"+map1.get("upCode")));
  80 +// Map<String, Object> tempmap = objectToMap(nodeList.get((Integer.parseInt(map1.get("level").toString())-1)+"_"+map1.get("upCode")));
  81 + System.out.println(tempmap);
  82 +
  83 + List templist = (List) tempmap.get("children");
  84 + if (null != templist) {
  85 + templist.add(map1);
  86 + } else {
  87 + templist = new ArrayList();
  88 + templist.add(map1);
  89 + }
  90 + tempmap.put("children", templist);
  91 + }
  92 + }
  93 + getRoleList(rootlist,ro.getLevelCode(),rsRoleList,false);
  94 +
  95 + // 排序后输出
  96 +// ComparatorSysrole(rootlist);
  97 + map.put("list", rsRoleList);
  98 + map.put("status", ResponseCode.SUCCESS);
  99 + map.put("msg", "成功");
  100 + } catch (Exception e) {
  101 + map.put("status", ResponseCode.ERROR);
  102 + map.put("msg", e);
  103 + logger.error("error",e);
  104 + }
  105 + return map;
  106 + }
  107 +
  108 + private void getRoleList(List<Map<String, Object>> list, String levelCode, List<Map<String, Object>> roleList,boolean isChildren){
  109 + try{
  110 + if(isChildren){
  111 + for (Map<String, Object> map : list) {
  112 + roleList.add(map);
  113 + List mapList = (List) map.get("children");
  114 + if (mapList != null && mapList.size() > 0) {
  115 + getRoleList(mapList,levelCode,roleList,isChildren);
  116 + }
  117 + }
  118 +
  119 + } else {
  120 + for (Map<String, Object> map : list) {
  121 + if(map.get("levelCode").equals(levelCode)){
  122 + isChildren = true;
  123 + List mapList = (List) map.get("children");
  124 + if (mapList != null && mapList.size() > 0) {
  125 + getRoleList(mapList,levelCode,roleList,isChildren);
  126 + }
  127 + break;
  128 + } else {
  129 + List mapList = (List) map.get("children");
  130 + if (mapList != null && mapList.size() > 0) {
  131 + getRoleList(mapList,levelCode,roleList,isChildren);
  132 + }
  133 + }
  134 + }
  135 + }
  136 + } catch (Exception e) {
  137 + logger.error("error",e);
  138 + }
  139 + }
  140 +
  141 + public Map<String, Object> objectToMap(Object obj) throws Exception {
  142 + if(obj == null)
  143 + return null;
  144 +
  145 + Map<String, Object> map = new HashMap<>();
  146 +
  147 + BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
  148 + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
  149 + for (PropertyDescriptor property : propertyDescriptors) {
  150 + String key = property.getName();
  151 + if (key.compareToIgnoreCase("class") == 0) {
  152 + continue;
  153 + }
  154 + Method getter = property.getReadMethod();
  155 + Object value = getter!=null ? getter.invoke(obj) : null;
  156 + map.put(key, value);
  157 + }
  158 +
  159 + return map;
  160 + }
  161 +
  162 + private void ComparatorSysrole(List<HashMap> list) {
  163 + ComparatorSysrole comparator = new ComparatorSysrole();
  164 + Collections.sort(list, comparator);
  165 + for (HashMap map : list) {
  166 + List mapList = (List) map.get("children");
  167 + if (mapList != null && mapList.size() > 0) {
  168 + ComparatorSysrole(mapList);
  169 + }
  170 + }
  171 + }
  172 +
  173 + private class ComparatorSysrole implements Comparator {
  174 + public int compare(Object arg0, Object arg1) {
  175 + HashMap role0 = (HashMap) arg0;
  176 + HashMap role1 = (HashMap) arg1;
  177 +
  178 + // 首先比较父节点 相同比较 子 位序
  179 + Long role0Pid = (Long) (role0.get("upCode") == null ? (long) 0 : role0.get("upCode"));
  180 + Long role1Pid = (Long) (role1.get("upCode") == null ? (long) 0 : role1.get("upCode"));
  181 + int flag = role0Pid.compareTo(role1Pid);
  182 + if (flag == 0) {
  183 + return (Integer.valueOf(role0.get("roleIndex").toString())).compareTo(Integer.valueOf(role1.get(
  184 + "roleIndex").toString()));
  185 + } else {
  186 + return flag;
  187 + }
  188 + }
  189 + }
  190 +
  191 + @Override
  192 + public Map<String, Object> add(Role role) {
  193 + Map<String, Object> rs = new HashMap();
  194 + try{
  195 + SysUser user = SecurityUtils.getCurrentUser();
  196 + Iterator<Role> itRole = user.getRoles().iterator();
  197 + Role ro = new Role();
  198 + while(itRole.hasNext()){//判断是否有下一个
  199 + ro = itRole.next();
  200 + }
  201 + int id = roleRepository.roleMaxId()+1;
  202 + role.setUpCode(ro.getRoleCode());
  203 + role.setLevel(ro.getLevel()+1);
  204 + role.setRoleCode(id);
  205 + role.setId(id);
  206 + return super.save(role);
  207 + }catch (Exception e){
  208 + logger.error("", e);
  209 + rs.put("status", ResponseCode.ERROR);
  210 + rs.put("msg", e.getMessage());
  211 + }
  212 + return rs;
  213 + }
  214 +
  215 + @Override
  216 + public Map<String, Object> save(Role t) {
  217 + if (t.getId() != null) {
  218 + // 更新
  219 + Map<String, Object> map = new HashMap<>();
  220 + try {
  221 + roleRepository.update(t.getCodeName(), t.getRoleName(),
  222 + t.isEnable(), t.getDescriptions(), t.getId());
  223 + map.put("status", ResponseCode.SUCCESS);
  224 + } catch (Exception e) {
  225 + map.put("status", ResponseCode.ERROR);
  226 + }
  227 + return map;
  228 + }
  229 + return super.save(t);
  230 + }
  231 +
  232 + @Override
  233 + public Map<String, Object> settRoleModules(Integer roleId, String mIds) {
  234 +
  235 + Map<String, Object> map = new HashMap<>();
  236 + try {
  237 + Role role = roleRepository.findOne(roleId);
  238 +
  239 + List<Integer> idList = new ArrayList<>();
  240 + String[] array = mIds.split(",");
  241 + for (String id : array) {
  242 + if (null == id || id.trim().equals(""))
  243 + continue;
  244 + idList.add(Integer.parseInt(id));
  245 + }
  246 +
  247 + Set<Module> mList = moduleRepository.findByIds(idList);
  248 + role.setModules(mList);
  249 + roleRepository.save(role);
  250 + map.put("status", ResponseCode.SUCCESS);
  251 + } catch (Exception e) {
  252 + logger.error("", e);
  253 + map.put("status", ResponseCode.ERROR);
  254 + }
  255 + return map;
  256 + }
  257 +
  258 + @Override
  259 + public Map<String, Object> roleInfo(Integer id) {
  260 + Map<String, Object> map = new HashMap<>();
  261 + Role role = roleRepository.findOne(id);
  262 + map.put("codeName", role.getCodeName());
  263 + map.put("roleName", role.getRoleName());
  264 + map.put("createDate", sdfMinute.format(role.getCreateDate()));
  265 + map.put("updateDate", sdfMinute.format(role.getUpdateDate()));
  266 + map.put("enable", role.isEnable()==true?1:0);
  267 + map.put("descriptions", role.getDescriptions());
  268 + map.put("modules", role.getModules().size());
  269 + map.put("resources", role.getResources().size());
  270 + String userNames = "";
  271 + Set<SysUser> users = role.getUsers();
  272 + if(!users.isEmpty()){
  273 + Iterator<SysUser> it = users.iterator();
  274 + while(it.hasNext()){
  275 + SysUser user = it.next();
  276 + userNames = user.getUserName()+"...";
  277 + }
  278 + }
  279 + map.put("userNames", userNames);
  280 + return map;
  281 + }
  282 +
  283 + @Override
  284 + public List<Role> findAllByIds(String ids) {
  285 + return roleRepository.findAllById(ids);
  286 + }
  287 +
  288 + @Override
  289 + public boolean checkOperationLegality(Integer operationRoleId){
  290 + boolean isLegality = false;
  291 + Map<String, Object> roleMap = findSubordinate();
  292 + isLegality = (roleMap.get(operationRoleId) == null ? true:false );
  293 + return isLegality;
  294 + }
  295 +}
... ...
src/main/java/com/bsth/service/sys/impl/SysUserServiceImpl.java
1   -package com.bsth.service.sys.impl;
2   -
3   -import com.bsth.common.ResponseCode;
4   -import com.bsth.entity.sys.SysUser;
5   -import com.bsth.repository.sys.SysUserRepository;
6   -import com.bsth.service.impl.BaseServiceImpl;
7   -import com.bsth.service.sys.SysUserService;
8   -import org.slf4j.Logger;
9   -import org.slf4j.LoggerFactory;
10   -import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
12   -import org.springframework.stereotype.Service;
13   -
14   -import java.util.HashMap;
15   -import java.util.List;
16   -import java.util.Map;
17   -
18   -@Service
19   -public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implements SysUserService{
20   -
21   - @Autowired
22   - SysUserRepository sysUserRepository;
23   -
24   - Logger logger = LoggerFactory.getLogger(this.getClass());
25   -
26   - @Override
27   - public SysUser findByUserName(String name) {
28   - return sysUserRepository.findByUserName(name);
29   - }
30   -
31   - @Override
32   - public Map<String, Object> save(SysUser t) {
33   - //
34   - if(t.getPassword() == null || t.getPassword().trim().equals("")){
35   - SysUser user = sysUserRepository.findOne(t.getId());
36   - t.setPassword(user.getPassword());
37   - }else{
38   - t.setPassword(new BCryptPasswordEncoder(4).encode(t.getPassword()));
39   - }
40   - return super.save(t);
41   - }
42   -
43   - @Override
44   - public int changeEnabled(int id, int enabled) {
45   - sysUserRepository.changeEnabled(id,enabled);
46   - return 0;
47   - }
48   -
49   - @Override
50   - public int changePWD(int id,String newPWD) {
51   - return sysUserRepository.changePWD(id,new BCryptPasswordEncoder(4).encode(newPWD));
52   - }
53   -
54   - @Override
55   - public Map<String, Object> register(SysUser u) {
56   - Map<String, Object> rs = new HashMap();
57   - try{
58   - //检查用户名是否存在
59   - if(findByUserName(u.getUserName()) != null){
60   - rs.put("status", ResponseCode.ERROR);
61   - rs.put("msg", "用户名" + u.getUserName() + "已存在!");
62   - }
63   - else{
64   - u.setPassword(new BCryptPasswordEncoder(4).encode(u.getPassword()));
65   - rs = super.save(u);
66   - }
67   - }catch (Exception e){
68   - logger.error("", e);
69   - rs.put("status", ResponseCode.ERROR);
70   - rs.put("msg", e.getMessage());
71   - }
72   - return rs;
73   - }
74   -
75   - @Override
76   - public List<SysUser> findAll_distinct() {
77   - return sysUserRepository.findAll_distinct();
78   - }
79   -}
  1 +package com.bsth.service.sys.impl;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.controller.sys.util.RSAUtils;
  5 +import com.bsth.email.entity.EmailBean;
  6 +import com.bsth.entity.sys.Role;
  7 +import com.bsth.entity.sys.SysUser;
  8 +import com.bsth.repository.sys.SysUserRepository;
  9 +import com.bsth.security.util.SecurityUtils;
  10 +import com.bsth.service.impl.BaseServiceImpl;
  11 +import com.bsth.service.sys.RoleService;
  12 +import com.bsth.service.sys.SysUserService;
  13 +import com.bsth.util.IpUtils;
  14 +import com.bsth.util.MailUtils;
  15 +import com.google.gson.Gson;
  16 +import com.google.gson.reflect.TypeToken;
  17 +import org.joda.time.DateTime;
  18 +import org.joda.time.Days;
  19 +import org.slf4j.Logger;
  20 +import org.slf4j.LoggerFactory;
  21 +import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  23 +import org.springframework.stereotype.Service;
  24 +import org.springframework.transaction.annotation.Transactional;
  25 +
  26 +import java.util.ArrayList;
  27 +import java.util.HashMap;
  28 +import java.util.Iterator;
  29 +import java.util.List;
  30 +import java.util.Map;
  31 +
  32 +@Service
  33 +public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implements SysUserService{
  34 +
  35 + @Autowired
  36 + SysUserRepository sysUserRepository;
  37 +
  38 + @Autowired
  39 + RoleService roleService;
  40 +
  41 + // 发送邮件
  42 + @Autowired
  43 + private MailUtils mailUtils;
  44 +
  45 + Logger logger = LoggerFactory.getLogger(this.getClass());
  46 +
  47 + @Override
  48 + public SysUser findByUserName(String name) {
  49 + return sysUserRepository.findByUserName(name);
  50 + }
  51 +
  52 + @Override
  53 + public Map<String, Object> save(SysUser t) {
  54 + //
  55 + if(t.getPassword() == null || t.getPassword().trim().equals("")){
  56 + SysUser user = sysUserRepository.findOne(t.getId());
  57 + t.setPassword(user.getPassword());
  58 + }else{
  59 + t.setPassword(new BCryptPasswordEncoder(4).encode(t.getPassword()));
  60 + }
  61 + return super.save(t);
  62 + }
  63 +
  64 + @Override
  65 + public int changeEnabled(int id, int enabled) {
  66 + sysUserRepository.changeEnabled(id,enabled);
  67 + return 0;
  68 + }
  69 +
  70 + @Override
  71 + public int changePWD(int id,String newPWD) {
  72 + return sysUserRepository.changePWD(id,new BCryptPasswordEncoder(4).encode(newPWD));
  73 + }
  74 +
  75 + @Override
  76 + public boolean validPWDExpired(String userName) {
  77 + SysUser sysUser = this.sysUserRepository.findByUserName(userName);
  78 + if (sysUser == null) {
  79 + throw new RuntimeException("用户[" + userName + "]不存在!");
  80 + }
  81 + if (sysUser.getPwdValidPeriod() == null || sysUser.getLastPwdDate() == null) {
  82 + // 如果没有设定密码过期时间,判定为不过期
  83 + return true;
  84 + }
  85 + DateTime now = new DateTime();
  86 + DateTime lastPwdDate = new DateTime(sysUser.getLastPwdDate());
  87 + Integer now_period_days = Days.daysBetween(lastPwdDate, now).getDays();
  88 + Integer expiredTipDays = 3; // 密码过期提前提示天数
  89 + if (now_period_days < (sysUser.getPwdValidPeriod() - expiredTipDays)) {
  90 + return true;
  91 + } else if (now_period_days >= (sysUser.getPwdValidPeriod() - expiredTipDays) &&
  92 + now_period_days < sysUser.getPwdValidPeriod()) {
  93 + // 快过期前提示
  94 + throw new RuntimeException("当前用户密码还有[" + (sysUser.getPwdValidPeriod() - now_period_days) + "]天过期!");
  95 + } else {
  96 + throw new RuntimeException("当前用户密码已过期!");
  97 + }
  98 +
  99 + }
  100 +
  101 + @Override
  102 + public Map<String, Object> register(SysUser u) {
  103 + Map<String, Object> rs = new HashMap();
  104 + boolean isLegality = false;
  105 + Iterator<Role> itRole = u.getRoles().iterator();
  106 + Role ro = new Role();
  107 + while(itRole.hasNext()){//判断是否有下一个
  108 + ro = itRole.next();
  109 + if(roleService.checkOperationLegality(ro.getId())){
  110 + isLegality = true;
  111 + } else {
  112 + rs.put("status", ResponseCode.ERROR);
  113 + rs.put("msg", "用户权限不够,请联系管理员!");
  114 + return rs;
  115 + }
  116 + }
  117 + if(isLegality){
  118 + try{
  119 + //解密RSA
  120 + try{
  121 + u.setUserName(RSAUtils.decryptBase64(u.getUserName()));
  122 + u.setPassword(RSAUtils.decryptBase64(u.getPassword()));
  123 + }catch (RuntimeException e) {
  124 + rs.put("msg", "网络延迟,解密失败,请重新添加!");
  125 + }
  126 + //检查用户名是否存在
  127 + if(findByUserName(u.getUserName()) != null){
  128 + rs.put("status", ResponseCode.ERROR);
  129 + rs.put("msg", "用户名" + u.getUserName() + "已存在!");
  130 + }
  131 + else{
  132 + u.setPassword(new BCryptPasswordEncoder(4).encode(u.getPassword()));
  133 + rs = super.save(u);
  134 + }
  135 + }catch (Exception e){
  136 + logger.error("", e);
  137 + rs.put("status", ResponseCode.ERROR);
  138 + rs.put("msg", e.getMessage());
  139 + }
  140 + }else {
  141 + rs.put("status", ResponseCode.ERROR);
  142 + rs.put("msg", "用户权限不够,请联系管理员!");
  143 + }
  144 + return rs;
  145 + }
  146 +
  147 + @Override
  148 + public List<SysUser> findAll_distinct() {
  149 + Map<String, Object> map = roleService.findSubordinate();
  150 + Object object = roleService.findSubordinate().get("list");
  151 + List<SysUser> rsList = new ArrayList<>();
  152 +
  153 + // 有权限查看的角色
  154 +// List<Role> roleList = JSONArray.parseArray(map.get("list").toString(), Role.class);
  155 +
  156 + try{
  157 + Gson gson = new Gson();
  158 + // 有权限查看的角色
  159 + List<Role> roleList = gson.fromJson(map.get("list").toString(), new TypeToken<List<Role>>(){}.getType());
  160 +
  161 + if(roleList.size() != 0 && !roleList.isEmpty()){
  162 + // 遍历有权限查看的角色
  163 + Map<Integer,Role> roleMap = new HashMap<>();
  164 + for (Role role: roleList) {
  165 + roleMap.put(role.getId(),role);
  166 + }
  167 +
  168 + List<SysUser> list = new ArrayList<>();
  169 + list = sysUserRepository.findAll_distinct();
  170 + for (SysUser sysUsers:list) {
  171 +
  172 + Iterator<Role> itUser = sysUsers.getRoles().iterator();
  173 + Role roleUser = new Role();
  174 + while(itUser.hasNext()){//判断是否有下一个
  175 + roleUser = itUser.next();
  176 + }
  177 + // 添加权限内的用户
  178 + if(roleMap.get(roleUser.getId()) != null){
  179 + rsList.add(sysUsers);
  180 + }
  181 + }
  182 + }
  183 + } catch (Exception e){
  184 + logger.error("error", e);
  185 + }
  186 + return rsList;
  187 + }
  188 +
  189 + @Override
  190 + @Transactional
  191 + public Map<String, Object> resetPassword(Integer id, Integer pwdValidPeriod){
  192 + Map<String, Object> rs = new HashMap();
  193 + try{
  194 + // 获取当前用户
  195 + SysUser user = SecurityUtils.getCurrentUser();
  196 + Iterator<Role> itRole = user.getRoles().iterator();
  197 + Role ro = new Role();
  198 + boolean Legality = false;
  199 + while(itRole.hasNext()){//判断是否有下一个
  200 + ro = itRole.next();
  201 + if(ro.getLevel() == 1)
  202 + Legality = true;
  203 + }
  204 + if(Legality){
  205 + String pwd = PwdGenerator.randomPassword(16);
  206 + user = sysUserRepository.findOne(id);
  207 + user.setPwdValidPeriod(pwdValidPeriod);
  208 + sysUserRepository.save(user);
  209 + sysUserRepository.changePWD(id, new BCryptPasswordEncoder(4).encode(pwd));
  210 + //发送邮件
  211 + EmailBean mail = new EmailBean();
  212 + mail.setSubject(IpUtils.getLocalIpAddress() +":密码重置");
  213 + mail.setContent(pwd);
  214 + mailUtils.sendMail(mail);
  215 + logger.info("setLD-sendMail:邮件发送成功!");
  216 + rs.put("status", ResponseCode.SUCCESS);
  217 + rs.put("msg", "密码重置成功!");
  218 + }else {
  219 + rs.put("status", ResponseCode.ERROR);
  220 + rs.put("msg", "您不是管理员无权限重置其他用户密码");
  221 + }
  222 + }catch (Exception e){
  223 + logger.error("", e);
  224 + rs.put("status", ResponseCode.ERROR);
  225 + rs.put("msg", e.getMessage());
  226 + }
  227 + return rs;
  228 + }
  229 +
  230 + @Override
  231 + @Transactional(rollbackFor = Exception.class)
  232 + public void recordLoginDate(String userName) {
  233 + sysUserRepository.recordLoginDate(userName);
  234 + }
  235 +
  236 + @Override
  237 + @Transactional(rollbackFor = Exception.class)
  238 + public void realName(String jobCode, String realName, int id) {
  239 + sysUserRepository.realName(jobCode, realName, id);
  240 + }
  241 +}
... ...
src/main/java/com/bsth/util/IpUtils.java
... ... @@ -12,17 +12,11 @@ public class IpUtils {
12 12 if (request == null) {
13 13 return "unknown";
14 14 }
15   - String ip = request.getHeader("x-forwarded-for");
16   - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
17   - ip = request.getHeader("Proxy-Client-IP");
18   - }
  15 + String ip = null;
19 16 if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
20 17 ip = request.getHeader("X-Forwarded-For");
21 18 }
22 19 if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
23   - ip = request.getHeader("WL-Proxy-Client-IP");
24   - }
25   - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
26 20 ip = request.getHeader("X-Real-IP");
27 21 }
28 22 if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
... ...
src/main/java/com/bsth/util/MailUtils.java 0 → 100644
  1 +package com.bsth.util;
  2 +
  3 +import com.bsth.data.SystemParamCache;
  4 +import com.bsth.email.SimpleMailSender;
  5 +import com.bsth.email.entity.EmailBean;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * @author Hill
  12 + */
  13 +@Component
  14 +public class MailUtils {
  15 +
  16 + private Tools tools = new Tools("mailbox.properties");
  17 +
  18 + private SimpleMailSender sms = new SimpleMailSender(tools.getValue("username"),tools.getValue("password"));
  19 +
  20 + /**
  21 + * recipients
  22 + * 收件人集合
  23 + * mail
  24 + * 邮件
  25 + */
  26 + public int sendMail(List<String> recipients, EmailBean mail){
  27 + try {
  28 + for (String recipient : recipients) {
  29 + sms.send(recipient, mail.getSubject(),mail.getContent());
  30 + }
  31 + } catch (Exception e) {
  32 + e.printStackTrace();
  33 + return -1;
  34 + }
  35 + return 1;
  36 + }
  37 +
  38 + /**
  39 + * recipient
  40 + * 收件人
  41 + * mail
  42 + * 邮件
  43 + */
  44 + public int sendMail(String recipient, EmailBean mail){
  45 + try {
  46 + sms.send(recipient, mail.getSubject(), mail.getContent());
  47 + } catch (Exception e) {
  48 + e.printStackTrace();
  49 + return -1;
  50 + }
  51 + return 1;
  52 + }
  53 +
  54 + public int sendMail(EmailBean mail){
  55 + return sendMail(SystemParamCache.getMailAdmin(), mail);
  56 + }
  57 +}
0 58 \ No newline at end of file
... ...
src/main/resources/static/index.html
1   -<!DOCTYPE html>
2   -<html lang="zh">
3   -<head>
4   - <meta name="renderer" content="webkit" />
5   - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
6   - <meta charset="UTF-8">
7   - <title>调度系统</title>
8   -
9   - <meta http-equiv="Pragma" content="no-cache">
10   - <meta http-equiv="Cache-control" content="no-cache">
11   - <meta http-equiv="Cache" content="no-cache">
12   -
13   - <!-- Font Awesome 图标字体 -->
14   - <link
15   - href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css"
16   - rel="stylesheet" type="text/css" />
17   - <!-- Bootstrap style -->
18   - <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css"
19   - rel="stylesheet" type="text/css" />
20   - <!-- jsTree 数插件 -->
21   - <link
22   - href="/metronic_v4.5.4/plugins/jstree/dist/themes/default/style.min.css"
23   - rel="stylesheet" type="text/css" />
24   - <!-- MULTI-select 多选下拉框美化 -->
25   - <link
26   - href="/metronic_v4.5.4/plugins/jquery-multi-select/css/multi-select.css"
27   - rel="stylesheet" type="text/css" />
28   -
29   - <!-- editable -->
30   - <link
31   - href="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/css/bootstrap-editable.css"
32   - rel="stylesheet" type="text/css" />
33   - <!-- METRONIC style -->
34   - <link href="/metronic_v4.5.4/layout4/css/themes/light.min.css"
35   - rel="stylesheet" type="text/css" id="style_color" />
36   - <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet"
37   - type="text/css" />
38   - <link href="/metronic_v4.5.4/css/plugins.css" rel="stylesheet"
39   - type="text/css" />
40   - <link href="/metronic_v4.5.4/layout4/css/layout.min.css"
41   - rel="stylesheet" type="text/css" />
42   - <link href="/metronic_v4.5.4/layout4/css/custom.min.css"
43   - rel="stylesheet" type="text/css" />
44   - <!-- select2 下拉框插件 -->
45   - <link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css"
46   - rel="stylesheet" type="text/css" />
47   - <link
48   - href="/metronic_v4.5.4/plugins/select2/css/select2-bootstrap.min.css"
49   - rel="stylesheet" type="text/css" />
50   - <!-- layer 弹层 插件 -->
51   - <link href="/assets/plugins/layer-v2.4/layer/skin/layer.css"
52   - rel="stylesheet" type="text/css" />
53   - <!-- fileinput 上传 插件 -->
54   - <link href="/assets/plugins/fileinput/css/fileinput.min.css"
55   - rel="stylesheet" type="text/css" />
56   - <!-- iCheck 单选框和复选框 -->
57   - <link href="/metronic_v4.5.4/plugins/icheck/skins/all.css"
58   - rel="stylesheet" type="text/css" />
59   - <!-- 日期控件 -->
60   - <link
61   - href="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/css/bootstrap-datetimepicker.min.css"
62   - rel="stylesheet" type="text/css" />
63   - <!-- table 表格控件 -->
64   - <!--<link rel="stylesheet"-->
65   - <!--href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css"-->
66   - <!--type="text/css" />-->
67   - <link href="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet" type="text/css"/>
68   - <!-- handsontable样式 -->
69   - <link rel="stylesheet"
70   - href="/assets/bower_components/handsontable/dist/handsontable.full.css" />
71   - <!-- sweetalert样式 -->
72   - <link rel="stylesheet"
73   - href="/assets/bower_components/sweetalert/dist/sweetalert.css" />
74   - <!-- schedule计划调度AngularJS模块主css -->
75   - <link rel="stylesheet" href="/pages/scheduleApp/module/common/main.css"
76   - type="text/css" />
77   - <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" merge="plugins"/>
78   -
79   - <!-- CSS动画 -->
80   - <link
81   - href="/metronic_v4.5.4/plugins/tipso/css/animate.css"
82   - rel="stylesheet" type="text/css" />
83   -
84   - <!-- 提示工具样式 -->
85   - <link
86   - href="/metronic_v4.5.4/plugins/tipso/css/tipso.css"
87   - rel="stylesheet" type="text/css" />
88   -
89   - <style type="text/css">
90   - .searchForm {
91   -
92   - }
93   -
94   - .searchForm .form-group .control-label {
95   - padding-right: 0px;
96   - text-align: right;
97   - margin-top: 7px;
98   - }
99   -
100   - .searchForm .form-group>div {
101   - padding-left: 10px;
102   - padding-right: 0px;
103   - }
104   -
105   - .searchForm .row>div {
106   - padding-left: 0px;
107   - padding-right: 0px;
108   - padding: 5px 0 5px 0;
109   - width: 270px;
110   - display: inline-block;
111   - }
112   -
113   - .searchForm .form-actions {
114   -
115   - }
116   -
117   - tr.row-active td {
118   - border-bottom: 1px solid blue !important;
119   - color: blue;
120   - }
121   -
122   - .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection
123   - {
124   - font-size: 14px;
125   - }
126   -
127   - .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection
128   - {
129   - padding: 6px 26px;
130   - }
131   -
132   - .ms-container .ms-list {
133   - height: 306px;
134   - }
135   -
136   - .ms-container .ms-selectable,.ms-container .ms-selection {
137   - width: 47%;
138   - }
139   -
140   - .ms-container {
141   - width: 470px;
142   - margin: auto;
143   - }
144   -
145   - .multi-custom-header-left {
146   - text-align: center;
147   - padding: 7px;
148   - color: #3B3F51;
149   - }
150   -
151   - .multi-custom-header-right {
152   - text-align: center;
153   - padding: 7px;
154   - font-weight: bold;
155   - color: #36C6D3;
156   - }
157   -
158   - .mt-element-list .list-simple.mt-list-container ul>.mt-list-item>.list-item-content
159   - {
160   - padding: 0 55px 0 0px;
161   - }
162   -
163   - .mt-element-list .list-simple.mt-list-container ul>.mt-list-item {
164   - padding: 3.3px 0;
165   - }
166   -
167   - #route-container {
168   - display: none;
169   - }
170   -
171   - .page-content.active {
172   - display: block !important;
173   - }
174   -
175   - .page-header.navbar .page-logo .logo-default {
176   - margin: 0;
177   - }
178   -
179   - .page-header.navbar .top-menu .navbar-nav>li.dropdown.open .dropdown-toggle
180   - {
181   - background-color: #284a99;
182   - }
183   -
184   - .page-header.navbar .page-logo {
185   - padding-right: 10px;
186   - }
187   -
188   - .page-logo .logo-default.logo-default-text {
189   - font-weight: 600;
190   - color: white !important;
191   - margin-top: 19px !important;
192   - font-size: 24px;
193   - text-decoration: none;
194   - }
195   -
196   - .page-logo .logo-default.logo-default-text:HOVER {
197   - color: #dedede !important;
198   - }
199   -
200   - body,.page-content-wrapper,#pjax-container{
201   - height: 100%;
202   - }
203   - html{
204   - height: 90%;
205   - }
206   - .page-container{
207   - height: 100%;
208   - }
209   - </style>
210   -
211   - <!-- ocLazyLoading载入文件的位置 -->
212   - <link id="ng_load_plugins_before" />
213   -
214   -</head>
215   -<body
216   - class="page-container-bg-solid page-header-fixed page-sidebar-closed-hide-logo page-sidebar-fixed">
217   -<div class="page-header navbar navbar-fixed-top"
218   - style="background: linear-gradient(to bottom, #124e78, #125688);">
219   - <div class="page-header-inner ">
220   - <!-- LOGO -->
221   - <div class="page-logo">
222   - <a href="index.html" class="logo-default logo-default-text">
223   - 青浦公交调度系统 </a>
224   - <div class="menu-toggler sidebar-toggler"></div>
225   - </div>
226   - <!-- END LOGO -->
227   - <a href="javascript:;" class="menu-toggler responsive-toggler"
228   - data-toggle="collapse" data-target=".navbar-collapse"> </a>
229   - <div class="page-top">
230   - <div class="top-menu">
231   - <ul class="nav navbar-nav pull-right">
232   - <!-- 信息通知区 -->
233   - <li
234   - class="dropdown dropdown-extended dropdown-notification dropdown-dark"
235   - id="header_notification_bar"><a href="javascript:;"
236   - class="dropdown-toggle" data-toggle="dropdown"
237   - data-hover="dropdown" data-close-others="true"> <i
238   - class="fa fa-bell"></i> <span class="badge badge-success">
239   - 0 </span>
240   - </a>
241   - <ul class="dropdown-menu" style="max-width: 345px; width: 345px;">
242   - <li class="external">
243   - <h3>
244   - 今日 <span class="bold">0 条</span> 通知
245   - </h3> <a href="javascript:;">查看全部</a>
246   - </li>
247   - <li>
248   - <ul class="dropdown-menu-list scroller" style="height: 250px;"
249   - data-handle-color="#637283">
250   - </ul>
251   - </li>
252   - </ul></li>
253   - <li class="dropdown dropdown-user dropdown-dark"><a
254   - href="javascript:;" class="dropdown-toggle"
255   - data-toggle="dropdown" data-hover="dropdown"
256   - data-close-others="true"> <span id="indexTopUName"
257   - class="username username-hide-on-mobile"
258   - style="vertical-align: middle;"> <i class="fa fa-user"></i></span>
259   - </a>
260   - <ul class="dropdown-menu dropdown-menu-default">
261   - <li><a href="javascript:;"> <i class="fa fa-user"></i>
262   - 我的信息
263   - </a></li>
264   - <li><a href="javascript:;" id="changePWD"> <i
265   - class="fa fa-unlock-alt"></i> 修改密码
266   - </a></li>
267   - <li class="divider"></li>
268   - <li><a href="javascript:;"> <i class="fa fa-lock"></i>
269   - 锁屏
270   - </a></li>
271   - <li><a href="/logout"> <i class="fa fa-key"></i> 注销登陆
272   - </a></li>
273   - </ul></li>
274   - </ul>
275   - </div>
276   - </div>
277   - </div>
278   -</div>
279   -<div class="page-container">
280   - <div class="page-sidebar-wrapper">
281   - <div class="page-sidebar navbar-collapse collapse">
282   - <ul class="page-sidebar-menu page-sidebar-menu-fixed"
283   - data-keep-expanded="false" data-auto-scroll="true"
284   - data-slide-speed="200" id="leftMenuSidebar">
285   - </ul>
286   - </div>
287   - </div>
288   - <div class="page-content-wrapper">
289   - <div id="pjax-container" class="page-content"></div>
290   - <a name="xd_position"></a>
291   - <div id="route-container">
292   - <div ng-app="ScheduleApp">
293   - <div ng-controller="ScheduleAppController">
294   -
295   - <!-- loading widget -->
296   - <div id="loadingWidget" class="flyover mask" loading-widget>
297   - <div class="alert alert-info">
298   - <strong>载入中......</strong>
299   - </div>
300   - </div>
301   -
302   - <div ui-view class="uv"></div>
303   - </div>
304   - </div>
305   - </div>
306   - </div>
307   -</div>
308   -
309   -<script id="menu_list_temp" type="text/html">
310   - {{each list as group i}}
311   - <li class="heading">
312   - <h3 class="uppercase">{{group.name}}</h3>
313   - </li>
314   - {{each group.children as dir j}}
315   - <li class="nav-item">
316   - <a href="javascript:;" class="nav-link nav-toggle ">
317   - <i class="{{dir.icon}}"></i>
318   - <span class="title">{{dir.name}}</span>
319   - <span class="arrow"></span>
320   - </a>
321   - <ul class="sub-menu">
322   - {{each dir.children as module s}}
323   - <li class="nav-item ">
324   - {{if module.container=="pjax-container"}}
325   - <a href="/pages/{{module.path}}" class="nav-link " data-pjax>
326   - <span class="title">{{module.name}}</span>
327   - </a>
328   - {{else}}
329   - <a href="{{module.path}}" class="nav-link " data-angularjs>
330   - <span class="title">{{module.name}}</span>
331   - </a>
332   - {{/if}}
333   - </li>
334   - {{/each}}
335   - </ul>
336   - </li>
337   - {{/each}}
338   - {{/each}}
339   -
340   -</script>
341   -<script>
342   - delete window.require;
343   - delete window.exports;
344   - delete window.module;
345   -</script>
346   -<!-- jQuery -->
347   -<script src="/metronic_v4.5.4/plugins/jquery.min.js" data-exclude=1></script>
348   -<!-- bootstrap -->
349   -<script src="/metronic_v4.5.4/plugins/bootstrap/js/bootstrap.min.js"
350   - data-exclude=1></script>
351   -<script src="/pages/forms/statement/js/jquery.autocompleter.js"></script>
352   -<script src="/pages/forms/statement/js/jquery.PrintArea.js"></script>
353   -<!-- MTRONIC JS -->
354   -<script src="/metronic_v4.5.4/scripts/app.min.js" data-exclude=1></script>
355   -<script src="/metronic_v4.5.4/layout4/scripts/layout.min.js"
356   - data-exclude=1></script>
357   -<!-- 虚拟滚动条 -->
358   -<script
359   - src="/metronic_v4.5.4/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script>
360   -<!-- jsTree 树插件 -->
361   -<script src="/metronic_v4.5.4/plugins/jstree/dist/jstree.min.js"></script>
362   -<!-- bootstrap-hover-dropDown -->
363   -<script
364   - src="/metronic_v4.5.4/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"></script>
365   -<!-- jquery.validate 表单验证 -->
366   -<script
367   - src="/metronic_v4.5.4/plugins/jquery-validation/js/jquery.validate.min.js"></script>
368   -<script
369   - src="/metronic_v4.5.4/plugins/jquery-validation/js/localization/messages_zh.js"></script>
370   -<!-- 向导式插件 -->
371   -<script
372   - src="/metronic_v4.5.4//plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
373   -<!-- iCheck 单选框和复选框 -->
374   -<script src="/metronic_v4.5.4/plugins/icheck/icheck.min.js"></script>
375   -<!-- select2 下拉框 -->
376   -<script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script>
377   -<!-- MULTI SELECT 多选下拉框 -->
378   -<script
379   - src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js"></script>
380   -<!-- editable.js -->
381   -<script
382   - src="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/js/bootstrap-editable.min.js"></script>
383   -<!-- PJAX -->
384   -<script src="/assets/plugins/jquery.pjax.js"></script>
385   -<!-- layer 弹层 -->
386   -<script src="/assets/plugins/layer-v2.4/layer/layer.js" data-exclude=1></script>
387   -<!-- fileinput 上传 -->
388   -<script src="/assets/plugins/fileinput/canvas-to-blob.min.js"></script>
389   -<script src="/assets/plugins/fileinput/purify.min.js"></script>
390   -<script src="/assets/plugins/fileinput/sortable.min.js"></script>
391   -<script src="/assets/plugins/fileinput/fileinput.min.js"></script>
392   -<script src="/assets/plugins/fileinput/fileinput_locale_zh.js"></script>
393   -<!-- jquery.purl URL解析 -->
394   -<script src="/assets/plugins/purl.js"></script>
395   -<!-- jquery.serializejson JSON序列化插件 -->
396   -<script src="/assets/plugins/jquery.serializejson.js"></script>
397   -<!-- art-template 模版引擎 -->
398   -<script src="/assets/plugins/template.js"></script>
399   -<!-- jquery.pageinator 分页 -->
400   -<script src="/assets/plugins/jqPaginator.min.js"></script>
401   -<!-- moment.js 日期处理类库 -->
402   -<script src="/assets/plugins/moment-with-locales.js"></script>
403   -
404   -<script src="/assets/plugins/pinyin.js"></script>
405   -<!-- 日期控件 -->
406   -<script
407   - src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js"></script>
408   -<!-- 表格控件 -->
409   -<script src="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script>
410   -<!-- 统计图控件 -->
411   -<!--<script src="/assets/global/getEchart.js"></script>
412   -<script src="/assets/global/echarts.js"></script> -->
413   -<script src="/assets/js/common.js"></script>
414   -<script src="/assets/js/dictionary.js"></script>
415   -<!-- tipso JS -->
416   -<script src="/metronic_v4.5.4/plugins/tipso/js/tipso.js"></script>
417   -<script data-exclude=1>
418   - //初始打开的片段地址
419   - var initFragment = "^_^initFragment^_^";
420   - //静态文件目录
421   - var dir = '/pages/';
422   - //片段容器
423   - var pjaxContainer = '#pjax-container'
424   - , angJsContainer = '#route-container';
425   -
426   - $(document).ajaxError(function (event, jqxhr, settings, thrownError) {
427   - if(jqxhr.status == 403){
428   - layer.closeAll();
429   - layer.alert(jqxhr.message?jqxhr.message:'访问被拒绝', {icon: 2, title: '操作失败'});
430   - }
431   - });
432   -
433   - $(function () {
434   - $.get('/user/currentUser', function (user) {
435   - $('#indexTopUName').text(user.userName);
436   - });
437   -
438   - //带 data-pjax 的链接由pjax加载
439   - $(document).pjax('a[data-pjax]', pjaxContainer);
440   -
441   - //pjax左菜单点击事件
442   - $(document).on('click', '#leftMenuSidebar a[data-pjax]', function () {
443   - setTitle(this);
444   -
445   - $('#leftMenuSidebar li.nav-item.active').removeClass('active');
446   - $(this).parent().addClass('active');
447   - showPjax();
448   - });
449   -
450   - //angularjs左菜单点击事件
451   - $(document).on('click', '#leftMenuSidebar a[data-angularjs]', function () {
452   - setTitle(this);
453   -
454   - $('#leftMenuSidebar li.nav-item.active').removeClass('active');
455   - $(this).parent().addClass('active');
456   - showAngJs();
457   - });
458   -
459   - //加载左菜单栏
460   - $get('/module/findByCurrentUser', null,
461   - function (ms) {
462   - var treeArray = createTreeData(ms);
463   - treeArray.sort(function (a, b) {
464   - return a.createDate - b.createDate;
465   - });
466   - var menuHtml = template('menu_list_temp', {list: treeArray});
467   - $('#leftMenuSidebar').html(menuHtml);
468   -
469   - //----------- 检查URL ----------------
470   - var h = location.hash;
471   - if (initFragment && initFragment != '') {
472   - showPjax();
473   - //普通片段
474   - loadPage(initFragment);
475   - //选中菜单
476   - $.each($('#leftMenuSidebar a'), function (i, item) {
477   - if (urlPattern($(item).attr('href'), initFragment)) {
478   - activeLeftMenu(item);
479   - }
480   - });
481   - } else if (h) {
482   - //angularjs片段
483   - showAngJs();
484   - //选中菜单
485   - $.each($('#leftMenuSidebar a'), function (i, item) {
486   - if ($(item).attr('href') == h) {
487   - activeLeftMenu(item);
488   - }
489   - });
490   - }
491   - else {
492   - //加载主页
493   - loadPage('/pages/home.html');
494   - }
495   - });
496   -
497   - //修改密码
498   - $('#changePWD').on('click', function () {
499   - $.get('/pages/permission/user/changePWD.html', function (content) {
500   - layer.open({
501   - type: 1,
502   - area: ['600px', '360px'],
503   - content: content,
504   - title: '修改密码',
505   - shift: 5,
506   - scrollbar: false,
507   - success: function () {
508   - }
509   - });
510   - });
511   - });
512   - });
513   -
514   - //modal关闭时销毁dom
515   - $(document).on('hidden.bs.modal', '.modal', function () {
516   - $(this).remove();
517   - });
518   -
519   - //pjax加载完成事件
520   - $(document).on('pjax:success', function () {
521   - var dicts = $(pjaxContainer).find('.nt-dictionary');
522   - dictionaryUtils.transformDom(dicts);
523   - });
524   -
525   - function loadPage(url) {
526   - $.pjax({url: url, container: pjaxContainer})
527   - }
528   -
529   - function urlPattern(a, b) {
530   - var r;
531   - try {
532   - r = a.substring(0, a.lastIndexOf('/')) == b.substring(0, b.lastIndexOf('/'));
533   - } catch (e) {
534   - r = false;
535   - }
536   - return r;
537   - }
538   -
539   - function showPjax() {
540   - $(angJsContainer).removeClass('page-content active').hide();
541   - $(pjaxContainer).addClass('page-content active');
542   - }
543   -
544   - function showAngJs() {
545   - $(pjaxContainer).html('').removeClass('page-content active').hide();
546   - $(angJsContainer).addClass('page-content active');
547   - }
548   -
549   - function activeLeftMenu(item) {
550   - $(item).parent('.nav-item').addClass('active').parent('.sub-menu').show().parent().addClass('open');
551   - setTitle(item);
552   - }
553   -
554   - function setTitle(menuItem){
555   - document.title = $('span.title', menuItem).text();
556   - }
557   -
558   -</script>
559   -<!-- d3 -->
560   -<script src="/assets/js/d3.min.js" data-exclude=1></script>
561   -<!-- webSocket JS -->
562   -<script src="/assets/js/sockjs.min.js"></script>
563   -
564   -<!-- TODO:angularJS相关库 -->
565   -
566   -<!-- angularJS相关库 -->
567   -<!-- 这个是基于angularjs 1.4.10修改的版本,主要是修改了history控制部分,用于兼容route和pjax的同时操作history的冲突 -->
568   -<script src="/assets/js/angular.js" data-autocephaly=1></script>
569   -<script src="/assets/bower_components/angular-i18n/angular-locale_zh-cn.js" data-autocephaly=1></script>
570   -<script
571   - src="/assets/bower_components/angular-resource/angular-resource.min.js"
572   - data-exclude=1></script>
573   -<script
574   - src="/assets/bower_components/angular-sanitize/angular-sanitize.min.js"
575   - data-exclude=1></script>
576   -<script
577   - src="/assets/bower_components/angular-animate/angular-animate.min.js"
578   - data-exclude=1></script>
579   -<script
580   - src="/assets/bower_components/angular-touch/angular-touch.min.js"
581   - data-exclude=1></script>
582   -<script
583   - src="/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js"
584   - data-exclude=1></script>
585   -<script
586   - src="/assets/bower_components/oclazyload/dist/ocLazyLoad.min.js"
587   - data-exclude=1></script>
588   -<script
589   - src="/assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"
590   - data-exclude=1></script>
591   -<!-- handsontable相关js -->
592   -<script
593   - src="/assets/bower_components/handsontable/dist/handsontable.full.js"></script>
594   -<script
595   - src="/assets/bower_components/ngHandsontable/dist/ngHandsontable.js"></script>
596   -<!-- sweetalert相关js -->
597   -<script src="/assets/bower_components/sweetalert/dist/sweetalert.min.js"></script>
598   -<script src="/assets/bower_components/ng-sweet-alert/ng-sweet-alert.js"></script>
599   -
600   -<!-- schedule计划调度AngularJS模块主JS -->
601   -<script src="/pages/scheduleApp/module/common/main.js" data-exclude=1></script>
602   -<script
603   - src="/pages/scheduleApp/module/common/prj-common-globalservice.js"
604   - data-exclude=1></script>
605   -<script src="/pages/scheduleApp/module/common/prj-common-filter.js"
606   - data-exclude=1></script>
607   -<script src="/pages/scheduleApp/module/common/prj-common-directive.js"
608   - data-exclude=1></script>
609   -<script
610   - src="/pages/scheduleApp/module/common/prj-common-ui-route-state.js"
611   - data-exclude=1></script>
612   -
613   -<!-- 地图相关 -->
614   -<!-- 百度 -->
615   -<script
616   - src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"
617   - data-exclude=1></script>
618   -<script
619   - src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"
620   - data-exclude=1></script>
621   -<script type="text/javascript"
622   - src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"
623   - data-exclude=1></script>
624   -<script type="text/javascript"
625   - src="http://api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js "
626   - data-exclude=1></script>
627   -<script src="/assets/js/baidu/TextIconOverlay.js" data-exclude=1></script>
628   -<script src="/assets/js/baidu//MarkerClusterer.js" data-exclude=1></script>
629   -<!-- 高德 -->
630   -<script
631   - src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"
632   - data-exclude=1></script>
633   -<!-- echarts4 误删 -->
634   -<script src="/metronic_v4.5.4/plugins/echarts4/echarts.min.js"></script>
635   -<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script>
636   -
637   -</body>
  1 +<!DOCTYPE html>
  2 +<html lang="zh">
  3 +<head>
  4 + <meta name="renderer" content="webkit" />
  5 + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  6 + <meta charset="UTF-8">
  7 + <title>调度系统</title>
  8 +
  9 + <meta http-equiv="Pragma" content="no-cache">
  10 + <meta http-equiv="Cache-control" content="no-cache">
  11 + <meta http-equiv="Cache" content="no-cache">
  12 +
  13 + <!-- Font Awesome 图标字体 -->
  14 + <link
  15 + href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css"
  16 + rel="stylesheet" type="text/css" />
  17 + <!-- Bootstrap style -->
  18 + <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css"
  19 + rel="stylesheet" type="text/css" />
  20 + <!-- jsTree 数插件 -->
  21 + <link
  22 + href="/metronic_v4.5.4/plugins/jstree/dist/themes/default/style.min.css"
  23 + rel="stylesheet" type="text/css" />
  24 + <!-- MULTI-select 多选下拉框美化 -->
  25 + <link
  26 + href="/metronic_v4.5.4/plugins/jquery-multi-select/css/multi-select.css"
  27 + rel="stylesheet" type="text/css" />
  28 +
  29 + <!-- editable -->
  30 + <link
  31 + href="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/css/bootstrap-editable.css"
  32 + rel="stylesheet" type="text/css" />
  33 + <!-- METRONIC style -->
  34 + <link href="/metronic_v4.5.4/layout4/css/themes/light.min.css"
  35 + rel="stylesheet" type="text/css" id="style_color" />
  36 + <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet"
  37 + type="text/css" />
  38 + <link href="/metronic_v4.5.4/css/plugins.css" rel="stylesheet"
  39 + type="text/css" />
  40 + <link href="/metronic_v4.5.4/layout4/css/layout.min.css"
  41 + rel="stylesheet" type="text/css" />
  42 + <link href="/metronic_v4.5.4/layout4/css/custom.min.css"
  43 + rel="stylesheet" type="text/css" />
  44 + <!-- select2 下拉框插件 -->
  45 + <link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css"
  46 + rel="stylesheet" type="text/css" />
  47 + <link
  48 + href="/metronic_v4.5.4/plugins/select2/css/select2-bootstrap.min.css"
  49 + rel="stylesheet" type="text/css" />
  50 + <!-- layer 弹层 插件 -->
  51 + <link href="/assets/plugins/layer-v2.4/layer/skin/layer.css"
  52 + rel="stylesheet" type="text/css" />
  53 + <!-- fileinput 上传 插件 -->
  54 + <link href="/assets/plugins/fileinput/css/fileinput.min.css"
  55 + rel="stylesheet" type="text/css" />
  56 + <!-- iCheck 单选框和复选框 -->
  57 + <link href="/metronic_v4.5.4/plugins/icheck/skins/all.css"
  58 + rel="stylesheet" type="text/css" />
  59 + <!-- 日期控件 -->
  60 + <link
  61 + href="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/css/bootstrap-datetimepicker.min.css"
  62 + rel="stylesheet" type="text/css" />
  63 + <!-- table 表格控件 -->
  64 + <!--<link rel="stylesheet"-->
  65 + <!--href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css"-->
  66 + <!--type="text/css" />-->
  67 + <link href="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet" type="text/css"/>
  68 + <!-- handsontable样式 -->
  69 + <link rel="stylesheet"
  70 + href="/assets/bower_components/handsontable/dist/handsontable.full.css" />
  71 + <!-- sweetalert样式 -->
  72 + <link rel="stylesheet"
  73 + href="/assets/bower_components/sweetalert/dist/sweetalert.css" />
  74 + <!-- schedule计划调度AngularJS模块主css -->
  75 + <link rel="stylesheet" href="/pages/scheduleApp/module/common/main.css"
  76 + type="text/css" />
  77 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" merge="plugins"/>
  78 +
  79 + <!-- CSS动画 -->
  80 + <link
  81 + href="/metronic_v4.5.4/plugins/tipso/css/animate.css"
  82 + rel="stylesheet" type="text/css" />
  83 +
  84 + <!-- 提示工具样式 -->
  85 + <link
  86 + href="/metronic_v4.5.4/plugins/tipso/css/tipso.css"
  87 + rel="stylesheet" type="text/css" />
  88 +
  89 + <style type="text/css">
  90 + .searchForm {
  91 +
  92 + }
  93 +
  94 + .searchForm .form-group .control-label {
  95 + padding-right: 0px;
  96 + text-align: right;
  97 + margin-top: 7px;
  98 + }
  99 +
  100 + .searchForm .form-group>div {
  101 + padding-left: 10px;
  102 + padding-right: 0px;
  103 + }
  104 +
  105 + .searchForm .row>div {
  106 + padding-left: 0px;
  107 + padding-right: 0px;
  108 + padding: 5px 0 5px 0;
  109 + width: 270px;
  110 + display: inline-block;
  111 + }
  112 +
  113 + .searchForm .form-actions {
  114 +
  115 + }
  116 +
  117 + tr.row-active td {
  118 + border-bottom: 1px solid blue !important;
  119 + color: blue;
  120 + }
  121 +
  122 + .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection
  123 + {
  124 + font-size: 14px;
  125 + }
  126 +
  127 + .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection
  128 + {
  129 + padding: 6px 26px;
  130 + }
  131 +
  132 + .ms-container .ms-list {
  133 + height: 306px;
  134 + }
  135 +
  136 + .ms-container .ms-selectable,.ms-container .ms-selection {
  137 + width: 47%;
  138 + }
  139 +
  140 + .ms-container {
  141 + width: 470px;
  142 + margin: auto;
  143 + }
  144 +
  145 + .multi-custom-header-left {
  146 + text-align: center;
  147 + padding: 7px;
  148 + color: #3B3F51;
  149 + }
  150 +
  151 + .multi-custom-header-right {
  152 + text-align: center;
  153 + padding: 7px;
  154 + font-weight: bold;
  155 + color: #36C6D3;
  156 + }
  157 +
  158 + .mt-element-list .list-simple.mt-list-container ul>.mt-list-item>.list-item-content
  159 + {
  160 + padding: 0 55px 0 0px;
  161 + }
  162 +
  163 + .mt-element-list .list-simple.mt-list-container ul>.mt-list-item {
  164 + padding: 3.3px 0;
  165 + }
  166 +
  167 + #route-container {
  168 + display: none;
  169 + }
  170 +
  171 + .page-content.active {
  172 + display: block !important;
  173 + }
  174 +
  175 + .page-header.navbar .page-logo .logo-default {
  176 + margin: 0;
  177 + }
  178 +
  179 + .page-header.navbar .top-menu .navbar-nav>li.dropdown.open .dropdown-toggle
  180 + {
  181 + background-color: #284a99;
  182 + }
  183 +
  184 + .page-header.navbar .page-logo {
  185 + padding-right: 10px;
  186 + }
  187 +
  188 + .page-logo .logo-default.logo-default-text {
  189 + font-weight: 600;
  190 + color: white !important;
  191 + margin-top: 19px !important;
  192 + font-size: 24px;
  193 + text-decoration: none;
  194 + }
  195 +
  196 + .page-logo .logo-default.logo-default-text:HOVER {
  197 + color: #dedede !important;
  198 + }
  199 +
  200 + body,.page-content-wrapper,#pjax-container{
  201 + height: 100%;
  202 + }
  203 + html{
  204 + height: 90%;
  205 + }
  206 + .page-container{
  207 + height: 100%;
  208 + }
  209 + </style>
  210 +
  211 + <!-- ocLazyLoading载入文件的位置 -->
  212 + <link id="ng_load_plugins_before" />
  213 +
  214 +</head>
  215 +<body
  216 + class="page-container-bg-solid page-header-fixed page-sidebar-closed-hide-logo page-sidebar-fixed">
  217 +<div class="page-header navbar navbar-fixed-top"
  218 + style="background: linear-gradient(to bottom, #124e78, #125688);">
  219 + <div class="page-header-inner ">
  220 + <!-- LOGO -->
  221 + <div class="page-logo">
  222 + <a href="index.html" class="logo-default logo-default-text">
  223 + 青浦公交调度系统 </a>
  224 + <div class="menu-toggler sidebar-toggler"></div>
  225 + </div>
  226 + <!-- END LOGO -->
  227 + <a href="javascript:;" class="menu-toggler responsive-toggler"
  228 + data-toggle="collapse" data-target=".navbar-collapse"> </a>
  229 + <div class="page-top">
  230 + <div class="top-menu">
  231 + <ul class="nav navbar-nav pull-right">
  232 + <!-- 信息通知区 -->
  233 + <li
  234 + class="dropdown dropdown-extended dropdown-notification dropdown-dark"
  235 + id="header_notification_bar"><a href="javascript:;"
  236 + class="dropdown-toggle" data-toggle="dropdown"
  237 + data-hover="dropdown" data-close-others="true"> <i
  238 + class="fa fa-bell"></i> <span class="badge badge-success">
  239 + 0 </span>
  240 + </a>
  241 + <ul class="dropdown-menu" style="max-width: 345px; width: 345px;">
  242 + <li class="external">
  243 + <h3>
  244 + 今日 <span class="bold">0 条</span> 通知
  245 + </h3> <a href="javascript:;">查看全部</a>
  246 + </li>
  247 + <li>
  248 + <ul class="dropdown-menu-list scroller" style="height: 250px;"
  249 + data-handle-color="#637283">
  250 + </ul>
  251 + </li>
  252 + </ul></li>
  253 + <li class="dropdown dropdown-user dropdown-dark"><a
  254 + href="javascript:;" class="dropdown-toggle"
  255 + data-toggle="dropdown" data-hover="dropdown"
  256 + data-close-others="true"> <span id="indexTopUName"
  257 + class="username username-hide-on-mobile"
  258 + style="vertical-align: middle;"> <i class="fa fa-user"></i></span>
  259 + </a>
  260 + <ul class="dropdown-menu dropdown-menu-default">
  261 + <li><a href="javascript:;"> <i class="fa fa-user"></i>
  262 + 我的信息
  263 + </a></li>
  264 + <li><a href="javascript:;" id="changePWD"> <i
  265 + class="fa fa-unlock-alt"></i> 修改密码
  266 + </a></li>
  267 + <li class="divider"></li>
  268 + <li><a href="javascript:;"> <i class="fa fa-lock"></i>
  269 + 锁屏
  270 + </a></li>
  271 + <li><a href="/logout"> <i class="fa fa-key"></i> 注销登陆
  272 + </a></li>
  273 + </ul></li>
  274 + </ul>
  275 + </div>
  276 + </div>
  277 + </div>
  278 +</div>
  279 +<div class="page-container">
  280 + <div class="page-sidebar-wrapper">
  281 + <div class="page-sidebar navbar-collapse collapse">
  282 + <ul class="page-sidebar-menu page-sidebar-menu-fixed"
  283 + data-keep-expanded="false" data-auto-scroll="true"
  284 + data-slide-speed="200" id="leftMenuSidebar">
  285 + </ul>
  286 + </div>
  287 + </div>
  288 + <div class="page-content-wrapper">
  289 + <div id="pjax-container" class="page-content"></div>
  290 + <a name="xd_position"></a>
  291 + <div id="route-container">
  292 + <div ng-app="ScheduleApp">
  293 + <div ng-controller="ScheduleAppController">
  294 +
  295 + <!-- loading widget -->
  296 + <div id="loadingWidget" class="flyover mask" loading-widget>
  297 + <div class="alert alert-info">
  298 + <strong>载入中......</strong>
  299 + </div>
  300 + </div>
  301 +
  302 + <div ui-view class="uv"></div>
  303 + </div>
  304 + </div>
  305 + </div>
  306 + </div>
  307 +</div>
  308 +
  309 +<script id="menu_list_temp" type="text/html">
  310 + {{each list as group i}}
  311 + <li class="heading">
  312 + <h3 class="uppercase">{{group.name}}</h3>
  313 + </li>
  314 + {{each group.children as dir j}}
  315 + <li class="nav-item">
  316 + <a href="javascript:;" class="nav-link nav-toggle ">
  317 + <i class="{{dir.icon}}"></i>
  318 + <span class="title">{{dir.name}}</span>
  319 + <span class="arrow"></span>
  320 + </a>
  321 + <ul class="sub-menu">
  322 + {{each dir.children as module s}}
  323 + <li class="nav-item ">
  324 + {{if module.container=="pjax-container"}}
  325 + <a href="/pages/{{module.path}}" class="nav-link " data-pjax>
  326 + <span class="title">{{module.name}}</span>
  327 + </a>
  328 + {{else}}
  329 + <a href="{{module.path}}" class="nav-link " data-angularjs>
  330 + <span class="title">{{module.name}}</span>
  331 + </a>
  332 + {{/if}}
  333 + </li>
  334 + {{/each}}
  335 + </ul>
  336 + </li>
  337 + {{/each}}
  338 + {{/each}}
  339 +
  340 +</script>
  341 +<script>
  342 + delete window.require;
  343 + delete window.exports;
  344 + delete window.module;
  345 +</script>
  346 +<!-- jQuery -->
  347 +<script src="/metronic_v4.5.4/plugins/jquery.min.js" data-exclude=1></script>
  348 +<!-- bootstrap -->
  349 +<script src="/metronic_v4.5.4/plugins/bootstrap/js/bootstrap.min.js"
  350 + data-exclude=1></script>
  351 +<script src="/pages/forms/statement/js/jquery.autocompleter.js"></script>
  352 +<script src="/pages/forms/statement/js/jquery.PrintArea.js"></script>
  353 +<!-- MTRONIC JS -->
  354 +<script src="/metronic_v4.5.4/scripts/app.min.js" data-exclude=1></script>
  355 +<script src="/metronic_v4.5.4/layout4/scripts/layout.min.js"
  356 + data-exclude=1></script>
  357 +<!-- 虚拟滚动条 -->
  358 +<script
  359 + src="/metronic_v4.5.4/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script>
  360 +<!-- jsTree 树插件 -->
  361 +<script src="/metronic_v4.5.4/plugins/jstree/dist/jstree.min.js"></script>
  362 +<!-- bootstrap-hover-dropDown -->
  363 +<script
  364 + src="/metronic_v4.5.4/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"></script>
  365 +<!-- jquery.validate 表单验证 -->
  366 +<script
  367 + src="/metronic_v4.5.4/plugins/jquery-validation/js/jquery.validate.min.js"></script>
  368 +<script
  369 + src="/metronic_v4.5.4/plugins/jquery-validation/js/localization/messages_zh.js"></script>
  370 +<!-- 向导式插件 -->
  371 +<script
  372 + src="/metronic_v4.5.4//plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
  373 +<!-- iCheck 单选框和复选框 -->
  374 +<script src="/metronic_v4.5.4/plugins/icheck/icheck.min.js"></script>
  375 +<!-- select2 下拉框 -->
  376 +<script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script>
  377 +<!-- MULTI SELECT 多选下拉框 -->
  378 +<script
  379 + src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js"></script>
  380 +<!-- editable.js -->
  381 +<script
  382 + src="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/js/bootstrap-editable.min.js"></script>
  383 +<!-- PJAX -->
  384 +<script src="/assets/plugins/jquery.pjax.js"></script>
  385 +<!-- layer 弹层 -->
  386 +<script src="/assets/plugins/layer-v2.4/layer/layer.js" data-exclude=1></script>
  387 +<!-- fileinput 上传 -->
  388 +<script src="/assets/plugins/fileinput/canvas-to-blob.min.js"></script>
  389 +<script src="/assets/plugins/fileinput/purify.min.js"></script>
  390 +<script src="/assets/plugins/fileinput/sortable.min.js"></script>
  391 +<script src="/assets/plugins/fileinput/fileinput.min.js"></script>
  392 +<script src="/assets/plugins/fileinput/fileinput_locale_zh.js"></script>
  393 +<!-- jquery.purl URL解析 -->
  394 +<script src="/assets/plugins/purl.js"></script>
  395 +<!-- jquery.serializejson JSON序列化插件 -->
  396 +<script src="/assets/plugins/jquery.serializejson.js"></script>
  397 +<!-- art-template 模版引擎 -->
  398 +<script src="/assets/plugins/template.js"></script>
  399 +<!-- jquery.pageinator 分页 -->
  400 +<script src="/assets/plugins/jqPaginator.min.js"></script>
  401 +<!-- moment.js 日期处理类库 -->
  402 +<script src="/assets/plugins/moment-with-locales.js"></script>
  403 +
  404 +<script src="/assets/plugins/pinyin.js"></script>
  405 +<!-- 日期控件 -->
  406 +<script
  407 + src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js"></script>
  408 +<!-- 表格控件 -->
  409 +<script src="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script>
  410 +<!-- 统计图控件 -->
  411 +<!--<script src="/assets/global/getEchart.js"></script>
  412 +<script src="/assets/global/echarts.js"></script> -->
  413 +<script src="/assets/js/common.js"></script>
  414 +<script src="/assets/js/dictionary.js"></script>
  415 +<!-- tipso JS -->
  416 +<script src="/metronic_v4.5.4/plugins/tipso/js/tipso.js"></script>
  417 +<script data-exclude=1>
  418 + //初始打开的片段地址
  419 + var initFragment = "^_^initFragment^_^";
  420 + //静态文件目录
  421 + var dir = '/pages/';
  422 + //片段容器
  423 + var pjaxContainer = '#pjax-container'
  424 + , angJsContainer = '#route-container';
  425 +
  426 + $(document).ajaxError(function (event, jqxhr, settings, thrownError) {
  427 + if(jqxhr.status == 403){
  428 + layer.closeAll();
  429 + layer.alert(jqxhr.message?jqxhr.message:'访问被拒绝', {icon: 2, title: '操作失败'});
  430 + }
  431 + });
  432 +
  433 + $(function () {
  434 + $.ajax({
  435 + url: '/user/isWeakCipher',
  436 + type: 'POST',
  437 + async: false,
  438 + success: function (result,status,xhr) {
  439 + if (result.data == 1) {
  440 + $.get('/pages/permission/user/forceChangePWD.html', function (content) {
  441 + layer.open({
  442 + type: 1,
  443 + area: ['600px', '360px'],
  444 + content: content,
  445 + title: '修改密码',
  446 + shift: 5,
  447 + scrollbar: false,
  448 + closeBtn: 0,
  449 + success: function () {
  450 + }
  451 + });
  452 + });
  453 + }
  454 + }
  455 + });
  456 +
  457 + $.get('/user/currentUser', function (user) {
  458 + $('#indexTopUName').text(user.userName);
  459 + });
  460 +
  461 + //带 data-pjax 的链接由pjax加载
  462 + $(document).pjax('a[data-pjax]', pjaxContainer);
  463 +
  464 + //pjax左菜单点击事件
  465 + $(document).on('click', '#leftMenuSidebar a[data-pjax]', function () {
  466 + setTitle(this);
  467 +
  468 + $('#leftMenuSidebar li.nav-item.active').removeClass('active');
  469 + $(this).parent().addClass('active');
  470 + showPjax();
  471 + });
  472 +
  473 + //angularjs左菜单点击事件
  474 + $(document).on('click', '#leftMenuSidebar a[data-angularjs]', function () {
  475 + setTitle(this);
  476 +
  477 + $('#leftMenuSidebar li.nav-item.active').removeClass('active');
  478 + $(this).parent().addClass('active');
  479 + showAngJs();
  480 + });
  481 +
  482 + //加载左菜单栏
  483 + $get('/module/findByCurrentUser', null,
  484 + function (ms) {
  485 + var treeArray = createTreeData(ms);
  486 + treeArray.sort(function (a, b) {
  487 + return a.createDate - b.createDate;
  488 + });
  489 + var menuHtml = template('menu_list_temp', {list: treeArray});
  490 + $('#leftMenuSidebar').html(menuHtml);
  491 +
  492 + //----------- 检查URL ----------------
  493 + var h = location.hash;
  494 + if (initFragment && initFragment != '') {
  495 + showPjax();
  496 + //普通片段
  497 + loadPage(initFragment);
  498 + //选中菜单
  499 + $.each($('#leftMenuSidebar a'), function (i, item) {
  500 + if (urlPattern($(item).attr('href'), initFragment)) {
  501 + activeLeftMenu(item);
  502 + }
  503 + });
  504 + } else if (h) {
  505 + //angularjs片段
  506 + showAngJs();
  507 + //选中菜单
  508 + $.each($('#leftMenuSidebar a'), function (i, item) {
  509 + if ($(item).attr('href') == h) {
  510 + activeLeftMenu(item);
  511 + }
  512 + });
  513 + }
  514 + else {
  515 + //加载主页
  516 + loadPage('/pages/home.html');
  517 + }
  518 + });
  519 +
  520 + //修改密码
  521 + $('#changePWD').on('click', function () {
  522 + $.get('/pages/permission/user/changePWD.html', function (content) {
  523 + layer.open({
  524 + type: 1,
  525 + area: ['600px', '360px'],
  526 + content: content,
  527 + title: '修改密码',
  528 + shift: 5,
  529 + scrollbar: false,
  530 + success: function () {
  531 + }
  532 + });
  533 + });
  534 + });
  535 + });
  536 +
  537 + //modal关闭时销毁dom
  538 + $(document).on('hidden.bs.modal', '.modal', function () {
  539 + $(this).remove();
  540 + });
  541 +
  542 + //pjax加载完成事件
  543 + $(document).on('pjax:success', function () {
  544 + var dicts = $(pjaxContainer).find('.nt-dictionary');
  545 + dictionaryUtils.transformDom(dicts);
  546 + });
  547 +
  548 + function loadPage(url) {
  549 + $.pjax({url: url, container: pjaxContainer})
  550 + }
  551 +
  552 + function urlPattern(a, b) {
  553 + var r;
  554 + try {
  555 + r = a.substring(0, a.lastIndexOf('/')) == b.substring(0, b.lastIndexOf('/'));
  556 + } catch (e) {
  557 + r = false;
  558 + }
  559 + return r;
  560 + }
  561 +
  562 + function showPjax() {
  563 + $(angJsContainer).removeClass('page-content active').hide();
  564 + $(pjaxContainer).addClass('page-content active');
  565 + }
  566 +
  567 + function showAngJs() {
  568 + $(pjaxContainer).html('').removeClass('page-content active').hide();
  569 + $(angJsContainer).addClass('page-content active');
  570 + }
  571 +
  572 + function activeLeftMenu(item) {
  573 + $(item).parent('.nav-item').addClass('active').parent('.sub-menu').show().parent().addClass('open');
  574 + setTitle(item);
  575 + }
  576 +
  577 + function setTitle(menuItem){
  578 + document.title = $('span.title', menuItem).text();
  579 + }
  580 +
  581 +</script>
  582 +<!-- d3 -->
  583 +<script src="/assets/js/d3.min.js" data-exclude=1></script>
  584 +<!-- webSocket JS -->
  585 +<script src="/assets/js/sockjs.min.js"></script>
  586 +
  587 +<!-- TODO:angularJS相关库 -->
  588 +
  589 +<!-- angularJS相关库 -->
  590 +<!-- 这个是基于angularjs 1.4.10修改的版本,主要是修改了history控制部分,用于兼容route和pjax的同时操作history的冲突 -->
  591 +<script src="/assets/js/angular.js" data-autocephaly=1></script>
  592 +<script src="/assets/bower_components/angular-i18n/angular-locale_zh-cn.js" data-autocephaly=1></script>
  593 +<script
  594 + src="/assets/bower_components/angular-resource/angular-resource.min.js"
  595 + data-exclude=1></script>
  596 +<script
  597 + src="/assets/bower_components/angular-sanitize/angular-sanitize.min.js"
  598 + data-exclude=1></script>
  599 +<script
  600 + src="/assets/bower_components/angular-animate/angular-animate.min.js"
  601 + data-exclude=1></script>
  602 +<script
  603 + src="/assets/bower_components/angular-touch/angular-touch.min.js"
  604 + data-exclude=1></script>
  605 +<script
  606 + src="/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js"
  607 + data-exclude=1></script>
  608 +<script
  609 + src="/assets/bower_components/oclazyload/dist/ocLazyLoad.min.js"
  610 + data-exclude=1></script>
  611 +<script
  612 + src="/assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"
  613 + data-exclude=1></script>
  614 +<!-- handsontable相关js -->
  615 +<script
  616 + src="/assets/bower_components/handsontable/dist/handsontable.full.js"></script>
  617 +<script
  618 + src="/assets/bower_components/ngHandsontable/dist/ngHandsontable.js"></script>
  619 +<!-- sweetalert相关js -->
  620 +<script src="/assets/bower_components/sweetalert/dist/sweetalert.min.js"></script>
  621 +<script src="/assets/bower_components/ng-sweet-alert/ng-sweet-alert.js"></script>
  622 +
  623 +<!-- schedule计划调度AngularJS模块主JS -->
  624 +<script src="/pages/scheduleApp/module/common/main.js" data-exclude=1></script>
  625 +<script
  626 + src="/pages/scheduleApp/module/common/prj-common-globalservice.js"
  627 + data-exclude=1></script>
  628 +<script src="/pages/scheduleApp/module/common/prj-common-filter.js"
  629 + data-exclude=1></script>
  630 +<script src="/pages/scheduleApp/module/common/prj-common-directive.js"
  631 + data-exclude=1></script>
  632 +<script
  633 + src="/pages/scheduleApp/module/common/prj-common-ui-route-state.js"
  634 + data-exclude=1></script>
  635 +
  636 +<!-- 地图相关 -->
  637 +<!-- 百度 -->
  638 +<script
  639 + src="//api.map.baidu.com/api?v=2.0&ak=1TgEKvYqohJyeGXnN6yHSSTb4psOarQw"
  640 + data-exclude=1></script>
  641 +<script
  642 + src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"
  643 + data-exclude=1></script>
  644 +<script type="text/javascript"
  645 + src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"
  646 + data-exclude=1></script>
  647 +<script type="text/javascript"
  648 + src="http://api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js "
  649 + data-exclude=1></script>
  650 +<script src="/assets/js/baidu/TextIconOverlay.js" data-exclude=1></script>
  651 +<script src="/assets/js/baidu//MarkerClusterer.js" data-exclude=1></script>
  652 +<!-- 高德 -->
  653 +<script
  654 + src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"
  655 + data-exclude=1></script>
  656 +<!-- echarts4 误删 -->
  657 +<script src="/metronic_v4.5.4/plugins/echarts4/echarts.min.js"></script>
  658 +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script>
  659 +<!-- RSA加密 -->
  660 +<script src="/assets/plugins/jsencrypt.min.js"></script>
  661 +<script src="/assets/js/eventproxy.js"></script>
  662 +</body>
638 663 </html>
639 664 \ No newline at end of file
... ...
src/main/resources/static/login.html
1   -<!DOCTYPE html>
2   -<html lang="zh">
3   -<head>
4   - <meta name="renderer" content="webkit" />
5   - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
6   - <meta charset="utf-8" />
7   - <title>登录</title>
8   - <link
9   - href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css"
10   - rel="stylesheet" type="text/css" />
11   - <!-- Bootstrap style -->
12   - <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css"
13   - rel="stylesheet" type="text/css" />
14   -
15   - <!-- METRONIC style -->
16   - <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet"
17   - type="text/css" />
18   -
19   - <style type="text/css">
20   - body>.wrapper {
21   - background-image: url(/assets/img/bg_9b9dcb65ff.png);
22   - background-size: 100px;
23   - background-repeat: repeat;
24   - min-height: 800px;
25   - min-width: 630px;
26   - position: absolute;
27   - top: 0;
28   - bottom: 0;
29   - left: 0;
30   - right: 0;
31   - }
32   -
33   - #loginPanel.dialog-shadow {
34   - width: 450px;
35   - /* height: 400px; */
36   - border: 1px solid #dadada;
37   - border-radius: 10px !important;
38   - position: absolute;
39   - box-shadow: 0 9px 30px -6px rgba(0, 0, 0, .2), 0 18px 20px -10px
40   - rgba(0, 0, 0, .04), 0 18px 20px -10px rgba(0, 0, 0, .04), 0 10px 20px
41   - -10px rgba(0, 0, 0, .04);
42   - background: url(/assets/img/dialog-gray-bg_42c40b3eb6.png) #fff bottom
43   - repeat-x;
44   - top: 50%;
45   - left: 50%;
46   - margin-left: -225px;
47   - margin-top: -300px;
48   - text-align: center;
49   - color: #333;
50   - opacity: .5;
51   -
52   - padding-bottom: 56px;
53   -
54   - animation: to_center 1s forwards;
55   - animation-delay: .2s;
56   -
57   - transition: all .3s ease;
58   - }
59   -
60   - @keyframes to_center
61   - {
62   - 0% {margin-top: -300px;opacity: .5;}
63   - 100% {margin-top: -270px;opacity: 1;}
64   - }
65   -
66   -
67   - h3 {
68   - font-size: 25px;
69   - font-weight: 600;
70   - color: #4a4a4a
71   - }
72   -
73   - .input-icon input {
74   - height: 48px;
75   - border-radius: 5px !important;
76   - transition: all .5s ease;
77   - }
78   -
79   - .input-icon input:FOCUS {
80   - border-color: #c2cad8;
81   - box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) !important;
82   - }
83   -
84   - .input-icon>i {
85   - margin-top: 16px;
86   - }
87   -
88   - #loginPanel #loginBtn.btn{
89   - border-radius: 6px !important;
90   - width: 378px;
91   - height: 48px;
92   - font-size: 20px;
93   - font-family: 微软雅黑;
94   - transition: all .3s ease;
95   -
96   - background: #5f7ed7;
97   - background: linear-gradient(#6f97e5,#527ed9);
98   - box-shadow: inset 0 1px 2px #7ea1e8 !important;
99   - color: #fff;
100   - text-shadow: #4f70b3 0 -1px 0;
101   - border: none;
102   - }
103   -
104   - #loginPanel #loginBtn.btn:HOVER {
105   - box-shadow: inset 0 1px 1px #7696de,inset 0 0 2px #627dca,inset 0 -2px 3px #5a77c7,inset 0 0 100px rgba(48,77,147,.4) !important;
106   - }
107   -
108   -
109   - #loginPanel.show_msg{
110   - top: calc(50% - 10px);
111   - }
112   -
113   - #loginPanel .alert{
114   - display: none;
115   - padding: 12px;
116   - margin-top: 21px;
117   - border-radius: 0 0 10px 10px !important;
118   - font-size: 13px;
119   -
120   - position: absolute;
121   - width: 100%;
122   - border-bottom: 1px solid #dadada;
123   - }
124   -
125   - #loginPanel .alert.login-success{
126   - color: #27a4b0;
127   - background: #abe7ed;
128   - border-color: #abe7ed;
129   - }
130   -
131   - #loginPanel .alert i{
132   - font-size: 16px;
133   - vertical-align: middle;
134   - margin: 0 5px 3px;
135   - }
136   -
137   - #loginPanel.show_msg .alert{
138   - display: block;
139   - }
140   -
141   - #captchaWrap{
142   - display: none;
143   - text-align: left;
144   - border-top: 1px solid #f3f2f2;
145   - }
146   -
147   - img.captcha-img{
148   - cursor: pointer;
149   - }
150   -
151   - .login-footer{
152   - position: fixed;
153   - width: 100%;
154   - bottom: 35px;
155   - text-align: center;
156   - color: #a6a6a6;
157   - }
158   -
159   - h3.logo-text{
160   - font-family: 华文楷体,华文细黑;
161   - font-size: 28px;
162   - }
163   -
164   - .warn-note{
165   - width: 100%;
166   - position: absolute;
167   - top: 0;
168   - z-index: 2;
169   - text-align: center;
170   - background: #ff4646;
171   - color: white;
172   - padding: 12px;
173   - display: none;
174   - }
175   - </style>
176   -</head>
177   -
178   -<body>
179   -<div class="warn-note">警告!系统目前仅在 WebKit 内核下完成兼容性测试,请使用 Google
180   - Chrome 浏览器进入系统。</div>
181   -<div class="wrapper ng-scope">
182   - <div id="loginPanel" class="dialog dialog-shadow">
183   - <br>
184   - <h3 class="logo-text">青浦公交调度系统</h3>
185   - <hr>
186   - <form style="padding: 0px 35px;">
187   - <div class="form-group" style="margin-bottom: 0">
188   - <label></label>
189   - <div class="input-icon">
190   - <i class="fa fa-user font-gray"></i> <input type="text"
191   - name="userName" class="form-control" placeholder="输入用户名"
192   - autofocus="autofocus" autocomplete="off">
193   - </div>
194   - </div>
195   -
196   - <div class="form-group">
197   - <label></label>
198   - <div class="input-icon">
199   - <i class="fa fa-key font-gray"></i> <input type="password"
200   - name="password" class="form-control" placeholder="输入密码">
201   - </div>
202   - </div>
203   -
204   - <div class="form-group" id="captchaWrap">
205   - <label></label>
206   - <div class="input-icon">
207   - <input type="text" name="captcha" style="width: 153px !important;"
208   - class="form-control input-inline input-medium"
209   - placeholder="输入验证码"> <span class="help-inline"> <img
210   - alt="验证码" class="captcha-img" title="点击刷新验证码">
211   - </span>
212   - </div>
213   - </div>
214   - </form>
215   - <br>
216   - <br>
217   - <div class="form-actions">
218   - <button class="btn blue-steel" id="loginBtn" disabled="disabled">登录</button>
219   - </div>
220   -
221   - <div class="alert alert-danger"></div>
222   - </div>
223   -
224   - <div class="login-footer">© 2016 上海巴士拓华科技发展有限公司 Some Rights
225   - Reserved</div>
226   -</div>
227   -
228   -<script>
229   - delete window.require;
230   - delete window.exports;
231   - delete window.module;
232   -</script>
233   -<!-- jQuery -->
234   -<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
235   -<script src="/assets/plugins/jsencrypt.min.js"></script>
236   -<script>
237   - window.onload=function(){
238   - var body=document.getElementsByTagName("body")[0];
239   - if(typeof body.style.WebkitAnimation=="undefined")
240   - $('.warn-note').fadeIn();
241   - };
242   - !function(){
243   - var form = $('#loginPanel form')
244   - ,nameInput = $('input[name=userName]', form)
245   - ,pwdInput = $('input[name=password]', form)
246   - ,msgAlert = $('#loginPanel .alert-danger');
247   -
248   - $('input', form).on('keyup', checkBtnStatus);
249   -
250   - var keys;
251   - $.get('/user/login/jCryptionKey?t='+Math.random(), function(data){
252   - keys = data.publickey;
253   - });
254   -
255   -
256   -
257   - function checkBtnStatus(){
258   - var es = $('input:visible', form);
259   - for(var i = 0, e; e = es[i++];){
260   - if($.trim($(e).val()) == ''){
261   - $('#loginBtn').attr('disabled', 'disabled');
262   - $('#loginPanel').removeClass('show_msg');
263   - return;
264   - }
265   - }
266   - $('#loginBtn').removeAttr('disabled');
267   - }
268   -
269   - nameInput.on('blur', checkStatus);
270   - //keyup 事件做延迟
271   - var uNameKeyup;
272   - nameInput.on('keyup', function(){
273   - if(uNameKeyup)
274   - return;
275   - uNameKeyup = true;
276   - setTimeout(function(){
277   - checkStatus();
278   - uNameKeyup = false;
279   - }, 200);
280   - });
281   -
282   - //密码框回车事件
283   - pwdInput.on('keyup', function(e){
284   - if (e.keyCode == 13)
285   - $('#loginBtn').click();
286   - });
287   - //验证码框回车事件
288   - $('input[name=captcha]').on('keyup', function(e){
289   - if (e.keyCode == 13)
290   - $('#loginBtn').click();
291   - });
292   -
293   - $('#loginBtn').on('click', function(){
294   - if(lock || $(this).attr('disabled')) return;
295   - var userName = nameInput.val()
296   - ,pwd = pwdInput.val();
297   -
298   - //RSA加密
299   - var encrypt = new JSEncrypt();
300   - encrypt.setPublicKey(keys);
301   - userName = encrypt.encrypt(userName);
302   - pwd = encrypt.encrypt(pwd);
303   - //登录
304   - login(userName, pwd);
305   - });
306   -
307   - var lock;
308   - function login(userName, pwd){
309   - lock = true;
310   - $('#loginBtn').attr('disabled', 'disabled');
311   -
312   - var params = {
313   - userName: userName,
314   - password: pwd,
315   - captcha: $('input[name=captcha]').val()
316   - };
317   - $.post('/user/login', params
318   - ,function(rs){
319   -
320   - $('#loginPanel').addClass('show_msg');
321   - if(error(rs)){
322   - lock = false;
323   - $('#loginBtn').removeAttr('disabled');
324   -
325   - msgAlert.html('<i class="fa fa-times-circle"> </i> 登录失败,' + rs.msg);
326   -
327   - _captcha.refresh();
328   - checkStatus();
329   - }
330   - else{
331   - msgAlert.html('<i class="fa fa-check"> </i> 登录成功!');
332   - msgAlert.addClass('login-success');
333   - window.location.href = '/';
334   - }
335   - });
336   - }
337   -
338   - function checkStatus(){
339   - var t = nameInput.val();
340   - if(!t){
341   - hide();
342   - return;
343   - }
344   -
345   - $.get('/user/login/captchaStatus', {userName: t}, function(rs){
346   - if(rs >= 3)
347   - _captcha.show();
348   - else
349   - hide();
350   - });
351   -
352   - function hide(){
353   - if(!$("#captchaWrap").is(":hidden")){
354   - _captcha.hide();
355   - //隐藏提示消息
356   - msgAlert.html('');
357   - $('#loginPanel').removeClass('show_msg');
358   - }
359   - }
360   - }
361   -
362   -
363   - var _captcha = {
364   - show: function(){
365   - if($("#captchaWrap").is(":hidden")){
366   - $('#captchaWrap').fadeIn(500);
367   - _captcha.refresh();
368   - checkBtnStatus();
369   - }
370   - },
371   - refresh: function(){
372   - if($("#captchaWrap").is(":hidden"))
373   - return;
374   - $('#captchaWrap img.captcha-img').attr('src', '/captcha.jpg?t=' + Math.random());
375   - },
376   - hide: function(){
377   - $('#captchaWrap').hide();
378   - $('input[name=captcha]').val('');
379   - }
380   - };
381   -
382   - $('#captchaWrap img.captcha-img').on('click', function(){
383   - $(this).attr('src', '/captcha.jpg?t=' + Math.random());
384   - });
385   -
386   - function error(rs){
387   - return rs.status == 'ERROR' || rs.status == 500;
388   - }
389   - }();
390   -</script>
391   -</body>
  1 +<!DOCTYPE html>
  2 +<html lang="zh">
  3 +<head>
  4 + <meta name="renderer" content="webkit" />
  5 + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  6 + <meta charset="utf-8" />
  7 + <title>登录</title>
  8 + <link
  9 + href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css"
  10 + rel="stylesheet" type="text/css" />
  11 + <!-- Bootstrap style -->
  12 + <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css"
  13 + rel="stylesheet" type="text/css" />
  14 +
  15 + <!-- METRONIC style -->
  16 + <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet"
  17 + type="text/css" />
  18 +
  19 + <style type="text/css">
  20 + body>.wrapper {
  21 + background-image: url(/assets/img/bg_9b9dcb65ff.png);
  22 + background-size: 100px;
  23 + background-repeat: repeat;
  24 + min-height: 800px;
  25 + min-width: 630px;
  26 + position: absolute;
  27 + top: 0;
  28 + bottom: 0;
  29 + left: 0;
  30 + right: 0;
  31 + }
  32 +
  33 + #loginPanel.dialog-shadow {
  34 + width: 450px;
  35 + /* height: 400px; */
  36 + border: 1px solid #dadada;
  37 + border-radius: 10px !important;
  38 + position: absolute;
  39 + box-shadow: 0 9px 30px -6px rgba(0, 0, 0, .2), 0 18px 20px -10px
  40 + rgba(0, 0, 0, .04), 0 18px 20px -10px rgba(0, 0, 0, .04), 0 10px 20px
  41 + -10px rgba(0, 0, 0, .04);
  42 + background: url(/assets/img/dialog-gray-bg_42c40b3eb6.png) #fff bottom
  43 + repeat-x;
  44 + top: 50%;
  45 + left: 50%;
  46 + margin-left: -225px;
  47 + margin-top: -300px;
  48 + text-align: center;
  49 + color: #333;
  50 + opacity: .5;
  51 +
  52 + padding-bottom: 56px;
  53 +
  54 + animation: to_center 1s forwards;
  55 + animation-delay: .2s;
  56 +
  57 + transition: all .3s ease;
  58 + }
  59 +
  60 + @keyframes to_center
  61 + {
  62 + 0% {margin-top: -300px;opacity: .5;}
  63 + 100% {margin-top: -270px;opacity: 1;}
  64 + }
  65 +
  66 +
  67 + h3 {
  68 + font-size: 25px;
  69 + font-weight: 600;
  70 + color: #4a4a4a
  71 + }
  72 +
  73 + .input-icon input {
  74 + height: 48px;
  75 + border-radius: 5px !important;
  76 + transition: all .5s ease;
  77 + }
  78 +
  79 + .input-icon input:FOCUS {
  80 + border-color: #c2cad8;
  81 + box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) !important;
  82 + }
  83 +
  84 + .input-icon>i {
  85 + margin-top: 16px;
  86 + }
  87 +
  88 + #loginPanel #loginBtn.btn{
  89 + border-radius: 6px !important;
  90 + width: 378px;
  91 + height: 48px;
  92 + font-size: 20px;
  93 + font-family: 微软雅黑;
  94 + transition: all .3s ease;
  95 +
  96 + background: #5f7ed7;
  97 + background: linear-gradient(#6f97e5,#527ed9);
  98 + box-shadow: inset 0 1px 2px #7ea1e8 !important;
  99 + color: #fff;
  100 + text-shadow: #4f70b3 0 -1px 0;
  101 + border: none;
  102 + }
  103 +
  104 + #loginPanel #loginBtn.btn:HOVER {
  105 + box-shadow: inset 0 1px 1px #7696de,inset 0 0 2px #627dca,inset 0 -2px 3px #5a77c7,inset 0 0 100px rgba(48,77,147,.4) !important;
  106 + }
  107 +
  108 +
  109 + #loginPanel.show_msg{
  110 + top: calc(50% - 10px);
  111 + }
  112 +
  113 + #loginPanel .alert{
  114 + display: none;
  115 + padding: 12px;
  116 + margin-top: 21px;
  117 + border-radius: 0 0 10px 10px !important;
  118 + font-size: 13px;
  119 +
  120 + position: absolute;
  121 + width: 100%;
  122 + border-bottom: 1px solid #dadada;
  123 + }
  124 +
  125 + #loginPanel .alert.login-success{
  126 + color: #27a4b0;
  127 + background: #abe7ed;
  128 + border-color: #abe7ed;
  129 + }
  130 +
  131 + #loginPanel .alert i{
  132 + font-size: 16px;
  133 + vertical-align: middle;
  134 + margin: 0 5px 3px;
  135 + }
  136 +
  137 + #loginPanel.show_msg .alert{
  138 + display: block;
  139 + }
  140 +
  141 + #captchaWrap{
  142 + display: none;
  143 + text-align: left;
  144 + border-top: 1px solid #f3f2f2;
  145 + }
  146 +
  147 + img.captcha-img{
  148 + cursor: pointer;
  149 + }
  150 +
  151 + .login-footer{
  152 + position: fixed;
  153 + width: 100%;
  154 + bottom: 35px;
  155 + text-align: center;
  156 + color: #a6a6a6;
  157 + }
  158 +
  159 + h3.logo-text{
  160 + font-family: 华文楷体,华文细黑;
  161 + font-size: 28px;
  162 + }
  163 +
  164 + .warn-note{
  165 + width: 100%;
  166 + position: absolute;
  167 + top: 0;
  168 + z-index: 2;
  169 + text-align: center;
  170 + background: #ff4646;
  171 + color: white;
  172 + padding: 12px;
  173 + display: none;
  174 + }
  175 + </style>
  176 +</head>
  177 +
  178 +<body>
  179 +<div class="warn-note">警告!系统目前仅在 WebKit 内核下完成兼容性测试,请使用 Google
  180 + Chrome 浏览器进入系统。</div>
  181 +<div class="wrapper ng-scope">
  182 + <div id="loginPanel" class="dialog dialog-shadow">
  183 + <br>
  184 + <h3 class="logo-text">青浦公交调度系统</h3>
  185 + <hr>
  186 + <form style="padding: 0px 35px;">
  187 + <div class="form-group" style="margin-bottom: 0">
  188 + <label></label>
  189 + <div class="input-icon">
  190 + <i class="fa fa-user font-gray"></i> <input type="text"
  191 + name="userName" class="form-control" placeholder="输入用户名"
  192 + autofocus="autofocus" autocomplete="off">
  193 + </div>
  194 + </div>
  195 +
  196 + <div class="form-group">
  197 + <label></label>
  198 + <div class="input-icon">
  199 + <i class="fa fa-key font-gray"></i> <input type="password"
  200 + name="password" class="form-control" placeholder="输入密码">
  201 + </div>
  202 + </div>
  203 +
  204 + <div class="form-group" id="captchaWrap">
  205 + <label></label>
  206 + <div class="input-icon">
  207 + <input type="text" name="captcha" style="width: 153px !important;"
  208 + class="form-control input-inline input-medium"
  209 + placeholder="输入验证码"> <span class="help-inline"> <img
  210 + alt="验证码" class="captcha-img" title="点击刷新验证码">
  211 + </span>
  212 + </div>
  213 + </div>
  214 + </form>
  215 + <br>
  216 + <br>
  217 + <div class="form-actions">
  218 + <button class="btn blue-steel" id="loginBtn" disabled="disabled">登录</button>
  219 + </div>
  220 +
  221 + <div class="alert alert-danger"></div>
  222 + </div>
  223 +
  224 + <div class="login-footer">© 2016 上海巴士拓华科技发展有限公司 Some Rights
  225 + Reserved</div>
  226 +</div>
  227 +
  228 +<script>
  229 + delete window.require;
  230 + delete window.exports;
  231 + delete window.module;
  232 +</script>
  233 +<!-- jQuery -->
  234 +<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
  235 +<script src="/assets/plugins/jsencrypt.min.js"></script>
  236 +<script>
  237 + window.onload=function(){
  238 + var body=document.getElementsByTagName("body")[0];
  239 + if(typeof body.style.WebkitAnimation=="undefined")
  240 + $('.warn-note').fadeIn();
  241 + };
  242 + !function(){
  243 + var form = $('#loginPanel form')
  244 + ,nameInput = $('input[name=userName]', form)
  245 + ,pwdInput = $('input[name=password]', form)
  246 + ,msgAlert = $('#loginPanel .alert-danger');
  247 +
  248 + $('input', form).on('keyup', checkBtnStatus);
  249 +
  250 + var keys;
  251 + $.get('/user/login/jCryptionKey?t='+Math.random(), function(data){
  252 + keys = data.publickey;
  253 + });
  254 +
  255 +
  256 +
  257 + function checkBtnStatus(){
  258 + var es = $('input:visible', form);
  259 + for(var i = 0, e; e = es[i++];){
  260 + if($.trim($(e).val()) == ''){
  261 + $('#loginBtn').attr('disabled', 'disabled');
  262 + $('#loginPanel').removeClass('show_msg');
  263 + return;
  264 + }
  265 + }
  266 + $('#loginBtn').removeAttr('disabled');
  267 + }
  268 +
  269 + nameInput.on('blur', checkStatus);
  270 + //keyup 事件做延迟
  271 + var uNameKeyup;
  272 + nameInput.on('keyup', function(){
  273 + if(uNameKeyup)
  274 + return;
  275 + uNameKeyup = true;
  276 + setTimeout(function(){
  277 + checkStatus();
  278 + uNameKeyup = false;
  279 + }, 200);
  280 + });
  281 +
  282 + //密码框回车事件
  283 + pwdInput.on('keyup', function(e){
  284 + if (e.keyCode == 13)
  285 + $('#loginBtn').click();
  286 + });
  287 + //验证码框回车事件
  288 + $('input[name=captcha]').on('keyup', function(e){
  289 + if (e.keyCode == 13)
  290 + $('#loginBtn').click();
  291 + });
  292 +
  293 + $('#loginBtn').on('click', function(){
  294 + if(lock || $(this).attr('disabled')) return;
  295 + var userName = nameInput.val()
  296 + ,pwd = pwdInput.val();
  297 +
  298 + //RSA加密
  299 + var encrypt = new JSEncrypt();
  300 + encrypt.setPublicKey(keys);
  301 + userName = encrypt.encrypt(userName);
  302 + pwd = encrypt.encrypt(pwd);
  303 + //登录
  304 + login(userName, pwd);
  305 + });
  306 +
  307 + var lock;
  308 + function login(userName, pwd){
  309 + lock = true;
  310 + $('#loginBtn').attr('disabled', 'disabled');
  311 +
  312 + var params = {
  313 + userName: userName,
  314 + password: pwd,
  315 + captcha: $('input[name=captcha]').val()
  316 + };
  317 + $.post('/user/login', params
  318 + ,function(rs){
  319 +
  320 + $('#loginPanel').addClass('show_msg');
  321 + if(error(rs)){
  322 + lock = false;
  323 + $('#loginBtn').removeAttr('disabled');
  324 + msgAlert.html('<i class="fa fa-times-circle"> </i> 登录失败,' + rs.msg);
  325 +
  326 + _captcha.refresh();
  327 + checkStatus();
  328 + }
  329 + else{
  330 + msgAlert.html('<i class="fa fa-check"> </i> 登录成功!');
  331 + msgAlert.addClass('login-success');
  332 + window.location.href = '/';
  333 + }
  334 + });
  335 + }
  336 +
  337 + function checkStatus(){
  338 + var t = nameInput.val();
  339 + if(!t){
  340 + hide();
  341 + return;
  342 + }
  343 +
  344 + $.get('/user/login/captchaStatus', {userName: t}, function(rs){
  345 + if(rs > 1)
  346 + _captcha.show();
  347 + else
  348 + hide();
  349 + });
  350 +
  351 + function hide(){
  352 + if(!$("#captchaWrap").is(":hidden")){
  353 + _captcha.hide();
  354 + //隐藏提示消息
  355 + //msgAlert.html('');
  356 + //$('#loginPanel').removeClass('show_msg');
  357 + }
  358 + }
  359 + }
  360 +
  361 +
  362 + var _captcha = {
  363 + show: function(){
  364 + if($("#captchaWrap").is(":hidden")){
  365 + $('#captchaWrap').fadeIn(500);
  366 + _captcha.refresh();
  367 + checkBtnStatus();
  368 + }
  369 + },
  370 + refresh: function(){
  371 + if($("#captchaWrap").is(":hidden"))
  372 + return;
  373 + $('#captchaWrap img.captcha-img').attr('src', '/captcha.jpg?t=' + Math.random());
  374 + },
  375 + hide: function(){
  376 + $('#captchaWrap').hide();
  377 + $('input[name=captcha]').val('');
  378 + }
  379 + };
  380 +
  381 + $('#captchaWrap img.captcha-img').on('click', function(){
  382 + $(this).attr('src', '/captcha.jpg?t=' + Math.random());
  383 + });
  384 +
  385 + function error(rs){
  386 + return rs.status == 'ERROR' || rs.status == 500;
  387 + }
  388 + }();
  389 +</script>
  390 +</body>
392 391 </html>
393 392 \ No newline at end of file
... ...
src/main/resources/static/pages/home.html
1   -<style>
2   - .system_change_log{
3   - background: #fff;
4   - color: #666;
5   - box-shadow: 0 5px 15px rgba(0,0,0,0.08);
6   - height: calc(100% + 10px);
7   - margin-top: -10px;
8   - font-size: 14px;
9   - padding: 10px 0 0 15px;
10   - overflow: auto;
11   - }
12   - .system_change_log>ul{
13   - margin:0px;
14   - list-style:none;
15   - }
16   -
17   - .system_change_log>ul>li.sub_title{
18   - text-indent: 0;
19   - }
20   -
21   - .system_change_log>ul>li.sub_title>h6{
22   - font-size: 12px;
23   - font-family: 微软雅黑;
24   - color: #000;
25   - margin-top: 8px;
26   - margin-bottom: 8px;
27   - }
28   -
29   - .system_change_log>ul>li{
30   - margin: 5px 0;
31   - text-indent: 25px;
32   - }
33   -
34   - .system_change_log .label{
35   - width: 55px;
36   - display: inline-block;
37   - padding: 0 10px;
38   - line-height: 1.5;
39   - font-size: 12px;
40   - color: #fff;
41   - vertical-align: middle;
42   - white-space: nowrap;
43   - border-radius: 2px !important;
44   - text-transform: uppercase;
45   - text-align: center;
46   - text-indent: 3px;
47   - margin-right: 15px;
48   - }
49   - .system_change_log .label.s_c_add{
50   - background-color: #32d296;
51   - }
52   -
53   - .system_change_log .label.s_c_change{
54   - background-color: #1e87f0;
55   - }
56   -
57   - .system_change_log .label.s_c_remove{
58   - background-color: #faa05a;
59   - }
60   -</style>
61   -<div class="system_change_log">
62   - <h2 style="text-indent: 35px;margin: 10px 0 5px;">2019-06-26 更新说明 Changelog</h2>
63   - <br><br>
64   - <ul >
65   - <li class="sub_title"><h6>计划调度</h6></li>
66   - <li><span class="label s_c_change">新增</span>1、新增智能时刻表。</li>
67   - <li class="sub_title"><h6>线调</h6></li>
68   - <li><span class="label s_c_change">修复</span>1、线调班次列表页滚动条问题。</li>
69   - <li><span class="label s_c_change">新增</span>2、新增移动调度,适配IPAD。</li>
70   - </ul>
71   -</div>
  1 +<style>
  2 + .system_change_log{
  3 + background: #fff;
  4 + color: #666;
  5 + box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  6 + height: calc(100% + 10px);
  7 + margin-top: -10px;
  8 + font-size: 14px;
  9 + padding: 10px 0 0 15px;
  10 + overflow: auto;
  11 + }
  12 + .system_change_log>ul{
  13 + margin:0px;
  14 + list-style:none;
  15 + }
  16 +
  17 + .system_change_log>ul>li.sub_title{
  18 + text-indent: 0;
  19 + }
  20 +
  21 + .system_change_log>ul>li.sub_title>h6{
  22 + font-size: 12px;
  23 + font-family: 微软雅黑;
  24 + color: #000;
  25 + margin-top: 8px;
  26 + margin-bottom: 8px;
  27 + }
  28 +
  29 + .system_change_log>ul>li{
  30 + margin: 5px 0;
  31 + text-indent: 25px;
  32 + }
  33 +
  34 + .system_change_log .label{
  35 + width: 55px;
  36 + display: inline-block;
  37 + padding: 0 10px;
  38 + line-height: 1.5;
  39 + font-size: 12px;
  40 + color: #fff;
  41 + vertical-align: middle;
  42 + white-space: nowrap;
  43 + border-radius: 2px !important;
  44 + text-transform: uppercase;
  45 + text-align: center;
  46 + text-indent: 3px;
  47 + margin-right: 15px;
  48 + }
  49 + .system_change_log .label.s_c_add{
  50 + background-color: #32d296;
  51 + }
  52 +
  53 + .system_change_log .label.s_c_change{
  54 + background-color: #1e87f0;
  55 + }
  56 +
  57 + .system_change_log .label.s_c_remove{
  58 + background-color: #faa05a;
  59 + }
  60 +</style>
  61 +<div class="system_change_log">
  62 + <h2 style="text-indent: 35px;margin: 10px 0 5px;">2019-06-26 更新说明 Changelog</h2>
  63 + <br><br>
  64 + <ul >
  65 + <li class="sub_title"><h6>计划调度</h6></li>
  66 + <li><span class="label s_c_change">新增</span>1、新增智能时刻表。</li>
  67 + <li class="sub_title"><h6>线调</h6></li>
  68 + <li><span class="label s_c_change">修复</span>1、线调班次列表页滚动条问题。</li>
  69 + <li><span class="label s_c_change">新增</span>2、新增移动调度,适配IPAD。</li>
  70 + </ul>
  71 +</div>
  72 +
  73 +<script type="text/javascript">
  74 + $.ajax({
  75 + url: '/eci/validate_get_destroy_info',
  76 + dataType: "json",
  77 + success: function(rs) {
  78 + if (rs && rs.status === "SUCCESS") {
  79 + if (rs.data && rs.data.length && rs.data.length > 0) {
  80 + var htmlText = "";
  81 + var wrapData = [];
  82 + if (rs.data.length > 8) {
  83 + htmlText = "<span style='font-weight: bold; font-style: italic; '>部分停用信息如下:</span></br>";
  84 + wrapData = rs.data.slice(0, 8);
  85 + } else {
  86 + htmlText = "<span style='font-weight: bold; font-style: italic; '>所有停用信息如下:</span></br>";
  87 + wrapData = rs.data;
  88 + }
  89 + $.each(wrapData, function(index, value) {
  90 + wrapData[index] = "<span style='font-size: 14px;'>" + value + "</span>";
  91 + });
  92 +
  93 + htmlText += wrapData.join("</br>");
  94 +
  95 + swal({
  96 + title: "排班人员停用信息",
  97 + text: htmlText,
  98 + html: true,
  99 + type: "warning",
  100 + showCancelButton: true,
  101 + cancelButtonText: "关闭",
  102 + confirmButtonColor: "#3598dc",
  103 + confirmButtonText: "下载所有停用信息",
  104 + closeOnConfirm: false
  105 +
  106 + }, function() {
  107 + window.location.href = "/eci/validate_get_destroy_info/download";
  108 + });
  109 + }
  110 + }
  111 + }
  112 + });
  113 +
  114 + $.get("/user/validPWDExpired", function(msg) {
  115 + if ("ok" === msg) {
  116 + return;
  117 + }
  118 +
  119 + var htmlText = [];
  120 + htmlText.push("<span style='font-weight: bold; font-style: italic; '>" + msg + "</span></br>");
  121 + swal({
  122 + title: "账户密码提示",
  123 + text: htmlText.join("</br>"),
  124 + html: true,
  125 + type: "warning",
  126 + showCancelButton: true,
  127 + cancelButtonText: "关闭",
  128 + confirmButtonColor: "#3598dc",
  129 + closeOnConfirm: false
  130 + });
  131 + });
  132 +
  133 +</script>
... ...
src/main/resources/static/pages/permission/role/add.html
1   -<div class="page-head">
2   - <div class="page-title">
3   - <h1>添加角色</h1>
4   - </div>
5   -</div>
6   -
7   -<ul class="page-breadcrumb breadcrumb">
8   - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
9   - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
10   - <li><a href="list.html" data-pjax>角色管理</a> <i class="fa fa-circle"></i></li>
11   - <li><span class="active">添加角色</span></li>
12   -</ul>
13   -
14   -<div class="portlet light bordered">
15   - <div class="portlet-title">
16   - <div class="caption">
17   - <i class="icon-equalizer font-red-sunglo"></i> <span
18   - class="caption-subject font-red-sunglo bold uppercase">表单</span>
19   - </div>
20   - </div>
21   - <div class="portlet-body form">
22   - <form action="/resource" class="form-horizontal" id="role_add_form" >
23   - <div class="alert alert-danger display-hide">
24   - <button class="close" data-close="alert"></button>
25   - 您的输入有误,请检查下面的输入项
26   - </div>
27   - <div class="form-body">
28   - <div class="form-group">
29   - <label class="col-md-3 control-label">角色代码</label>
30   - <div class="col-md-4">
31   - <input type="text" class="form-control" name="codeName">
32   - <span class="help-block"> 角色的唯一标识符,不允许重复</span>
33   - </div>
34   - </div>
35   - <div class="form-group">
36   - <label class="col-md-3 control-label">角色名称</label>
37   - <div class="col-md-4">
38   - <input type="text" class="form-control" name="roleName">
39   - </div>
40   - </div>
41   - <div class="form-group">
42   - <label class="col-md-3 control-label">是否启用</label>
43   - <div class="col-md-4">
44   - <div class="input-group">
45   - <select class="form-control" name="enable" style="width: 160px;">
46   - <option value="1">可用</option>
47   - <option value="0">禁用</option>
48   - </select>
49   - </div>
50   - </div>
51   - </div>
52   - <div class="form-group">
53   - <label class="col-md-3 control-label">备注/描述</label>
54   - <div class="col-md-4">
55   - <textarea class="form-control" rows="3" name="descriptions"></textarea>
56   - </div>
57   - </div>
58   - </div>
59   - <div class="form-actions">
60   - <div class="row">
61   - <div class="col-md-offset-3 col-md-4">
62   - <button type="submit" class="btn green" id="addRoleButton"><i class="fa fa-check"></i> 提交</button>
63   - <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
64   - </div>
65   - </div>
66   - </div>
67   - </form>
68   - <!-- END FORM-->
69   - </div>
70   -</div>
71   -
72   -<script>
73   -$(function(){
74   -
75   - var form = $('#role_add_form');
76   - var error = $('.alert-danger', form);
77   -
78   - //form validate
79   - form.validate({
80   - errorElement : 'span',
81   - errorClass : 'help-block help-block-error',
82   - focusInvalid : false,
83   - rules : {
84   - 'codeName' : {
85   - required : true,
86   - minlength: 2,
87   - maxlength: 15
88   - },
89   - 'roleName' : {
90   - required : true,
91   - minlength: 2,
92   - maxlength: 9
93   - }
94   - },
95   - invalidHandler : function(event, validator) {
96   - error.show();
97   - App.scrollTo(error, -200);
98   - },
99   -
100   - highlight : function(element) {
101   - $(element).closest('.form-group').addClass('has-error');
102   - },
103   -
104   - unhighlight : function(element) {
105   - $(element).closest('.form-group').removeClass('has-error');
106   - },
107   -
108   - success : function(label) {
109   - label.closest('.form-group').removeClass('has-error');
110   - },
111   -
112   - submitHandler : function(f) {
113   - var params = form.serializeJSON();
114   - error.hide();
115   - console.log(params);
116   -
117   - //检查一下角色代码是否存在
118   - $get('/role/all', {codeName_eq: params.codeName}, function(list){
119   - if(!list || list.length == 0){
120   - $post('/role', params, function(res){
121   - layer.msg('添加角色成功.');
122   - loadPage('list.html');
123   - });
124   - }
125   - else
126   - layer.alert('角色代码【' + params.codeName + '】已存在', {icon: 2, title: '提交被拒绝'});
127   - });
128   - }
129   - });
130   -
131   -});
  1 +<div class="page-head">
  2 + <div class="page-title">
  3 + <h1>添加角色</h1>
  4 + </div>
  5 +</div>
  6 +
  7 +<ul class="page-breadcrumb breadcrumb">
  8 + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
  9 + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
  10 + <li><a href="list.html" data-pjax>角色管理</a> <i class="fa fa-circle"></i></li>
  11 + <li><span class="active">添加角色</span></li>
  12 +</ul>
  13 +
  14 +<div class="portlet light bordered">
  15 + <div class="portlet-title">
  16 + <div class="caption">
  17 + <i class="icon-equalizer font-red-sunglo"></i> <span
  18 + class="caption-subject font-red-sunglo bold uppercase">表单</span>
  19 + </div>
  20 + </div>
  21 + <div class="portlet-body form">
  22 + <form action="/resource" class="form-horizontal" id="role_add_form" >
  23 + <div class="alert alert-danger display-hide">
  24 + <button class="close" data-close="alert"></button>
  25 + 您的输入有误,请检查下面的输入项
  26 + </div>
  27 + <div class="form-body">
  28 + <div class="form-group">
  29 + <label class="col-md-3 control-label">角色代码</label>
  30 + <div class="col-md-4">
  31 + <input type="text" class="form-control" name="codeName">
  32 + <span class="help-block"> 角色的唯一标识符,不允许重复</span>
  33 + </div>
  34 + </div>
  35 + <div class="form-group">
  36 + <label class="col-md-3 control-label">角色名称</label>
  37 + <div class="col-md-4">
  38 + <input type="text" class="form-control" name="roleName">
  39 + </div>
  40 + </div>
  41 + <div class="form-group">
  42 + <label class="col-md-3 control-label">是否启用</label>
  43 + <div class="col-md-4">
  44 + <div class="input-group">
  45 + <select class="form-control" name="enable" style="width: 160px;">
  46 + <option value="1">可用</option>
  47 + <option value="0">禁用</option>
  48 + </select>
  49 + </div>
  50 + </div>
  51 + </div>
  52 + <div class="form-group">
  53 + <label class="col-md-3 control-label">备注/描述</label>
  54 + <div class="col-md-4">
  55 + <textarea class="form-control" rows="3" name="descriptions"></textarea>
  56 + </div>
  57 + </div>
  58 + </div>
  59 + <div class="form-actions">
  60 + <div class="row">
  61 + <div class="col-md-offset-3 col-md-4">
  62 + <button type="submit" class="btn green" id="addRoleButton"><i class="fa fa-check"></i> 提交</button>
  63 + <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
  64 + </div>
  65 + </div>
  66 + </div>
  67 + </form>
  68 + <!-- END FORM-->
  69 + </div>
  70 +</div>
  71 +
  72 +<script>
  73 +$(function(){
  74 +
  75 + var form = $('#role_add_form');
  76 + var error = $('.alert-danger', form);
  77 +
  78 + //form validate
  79 + form.validate({
  80 + errorElement : 'span',
  81 + errorClass : 'help-block help-block-error',
  82 + focusInvalid : false,
  83 + rules : {
  84 + 'codeName' : {
  85 + required : true,
  86 + minlength: 2,
  87 + maxlength: 15
  88 + },
  89 + 'roleName' : {
  90 + required : true,
  91 + minlength: 2,
  92 + maxlength: 9
  93 + }
  94 + },
  95 + invalidHandler : function(event, validator) {
  96 + error.show();
  97 + App.scrollTo(error, -200);
  98 + },
  99 +
  100 + highlight : function(element) {
  101 + $(element).closest('.form-group').addClass('has-error');
  102 + },
  103 +
  104 + unhighlight : function(element) {
  105 + $(element).closest('.form-group').removeClass('has-error');
  106 + },
  107 +
  108 + success : function(label) {
  109 + label.closest('.form-group').removeClass('has-error');
  110 + },
  111 +
  112 + submitHandler : function(f) {
  113 + var params = form.serializeJSON();
  114 + error.hide();
  115 + console.log(params);
  116 +
  117 + //检查一下角色代码是否存在
  118 + $get('/role/all', {codeName_eq: params.codeName}, function(list){
  119 + if(!list || list.length == 0){
  120 + params.level = 2;
  121 + /*$post('/role/add', params, function(res){
  122 + layer.msg('添加角色成功.');
  123 + loadPage('list.html');
  124 + });*/
  125 + $.ajax({
  126 + url: '/role/add',
  127 + type: 'POST',
  128 + traditional: true,
  129 + data: params,
  130 + success: function(rs){
  131 + if(!rs){
  132 + layer.msg('未知异常!');
  133 + }
  134 + if(rs.status=='SUCCESS'){
  135 + layer.msg('添加角色成功.');
  136 + loadPage('list.html');
  137 + }
  138 + else if(rs.status=='ERROR'){
  139 + layer.msg('添加失败[ ' + rs.msg + ']');
  140 + }
  141 + }
  142 + });
  143 + }
  144 + else
  145 + layer.alert('角色代码【' + params.codeName + '】已存在', {icon: 2, title: '提交被拒绝'});
  146 + });
  147 + }
  148 + });
  149 +
  150 +});
132 151 </script>
133 152 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/role/list.html
1   -<div class="page-head">
2   - <div class="page-title">
3   - <h1>角色管理</h1>
4   - </div>
5   -</div>
6   -
7   -<ul class="page-breadcrumb breadcrumb">
8   - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
9   - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
10   - <li><span class="active">角色管理</span></li>
11   -</ul>
12   -
13   -<div class="row">
14   - <div class="col-md-12">
15   - <div class="portlet light portlet-fit bordered">
16   - <div class="portlet-title">
17   - <div class="caption">
18   - <i class="fa fa-database font-dark"></i> <span
19   - class="caption-subject font-dark sbold uppercase">角色列表</span>
20   - </div>
21   - <div class="actions">
22   - <a data-pjax href="add.html" class="btn btn-circle blue" id="addRoleButton" style="padding: 5px 15px;font-size: 13px;line-height: 1.3;">
23   - <i class="fa fa-plus"></i> 添加角色
24   - </a>
25   - </div>
26   - </div>
27   - <div class="portlet-body">
28   - <div class="mt-element-card mt-card-round mt-element-overlay" id="roleCards">
29   - </div>
30   - </div>
31   - </div>
32   - </div>
33   -</div>
34   -
35   -<script id="role_list_temp" type="text/html">
36   -{{each list as role i}}
37   -<div
38   - style="width: 290px; display: inline-block; padding: 0 5px 0 20px;">
39   - <div class="mt-card-item" style="padding-top: 22px;">
40   - <div class="mt-card-avatar mt-overlay-1">
41   - {{if role.pic == 1}}
42   - <img src="/assets/img/roleHead/{{role.codeName}}.png" />
43   - {{else}}
44   - <img src="/assets/img/roleHead/normal.png" />
45   - {{/if}}
46   -
47   - <div class="mt-overlay">
48   - <ul class="mt-info">
49   - <li><a class="btn default btn-outline"
50   - href="edit.html?no={{role.id}}" data-pjax> <i class="fa fa-edit"></i> 编辑
51   - </a></li>
52   - </ul>
53   - </div>
54   - </div>
55   - <div class="mt-card-content">
56   - <h3 class="mt-card-name" >{{role.codeName}}</h3>
57   - <p class="mt-card-desc font-grey-mint" >{{role.roleName}}</p>
58   - <p class="mt-card-desc font-grey-mint">创建于 {{role.createDateStr}}</p>
59   - <div class="mt-card-social">
60   - <!--<a href="javascript:;" disabled
61   - class="btn grey-mint btn-outline btn-circle"
62   - style="margin: 5px;"> <i class="fa fa-user"></i> 用户 <span
63   - class="badge"> 1 </span>
64   - </a>-->
65   - <hr>
66   - <a href="settings.html?no={{role.id}}" data-pjax class=" font-blue "
67   - style="display: inline-block; margin-right: 5px;"> <i
68   - class="fa fa-meh-o"> </i> 模块配置
69   - </a>
70   - <a href="resourcesSetting.html?no={{role.id}}" class=" font-blue "
71   - style="display: inline-block;color: #aaaaaa !important;" > <i class="fa fa-key">
72   - </i> 系统资源权限
73   - </a>
74   -
75   - <hr>
76   - <a href="companyAuthority.html?no={{role.id}}" data-pjax class="font-blue"
77   - style="display: inline-block; font-size: 12px;" > 分公司数据权限
78   - </a>
79   - </div>
80   - </div>
81   - </div>
82   -</div>
83   -{{/each}}
84   -</script>
85   -
86   -<script>
87   -$(function(){
88   - $get('/role/all', null, function(list){
89   - roleDateFormat(list);
90   - var htmlStr = template('role_list_temp', {list: list});
91   - $('#roleCards').html(htmlStr);
92   - });
93   -
94   - //转换时间格式
95   - function roleDateFormat(list){
96   - var fs = 'YYYY-MM-DD HH:mm';
97   - $.each(list, function(i, role){
98   - role.createDateStr = moment(role.createDate).format(fs);
99   - role.updateDateStr = moment(role.updateDate).format(fs);
100   - });
101   - }
102   -});
103   -</script>
  1 +<div class="page-head">
  2 + <div class="page-title">
  3 + <h1>角色管理</h1>
  4 + </div>
  5 +</div>
  6 +
  7 +<ul class="page-breadcrumb breadcrumb">
  8 + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
  9 + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
  10 + <li><span class="active">角色管理</span></li>
  11 +</ul>
  12 +
  13 +<div class="row">
  14 + <div class="col-md-12">
  15 + <div class="portlet light portlet-fit bordered">
  16 + <div class="portlet-title">
  17 + <div class="caption">
  18 + <i class="fa fa-database font-dark"></i> <span
  19 + class="caption-subject font-dark sbold uppercase">角色列表</span>
  20 + </div>
  21 + <div class="actions">
  22 + <a data-pjax href="add.html" class="btn btn-circle blue" id="addRoleButton" style="padding: 5px 15px;font-size: 13px;line-height: 1.3;">
  23 + <i class="fa fa-plus"></i> 添加角色
  24 + </a>
  25 + </div>
  26 + </div>
  27 + <div class="portlet-body">
  28 + <div class="mt-element-card mt-card-round mt-element-overlay" id="roleCards">
  29 + </div>
  30 + </div>
  31 + </div>
  32 + </div>
  33 +</div>
  34 +
  35 +<script id="role_list_temp" type="text/html">
  36 +{{each list as role i}}
  37 +<div
  38 + style="width: 290px; display: inline-block; padding: 0 5px 0 20px;">
  39 + <div class="mt-card-item" style="padding-top: 22px;">
  40 + <div class="mt-card-avatar mt-overlay-1">
  41 + {{if role.pic == 1}}
  42 + <img src="/assets/img/roleHead/{{role.codeName}}.png" />
  43 + {{else}}
  44 + <img src="/assets/img/roleHead/normal.png" />
  45 + {{/if}}
  46 +
  47 + <div class="mt-overlay">
  48 + <ul class="mt-info">
  49 + <li><a class="btn default btn-outline"
  50 + href="edit.html?no={{role.id}}" data-pjax> <i class="fa fa-edit"></i> 编辑
  51 + </a></li>
  52 + </ul>
  53 + </div>
  54 + </div>
  55 + <div class="mt-card-content">
  56 + <h3 class="mt-card-name" >{{role.codeName}}</h3>
  57 + <p class="mt-card-desc font-grey-mint" >{{role.roleName}}</p>
  58 + <p class="mt-card-desc font-grey-mint">创建于 {{role.createDateStr}}</p>
  59 + <div class="mt-card-social">
  60 + <!--<a href="javascript:;" disabled
  61 + class="btn grey-mint btn-outline btn-circle"
  62 + style="margin: 5px;"> <i class="fa fa-user"></i> 用户 <span
  63 + class="badge"> 1 </span>
  64 + </a>-->
  65 + <hr>
  66 + <a href="settings.html?no={{role.id}}" data-pjax class=" font-blue "
  67 + style="display: inline-block; margin-right: 5px;"> <i
  68 + class="fa fa-meh-o"> </i> 模块配置
  69 + </a>
  70 + <a href="javascript:;" class=" font-blue "
  71 + style="display: inline-block;color: #aaaaaa !important;" > <i class="fa fa-key">
  72 + </i> 系统资源权限
  73 + </a>
  74 +
  75 + <hr>
  76 + <a href="companyAuthority.html?no={{role.id}}" data-pjax class="font-blue"
  77 + style="display: inline-block; font-size: 12px;" > 分公司数据权限
  78 + </a>
  79 + </div>
  80 + </div>
  81 + </div>
  82 +</div>
  83 +{{/each}}
  84 +</script>
  85 +
  86 +<script>
  87 +$(function(){
  88 + $get('/role/findSubordinate', null, function(rs){
  89 + var list = rs.list;
  90 + roleDateFormat(list);
  91 + var htmlStr = template('role_list_temp', {list: list});
  92 + $('#roleCards').html(htmlStr);
  93 + });
  94 +
  95 + //转换时间格式
  96 + function roleDateFormat(list){
  97 + var fs = 'YYYY-MM-DD HH:mm';
  98 + $.each(list, function(i, role){
  99 + role.createDateStr = moment(role.createDate).format(fs);
  100 + role.updateDateStr = moment(role.updateDate).format(fs);
  101 + });
  102 + }
  103 +});
  104 +</script>
... ...
src/main/resources/static/pages/permission/user/add.html
1   -<div class="page-head">
2   - <div class="page-title">
3   - <h1>添加用户</h1>
4   - </div>
5   -</div>
6   -
7   -<ul class="page-breadcrumb breadcrumb">
8   - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
9   - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
10   - <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li>
11   - <li><span class="active">添加用户</span></li>
12   -</ul>
13   -
14   -<div class="portlet light bordered">
15   - <div class="portlet-title">
16   - <div class="caption">
17   - <i class="icon-equalizer font-red-sunglo"></i> <span
18   - class="caption-subject font-red-sunglo bold uppercase">表单</span>
19   - </div>
20   - </div>
21   - <div class="portlet-body form">
22   - <form action="/addUser" class="form-horizontal" id="user_add_form" >
23   - <div class="alert alert-danger display-hide">
24   - <button class="close" data-close="alert"></button>
25   - 您的输入有误,请检查下面的输入项
26   - </div>
27   - <div class="form-body">
28   - <div class="form-group">
29   - <label class="col-md-3 control-label">登录名</label>
30   - <div class="col-md-4">
31   - <input type="text" class="form-control" name="userName" >
32   - <span class="help-block"> 登录时的帐号</span>
33   - </div>
34   - </div>
35   - <div class="form-group">
36   - <label class="col-md-3 control-label">姓名</label>
37   - <div class="col-md-4">
38   - <input type="text" class="form-control" name="name" >
39   - </div>
40   - </div>
41   - <div class="form-group">
42   - <label class="col-md-3 control-label">密码</label>
43   - <div class="col-md-4">
44   - <input type="password" class="form-control" id="password" name="password" >
45   - <span class="help-block"> 请输入6位以上密码</span>
46   - </div>
47   - </div>
48   - <div class="form-group">
49   - <label class="col-md-3 control-label">确认密码</label>
50   - <div class="col-md-4">
51   - <input type="password" class="form-control" name="cfmPassword" >
52   - <span class="help-block"> 请重新输入密码</span>
53   - </div>
54   - </div>
55   - <div class="form-group">
56   - <label class="col-md-3 control-label">所属机构</label>
57   - <div class="col-md-4">
58   - <input type="text" class="form-control" name="agencies" >
59   - </div>
60   - </div>
61   -
62   - <div class="form-group">
63   - <label class="col-md-3 control-label">角色</label>
64   - <div class="col-md-4">
65   - <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple">
66   -
67   - </select>
68   - </div>
69   - </div>
70   -
71   - <div class="form-group">
72   - <label class="col-md-3 control-label">是否启用</label>
73   - <div class="col-md-4">
74   - <div class="input-group">
75   - <select class="form-control" name="enabled" style="width: 160px;">
76   - <option value="1">可用</option>
77   - <option value="0">禁用</option>
78   - </select>
79   - </div>
80   - </div>
81   - </div>
82   - </div>
83   - <div class="form-actions">
84   - <div class="row">
85   - <div class="col-md-offset-3 col-md-4">
86   - <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button>
87   - <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
88   - </div>
89   - </div>
90   - </div>
91   - </form>
92   - <!-- END FORM-->
93   - </div>
94   -</div>
95   -<script>
96   - $(function(){
97   - $get('/role/all',null,function(result){
98   - $.each(result,function(i,obj){
99   - $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
100   - });
101   - });
102   -
103   - var form = $('#user_add_form');
104   - var error = $('.alert-danger', form);
105   -
106   - //表单 validate
107   - form.validate({
108   - errorElement : 'span',
109   - errorClass : 'help-block help-block-error',
110   - focusInvalid : false,
111   - rules : {
112   - 'userName' : {
113   - required : true,
114   - maxlength: 25
115   - },
116   - 'name' : {
117   - required : true,
118   - maxlength: 25
119   - },
120   - 'password' : {
121   - required : true,
122   - minlength: 6,
123   - maxlength: 25
124   - },
125   - 'cfmPassword' : {
126   - equalTo: '#password'
127   - },
128   - 'role' : {
129   - required : true,
130   - minlength: 1
131   - }
132   - },
133   - invalidHandler : function(event, validator) {
134   - error.show();
135   - App.scrollTo(error, -200);
136   - },
137   -
138   - highlight : function(element) {
139   - $(element).closest('.form-group').addClass('has-error');
140   - },
141   -
142   - unhighlight : function(element) {
143   - $(element).closest('.form-group').removeClass('has-error');
144   - },
145   -
146   - success : function(label) {
147   - label.closest('.form-group').removeClass('has-error');
148   - },
149   -
150   - submitHandler : function(f) {
151   - var params = form.serializeJSON();
152   - error.hide();
153   -
154   - $.ajax({
155   - url: '/user/register',
156   - type: 'POST',
157   - traditional: true,
158   - data: params,
159   - success: function(rs){
160   - if(!rs){
161   - layer.msg('未知异常!');
162   - }
163   - if(rs.status=='SUCCESS'){
164   - layer.msg('添加用户成功.');
165   - loadPage('list.html');
166   - }
167   - else if(rs.status=='ERROR'){
168   - layer.msg('添加失败[ ' + rs.msg + ']');
169   - }
170   - }
171   - });
172   - /*$get('/user/all', {userName_eq: params.userName}, function(list){
173   - if(!list || list.length == 0){
174   - console.log(params);
175   - $.ajax({
176   - url: '/user',
177   - type: 'POST',
178   - traditional: true,
179   - data: params,
180   - success: function(res){
181   - layer.msg('添加用户成功.');
182   - loadPage('list.html');
183   - }
184   - });
185   - /!* $post('/user', params, function(res){
186   - layer.msg('添加用户成功.');
187   - loadPage('list.html');
188   - }); *!/
189   - }
190   - else
191   - layer.alert('用户【' + params.userName + '】已存在', {icon: 2, title: '提交被拒绝'});
192   - });*/
193   - }
194   - });
195   - });
  1 +<div class="page-head">
  2 + <div class="page-title">
  3 + <h1>添加用户</h1>
  4 + </div>
  5 +</div>
  6 +
  7 +<ul class="page-breadcrumb breadcrumb">
  8 + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
  9 + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
  10 + <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li>
  11 + <li><span class="active">添加用户</span></li>
  12 +</ul>
  13 +
  14 +<div class="portlet light bordered">
  15 + <div class="portlet-title">
  16 + <div class="caption">
  17 + <i class="icon-equalizer font-red-sunglo"></i> <span
  18 + class="caption-subject font-red-sunglo bold uppercase">表单</span>
  19 + </div>
  20 + </div>
  21 + <div class="portlet-body form">
  22 + <form action="/addUser" class="form-horizontal" id="user_add_form" >
  23 + <div class="alert alert-danger display-hide">
  24 + <button class="close" data-close="alert"></button>
  25 + 您的输入有误,请检查下面的输入项
  26 + </div>
  27 + <div class="form-body">
  28 + <div class="form-group">
  29 + <label class="col-md-3 control-label">登录名</label>
  30 + <div class="col-md-4">
  31 + <input type="text" class="form-control" name="userName" >
  32 + <span class="help-block"> 登录时的帐号</span>
  33 + </div>
  34 + </div>
  35 + <div class="form-group">
  36 + <label class="col-md-3 control-label">姓名</label>
  37 + <div class="col-md-4">
  38 + <input type="text" class="form-control" name="name" >
  39 + </div>
  40 + </div>
  41 + <div class="form-group">
  42 + <label class="col-md-3 control-label">密码</label>
  43 + <div class="col-md-4">
  44 + <input type="password" class="form-control" id="password" name="password" >
  45 + <!--<span class="help-block"> 请输入6位以上密码</span>-->
  46 + </div>
  47 + </div>
  48 + <div class="form-group">
  49 + <label class="col-md-3 control-label">确认密码</label>
  50 + <div class="col-md-4">
  51 + <input type="password" class="form-control" name="cfmPassword" >
  52 + <span class="help-block"> 请重新输入密码</span>
  53 + </div>
  54 + </div>
  55 + <div class="form-group">
  56 + <label class="col-md-3 control-label">所属机构</label>
  57 + <div class="col-md-4">
  58 + <input type="text" class="form-control" name="agencies" >
  59 + </div>
  60 + </div>
  61 +
  62 + <div class="form-group">
  63 + <label class="col-md-3 control-label">角色</label>
  64 + <div class="col-md-4">
  65 + <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple">
  66 +
  67 + </select>
  68 + </div>
  69 + </div>
  70 +
  71 + <div class="form-group">
  72 + <label class="col-md-3 control-label">是否启用</label>
  73 + <div class="col-md-4">
  74 + <div class="input-group">
  75 + <select class="form-control" name="enabled" style="width: 160px;">
  76 + <option value="1">可用</option>
  77 + <option value="0">禁用</option>
  78 + </select>
  79 + </div>
  80 + </div>
  81 + </div>
  82 + </div>
  83 + <div class="form-actions">
  84 + <div class="row">
  85 + <div class="col-md-offset-3 col-md-4">
  86 + <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button>
  87 + <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
  88 + </div>
  89 + </div>
  90 + </div>
  91 + </form>
  92 + <!-- END FORM-->
  93 + </div>
  94 +</div>
  95 +<script>
  96 + $(function(){
  97 + /*$get('/role/all',null,function(result){
  98 + $.each(result,function(i,obj){
  99 + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
  100 + });
  101 + });*/
  102 +
  103 + // 查询下级角色
  104 + $.get('/role/findSubordinate', function (rs) {
  105 + if(rs.status == "SUCCESS"){
  106 + if(rs.list.length < 1){
  107 + loadPage('/pages/permission/role/add.html');
  108 + layer.open({
  109 + // type: 2,
  110 + content: '用户需要有下级角色才能添加用户!',
  111 + title: '请添加下级角色',
  112 + shift: 5,
  113 + scrollbar: false
  114 + });
  115 + return;
  116 + }
  117 +
  118 + $.each(rs.list,function(i,obj){
  119 + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
  120 + });
  121 + }else {
  122 + loadPage('/pages/permission/role/list.html');
  123 + layer.open({
  124 + // type: 2,
  125 + content: rs.msg,
  126 + title: "用户的下级角色有问题",
  127 + shift: 5,
  128 + scrollbar: false
  129 + });
  130 + }
  131 + });
  132 +
  133 +
  134 + var form = $('#user_add_form');
  135 + var error = $('.alert-danger', form);
  136 +
  137 + $.validator.addMethod("passwordrule", function(value, element) {
  138 + var userblank = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-.]).{8,16}$/;
  139 + //var userblank = /^(?=.*[a-zA-Z])(?=.*\d).{8,16}$/;
  140 + return this.optional(element) ||(userblank.test(value));
  141 + }, "需包含大小写字母、数字、以及特殊符号的8-16位字符,并不能有123、abc这样的连续字符");
  142 +
  143 + //表单 validate
  144 + form.validate({
  145 + errorElement : 'span',
  146 + errorClass : 'help-block help-block-error',
  147 + focusInvalid : false,
  148 + rules : {
  149 + 'userName' : {
  150 + required : true,
  151 + maxlength: 25
  152 + },
  153 + 'name' : {
  154 + required : true,
  155 + maxlength: 25
  156 + },
  157 + 'password' : {
  158 + required : true,
  159 + minlength: 8,
  160 + maxlength: 16,
  161 + passwordrule: true
  162 + },
  163 + 'cfmPassword' : {
  164 + equalTo: '#password'
  165 + },
  166 + 'roles[]' : {
  167 + required : true,
  168 + minlength: 1
  169 + }
  170 + },
  171 + invalidHandler : function(event, validator) {
  172 + error.show();
  173 + App.scrollTo(error, -200);
  174 + },
  175 +
  176 + highlight : function(element) {
  177 + $(element).closest('.form-group').addClass('has-error');
  178 + },
  179 +
  180 + unhighlight : function(element) {
  181 + $(element).closest('.form-group').removeClass('has-error');
  182 + },
  183 +
  184 + success : function(label) {
  185 + label.closest('.form-group').removeClass('has-error');
  186 + },
  187 +
  188 + submitHandler : function(f) {
  189 + var params = form.serializeJSON();
  190 + error.hide();
  191 +
  192 + var keys;
  193 + $.ajax({
  194 + url: "/user/login/jCryptionKey?t="+Math.random(),
  195 + type: "Get",
  196 + async:false,
  197 + data: null,
  198 + success: function(data) {
  199 + keys = data.publickey;
  200 + }
  201 + });
  202 + //RSA加密
  203 + var encrypt = new JSEncrypt();
  204 + encrypt.setPublicKey(keys);
  205 + params.userName = encrypt.encrypt(params.userName);
  206 + params.password = encrypt.encrypt(params.password);
  207 + $.ajax({
  208 + url: '/user/register',
  209 + type: 'POST',
  210 + traditional: true,
  211 + data: params,
  212 + success: function(rs){
  213 + if(!rs){
  214 + layer.msg('未知异常!');
  215 + }
  216 + if(rs.status=='SUCCESS'){
  217 + layer.msg('添加用户成功.');
  218 + loadPage('list.html');
  219 + }
  220 + else if(rs.status=='ERROR'){
  221 + layer.msg('添加失败[ ' + rs.msg + ']');
  222 + }
  223 + }
  224 + });
  225 + }
  226 + });
  227 + });
196 228 </script>
197 229 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/authorize.html 0 → 100644
  1 +<!--<!DOCTYPE html>-->
  2 +<html lang="zh-cn">
  3 +
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
  7 + <script src="/assets/js/common.js"></script>
  8 + <script src="/assets/plugins/uk3.0/uikit.min.js"></script>
  9 + <script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script>
  10 + <script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js"></script>
  11 + <!-- EventProxy -->
  12 + <script src="/assets/js/eventproxy.js"></script>
  13 + <!-- art-template 模版引擎 -->
  14 + <script src="/assets/plugins/template.js"></script>
  15 + <script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script>
  16 + <script src="/assets/plugins/ztree_v3/js/jquery.ztree.core.min.js"></script>
  17 + <script src="/assets/plugins/ztree_v3/js/jquery.ztree.excheck.min.js"></script>
  18 + <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/>
  19 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" />
  20 + <link rel="stylesheet" href="/assets/plugins/ztree_v3/css/zTreeStyle/zTreeStyle.css" />
  21 + <style>
  22 + html,body{
  23 + height: 100%;
  24 + }
  25 + .ct_page{
  26 + padding: 25px 15px;
  27 + height: 100%;
  28 + height: calc(100% - 50px);
  29 + }
  30 +
  31 + .ct_cont{
  32 + height: calc(100% - 41px);
  33 + }
  34 +
  35 + .ct_cont>div>div.uk-card{
  36 + height: 99%;
  37 + }
  38 +
  39 + form .uk-inline{
  40 + width: calc(100% - 4px);
  41 + margin-left: 2px;
  42 + }
  43 +
  44 + .ct-card-body{
  45 + overflow: auto;
  46 + padding: 1px 1px 0 2px;
  47 + height: calc(100% - 54px);
  48 + position: relative;
  49 + margin-top: -12px;
  50 + }
  51 +
  52 + .ct_li_desc{
  53 + color: #a8a8a8;
  54 + font-size: 13px;
  55 + }
  56 +
  57 + .ct-card-body .uk-list-large{
  58 + font-size: 14px;
  59 + }
  60 +
  61 + .ct-card-body .uk-list-large>li{
  62 + cursor: default;
  63 + padding-left: 20px;
  64 + margin-top: 2px !important;
  65 + padding-top: 17px !important;
  66 + position: relative;
  67 + }
  68 +
  69 + .ct-card-body .uk-list-large>li:hover{
  70 + background: #edecec;
  71 + }
  72 +
  73 + .ct-card-body .uk-list-large>li.active{
  74 + background: #1e87f0 !important;
  75 + color: white;
  76 + }
  77 +
  78 + .ct-card-body .uk-list-large>li.active>span.role-code{
  79 + color: #ffffff;
  80 + }
  81 +
  82 + .ct-card-body .uk-list-large.role-list>li:hover{
  83 + background: #fff494;
  84 + }
  85 +
  86 + .ct-card-body .uk-list-large>li.active .ct_li_desc{
  87 + color: #e6e6e6;
  88 + }
  89 +
  90 + .ct-card-body .uk-list-large>li>span.uk-badge{
  91 + position: absolute;
  92 + top: 17px;
  93 + right: 25px;
  94 + }
  95 +
  96 + .ct-card-body .uk-list-large>li>span.role-code{
  97 + padding: 4px 6px;
  98 + color: #a8a8a8;
  99 + margin-left: 5px;
  100 + }
  101 +
  102 + .top_title{
  103 + padding: 9px 0 5px 15px;
  104 + border-bottom: 1px solid #ededed;
  105 + border-left: 5px solid #FFC107;
  106 + }
  107 +
  108 + .top_title>.desc{
  109 + font-size: 13px;
  110 + color: grey;
  111 + margin-top: 3px;
  112 + }
  113 +
  114 + .left_menu_list{
  115 + overflow: auto;
  116 + position: relative;
  117 + }
  118 +
  119 + .left_menu_list .ps-container > .ps-scrollbar-x-rail, .ps-container > .ps-scrollbar-y-rail{
  120 + opacity: 0.6 !important;
  121 + padding: 0 !important;
  122 + }
  123 +
  124 + ._company{
  125 + margin: 15px 0px;
  126 + }
  127 + ._company>h5{
  128 + margin-bottom: 10px;
  129 + font-size: 15px;
  130 + color: #6b6b6b;
  131 + text-indent: 12px;
  132 + }
  133 + ._company>._fgs>label{
  134 + padding: 3px 12px 3px 10px;
  135 + display: inline-block;
  136 + border: 1px solid gainsboro;
  137 + border-radius: 2px;
  138 + margin: 5px;
  139 + font-size: 14px;
  140 + }
  141 + ._company>._fgs>label.active{
  142 + background: #1e87f0;
  143 + color: #fff;
  144 + }
  145 + ._company .uk-checkbox:checked:focus,
  146 + .line_checkbox_list .uk-checkbox:checked:focus{
  147 + background-color: #1e87f0 !important;
  148 + }
  149 + .save_icon{
  150 + position: absolute;
  151 + right: 2px;
  152 + background: #bec4c9;
  153 + font-size: 12px;
  154 + padding: 2px 15px;
  155 + color: #fff;
  156 + box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  157 + cursor: pointer;
  158 + }
  159 + .save_icon:hover{
  160 + background: #FFC107;
  161 + }
  162 + .data_auth_list{
  163 + position: relative;
  164 + }
  165 + #user_authorize_wrap .top_title{
  166 + border-left: 5px solid #cacac8;
  167 + }
  168 + .xd_line_list{
  169 + height: 37%;
  170 + padding: 7px;
  171 + border-bottom: 1px solid #f2f2f2;
  172 + overflow: auto;
  173 + position: relative;
  174 + }
  175 + .xd_line_list>h5{
  176 + color: #858585;
  177 + margin: 5px 5px 5px 0;
  178 + font-size: 14px;
  179 + }
  180 + .sub_lines{
  181 + padding-left: 15px;
  182 + }
  183 + .sub_lines>span.line_btn {
  184 + background: #00BCD4;
  185 + color: #fff;
  186 + padding: 4px 9px;
  187 + display: inline-block;
  188 + min-width: 68px;
  189 + text-align: center;
  190 + margin: 5px 2px;
  191 + box-shadow: 0 5px 9px rgba(0,0,0,0.08);
  192 + cursor: pointer;
  193 + font-size: 14px;
  194 + font-family: 微软雅黑;
  195 + }
  196 +
  197 + .sub_lines>span.line_btn.destroy{
  198 + background: #ff5c5c;
  199 + }
  200 +
  201 + .sub_lines>span.line_btn.destroy:hover{
  202 + background: #ff7373;
  203 + }
  204 +
  205 + .sub_lines>span.line_btn:hover{
  206 + background: #2dd7ed;
  207 + }
  208 + .add_line_icon{
  209 + cursor: pointer;
  210 + padding: 2px 5px;
  211 + border-radius: 5px;
  212 + display: inline-block;
  213 + }
  214 + .add_line_icon>i{
  215 + vertical-align: top;
  216 + margin-top: 3px;
  217 + }
  218 + .add_line_icon:hover{
  219 + background: #ededed;
  220 + }
  221 + .ct_pattern_form{
  222 + display: inline-block;
  223 + }
  224 + .xd_menu_grid{
  225 + padding: 25px 25px 0 25px;
  226 + height: calc(63% - 91px);
  227 + }
  228 + .xd_menu_grid .uk-list{
  229 + border: 1px solid #ededed;
  230 + height: calc(100% - 70px);
  231 + overflow: auto;
  232 + position: relative;
  233 + }
  234 +
  235 + .xd_menu_grid .uk-list>li{
  236 + margin: 5px 0 !important;
  237 + padding: 10px 0 0 10px !important;
  238 + font-size: 14px;
  239 + }
  240 + .top_tools{
  241 + position: absolute;
  242 + top: 15px;
  243 + right: 25px;
  244 + }
  245 + .ct_field {
  246 + display: inline-block;
  247 + width: 240px;
  248 + }
  249 + .ct_field>select,.ct_field>input{
  250 + width: calc(100% - 60px);
  251 + }
  252 + .line_checkbox_list{
  253 + margin-top: 15px;
  254 + }
  255 + .line_checkbox_list>.btn{
  256 + padding: 5px 7px;
  257 + border-radius: 2px;
  258 + display: inline-block;
  259 + margin: 4px 9px;
  260 + font-size: 14px;
  261 + font-family: 微软雅黑;
  262 + border: 1px solid #d9d9d9;
  263 + width: 100px;
  264 + overflow: hidden;
  265 + text-overflow: ellipsis;
  266 + white-space: nowrap;
  267 + }
  268 + .line_checkbox_list>.btn>input{
  269 + margin-right: 5px;
  270 + }
  271 + .line_checkbox_list>.btn.active{
  272 + background: #1e87f0;
  273 + color: #fff;
  274 + }
  275 +
  276 + .line_checkbox_list>.btn.destroy,
  277 + .line_checkbox_list>.btn.destroy>input{
  278 + border-color: #ff9595;
  279 + color: #ff5c5c;
  280 + }
  281 +
  282 + .line_checkbox_list>.btn.destroy.active{
  283 + background: #ff5c5c;
  284 + color: #fff;
  285 + }
  286 +
  287 + .line_checkbox_list>.btn.destroy.active>input{
  288 + background-color: #ff5c5c !important;
  289 + border-color: #ff5c5c !important;
  290 + }
  291 +
  292 + #role_authorize_wrap .ztree *{
  293 + font-size: 14px;
  294 + }
  295 + #role_authorize_wrap .ztree li{
  296 + line-height: 21px;
  297 + }
  298 + .loading{
  299 + height: 100%;
  300 + text-align: center;
  301 + }
  302 + .loading .uk-spinner{
  303 + margin-top: 200px;
  304 + }
  305 + .loading circle{
  306 + stroke: red;
  307 + }
  308 +
  309 + #select_line_modal .uk-checkbox:checked {
  310 + background-color: #1e87f0;
  311 + }
  312 + </style>
  313 +
  314 +</head>
  315 +
  316 +<body>
  317 +<div class="loading">
  318 + <div uk-spinner></div>
  319 +</div>
  320 +<div class="ct_page" style="display: none;">
  321 + <h2 class="uk-heading-line uk-heading-bullet"><span>用户授权管理</span></h2>
  322 + <div class="ct_cont uk-grid-small uk-child-width-expand" uk-grid>
  323 + <div class="role_list uk-width-1-4 ">
  324 + <div class="uk-card uk-card-default">
  325 + <form>
  326 + <div class="uk-margin">
  327 + <div class="uk-inline" >
  328 + </div>
  329 + </div>
  330 + </form>
  331 +
  332 + <div class="ct-card-body" >
  333 + <ul class="uk-list uk-list-large uk-list-divider role-list">
  334 + </ul>
  335 + </div>
  336 + </div>
  337 + </div>
  338 + <div class="user_list uk-width-1-5 ">
  339 + <div class="uk-card uk-card-default">
  340 + <form>
  341 + <div class="uk-margin">
  342 + <div class="uk-inline" >
  343 + </div>
  344 + </div>
  345 + </form>
  346 +
  347 + <div class="ct-card-body">
  348 + <ul class="uk-list uk-list-large user-list">
  349 + </ul>
  350 + </div>
  351 + </div>
  352 + </div>
  353 + <div class="auth_cont ">
  354 + <div class="uk-card uk-card-default authorize_right_cont">
  355 +
  356 + </div>
  357 + </div>
  358 +
  359 + </div>
  360 +</div>
  361 +
  362 +<script id="authorize-role-list-temp1" type="text/html">
  363 + {{each list as r i}}
  364 + <li data-id="{{r.id}}" data-name="{{r.roleName}}" data-code="{{r.codeUp}}">{{r.roleName}}
  365 + <span class="role-code">{{r.codeName}}</span>
  366 + <div class="ct_li_desc">{{r.createDateStr}}</div>
  367 + <span class="uk-badge">{{r.count}}</span>
  368 + </li>
  369 + {{/each}}
  370 +</script>
  371 +<script id="authorize-user-list-temp1" type="text/html">
  372 + {{each list as u i}}
  373 + <li class="uk-animation-fade uk-animation-fast" data-name="{{u.name}}" data-code="{{u.userNameUp}}" data-id="{{u.id}}">{{u.name}}<span class="role-code">{{u.userName}}</span></li>
  374 + {{/each}}
  375 +</script>
  376 +<script>
  377 + var storage = window.localStorage;
  378 +
  379 + if (typeof String.prototype.startsWith != 'function') {
  380 + String.prototype.startsWith = function (prefix){
  381 + return this.slice(0, prefix.length) === prefix;
  382 + };
  383 + }
  384 + var roles,users,role_users,modules,companyData,lineArray;
  385 +
  386 + var ep = EventProxy.create('query_roles', 'query_users', 'query_modules', 'query_company', 'query_line', function (rs, us, ms, cs, lines) {
  387 + roles = rs;
  388 + users = us;
  389 + modules = ms;
  390 + companyData = cs;
  391 + lineArray=lines;
  392 + role_users = {};
  393 + for(var i=0,r;r=roles[i++];){
  394 + r.count=0;
  395 + role_users[r.id]=[];
  396 + r.createDateStr=moment(r.createDate).format('YYYY-MM-DD HH:ss');
  397 + r.codeUp=r.codeName.toUpperCase();
  398 + for(var j=0,u;u=users[j++];){
  399 + if(u.roles.indexOf(r.id)!=-1){
  400 + r.count++;
  401 + role_users[r.id].push(u);
  402 + }
  403 + }
  404 + }
  405 + //渲染角色list
  406 + render_role_list(roles);
  407 + //渲染用户list
  408 + render_user_list(users);
  409 +
  410 + $('.loading').remove();
  411 + $('.ct_page').show();
  412 + });
  413 +
  414 + //角色点击
  415 + $('ul.role-list').on('click', 'li', roleClickHanlder);
  416 + //用户点击
  417 + $('ul.user-list').on('click', 'li', userClickHanlder);
  418 +
  419 +
  420 + function roleClickHanlder() {
  421 + if($(this).hasClass('active') && $('ul.user-list>li.active').length==0)
  422 + return;
  423 +
  424 + reset_dom();
  425 + $('ul.role-list>li.active').removeClass('active');
  426 + $(this).addClass('active');
  427 + //重新渲染用户list
  428 + var id = $(this).data('id');
  429 + render_user_list(role_users[id]);
  430 + //加载角色授权页面
  431 + $('.authorize_right_cont').load('/pages/permission/authorize_all/role_auth.html', function () {
  432 + $('#role_authorize_wrap', this).trigger('init', {role: get_role(id), modules: modules, companyData: companyData});
  433 + });
  434 + }
  435 +
  436 + function userClickHanlder() {
  437 + if($(this).hasClass('active'))
  438 + return;
  439 +
  440 + reset_dom();
  441 + $('ul.user-list>li.active').removeClass('active');
  442 + $(this).addClass('active');
  443 +
  444 + //加载用户授权页面
  445 + var id = $(this).data('id');
  446 + $('.authorize_right_cont').load('/pages/permission/authorize_all/user_auth.html', function () {
  447 + $('#user_authorize_wrap', this).trigger('init', {user: get_user(id),lineArray:lineArray, companyData:companyData});
  448 + });
  449 + }
  450 +
  451 + //refresh-user
  452 + $('.authorize_right_cont').on('refresh-user', function () {
  453 + $('ul.user-list>li.active').removeClass('active').trigger('click');
  454 + });
  455 +
  456 + function reset_dom() {
  457 + $('#select_line_modal').remove();
  458 + }
  459 +
  460 + //滚动条
  461 + $('.ct_page .uk-card .ct-card-body').perfectScrollbar({suppressScrollX: true});
  462 +
  463 + //query all role
  464 + var paramsRole = {};
  465 + paramsRole['codeName'] = 'ROLE_ADMIN';
  466 + var userId=storage.getItem("editUser");
  467 + $get('/user',{id_eq:userId}, function (rs) {
  468 + ep.emit('query_roles', rs.content[0].roles);
  469 + });
  470 +
  471 +
  472 + //query all user
  473 + var paramsUser = {};
  474 + paramsRole['name'] = 'name';
  475 + $.get('/user/all_distinct',paramsUser, function (rs) {
  476 + var userA={};
  477 + for(var i=0,u;u=rs[i++];){
  478 + if (u.id==userId){
  479 + discard_field(u);
  480 + u.userNameUp=u.userName.toUpperCase();
  481 + u.lastLoginDateStr=moment(u.lastLoginDate).format('YYYY-MM-DD HH:ss');
  482 + userA[0]=u;
  483 + }
  484 + }
  485 + ep.emit('query_users', userA);
  486 + });
  487 +
  488 + //query all modules
  489 + $.get('/module/all_distinct', function (rs) {
  490 + ep.emit('query_modules', rs);
  491 + });
  492 +
  493 + //query all company data
  494 + $.get('/business/all', function (rs) {
  495 + ep.emit('query_company', rs);
  496 + });
  497 +
  498 + //query all line
  499 + $.get('/line/all', {'remove_ne': 1}, function (rs) {
  500 + ep.emit('query_line', rs);
  501 + });
  502 +
  503 + function discard_field(u) {
  504 + var array = [];
  505 + $.each(u.roles, function () {
  506 + array.push(this.id);
  507 + });
  508 + u.roles = array;
  509 + }
  510 +
  511 + function render_role_list(list) {
  512 + var htmlStr = template('authorize-role-list-temp1', {list: list});
  513 + $('ul.role-list').html(htmlStr);
  514 + up_scroll();
  515 + }
  516 +
  517 +
  518 + function render_user_list(list) {
  519 + var htmlStr = template('authorize-user-list-temp1', {list: list});
  520 + $('ul.user-list').html(htmlStr);
  521 + up_scroll();
  522 + }
  523 +
  524 + function reset_role_list(){
  525 + var actives = $('ul.role-list>li.active');
  526 + if(actives.length > 0){
  527 + $('ul.role-list>li.active').removeClass('active');
  528 + render_user_list(users);
  529 + $('.authorize_right_cont').empty();
  530 + }
  531 + }
  532 +
  533 + function up_scroll() {
  534 + $('.ct_page .uk-card .ct-card-body').perfectScrollbar('update');
  535 + }
  536 +
  537 +
  538 +
  539 + function get_role(id) {
  540 + for(var i=0,r;r=roles[i++];){
  541 + if(r.id==id)
  542 + return r;
  543 + }
  544 + return null;
  545 + }
  546 +
  547 + function get_user(id) {
  548 + for(var i=0,u;u=users[i++];){
  549 + if(u.id==id)
  550 + return u;
  551 + }
  552 + return null;
  553 + }
  554 +
  555 + $(document).on('submit', 'form', function () {
  556 + return false;
  557 + });
  558 +
  559 + function convert_buss_data(rs) {
  560 + var baseCode;
  561 + //找到跟节点
  562 + $.each(rs, function () {
  563 + if(this.upCode == 0){
  564 + baseCode=this.businessCode;
  565 + return false;
  566 + }
  567 + });
  568 + if(!baseCode){
  569 + alert('大爷找不到根节点,数据有问题吧!!!');
  570 + return;
  571 + }
  572 + //提取二级节点
  573 + var secondMap={};
  574 + $.each(rs, function () {
  575 + if(this.upCode==baseCode){
  576 + secondMap[this.businessCode] = {
  577 + name: this.businessName,
  578 + childs: []
  579 + };
  580 + }
  581 + });
  582 + //分公司节点
  583 + $.each(rs, function () {
  584 + if(secondMap[this.upCode])
  585 + secondMap[this.upCode].childs.push(this);
  586 + });
  587 +
  588 + //排序
  589 + for(var sid in secondMap){
  590 + secondMap[sid].childs.sort(naturalSort);
  591 + }
  592 +
  593 + return secondMap;
  594 + }
  595 +
  596 + var naturalSort=function (a, b) {
  597 + return a.businessName.localeCompare(b.businessName);
  598 + };
  599 +
  600 + var groupBy = function (list, field) {
  601 + var rs = {},
  602 + key;
  603 + $.each(list, function () {
  604 + key = this[field];
  605 + if (!rs[key])
  606 + rs[key] = [];
  607 +
  608 + rs[key].push(this);
  609 + });
  610 +
  611 + return rs;
  612 + };
  613 +</script>
  614 +</body>
  615 +</html>
0 616 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/changePWD.html
1   -<div class="row">
2   -<div class="col-md-12">
3   -<!-- BEGIN VALIDATION STATES-->
4   -<div class="portlet light portlet-fit portlet-form bordered">
5   -<div class="portlet-body">
6   - <form class="form-horizontal" id="changePWDForm">
7   - <div class="form-group" style="margin-top: 60px">
8   - <label class="control-label col-md-5">原始密码:
9   - </label>
10   - <div class="col-md-4">
11   - <div class="input-icon right">
12   - <i class="fa"></i>
13   - <input type="password" class="form-control" name="oldPWD" /> </div>
14   - </div>
15   - </div>
16   - <div class="form-group">
17   - <label class="control-label col-md-5">输入新密码:
18   - </label>
19   - <div class="col-md-4">
20   - <div class="input-icon right">
21   - <i class="fa"></i>
22   - <input type="password" class="form-control" name="newPWD" /> </div>
23   - </div>
24   - </div>
25   - <div class="form-group">
26   - <label class="control-label col-md-5">确认新密码:
27   - </label>
28   - <div class="col-md-4">
29   - <div class="input-icon right">
30   - <i class="fa"></i>
31   - <input type="password" class="form-control" name="cnewPWD" /> </div>
32   - </div>
33   - </div>
34   - <div class="form-actions">
35   - <div class="row">
36   - <div class="col-md-offset-5 col-md-7">
37   - <button type="button" id="confirm" class="btn green">确定</button>
38   - <button type="reset" class="btn default">取消</button>
39   - </div>
40   - </div>
41   - </div>
42   - </form>
43   -</div>
44   -</div>
45   -</div>
46   -</div>
47   -
48   -<script>
49   -$(function(){
50   - $("#confirm").on("click",function(){
51   - var data = $('#changePWDForm').serializeJSON();
52   - $.post('/user/changePWD',data,function(msg){
53   - layer.alert(msg);
54   - });
55   - });
56   -});
  1 +<div class="row">
  2 +<div class="col-md-12">
  3 +<!-- BEGIN VALIDATION STATES-->
  4 +<div class="portlet light portlet-fit portlet-form bordered">
  5 +<div class="portlet-body">
  6 + <form class="form-horizontal" id="changePWDForm">
  7 + <div class="alert alert-danger display-hide">
  8 + <button class="close" data-close="alert"></button>您的输入有误,请检查下面的输入项
  9 + </div>
  10 + <div class="form-group" style="margin-top: 60px">
  11 + <label class="control-label col-md-5">原始密码:
  12 + </label>
  13 + <div class="col-md-4">
  14 + <div class="input-icon right">
  15 + <i class="fa"></i>
  16 + <input type="password" class="form-control" name="oldPWD" /> </div>
  17 + </div>
  18 + </div>
  19 + <div class="form-group">
  20 + <label class="control-label col-md-5">输入新密码:
  21 + </label>
  22 + <div class="col-md-4">
  23 + <div class="input-icon right">
  24 + <i class="fa"></i>
  25 + <input type="password" class="form-control" name="newPWD" id="newPWD"/> </div>
  26 + </div>
  27 + </div>
  28 + <div class="form-group">
  29 + <label class="control-label col-md-5">确认新密码:
  30 + </label>
  31 + <div class="col-md-4">
  32 + <div class="input-icon right">
  33 + <i class="fa"></i>
  34 + <input type="password" class="form-control" name="cnewPWD" /> </div>
  35 + </div>
  36 + </div>
  37 + <div class="form-actions">
  38 + <div class="row">
  39 + <div class="col-md-offset-5 col-md-7">
  40 + <button type="submit" id="confirm" class="btn green">确定</button>
  41 + <button type="reset" class="btn default">取消</button>
  42 + </div>
  43 + </div>
  44 + </div>
  45 + </form>
  46 +</div>
  47 +</div>
  48 +</div>
  49 +</div>
  50 +
  51 +<script>
  52 +$(function(){
  53 + var form = $('#changePWDForm');
  54 + //表单 validate
  55 + var error = $('.alert-danger', form);
  56 +
  57 + var validate = function (pwd) {
  58 + var flag = true;
  59 + for (var i = 1; i < pwd.length - 1; i++) {
  60 + var first = pwd.charCodeAt(i - 1);
  61 + var second = pwd.charCodeAt(i);
  62 + var third = pwd.charCodeAt(i + 1);
  63 + if (!(first >= 48 && third <= 57 || first >= 65 && third <= 90 || first >= 97 && third <= 122)) {
  64 + continue;
  65 + }
  66 + if (third - second == 1 && second - first == 1) {
  67 + flag = false;
  68 + }
  69 + }
  70 +
  71 + return flag;
  72 + }
  73 +
  74 + $.validator.addMethod("passwordrule", function(value, element) {
  75 + var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-.]).{8,16}$/;
  76 + return this.optional(element) || reg.test(value) && validate(value);
  77 + }, "需包含大小写字母、数字、以及特殊符号的8-16位字符,并不能有123、abc这样的连续字符");
  78 +
  79 + //表单 validate
  80 + form.validate({
  81 + errorElement : 'span',
  82 + errorClass : 'help-block help-block-error',
  83 + focusInvalid : false,
  84 + rules : {
  85 + 'newPWD' : {
  86 + required : true,
  87 + minlength: 6,
  88 + maxlength: 16,
  89 + passwordrule:true
  90 + },
  91 + 'cnewPWD' : {
  92 + equalTo: '#newPWD'
  93 + }
  94 + },
  95 + invalidHandler : function(event, validator) {
  96 + error.show();
  97 + App.scrollTo(error, -200);
  98 + },
  99 +
  100 + highlight : function(element) {
  101 + $(element).closest('.form-group').addClass('has-error');
  102 + },
  103 +
  104 + unhighlight : function(element) {
  105 + $(element).closest('.form-group').removeClass('has-error');
  106 + },
  107 +
  108 + success : function(label) {
  109 + label.closest('.form-group').removeClass('has-error');
  110 + },
  111 +
  112 + submitHandler : function(f) {
  113 + var params = form.serializeJSON();
  114 + error.hide();
  115 + var keys;
  116 + $.ajax({
  117 + url: "/user/login/jCryptionKey?t="+Math.random(),
  118 + type: "Get",
  119 + async:false,
  120 + data: null,
  121 + success: function(data) {
  122 + keys = data.publickey;
  123 + }
  124 + });
  125 + //RSA加密
  126 + var encrypt = new JSEncrypt();
  127 + encrypt.setPublicKey(keys);
  128 + params.oldPWD = encrypt.encrypt(params.oldPWD);
  129 + params.newPWD = encrypt.encrypt(params.newPWD);
  130 + params.cnewPWD = encrypt.encrypt(params.cnewPWD);
  131 + $.ajax({
  132 + url: '/user/changePWD',
  133 + type: 'POST',
  134 + traditional: true,
  135 + data: params,
  136 + success: function(msg){
  137 + layer.alert(msg);
  138 + layer.closeAll('page');
  139 + }
  140 + });
  141 + }
  142 + });
  143 +});
57 144 </script>
58 145 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/edit.html
1   -<div class="page-head">
2   - <div class="page-title">
3   - <h1>编辑用户</h1>
4   - </div>
5   -</div>
6   -
7   -<ul class="page-breadcrumb breadcrumb">
8   - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
9   - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
10   - <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li>
11   - <li><span class="active">编辑用户</span></li>
12   -</ul>
13   -
14   -<div class="portlet light bordered">
15   - <div class="portlet-title">
16   - <div class="caption">
17   - <i class="icon-equalizer font-red-sunglo"></i> <span
18   - class="caption-subject font-red-sunglo bold uppercase">表单</span>
19   - </div>
20   - </div>
21   - <div class="portlet-body form">
22   - <form action="/addUser" class="form-horizontal" id="user_edit_form" >
23   - <div class="alert alert-danger display-hide">
24   - <button class="close" data-close="alert"></button>
25   - 您的输入有误,请检查下面的输入项
26   - </div>
27   - <div class="form-body">
28   - <div class="form-group">
29   - <label class="col-md-3 control-label">登录名</label>
30   - <div class="col-md-4">
31   - <input type="hidden" id="id" name="id">
32   - <input type="text" class="form-control" id="userName" name="userName" readonly="readonly">
33   - <span class="help-block"> 登录时的帐号</span>
34   - </div>
35   - </div>
36   - <div class="form-group">
37   - <label class="col-md-3 control-label">姓名</label>
38   - <div class="col-md-4">
39   - <input type="text" class="form-control" id="name" name="name" readonly="readonly">
40   - </div>
41   - </div>
42   - <div class="form-group">
43   - <label class="col-md-3 control-label">所属机构</label>
44   - <div class="col-md-4">
45   - <input type="text" class="form-control" id="agencies" name="agencies" >
46   - </div>
47   - </div>
48   -
49   - <div class="form-group">
50   - <label class="col-md-3 control-label">角色</label>
51   - <div class="col-md-4">
52   - <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple">
53   -
54   - </select>
55   - </div>
56   - </div>
57   -
58   - <div class="form-group">
59   - <label class="col-md-3 control-label">是否启用</label>
60   - <div class="col-md-4">
61   - <div class="input-group">
62   - <select class="form-control" id="enabled" name="enabled" style="width: 160px;">
63   - <option value="1">可用</option>
64   - <option value="0">禁用</option>
65   - </select>
66   - </div>
67   - </div>
68   - </div>
69   - </div>
70   - <div class="form-actions">
71   - <div class="row">
72   - <div class="col-md-offset-3 col-md-4">
73   - <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button>
74   - <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
75   - </div>
76   - </div>
77   - </div>
78   - </form>
79   - <!-- END FORM-->
80   - </div>
81   -</div>
82   -<script>
83   - $(function(){
84   - var id = $.url().param('no');
85   - if(id){
86   - $get('/user/'+id,null,function(obj){
87   - $("#id").attr('value',obj.id);
88   - $("#userName").attr('value',obj.userName);
89   - $("#name").attr('value',obj.name);
90   - $("#agencies").attr('value',obj.agencies);
91   - $get('/role/all',null,function(result){
92   - $.each(result,function(i,r){
93   - $("#role").append("<option value='"+r.id+"'>"+r.roleName+"</option>");
94   - });
95   - $.each(obj.roles,function(i,obt){
96   - $("#role option[value="+obt.id+"]").attr("selected",true);
97   - });
98   - });
99   - if(obj.enabled){
100   - $("#enabled option[value=1]").attr("selected",true);
101   - }else{
102   - $("#enabled option[value=0]").attr("selected",true);
103   - }
104   - });
105   -
106   - }else {
107   -
108   - // 缺少ID
109   - layer.confirm('【ID缺失,请点击返回,重新进行修改操作】', {btn : [ '返回' ],icon: 3, title:'提示'}, function(index){
110   -
111   - // 关闭弹出层
112   - layer.close(index);
113   -
114   - // 跳转到list页面
115   - loadPage('list.html');
116   -
117   - });
118   - }
119   -
120   - var form = $('#user_edit_form');
121   - var error = $('.alert-danger', form);
122   -
123   - //表单 validate
124   - form.validate({
125   - errorElement : 'span',
126   - errorClass : 'help-block help-block-error',
127   - focusInvalid : false,
128   - rules : {
129   - 'userName' : {
130   - required : true,
131   - maxlength: 25
132   - },
133   - 'name' : {
134   - required : true,
135   - maxlength: 25
136   - },
137   - 'role' : {
138   - required : true,
139   - minlength: 1
140   - }
141   - },
142   - invalidHandler : function(event, validator) {
143   - error.show();
144   - App.scrollTo(error, -200);
145   - },
146   -
147   - highlight : function(element) {
148   - $(element).closest('.form-group').addClass('has-error');
149   - },
150   -
151   - unhighlight : function(element) {
152   - $(element).closest('.form-group').removeClass('has-error');
153   - },
154   -
155   - success : function(label) {
156   - label.closest('.form-group').removeClass('has-error');
157   - },
158   -
159   - submitHandler : function(f) {
160   - var params = form.serializeJSON();
161   - error.hide();
162   - console.log(params);
163   -
164   - //检查一下用户是否存在
165   - $.ajax({
166   - url: '/user',
167   - type: 'POST',
168   - traditional: true,
169   - data: params,
170   - success: function(res){
171   - layer.msg('修改用户信息成功.');
172   - loadPage('list.html');
173   - }
174   - });
175   - }
176   - });
177   - });
  1 +<div class="page-head">
  2 + <div class="page-title">
  3 + <h1>编辑用户</h1>
  4 + </div>
  5 +</div>
  6 +
  7 +<ul class="page-breadcrumb breadcrumb">
  8 + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
  9 + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
  10 + <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li>
  11 + <li><span class="active">编辑用户</span></li>
  12 +</ul>
  13 +
  14 +<div class="portlet light bordered">
  15 + <div class="portlet-title">
  16 + <div class="caption">
  17 + <i class="icon-equalizer font-red-sunglo"></i> <span
  18 + class="caption-subject font-red-sunglo bold uppercase">表单</span>
  19 + </div>
  20 + </div>
  21 + <div class="portlet-body form">
  22 + <form action="/addUser" class="form-horizontal" id="user_edit_form" >
  23 + <div class="alert alert-danger display-hide">
  24 + <button class="close" data-close="alert"></button>
  25 + 您的输入有误,请检查下面的输入项
  26 + </div>
  27 + <div class="form-body">
  28 + <div class="form-group">
  29 + <label class="col-md-3 control-label">登录名</label>
  30 + <div class="col-md-4">
  31 + <input type="hidden" id="id" name="id">
  32 + <input type="hidden" id="jobCode" name="jobCode">
  33 + <input type="hidden" id="realName" name="realName">
  34 + <input type="hidden" id="lastPwdDate" name="lastPwdDate">
  35 + <input type="hidden" id="pwdValidPeriod" name="pwdValidPeriod">
  36 + <input type="text" class="form-control" id="userName" name="userName" readonly="readonly">
  37 + <span class="help-block"> 登录时的帐号</span>
  38 + </div>
  39 + </div>
  40 + <div class="form-group">
  41 + <label class="col-md-3 control-label">姓名</label>
  42 + <div class="col-md-4">
  43 + <input type="text" class="form-control" id="name" name="name" readonly="readonly">
  44 + </div>
  45 + </div>
  46 + <div class="form-group">
  47 + <label class="col-md-3 control-label">所属机构</label>
  48 + <div class="col-md-4">
  49 + <input type="text" class="form-control" id="agencies" name="agencies" >
  50 + </div>
  51 + </div>
  52 +
  53 + <div class="form-group">
  54 + <label class="col-md-3 control-label">角色</label>
  55 + <div class="col-md-4">
  56 + <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple">
  57 +
  58 + </select>
  59 + </div>
  60 + </div>
  61 +
  62 + <div class="form-group">
  63 + <label class="col-md-3 control-label">是否启用</label>
  64 + <div class="col-md-4">
  65 + <div class="input-group">
  66 + <select class="form-control" id="enabled" name="enabled" style="width: 160px;">
  67 + <option value="1">可用</option>
  68 + <option value="0">禁用</option>
  69 + </select>
  70 + </div>
  71 + </div>
  72 + </div>
  73 + </div>
  74 + <div>
  75 + <!--<iframe src="authorize.html?origin=real_control_iframe" frameborder="0" style="height: 600px;width: 100%;"></iframe>-->
  76 + </div>
  77 + <div class="form-actions">
  78 + <div class="row">
  79 + <div class="col-md-offset-3 col-md-4">
  80 + <!--<a href="main.html" class="btn green" id="nextStep" ><i class="fa fa-check"></i> 下一步</a>-->
  81 + <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button>
  82 + <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
  83 + </div>
  84 + </div>
  85 + </div>
  86 + </form>
  87 + <!-- END FORM-->
  88 + </div>
  89 +</div>
  90 +
  91 +<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;left: 50%;
  92 + top: 50%;transform: translate(-50%,-50%);min-width:50%;overflow: visible;bottom: inherit; right: inherit;">
  93 + <div class="modal-dialog">
  94 + <div class="modal-content">
  95 + <div class="modal-body" style="text-align: center;"></div>
  96 + <div class="modal-footer" style="margin: 0 auto;">
  97 + <center>
  98 + <button type="button" class="btn btn-primary" data-dismiss="modal" id="noNext" style="margin-right: 20%;padding:5px 35px;background-color: #337AB7;color: white;">&nbsp;完&nbsp;成&nbsp;</button>
  99 + <button type="button" class="btn btn-primary" id="yesNext">继续配置授权</button>
  100 + </center>
  101 + </div>
  102 + </div><!-- /.modal-content -->
  103 + </div><!-- /.modal -->
  104 +</div>
  105 +<script>
  106 + $(function(){
  107 + var id = $.url().param('no');
  108 + if(id){
  109 + $get('/user/'+id,null,function(obj){
  110 + $("#id").attr('value',obj.id);
  111 + $("#userName").attr('value',obj.userName);
  112 + $("#name").attr('value',obj.name);
  113 + $("#agencies").attr('value',obj.agencies);
  114 + $("#jobCode").attr('value',obj.jobCode);
  115 + $("#realName").attr('value',obj.realName);
  116 + $("#lastPwdDate").attr('value',moment(obj.lastPwdDate).format('YYYY-MM-DD'));
  117 + $("#pwdValidPeriod").attr('value',obj.pwdValidPeriod);
  118 + /*$get('/role/all',null,function(result){
  119 + $.each(result,function(i,r){
  120 + $("#role").append("<option value='"+r.id+"'>"+r.roleName+"</option>");
  121 + });
  122 + $.each(obj.roles,function(i,obt){
  123 + $("#role option[value="+obt.id+"]").attr("selected",true);
  124 + });
  125 + });*/
  126 + // 查询下级角色
  127 + $.get('/role/findSubordinate', function (rs) {
  128 + if(rs.status == "SUCCESS"){
  129 + $.each(rs.list,function(i,obj){
  130 + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
  131 + });
  132 + }
  133 + $.each(obj.roles,function(i,obt){
  134 + $("#role option[value="+obt.id+"]").attr("selected",true);
  135 + });
  136 + });
  137 + if(obj.enabled){
  138 + $("#enabled option[value=1]").attr("selected",true);
  139 + }else{
  140 + $("#enabled option[value=0]").attr("selected",true);
  141 + }
  142 + });
  143 +
  144 + }else {
  145 +
  146 + // 缺少ID
  147 + layer.confirm('【ID缺失,请点击返回,重新进行修改操作】', {btn : [ '返回' ],icon: 3, title:'提示'}, function(index){
  148 +
  149 + // 关闭弹出层
  150 + layer.close(index);
  151 +
  152 + // 跳转到list页面
  153 + loadPage('list.html');
  154 +
  155 + });
  156 + }
  157 +
  158 + var form = $('#user_edit_form');
  159 + var error = $('.alert-danger', form);
  160 +
  161 + //表单 validate
  162 + form.validate({
  163 + errorElement : 'span',
  164 + errorClass : 'help-block help-block-error',
  165 + focusInvalid : false,
  166 + rules : {
  167 + 'userName' : {
  168 + required : true,
  169 + maxlength: 25
  170 + },
  171 + 'name' : {
  172 + required : true,
  173 + maxlength: 25
  174 + },
  175 + 'role' : {
  176 + required : true,
  177 + minlength: 1
  178 + }
  179 + },
  180 + invalidHandler : function(event, validator) {
  181 + error.show();
  182 + App.scrollTo(error, -200);
  183 + },
  184 +
  185 + highlight : function(element) {
  186 + $(element).closest('.form-group').addClass('has-error');
  187 + },
  188 +
  189 + unhighlight : function(element) {
  190 + $(element).closest('.form-group').removeClass('has-error');
  191 + },
  192 +
  193 + success : function(label) {
  194 + label.closest('.form-group').removeClass('has-error');
  195 + },
  196 +
  197 + submitHandler : function(f) {
  198 + var params = form.serializeJSON();
  199 + error.hide();
  200 + console.log(params);
  201 +
  202 + //检查一下用户是否存在
  203 + $.ajax({
  204 + url: '/user',
  205 + type: 'POST',
  206 + traditional: true,
  207 + data: params,
  208 + success: function(res){
  209 + layer.msg('修改用户信息成功.');
  210 + $('#myModal').modal();
  211 + //loadPage('list.html');
  212 + }
  213 + });
  214 + }
  215 + });
  216 +
  217 + $('#noNext').click(function () {
  218 + $('#myModal').modal('hide');
  219 + $('.modal-backdrop').remove();
  220 +
  221 + loadPage('list.html');
  222 + })
  223 + $('#yesNext').click(function () {
  224 + var storage = window.localStorage;
  225 + storage.setItem("editUser",$('#id').val());
  226 + $('#myModal').modal('hide');
  227 + window.location.href='main.html'
  228 + })
  229 + });
178 230 </script>
179 231 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/forceChangePWD.html 0 → 100644
  1 +<div class="row">
  2 + <div class="col-md-12">
  3 + <!-- BEGIN VALIDATION STATES-->
  4 + <div class="portlet light portlet-fit portlet-form bordered">
  5 + <div class="portlet-body">
  6 + <form class="form-horizontal" id="forceChangePWDForm">
  7 + <div class="alert alert-danger display-hide">
  8 + <button class="close" data-close="alert"></button>您的输入有误,请检查下面的输入项
  9 + </div>
  10 + <div class="form-group" style="margin-top: 60px">
  11 + <label class="control-label col-md-5">原始密码:
  12 + </label>
  13 + <div class="col-md-4">
  14 + <div class="input-icon right">
  15 + <i class="fa"></i>
  16 + <input type="password" class="form-control" name="oldPWD" /> </div>
  17 + </div>
  18 + </div>
  19 + <div class="form-group">
  20 + <label class="control-label col-md-5">输入新密码:
  21 + </label>
  22 + <div class="col-md-4">
  23 + <div class="input-icon right">
  24 + <i class="fa"></i>
  25 + <input type="password" class="form-control" name="newPWD" id="newPWD"/> </div>
  26 + </div>
  27 + </div>
  28 + <div class="form-group">
  29 + <label class="control-label col-md-5">确认新密码:
  30 + </label>
  31 + <div class="col-md-4">
  32 + <div class="input-icon right">
  33 + <i class="fa"></i>
  34 + <input type="password" class="form-control" name="cnewPWD" /> </div>
  35 + </div>
  36 + </div>
  37 + <div class="form-actions">
  38 + <div class="row">
  39 + <div class="col-md-offset-5 col-md-7">
  40 + <button type="submit" id="confirm" class="btn green">确定</button>
  41 + </div>
  42 + </div>
  43 + </div>
  44 + </form>
  45 + </div>
  46 + </div>
  47 + </div>
  48 +</div>
  49 +
  50 +<script>
  51 + $(function(){
  52 + var form = $('#forceChangePWDForm');
  53 + //表单 validate
  54 + var error = $('.alert-danger', form);
  55 +
  56 + var validate = function (pwd) {
  57 + var flag = true;
  58 + for (var i = 1; i < pwd.length - 1; i++) {
  59 + var first = pwd.charCodeAt(i - 1);
  60 + var second = pwd.charCodeAt(i);
  61 + var third = pwd.charCodeAt(i + 1);
  62 + if (!(first >= 48 && third <= 57 || first >= 65 && third <= 90 || first >= 97 && third <= 122)) {
  63 + continue;
  64 + }
  65 + if (third - second == 1 && second - first == 1) {
  66 + flag = false;
  67 + }
  68 + }
  69 +
  70 + return flag;
  71 + }
  72 +
  73 + $.validator.addMethod("passwordrule", function(value, element) {
  74 + var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-.]).{8,16}$/;
  75 + return this.optional(element) || reg.test(value) && validate(value);
  76 + }, "需包含大小写字母、数字、以及特殊符号的8-16位字符,并不能有123、abc这样的连续字符");
  77 +
  78 + //表单 validate
  79 + form.validate({
  80 + errorElement : 'span',
  81 + errorClass : 'help-block help-block-error',
  82 + focusInvalid : false,
  83 + rules : {
  84 + 'newPWD' : {
  85 + required : true,
  86 + minlength: 6,
  87 + maxlength: 16,
  88 + passwordrule:true
  89 + },
  90 + 'cnewPWD' : {
  91 + equalTo: '#newPWD'
  92 + }
  93 + },
  94 + invalidHandler : function(event, validator) {
  95 + error.show();
  96 + App.scrollTo(error, -200);
  97 + },
  98 +
  99 + highlight : function(element) {
  100 + $(element).closest('.form-group').addClass('has-error');
  101 + },
  102 +
  103 + unhighlight : function(element) {
  104 + $(element).closest('.form-group').removeClass('has-error');
  105 + },
  106 +
  107 + success : function(label) {
  108 + label.closest('.form-group').removeClass('has-error');
  109 + },
  110 +
  111 + submitHandler : function(f) {
  112 + var params = form.serializeJSON();
  113 + error.hide();
  114 + var keys;
  115 + $.ajax({
  116 + url: "/user/login/jCryptionKey?t="+Math.random(),
  117 + type: "Get",
  118 + async:false,
  119 + data: null,
  120 + success: function(data) {
  121 + keys = data.publickey;
  122 + }
  123 + });
  124 + //RSA加密
  125 + var encrypt = new JSEncrypt();
  126 + encrypt.setPublicKey(keys);
  127 + params.oldPWD = encrypt.encrypt(params.oldPWD);
  128 + params.newPWD = encrypt.encrypt(params.newPWD);
  129 + params.cnewPWD = encrypt.encrypt(params.cnewPWD);
  130 + $.ajax({
  131 + url: '/user/changePWD',
  132 + type: 'POST',
  133 + traditional: true,
  134 + data: params,
  135 + success: function(msg){
  136 + layer.alert(msg);
  137 + layer.closeAll('page');
  138 + }
  139 + });
  140 + }
  141 + });
  142 + });
  143 +</script>
0 144 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/list.html
1   -<div class="page-head">
2   - <div class="page-title">
3   - <h1>用户管理</h1>
4   - </div>
5   -</div>
6   -
7   -<ul class="page-breadcrumb breadcrumb">
8   - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
9   - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
10   - <li><span class="active">用户管理</span></li>
11   -</ul>
12   -
13   -<div class="row">
14   - <div class="col-md-12">
15   - <!-- Begin: life time stats -->
16   - <div class="portlet light portlet-fit portlet-datatable bordered">
17   - <div class="portlet-title">
18   - <div class="caption">
19   - <i class="fa fa-users font-dark"></i> <span
20   - class="caption-subject font-dark sbold uppercase">用户数据表</span>
21   - </div>
22   - <div class="actions">
23   - <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a>
24   -
25   - </div>
26   - </div>
27   - <div class="portlet-body">
28   - <div class="table-container" style="margin-top: 10px">
29   - <table
30   - class="table table-striped table-bordered table-hover table-checkable"
31   - id="datatable_user">
32   - <thead>
33   - <tr role="row" class="heading">
34   - <th width="3%">#</th>
35   - <th width="15%">登录名</th>
36   - <th width="13%">姓名</th>
37   - <th width="100">所属机构</th>
38   - <th width="11%">角色</th>
39   - <th width="10%">状态</th>
40   - <th width="18%">最后登录时间</th>
41   - <th width="18%">操作</th>
42   - </tr>
43   - <tr role="row" class="filter">
44   - <td></td>
45   - <td>
46   - <input type="text" class="form-control form-filter input-sm" name="userName_like">
47   - </td>
48   - <td>
49   - <input type="text" class="form-control form-filter input-sm" name="name_like">
50   - </td>
51   - <td>
52   - <input type="text" class="form-control form-filter input-sm" name="agencies_like">
53   - </td>
54   - <td></td>
55   - <td>
56   - <select class="form-control form-filter " name="enabled_eq">
57   - <option value="">请选择...</option>
58   - <option value="true">可用</option>
59   - <option value="false">禁用</option>
60   - </select>
61   - </td>
62   - <td></td>
63   - <td>
64   - <button class="btn btn-sm green btn-outline filter-submit margin-bottom" >
65   - <i class="fa fa-search"></i> 搜索</button>
66   -
67   - <button class="btn btn-sm red btn-outline filter-cancel">
68   - <i class="fa fa-times"></i> 重置</button>
69   - </td>
70   - </tr>
71   - </thead>
72   - <tbody></tbody>
73   - </table>
74   - <div style="text-align: right;">
75   - <ul id="pagination" class="pagination"></ul>
76   - </div>
77   - </div>
78   - </div>
79   - </div>
80   - </div>
81   -</div>
82   -
83   -<script id="user_list_temp" type="text/html">
84   -{{each list as obj i}}
85   -<tr>
86   - <td style="vertical-align: middle;">
87   - <input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">
88   - </td>
89   - <td>
90   - {{obj.userName}}
91   - </td>
92   - <td>
93   - {{obj.name}}
94   - </td>
95   - <td>
96   - {{obj.agencies}}
97   - </td>
98   - <td>
99   - {{each obj.roles as role j}}
100   - {{role.roleName}}、
101   - {{/each}}
102   - </td>
103   - <td>
104   - {{if obj.enabled}}
105   - 可用
106   - {{else}}
107   - 禁用
108   - {{/if}}
109   - </td>
110   - <td>
111   - {{obj.lastLoginDate}}
112   - </td>
113   - <td>
114   - <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}" data-pjax><i class="fa fa-edit"></i> 编辑</a>
115   - <!--<button type="button" class="btn btn-sm line_allot_btn" data-id="{{obj.id}}">线调线路分配</button>-->
116   - </td>
117   -</tr>
118   -{{/each}}
119   -{{if list.length == 0}}
120   -<tr>
121   - <td colspan=8><h6 class="muted">没有找到相关数据</h6></td>
122   -</tr>
123   -{{/if}}
124   -</script>
125   -
126   -<script>
127   -$(function(){
128   - var page = 0, initPagination;
129   - var icheckOptions = {
130   - checkboxClass: 'icheckbox_flat-blue',
131   - increaseArea: '20%'
132   - };
133   -
134   - jsDoQuery(null,true);
135   -
136   - //重置
137   - $('tr.filter .filter-cancel').on('click', function(){
138   - $('tr.filter input, select').val('').change();
139   - jsDoQuery(null, true);
140   - });
141   -
142   - //提交
143   - $('tr.filter .filter-submit').on('click', function(){
144   - var cells = $('tr.filter')[0].cells
145   - ,params = {}
146   - ,name;
147   - $.each(cells, function(i, cell){
148   - var items = $('input,select', cell);
149   - for(var j = 0, item; item = items[j++];){
150   - name = $(item).attr('name');
151   - if(name){
152   - params[name] = $(item).val();
153   - }
154   - }
155   - });
156   - page = 0;
157   - jsDoQuery(params, true);
158   - });
159   -
160   - /*
161   - * 获取数据 p: 要提交的参数, pagination: 是否重新分页
162   - */
163   - function jsDoQuery(p, pagination){
164   - var params = {};
165   - if(p)
166   - params = p;
167   - //更新时间排序
168   - params['order'] = 'lastLoginDate';
169   - params['page'] = page;
170   - var i = layer.load(2);
171   - $get('/user' ,params, function(data){
172   - $.each(data.content, function(i, obj) {
173   - obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss");
174   - });
175   - var bodyHtm = template('user_list_temp', {list: data.content});
176   -
177   - $('#datatable_user tbody').html(bodyHtm)
178   - .find('.icheck').iCheck(icheckOptions)
179   - .on('ifChanged', iCheckChange);
180   - if(pagination && data.content.length > 0){
181   - //重新分页
182   - initPagination = true;
183   - showPagination(data);
184   - }
185   - layer.close(i);
186   -
187   - $('.line_allot_btn').on('click', openAllotWindow);
188   - });
189   - }
190   -
191   - function iCheckChange(){
192   - var tr = $(this).parents('tr');
193   - if(this.checked)
194   - tr.addClass('row-active');
195   - else
196   - tr.removeClass('row-active');
197   -
198   - if($('#datatable_resource input.icheck:checked').length == 1)
199   - $('#removeButton').removeAttr('disabled');
200   - else
201   - $('#removeButton').attr('disabled', 'disabled');
202   - }
203   -
204   - function showPagination(data){
205   - //分页
206   - $('#pagination').jqPaginator({
207   - totalPages: data.totalPages,
208   - visiblePages: 6,
209   - currentPage: page + 1,
210   - first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
211   - prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
212   - next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
213   - last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
214   - page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
215   - onPageChange: function (num, type) {
216   - if(initPagination){
217   - initPagination = false;
218   - return;
219   - }
220   -
221   -
222   - page = num - 1;
223   - jsDoQuery(null, false);
224   - }
225   - });
226   - }
227   -
228   - function openAllotWindow() {
229   - var id = $(this).data('id');
230   - $.get('/pages/permission/user/controlAllot.html', function (content) {
231   - layer.open({
232   - type: 1,
233   - area: ['600px', '395px'],
234   - content: content,
235   - title: '线路调度权限分配',
236   - shift: 5,
237   - scrollbar: false,
238   - success: function () {
239   - $('#pageRealControlAllotWrap').trigger('init', id);
240   - }
241   - });
242   - });
243   - }
244   -
245   - //删除
246   - $('#removeButton').on('click', function(){
247   - if($(this).attr('disabled'))
248   - return;
249   -
250   - var id = $('#datatable_resource input.icheck:checked').data('id');
251   -
252   - removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){
253   - $('tr.filter .filter-submit').click();
254   - });
255   - });
256   -});
257   -//改变状态
258   -function changeEnabled(id,enabled){
259   - $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){
260   - jsDoQuery(null, true);
261   - })
262   -}
  1 +<div class="page-head">
  2 + <div class="page-title">
  3 + <h1>用户管理</h1>
  4 + </div>
  5 +</div>
  6 +
  7 +<ul class="page-breadcrumb breadcrumb">
  8 + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
  9 + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
  10 + <li><span class="active">用户管理</span></li>
  11 +</ul>
  12 +
  13 +<div class="row">
  14 + <div class="col-md-12">
  15 + <!-- Begin: life time stats -->
  16 + <div class="portlet light portlet-fit portlet-datatable bordered">
  17 + <div class="portlet-title">
  18 + <div class="caption">
  19 + <i class="fa fa-users font-dark"></i> <span
  20 + class="caption-subject font-dark sbold uppercase">用户数据表</span>
  21 + </div>
  22 + <div class="actions">
  23 + <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a>
  24 +
  25 + </div>
  26 + </div>
  27 + <div class="portlet-body">
  28 + <div class="table-container" style="margin-top: 10px">
  29 + <table
  30 + class="table table-striped table-bordered table-hover table-checkable"
  31 + id="datatable_user">
  32 + <thead>
  33 + <tr role="row" class="heading">
  34 + <th width="3%">#</th>
  35 + <th width="10%">登录名</th>
  36 + <th width="10%">姓名</th>
  37 + <th width="12%">所属机构</th>
  38 + <th width="11%">角色</th>
  39 + <th width="10%">状态</th>
  40 + <th width="18%">最后登录时间</th>
  41 + <th width="26%">操作</th>
  42 + </tr>
  43 + <tr role="row" class="filter">
  44 + <td></td>
  45 + <td>
  46 + <input type="text" class="form-control form-filter input-sm" name="userName_like">
  47 + </td>
  48 + <td>
  49 + <input type="text" class="form-control form-filter input-sm" name="name_like">
  50 + </td>
  51 + <td>
  52 + <input type="text" class="form-control form-filter input-sm" name="agencies_like">
  53 + </td>
  54 + <td></td>
  55 + <td>
  56 + <select class="form-control form-filter " name="enabled_eq">
  57 + <option value="">请选择...</option>
  58 + <option value="true">可用</option>
  59 + <option value="false">禁用</option>
  60 + </select>
  61 + </td>
  62 + <td></td>
  63 + <td>
  64 + <button class="btn btn-sm green btn-outline filter-submit margin-bottom" >
  65 + <i class="fa fa-search"></i> 搜索</button>
  66 +
  67 + <button class="btn btn-sm red btn-outline filter-cancel">
  68 + <i class="fa fa-times"></i> 重置</button>
  69 + </td>
  70 + </tr>
  71 + </thead>
  72 + <tbody></tbody>
  73 + </table>
  74 + <div style="text-align: right;">
  75 + <ul id="pagination" class="pagination"></ul>
  76 + </div>
  77 + </div>
  78 + </div>
  79 + </div>
  80 + </div>
  81 +</div>
  82 +
  83 +<script id="user_list_temp" type="text/html">
  84 +{{each list as obj i}}
  85 +<tr>
  86 + <td style="vertical-align: middle;">
  87 + <!--<input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">-->
  88 + {{++i}}
  89 + </td>
  90 + <td>
  91 + {{obj.userName}}
  92 + </td>
  93 + <td>
  94 + {{obj.name}}
  95 + </td>
  96 + <td>
  97 + {{obj.agencies}}
  98 + </td>
  99 + <td>
  100 + {{each obj.roles as role j}}
  101 + {{role.roleName}}、
  102 + {{/each}}
  103 + </td>
  104 + <td>
  105 + {{if obj.enabled}}
  106 + 可用
  107 + {{else}}
  108 + 禁用
  109 + {{/if}}
  110 + </td>
  111 + <td>
  112 + {{obj.lastLoginDate}}
  113 + </td>
  114 + <td>
  115 + {{if obj.isEdit == 0}}
  116 + <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}" data-pjax><i class="fa fa-edit"></i> 编辑</a>
  117 + <!--<button type="button" class="btn btn-sm line_allot_btn" data-id="{{obj.id}}">线调线路分配</button>-->
  118 + {{/if}}
  119 + {{if obj.isAdmin}}
  120 + <a class="btn btn-sm red btn-outline reset_password" data-id="{{obj.id}}" data-name="{{obj.userName}}" data-last="{{obj.lastPwdDate}}"><i class="fa fa-undo"></i> 重置密码</a>
  121 + {{/if}}
  122 + {{if obj.isAdmin}}
  123 + <a class="btn btn-sm red btn-outline unlock" data-name="{{obj.userName}}" data-pjax><i class="fa fa-unlock"></i> 解除锁定</a>
  124 + {{/if}}
  125 + </td>
  126 +</tr>
  127 +{{/each}}
  128 +{{if list.length == 0}}
  129 +<tr>
  130 + <td colspan=8><h6 class="muted">没有找到相关数据</h6></td>
  131 +</tr>
  132 +{{/if}}
  133 +</script>
  134 +
  135 +<script>
  136 +$(function(){
  137 + var page = 0, initPagination;
  138 + var user,isAdmin = false;
  139 + var icheckOptions = {
  140 + checkboxClass: 'icheckbox_flat-blue',
  141 + increaseArea: '20%'
  142 + };
  143 + $.get('/user/getCurrentUser', function(data) {
  144 + user = data;
  145 + var roles = user.roles;
  146 + $.each(roles,function () {
  147 + if(this.level == 1)
  148 + isAdmin = true;
  149 + })
  150 +
  151 + });
  152 +
  153 + setTimeout(function () {
  154 + $(document).on('click', 'a.reset_password', function () {
  155 + var id = $(this).data('id'), name = $(this).data('name'), last = $(this).data('last');
  156 + $.get('/pages/permission/user/resetPWD.html', function (content) {
  157 + layer.open({
  158 + type: 1,
  159 + area: ['600px', '360px'],
  160 + content: content,
  161 + title: '修改密码',
  162 + shift: 5,
  163 + scrollbar: false,
  164 + success: function (layero, index) {
  165 + $(layero).find('#user_id').val(id);
  166 + $(layero).find('#user_name').val(name);
  167 + $(layero).find('#last_pwd_date').val(last ? moment(last).format("YYYY-MM-DD HH:mm:ss") : '');
  168 + $(layero).find('#window_index').val(index);
  169 + }
  170 + });
  171 + });
  172 + }).on('click', 'a.unlock', function () {
  173 + var name = $(this).data('name');
  174 + swal({
  175 + title: "解除锁定",
  176 + text: "将登录名为"+name+"的用户,锁定状态解除!",
  177 + type: "warning",
  178 + showCancelButton: true,
  179 + confirmButtonColor: "#DD6B55",
  180 + confirmButtonText: "重置",
  181 + cancelButtonText: "取消",
  182 + closeOnConfirm: false },
  183 + function(){
  184 + $.post('/user/unlock',{'userName':name},function(result){
  185 + if(result.status=='SUCCESS') {
  186 + // 弹出添加成功提示消息
  187 + swal("登录名为"+name+"的用户锁定解除成功!", "success");
  188 + } else if(result.status=='ERROR') {
  189 + // 弹出添加失败提示消息
  190 + swal("锁定解除失败!", result.msg+",请联系开发人员!", "ERROR");
  191 + }
  192 + jsDoQuery(getParams(), true);
  193 + });
  194 + });
  195 + });
  196 + jsDoQuery(null,true);
  197 +
  198 + //重置
  199 + $('tr.filter .filter-cancel').on('click', function(){
  200 + $('tr.filter input, select').val('').change();
  201 + jsDoQuery(null, true);
  202 + });
  203 +
  204 + function getParams() {
  205 + var cells = $('tr.filter')[0].cells
  206 + ,params = {}
  207 + ,name;
  208 + $.each(cells, function(i, cell){
  209 + var items = $('input,select', cell);
  210 + for(var j = 0, item; item = items[j++];){
  211 + name = $(item).attr('name');
  212 + if(name){
  213 + params[name] = $(item).val();
  214 + }
  215 + }
  216 + });
  217 + return params;
  218 + }
  219 +
  220 + //提交
  221 + $('tr.filter .filter-submit').on('click', function(){
  222 + jsDoQuery(getParams(), true);
  223 + });
  224 +
  225 + /*
  226 + * 获取数据 p: 要提交的参数, pagination: 是否重新分页
  227 + */
  228 + function jsDoQuery(p, pagination){
  229 + var roles = new Map();
  230 + // 查询下级角色
  231 + $.ajax({
  232 + url: "/role/findSubordinate",
  233 + type: "Get",
  234 + async:false,
  235 + data: null,
  236 + success: function (rs) {
  237 + if(rs.status == "SUCCESS"){
  238 + $.each(rs.list,function(i,obj){
  239 + roles[obj.id] = obj;
  240 + });
  241 + }
  242 + }
  243 + });
  244 + var params = {};
  245 + if(p)
  246 + params = p;
  247 + //更新时间排序
  248 + params['order'] = 'lastLoginDate';
  249 + params['page'] = page;
  250 + // params['id_eq'] = "1";
  251 + var i = layer.load(2);
  252 + $get('/user' ,params, function(data){
  253 + var list = data.content;
  254 + $.each(list, function(i, obj) {
  255 + if(roles[obj.roles[0].id] != null && roles[obj.roles[0].id] != undefined){
  256 + obj.isEdit = 0;
  257 + } else{
  258 + obj.isEdit = 1;
  259 + }
  260 + obj.isAdmin = isAdmin;
  261 + obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss");
  262 + });
  263 +
  264 + var bodyHtm = template('user_list_temp', {list: list});
  265 +
  266 + $('#datatable_user tbody').html(bodyHtm)
  267 + .find('.icheck').iCheck(icheckOptions)
  268 + .on('ifChanged', iCheckChange);
  269 + if(pagination && list.length > 0){
  270 + //重新分页
  271 + initPagination = true;
  272 + showPagination(data);
  273 + }
  274 + layer.close(i);
  275 +
  276 + $('.line_allot_btn').on('click', openAllotWindow);
  277 + });
  278 + }
  279 +
  280 + function iCheckChange(){
  281 + var tr = $(this).parents('tr');
  282 + if(this.checked)
  283 + tr.addClass('row-active');
  284 + else
  285 + tr.removeClass('row-active');
  286 +
  287 + if($('#datatable_resource input.icheck:checked').length == 1)
  288 + $('#removeButton').removeAttr('disabled');
  289 + else
  290 + $('#removeButton').attr('disabled', 'disabled');
  291 + }
  292 +
  293 + function showPagination(data){
  294 + //分页
  295 + $('#pagination').jqPaginator({
  296 + totalPages: data.totalPages,
  297 + visiblePages: 6,
  298 + currentPage: page + 1,
  299 + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
  300 + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
  301 + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
  302 + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
  303 + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
  304 + onPageChange: function (num, type) {
  305 + if(initPagination){
  306 + initPagination = false;
  307 + return;
  308 + }
  309 +
  310 +
  311 + page = num - 1;
  312 + jsDoQuery(null, false);
  313 + }
  314 + });
  315 + }
  316 +
  317 + function openAllotWindow() {
  318 + var id = $(this).data('id');
  319 + $.get('/pages/permission/user/controlAllot.html', function (content) {
  320 + layer.open({
  321 + type: 1,
  322 + area: ['600px', '395px'],
  323 + content: content,
  324 + title: '线路调度权限分配',
  325 + shift: 5,
  326 + scrollbar: false,
  327 + success: function () {
  328 + $('#pageRealControlAllotWrap').trigger('init', id);
  329 + }
  330 + });
  331 + });
  332 + }
  333 +
  334 + //删除
  335 + $('#removeButton').on('click', function(){
  336 + if($(this).attr('disabled'))
  337 + return;
  338 +
  339 + var id = $('#datatable_resource input.icheck:checked').data('id');
  340 +
  341 + removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){
  342 + $('tr.filter .filter-submit').click();
  343 + });
  344 + });
  345 + },1000);
  346 +
  347 +});
  348 +//改变状态
  349 +function changeEnabled(id,enabled){
  350 + $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){
  351 + jsDoQuery(null, true);
  352 + })
  353 +}
  354 +// 重置密码
  355 +function resetPassword(userId, ld) {
  356 + $.get('/pages/permission/user/resetPWD.html', function (content) {
  357 + layer.open({
  358 + type: 1,
  359 + area: ['600px', '360px'],
  360 + content: content,
  361 + title: '修改密码',
  362 + shift: 5,
  363 + scrollbar: false,
  364 + success: function (layero, index) {
  365 + $(layero).find('#user_id').val(userId);
  366 + $(layero).find('#last_pwd_date').val(ld ? moment(ld).format("YYYY-MM-DD HH:mm:ss") : '');
  367 + $(layero).find('#window_index').val(index);
  368 + }
  369 + });
  370 + });
  371 +
  372 +}
263 373 </script>
264 374 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/main.html 0 → 100644
  1 +<iframe src="/pages/permission/user/authorize.html?origin=real_control_iframe" frameborder="0" style="height: 90%;width: 100%;"></iframe>
  2 +<div class="form-actions">
  3 + <div class="row">
  4 + <div class="col-md-offset-3 col-md-4">
  5 + </div>
  6 + </div>
  7 +</div>
0 8 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/resetPWD.html 0 → 100644
  1 +<div class="row">
  2 + <div class="col-md-12">
  3 + <!-- BEGIN VALIDATION STATES-->
  4 + <div class="portlet light portlet-fit portlet-form bordered">
  5 + <input type="hidden" id="window_index" name="window_index">
  6 + <div class="portlet-body">
  7 + <form class="form-horizontal" id="resetPWDForm">
  8 + <input type="hidden" id="user_id" name="id">
  9 + <input type="hidden" id="user_name">
  10 + <div class="form-group" style="margin-top: 60px">
  11 + <label class="control-label col-md-4">最近密码更新时间:
  12 + </label>
  13 + <div class="col-md-6">
  14 + <div class="input-icon right">
  15 + <i class="fa"></i>
  16 + <input type="text" readonly class="form-control" id="last_pwd_date" /> </div>
  17 + </div>
  18 + </div>
  19 +
  20 + <div class="form-group" >
  21 + <label class="control-label col-md-4">密码有效期(天):
  22 + </label>
  23 + <div class="col-md-6">
  24 + <div class="input-icon right">
  25 + <i class="fa"></i>
  26 + <input type="number" class="form-control" name="pwdValidPeriod" id="pwd_valid_period" value="30" /> </div>
  27 + </div>
  28 + </div>
  29 + <div class="form-actions">
  30 + <div class="row">
  31 + <div class="col-md-offset-5 col-md-7">
  32 + <button type="button" id="confirm" class="btn green">确定</button>
  33 + <button type="button" class="btn default">取消</button>
  34 + </div>
  35 + </div>
  36 + </div>
  37 + </form>
  38 + </div>
  39 + </div>
  40 + </div>
  41 +</div>
  42 +
  43 +
  44 +<script>
  45 + $(function(){
  46 + debugger
  47 + $("#confirm").on('click',function(){
  48 + var data = $('#resetPWDForm').serializeJSON();
  49 + var index = $('#window_index').val(), name = $('#user_name').val();
  50 + $.post('/user/resetPassword', data, function(result) {
  51 + parent.layer.close(index);
  52 + if(result.status == 'SUCCESS') {
  53 + // 弹出添加成功提示消息
  54 + swal('登录名为' + name + '的用户密码重置成功!', 'success');
  55 + } else if(result.status == 'ERROR') {
  56 + // 弹出添加失败提示消息
  57 + swal('重置失败!', result.msg + ',请联系开发人员!', 'ERROR');
  58 + }
  59 + });
  60 + });
  61 +
  62 + $("#pwd_cancel").on('click', function() {
  63 + var index = $('#window_index').val();
  64 + parent.layer.close(index);
  65 + });
  66 + });
  67 +</script>
0 68 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/main.html
... ... @@ -114,7 +114,7 @@
114 114 </script>
115 115  
116 116 <!-- 地图相关 -->
117   -<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script>
  117 +<script src="http://api.map.baidu.com/api?v=2.0&ak=1TgEKvYqohJyeGXnN6yHSSTb4psOarQw"></script>
118 118 <script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script>
119 119 <script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script>
120 120 <script src="/assets/js/TransGPS.js" merge="plugins"></script>
... ...