diff --git a/WebRoot/css/carousel.css b/WebRoot/css/carousel.css new file mode 100644 index 0000000..8833f82 --- /dev/null +++ b/WebRoot/css/carousel.css @@ -0,0 +1,134 @@ +/* GLOBAL STYLES +-------------------------------------------------- */ +/* Padding below the footer and lighter body text */ + +body { + padding-bottom: 40px; + color: #5a5a5a; +} + + +/* CUSTOMIZE THE NAVBAR +-------------------------------------------------- */ + +/* Special class on .container surrounding .navbar, used for positioning it into place. */ +.navbar-wrapper { + position: absolute; + top: 0; + right: 0; + left: 0; + z-index: 20; +} + +/* Flip around the padding for proper display in narrow viewports */ +.navbar-wrapper > .container { + padding-right: 0; + padding-left: 0; +} +.navbar-wrapper .navbar { + padding-right: 15px; + padding-left: 15px; +} +.navbar-wrapper .navbar .container { + width: auto; +} + + +/* CUSTOMIZE THE CAROUSEL +-------------------------------------------------- */ + +/* Carousel base class */ +.carousel { + height: 500px; + margin-bottom: 60px; +} +/* Since positioning the image, we need to help out the caption */ +.carousel-caption { + z-index: 10; +} + +/* Declare heights because of positioning of img element */ +.carousel .item { + height: 500px; + background-color: #777; +} +.carousel-inner > .item > img { + position: absolute; + top: 0; + left: 0; + min-width: 100%; + height: 500px; +} + + +/* MARKETING CONTENT +-------------------------------------------------- */ + +/* Center align the text within the three columns below the carousel */ +.marketing .col-lg-4 { + margin-bottom: 20px; + text-align: center; +} +.marketing h2 { + font-weight: normal; +} +.marketing .col-lg-4 p { + margin-right: 10px; + margin-left: 10px; +} + + +/* Featurettes +------------------------- */ + +.featurette-divider { + margin: 80px 0; /* Space out the Bootstrap
more */ +} + +/* Thin out the marketing headings */ +.featurette-heading { + font-weight: 300; + line-height: 1; + letter-spacing: -1px; +} + + +/* RESPONSIVE CSS +-------------------------------------------------- */ + +@media (min-width: 768px) { + /* Navbar positioning foo */ + .navbar-wrapper { + margin-top: 20px; + } + .navbar-wrapper .container { + padding-right: 15px; + padding-left: 15px; + } + .navbar-wrapper .navbar { + padding-right: 0; + padding-left: 0; + } + + /* The navbar becomes detached from the top, so we round the corners */ + .navbar-wrapper .navbar { + border-radius: 4px; + } + + /* Bump up size of carousel content */ + .carousel-caption p { + margin-bottom: 20px; + font-size: 21px; + line-height: 1.4; + } + + .featurette-heading { + font-size: 50px; + } +} + +@media (min-width: 992px) { + .featurette-heading { + margin-top: 120px; + } +} diff --git a/WebRoot/fonts/glyphicons-halflings-regular.eot b/WebRoot/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 0000000..b93a495 Binary files /dev/null and b/WebRoot/fonts/glyphicons-halflings-regular.eot differ diff --git a/WebRoot/fonts/glyphicons-halflings-regular.svg b/WebRoot/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 0000000..94fb549 --- /dev/null +++ b/WebRoot/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WebRoot/fonts/glyphicons-halflings-regular.ttf b/WebRoot/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 0000000..1413fc6 Binary files /dev/null and b/WebRoot/fonts/glyphicons-halflings-regular.ttf differ diff --git a/WebRoot/fonts/glyphicons-halflings-regular.woff b/WebRoot/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 0000000..9e61285 Binary files /dev/null and b/WebRoot/fonts/glyphicons-halflings-regular.woff differ diff --git a/WebRoot/fonts/glyphicons-halflings-regular.woff2 b/WebRoot/fonts/glyphicons-halflings-regular.woff2 new file mode 100644 index 0000000..64539b5 Binary files /dev/null and b/WebRoot/fonts/glyphicons-halflings-regular.woff2 differ diff --git a/WebRoot/images/CESA.jpg b/WebRoot/images/CESA.jpg new file mode 100644 index 0000000..5f58390 Binary files /dev/null and b/WebRoot/images/CESA.jpg differ diff --git a/WebRoot/images/Magic-Leap-hed.jpg b/WebRoot/images/Magic-Leap-hed.jpg new file mode 100644 index 0000000..c41379a Binary files /dev/null and b/WebRoot/images/Magic-Leap-hed.jpg differ diff --git a/WebRoot/images/Microsoft-HoloLens-Skype-RGB.png b/WebRoot/images/Microsoft-HoloLens-Skype-RGB.png new file mode 100644 index 0000000..8b9b339 Binary files /dev/null and b/WebRoot/images/Microsoft-HoloLens-Skype-RGB.png differ diff --git a/WebRoot/images/car.jpg b/WebRoot/images/car.jpg new file mode 100644 index 0000000..affc1b5 Binary files /dev/null and b/WebRoot/images/car.jpg differ diff --git a/WebRoot/images/carousel1.jpg b/WebRoot/images/carousel1.jpg new file mode 100644 index 0000000..b19a5b1 Binary files /dev/null and b/WebRoot/images/carousel1.jpg differ diff --git a/WebRoot/images/magic-leap-everest.jpg b/WebRoot/images/magic-leap-everest.jpg new file mode 100644 index 0000000..34a8042 Binary files /dev/null and b/WebRoot/images/magic-leap-everest.jpg differ diff --git a/WebRoot/images/magic_leap_solar.jpg b/WebRoot/images/magic_leap_solar.jpg new file mode 100644 index 0000000..a165392 Binary files /dev/null and b/WebRoot/images/magic_leap_solar.jpg differ diff --git a/WebRoot/images/microsoft_hololens_earth.jpg b/WebRoot/images/microsoft_hololens_earth.jpg new file mode 100644 index 0000000..e7ab595 Binary files /dev/null and b/WebRoot/images/microsoft_hololens_earth.jpg differ diff --git a/WebRoot/images/microsoft_hololens_me.jpg b/WebRoot/images/microsoft_hololens_me.jpg new file mode 100644 index 0000000..0b23e81 Binary files /dev/null and b/WebRoot/images/microsoft_hololens_me.jpg differ diff --git a/WebRoot/images/mr_global.jpg b/WebRoot/images/mr_global.jpg new file mode 100644 index 0000000..be21fdb Binary files /dev/null and b/WebRoot/images/mr_global.jpg differ diff --git a/WebRoot/images/oculus_rift_blur.jpg b/WebRoot/images/oculus_rift_blur.jpg new file mode 100644 index 0000000..33b8db4 Binary files /dev/null and b/WebRoot/images/oculus_rift_blur.jpg differ diff --git a/WebRoot/images/oculus_rift_hero.jpg b/WebRoot/images/oculus_rift_hero.jpg new file mode 100644 index 0000000..e015c8e Binary files /dev/null and b/WebRoot/images/oculus_rift_hero.jpg differ diff --git a/WebRoot/index.jsp b/WebRoot/index.jsp index cbf8e33..15f5115 100644 --- a/WebRoot/index.jsp +++ b/WebRoot/index.jsp @@ -1,71 +1,166 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> - - - - - - 首页 - - - - - + + + + + + Insert title here + + + + + - + - + + +
+ Third slide +
+ +
+
+ + + + Previous + + + + Next + + + + + + +
+ + + +
+ +
+
+

CES Asia为VR提供宽阔的展示空间 2016

+

2016年已经被称之为是虚拟现实元年,而虚拟现实这一概念也在各种巨头的普遍看好下异常火爆,索尼HTC三星谷歌群雄角力,各家的VR产品也是纷纷亮相,并且活跃在各大展会中,成为最引人注目的焦点。而本次的CES Asia展会中,索尼的PS VR和HTC Vive为代表的虚拟现实无疑将会是人们关注的焦点。

+
+
+ Generic placeholder image +

查看详情

+
+
+ +
+ +
+
+

未来汽车技术:从增强现实玻璃到智能公路

+

汽车平视显示器早在1988年的通用汽车上便已实现,可以带给驾驶者更直观的信息显示,防止交通意外发生。而现在,真正的AR(增强现实)挡风玻璃则成为汽车厂商们的下一个目标。目前,增强现实技术已经得到长足发展,汽车挡风玻璃便是一个非常具有前景的应用形式。驾驶者可以通过挡风玻璃直接看到叠加的信息,如仪表盘等内容,甚至还有望集成红外扫描、智能预测等功能,将汽车传感器收集的数据实时反馈在挡风玻璃上。

+
+
+ Generic placeholder image +

查看详情

+
+
+ +
+ +
+
+

MR(混合现实)智能头戴显示设备全球巡展启动

+

今天上午,北京微视国人恒宇科技在珠海德瀚国际会议中心酒店的海天一色厅举办的一场《中国首家MR(混合现实)智能头戴显示设备全球巡展启动仪式》,给众多的投资界和广大的消费行业以及各个领域的专家带来了一场别开生面的汇报及发布会,这家专门从事VR(虚拟现实)、AR(增强现实)、MR(混合现实)(以下简称3R) 等专业的人机数字交互领域的科技公司,从航天、教育、军事、体育、工业、旅游、娱乐等六大领域向我们展示了这些高科技技术对于未来的无限可能。

+
+
+ Generic placeholder image +

查看详情

+
+
+ +
+ + + + +
+
+ Generic placeholder image +

刘袁梦

+

CEO

+
+
+ Generic placeholder image +

黄惠娥

+

CFO

+
+
+ Generic placeholder image +

李思彤

+

PM

+
+
+ + + + +
+ + - + diff --git a/WebRoot/intro.jsp b/WebRoot/intro.jsp new file mode 100644 index 0000000..81d3344 --- /dev/null +++ b/WebRoot/intro.jsp @@ -0,0 +1,35 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + + + Insert title here + + + + + + + + + + + +
+
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/WebRoot/navbar.jsp b/WebRoot/navbar.jsp new file mode 100644 index 0000000..136ab25 --- /dev/null +++ b/WebRoot/navbar.jsp @@ -0,0 +1,72 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WebRoot/profile/user.jsp b/WebRoot/profile/user.jsp index 6f4fb1d..8ff26ac 100644 --- a/WebRoot/profile/user.jsp +++ b/WebRoot/profile/user.jsp @@ -18,10 +18,12 @@ - 用户主页 - userId: - sequence: - token: + 用户主页
+ userId:
+ adminId:
+ sequence:
+ token:
+ #context['struts.actionMapping'].name: diff --git a/WebRoot/signin.jsp b/WebRoot/signin.jsp index 3afe077..615f7ec 100644 --- a/WebRoot/signin.jsp +++ b/WebRoot/signin.jsp @@ -19,9 +19,11 @@ + +
-
- + + + diff --git a/WebRoot/video/Introducing the Games Coming to Oculus! 480p.mp4 b/WebRoot/video/Introducing the Games Coming to Oculus! 480p.mp4 new file mode 100644 index 0000000..a2ed55e Binary files /dev/null and b/WebRoot/video/Introducing the Games Coming to Oculus! 480p.mp4 differ diff --git a/src/main/java/org/fireply/enter/action/LoginAction.java b/src/main/java/org/fireply/enter/action/LoginAction.java index 8d03ed6..834e76e 100644 --- a/src/main/java/org/fireply/enter/action/LoginAction.java +++ b/src/main/java/org/fireply/enter/action/LoginAction.java @@ -1,6 +1,11 @@ package org.fireply.enter.action; -import static org.fireply.enter.constant.ResultConstants.*; +import static org.fireply.enter.constant.ResultConstants.PROFILE_ADMIN; +import static org.fireply.enter.constant.ResultConstants.PROFILE_USER; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_ADMIN; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_COOKIE_ADMIN; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_COOKIE_USER; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_USER; import java.util.ArrayList; import java.util.Date; @@ -14,8 +19,10 @@ import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import org.apache.struts2.interceptor.SessionAware; -import org.fireply.enter.model.Authorization; +import org.fireply.enter.model.Admin; +import org.fireply.enter.model.AdminAuthorization; import org.fireply.enter.model.User; +import org.fireply.enter.model.UserAuthorization; import org.fireply.enter.security.Md5; import org.fireply.enter.security.Sign; import org.fireply.enter.service.LoginService; @@ -27,115 +34,264 @@ @Controller public class LoginAction extends ActionSupport implements ServletRequestAware, ServletResponseAware, SessionAware { - + @Autowired @Qualifier("loginServiceImpl") private LoginService loginService; - + private HttpServletRequest request; private HttpServletResponse response; private Map session; - private String userId; // 登录页面填写的 userId - private String userPassword; // 登录页面填写的 userPassword - + // 登录页面填写的 userId, 不止是和 数据库里 user 表的 id 挂钩,还和 admin 表的 id 挂钩 + private String userId; + private String userPassword; // 登录页面填写的 userPassword + @Override public String execute() throws Exception { Cookie[] cookies = request.getCookies(); String remoteAddr = request.getRemoteAddr(); String actionPath = request.getServletPath(); - boolean success = false; + String loginResult = null; + String cookieUserId = null; + String cookieAdminId = null; + String cookieSequence = null; + String cookieToken = null; + if (userId != null && userPassword != null) { - String signedPassword = Md5.sign(userPassword); - success = loginService.loginByPassword(userId, signedPassword, remoteAddr); - if (success) { - // 数据库是否有 sequence, token 记录,如果有更新 session, 否则生成后存入 session - List authorizations = loginService.onceLogined(userId); - if (authorizations == null) { - List unEncrypted = new ArrayList<>(); - unEncrypted.add(userId); - unEncrypted.add(userPassword); - - String sequence = Sign.encrypt(unEncrypted); - String token = Sign.encrypt(unEncrypted); - - User user = (User) loginService.get(User.class, userId); - Authorization authorization = new Authorization(); - authorization.setUser(user); - authorization.setSequence(sequence); - authorization.setToken(token); - authorization.setLastTime(new Date()); - - loginService.persist(authorization); - - session.put("userId", userId); - session.put("sequence", sequence); - session.put("token", token); - } else { - String value; - for (Authorization auth : authorizations) { - value = auth.getUser().getId(); - if (value != null && value.length() > 0) { - session.put("userId", value); - } - value = auth.getSequence(); - if (value != null && value.length() > 0) { - session.put("sequence", value); - } - value = auth.getToken(); - if (value != null && value.length() > 0) { - session.put("token", value); - } - } - } - } + String signedPassword = Md5.md5(userPassword); + loginResult = loginService.loginByPassword(userId, signedPassword, remoteAddr); } else if (cookies != null) { - String cookieUserId = null; - String cookieSequence = null; - String cookieToken = null; boolean found = false; - + for (Cookie cookie : cookies) { if (cookie != null) { if ("userId".equals(cookie.getName())) { cookieUserId = cookie.getValue(); found = true; + } else if ("adminId".equals(cookie.getName())) { + cookieAdminId = cookie.getValue(); + found = true; } else if ("sequence".equals(cookie.getName())) { cookieSequence = cookie.getValue(); found = true; } else if ("token".equals(cookie.getName())) { - cookieToken= cookie.getValue(); + cookieToken = cookie.getValue(); found = true; } } } - - if (found) { // 使用 Cookie 登陆 - success = loginService.loginByCookie(cookieUserId, cookieSequence, cookieToken, remoteAddr); + + if (found) { // 使用 Cookie 登陆 + if (cookieAdminId != null && cookieAdminId.length() > 0) { + loginResult = loginService.loginByCookie(cookieAdminId, cookieSequence, cookieToken, + remoteAddr); + } else { + loginResult = loginService.loginByCookie(cookieUserId, cookieSequence, cookieToken, + remoteAddr); + } } else { return LOGIN; } + } else { + return LOGIN; } - + // 如果登录成功 - if (success) { + if (SUCCESS_USER.equals(loginResult)) { + updateUserAuthorization(userId); + //TODO if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) { - return actionPath; + return actionPath.startsWith("/") ? actionPath.substring(1) : actionPath; } else { return PROFILE_USER; } + } else if (SUCCESS_COOKIE_USER.equals(loginResult)) { + updateUserAuthorization(cookieUserId); + //TODO + if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) { + return actionPath.startsWith("/") ? actionPath.substring(1) : actionPath; + } else { + return PROFILE_USER; + } + }else if (SUCCESS_ADMIN.equals(loginResult)) { + updateAdminAuthorization(userId); // 前台页面 userId 与 adminId 共用一个 name="userId" 的 标签 + if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) { + return actionPath;//TODO + } else { + return PROFILE_ADMIN; + } + } else if (SUCCESS_COOKIE_ADMIN.equals(loginResult)) { + updateAdminAuthorization(cookieAdminId); + if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) { + return actionPath;//TODO + } else { + return PROFILE_ADMIN; + } } else { - return LOGIN_FAILURE; + deleteAuthorization(); + return LOGIN; } } + // 查询数据库是否有 sequence, token 记录,如果有更新 Cookie 和 Session, 否则生成后存入 Cookie 和 session + private void updateUserAuthorization(String userId) { + List userAuths = loginService.userLoginHistory(userId); + if (userAuths == null) { + List unSinged = new ArrayList<>(); + if (userId != null) { + unSinged.add(userId); + } + if (userPassword != null) { + unSinged.add(userPassword); + } + String sequence = Sign.sign(unSinged); // 登录序列,每个用户只有一个序列实例 + String token = Sign.sign(unSinged); // 登录令牌 + + //将 userId, sequence, token 存入数据库 + User user = (User) loginService.get(User.class, userId); + if (user != null) { + UserAuthorization userAuthorization = new UserAuthorization(); + userAuthorization.setUser(user); + userAuthorization.setSequence(sequence); + userAuthorization.setToken(token); + userAuthorization.setLastTime(new Date()); + loginService.persist(userAuthorization); + } + // 将 userId, sequence, token 存入 Cookie + Cookie cookie = new Cookie("userId", userId); + response.addCookie(cookie); + cookie = new Cookie("sequence", sequence); + response.addCookie(cookie); + cookie = new Cookie("token", token); + response.addCookie(cookie); + + // 删除 Cookie adminId + cookie = new Cookie("adminId", ""); + response.addCookie(cookie); + + // 将 userId, sequence, token 存入 Session + session.put("userId", userId); + session.put("sequence", sequence); + session.put("token", token); + } else { + String value; + Cookie cookie; + + for (UserAuthorization auth : userAuths) { + value = auth.getUser().getId(); + if (value != null && value.length() > 0) { + cookie = new Cookie("userId", value); + response.addCookie(cookie); + session.put("userId", value); + } + value = auth.getSequence(); + if (value != null && value.length() > 0) { + cookie = new Cookie("sequence", value); + response.addCookie(cookie); + session.put("sequence", value); + } + value = auth.getToken(); + if (value != null && value.length() > 0) { + cookie = new Cookie("token", value); + response.addCookie(cookie); + session.put("token", value); + } + } + } + } + + // 查询数据库是否有 sequence, token 记录,如果有更新 Cookie 和 Session, 否则生成后存入 Cookie 和 session + private void updateAdminAuthorization(String adminId) { + List adminAuths = loginService.adminLoginHistory(adminId); + if (adminAuths == null) { + List unSigned = new ArrayList<>(); + if (adminId != null) { + unSigned.add(adminId); + } + if (userPassword != null) { + unSigned.add(userPassword); + } + String sequence = Sign.sign(unSigned); + String token = Sign.sign(unSigned); + + //将 adminId, sequence, token 存入数据库 + Admin admin = (Admin) loginService.get(Admin.class, adminId); + if (admin != null) { + AdminAuthorization adminAuthorization = new AdminAuthorization(); + adminAuthorization.setAdmin(admin); + adminAuthorization.setSequence(sequence); + adminAuthorization.setToken(token); + adminAuthorization.setLastTime(new Date()); + loginService.persist(adminAuthorization); + } + + // 将 adminId, sequence, token 存入 Cookie + Cookie cookie = new Cookie("adminId", adminId); + response.addCookie(cookie); + cookie = new Cookie("sequence", sequence); + response.addCookie(cookie); + cookie = new Cookie("token", token); + response.addCookie(cookie); + + // 删除 Cookie userId + cookie = new Cookie("userId", ""); + response.addCookie(cookie); + + // 将 adminId, sequence, token 存入 Session + session.put("adminId", adminId); + session.put("sequence", sequence); + session.put("token", token); + } else { + String value; + Cookie cookie; + + for (AdminAuthorization auth : adminAuths) { + value = auth.getAdmin().getId(); + if (value != null && value.length() > 0) { + cookie = new Cookie("adminId", value); + response.addCookie(cookie); + session.put("adminId", value); + } + value = auth.getSequence(); + if (value != null && value.length() > 0) { + cookie = new Cookie("sequence", value); + response.addCookie(cookie); + session.put("sequence", value); + } + value = auth.getToken(); + if (value != null && value.length() > 0) { + cookie = new Cookie("token", value); + response.addCookie(cookie); + session.put("token", value); + } + } + } + } + + private void deleteAuthorization() { + + // 清空 Session + session.clear(); + + // 清空 Cookie 里的 userId, adminId, sequence, token + Cookie cookie = new Cookie("userId", ""); + response.addCookie(cookie); + cookie = new Cookie("adminId", ""); + response.addCookie(cookie); + cookie = new Cookie("sequence", ""); + response.addCookie(cookie); + cookie = new Cookie("token", ""); + response.addCookie(cookie); + } + @Override public void setServletRequest(HttpServletRequest request) { - this.request = request; + this.request = request; } - + @Override public void setSession(Map session) { this.session = session; diff --git a/src/main/java/org/fireply/enter/constant/ResultConstants.java b/src/main/java/org/fireply/enter/constant/ResultConstants.java index 77c5264..b89028a 100644 --- a/src/main/java/org/fireply/enter/constant/ResultConstants.java +++ b/src/main/java/org/fireply/enter/constant/ResultConstants.java @@ -1,10 +1,19 @@ package org.fireply.enter.constant; +import com.opensymphony.xwork2.Action; + public class ResultConstants { + public static final String SUCCESS = Action.SUCCESS; + public static final String ERROR = Action.ERROR; + public static final String LOGIN = Action.LOGIN; + public static final String SUCCESS_ADMIN = "success_admin"; + public static final String SUCCESS_USER = "success_user"; + public static final String SUCCESS_COOKIE_ADMIN = "success_cookie_admin"; + public static final String SUCCESS_COOKIE_USER = "success_cookie_user"; + public static final String LOGIN_FAILURE = "login_failure"; public static final String PROFILE_USER = "profile_user"; public static final String PROFILE_ADMIN = "profile_admin"; - public static final String LOGIN_FAILURE = "login_failure"; public static final String INDEX = "index"; public static final String LOGIN_ACTION = "login_action"; diff --git a/src/main/java/org/fireply/enter/model/Account.java b/src/main/java/org/fireply/enter/model/Account.java index c25ad85..ca3a76f 100644 --- a/src/main/java/org/fireply/enter/model/Account.java +++ b/src/main/java/org/fireply/enter/model/Account.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; diff --git a/src/main/java/org/fireply/enter/model/Admin.java b/src/main/java/org/fireply/enter/model/Admin.java index c392122..c5a59e4 100644 --- a/src/main/java/org/fireply/enter/model/Admin.java +++ b/src/main/java/org/fireply/enter/model/Admin.java @@ -1,5 +1,8 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final + +import java.util.HashSet; +import java.util.Set; /** * Admin generated by hbm2java @@ -8,13 +11,23 @@ public class Admin implements java.io.Serializable { private String id; private User user; + private String password; + private Set adminAuthorizations = new HashSet(0); public Admin() { } - public Admin(String id, User user) { + public Admin(String id, User user, String password) { this.id = id; this.user = user; + this.password = password; + } + + public Admin(String id, User user, String password, Set adminAuthorizations) { + this.id = id; + this.user = user; + this.password = password; + this.adminAuthorizations = adminAuthorizations; } public String getId() { @@ -33,4 +46,20 @@ public void setUser(User user) { this.user = user; } + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Set getAdminAuthorizations() { + return this.adminAuthorizations; + } + + public void setAdminAuthorizations(Set adminAuthorizations) { + this.adminAuthorizations = adminAuthorizations; + } + } diff --git a/src/main/java/org/fireply/enter/model/AdminAuthorization.java b/src/main/java/org/fireply/enter/model/AdminAuthorization.java new file mode 100644 index 0000000..dac05fc --- /dev/null +++ b/src/main/java/org/fireply/enter/model/AdminAuthorization.java @@ -0,0 +1,67 @@ +package org.fireply.enter.model; +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final + +import java.util.Date; + +/** + * AdminAuthorization generated by hbm2java + */ +public class AdminAuthorization implements java.io.Serializable { + + private Integer id; + private Admin admin; + private String sequence; + private String token; + private Date lastTime; + + public AdminAuthorization() { + } + + public AdminAuthorization(Admin admin, String sequence, String token, Date lastTime) { + this.admin = admin; + this.sequence = sequence; + this.token = token; + this.lastTime = lastTime; + } + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Admin getAdmin() { + return this.admin; + } + + public void setAdmin(Admin admin) { + this.admin = admin; + } + + public String getSequence() { + return this.sequence; + } + + public void setSequence(String sequence) { + this.sequence = sequence; + } + + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + + public Date getLastTime() { + return this.lastTime; + } + + public void setLastTime(Date lastTime) { + this.lastTime = lastTime; + } + +} diff --git a/src/main/java/org/fireply/enter/model/Category.java b/src/main/java/org/fireply/enter/model/Category.java index 066bd90..4df04f8 100644 --- a/src/main/java/org/fireply/enter/model/Category.java +++ b/src/main/java/org/fireply/enter/model/Category.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; diff --git a/src/main/java/org/fireply/enter/model/Commit.java b/src/main/java/org/fireply/enter/model/Commit.java index b4aa381..da56623 100644 --- a/src/main/java/org/fireply/enter/model/Commit.java +++ b/src/main/java/org/fireply/enter/model/Commit.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.Date; diff --git a/src/main/java/org/fireply/enter/model/Login.java b/src/main/java/org/fireply/enter/model/Login.java index 03723d3..37ba841 100644 --- a/src/main/java/org/fireply/enter/model/Login.java +++ b/src/main/java/org/fireply/enter/model/Login.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.Date; diff --git a/src/main/java/org/fireply/enter/model/News.java b/src/main/java/org/fireply/enter/model/News.java index e980fdc..8cc3865 100644 --- a/src/main/java/org/fireply/enter/model/News.java +++ b/src/main/java/org/fireply/enter/model/News.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.Date; import java.util.HashSet; diff --git a/src/main/java/org/fireply/enter/model/Order.java b/src/main/java/org/fireply/enter/model/Order.java index 554353d..0651d67 100644 --- a/src/main/java/org/fireply/enter/model/Order.java +++ b/src/main/java/org/fireply/enter/model/Order.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.Date; diff --git a/src/main/java/org/fireply/enter/model/Production.java b/src/main/java/org/fireply/enter/model/Production.java index c4e7338..d42f72d 100644 --- a/src/main/java/org/fireply/enter/model/Production.java +++ b/src/main/java/org/fireply/enter/model/Production.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; diff --git a/src/main/java/org/fireply/enter/model/ProductionGallery.java b/src/main/java/org/fireply/enter/model/ProductionGallery.java index 85feb60..5e6d909 100644 --- a/src/main/java/org/fireply/enter/model/ProductionGallery.java +++ b/src/main/java/org/fireply/enter/model/ProductionGallery.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final /** * ProductionGallery generated by hbm2java diff --git a/src/main/java/org/fireply/enter/model/Proxy.java b/src/main/java/org/fireply/enter/model/Proxy.java index 4092739..e7fa5c7 100644 --- a/src/main/java/org/fireply/enter/model/Proxy.java +++ b/src/main/java/org/fireply/enter/model/Proxy.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; diff --git a/src/main/java/org/fireply/enter/model/Qrcode.java b/src/main/java/org/fireply/enter/model/Qrcode.java index 1616736..1827cad 100644 --- a/src/main/java/org/fireply/enter/model/Qrcode.java +++ b/src/main/java/org/fireply/enter/model/Qrcode.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; diff --git a/src/main/java/org/fireply/enter/model/User.java b/src/main/java/org/fireply/enter/model/User.java index f7ec501..b83c706 100644 --- a/src/main/java/org/fireply/enter/model/User.java +++ b/src/main/java/org/fireply/enter/model/User.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; @@ -27,7 +27,7 @@ public class User implements java.io.Serializable { private Set orders = new HashSet(0); private Set commits = new HashSet(0); private Set admins = new HashSet(0); - private Set authorizations = new HashSet(0); + private Set userAuthorizations = new HashSet(0); public User() { } @@ -39,7 +39,7 @@ public User(String id) { public User(String id, Account account, Qrcode qrcode, String password, String name, Boolean sex, String nativePlace, String birthday, String mobile, String email, String userDesc, String headThumb, Set logins, Set newses, Set proxies, Set orders, Set commits, - Set admins, Set authorizations) { + Set admins, Set userAuthorizations) { this.id = id; this.account = account; this.qrcode = qrcode; @@ -58,7 +58,7 @@ public User(String id, Account account, Qrcode qrcode, String password, String n this.orders = orders; this.commits = commits; this.admins = admins; - this.authorizations = authorizations; + this.userAuthorizations = userAuthorizations; } public String getId() { @@ -205,12 +205,12 @@ public void setAdmins(Set admins) { this.admins = admins; } - public Set getAuthorizations() { - return this.authorizations; + public Set getUserAuthorizations() { + return this.userAuthorizations; } - public void setAuthorizations(Set authorizations) { - this.authorizations = authorizations; + public void setUserAuthorizations(Set userAuthorizations) { + this.userAuthorizations = userAuthorizations; } } diff --git a/src/main/java/org/fireply/enter/model/Authorization.java b/src/main/java/org/fireply/enter/model/UserAuthorization.java similarity index 74% rename from src/main/java/org/fireply/enter/model/Authorization.java rename to src/main/java/org/fireply/enter/model/UserAuthorization.java index 242e161..b55c5e0 100644 --- a/src/main/java/org/fireply/enter/model/Authorization.java +++ b/src/main/java/org/fireply/enter/model/UserAuthorization.java @@ -1,12 +1,12 @@ package org.fireply.enter.model; -// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-26 6:45:30 by Hibernate Tools 4.3.1.Final import java.util.Date; /** - * Authorization generated by hbm2java + * UserAuthorization generated by hbm2java */ -public class Authorization implements java.io.Serializable { +public class UserAuthorization implements java.io.Serializable { private Integer id; private User user; @@ -14,10 +14,10 @@ public class Authorization implements java.io.Serializable { private String token; private Date lastTime; - public Authorization() { + public UserAuthorization() { } - public Authorization(User user, String sequence, String token, Date lastTime) { + public UserAuthorization(User user, String sequence, String token, Date lastTime) { this.user = user; this.sequence = sequence; this.token = token; diff --git a/src/main/java/org/fireply/enter/security/Md5.java b/src/main/java/org/fireply/enter/security/Md5.java index 8ae0a91..2d2daba 100644 --- a/src/main/java/org/fireply/enter/security/Md5.java +++ b/src/main/java/org/fireply/enter/security/Md5.java @@ -12,26 +12,26 @@ public class Md5 { /** * 用 SHA1算法生成安全签名 - * @param unsign 待签名字符串 + * @param undigested 待签名字符串 * @return 安全签名 * @throws AesException * */ - public static String sign(String unsign) throws AesException { + public static String md5(String undigested) throws AesException { try { - // SHA1签名生成 + // MD5 签名生成 MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(unsign.getBytes()); + md.update(undigested.getBytes()); byte[] digest = md.digest(); StringBuffer hexStr = new StringBuffer(); - String shaHex = ""; + String byteHex = ""; for (int i = 0; i < digest.length; i++) { - shaHex = Integer.toHexString(digest[i] & 0xFF); - if (shaHex.length() < 2) { + byteHex = Integer.toHexString(digest[i] & 0xFF); + if (byteHex.length() < 2) { hexStr.append(0); } - hexStr.append(shaHex); + hexStr.append(byteHex); } return hexStr.toString(); } catch (Exception e) { diff --git a/src/main/java/org/fireply/enter/security/Sign.java b/src/main/java/org/fireply/enter/security/Sign.java index 02923cc..5918252 100644 --- a/src/main/java/org/fireply/enter/security/Sign.java +++ b/src/main/java/org/fireply/enter/security/Sign.java @@ -2,32 +2,41 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Random; public class Sign { - public static String encrypt(List unEncrypted) { - String encrypted = null; + public static String sign(List unSigned) { + String signed = null; - if (unEncrypted == null) { - unEncrypted = new ArrayList<>(); + if (unSigned == null) { + unSigned = new ArrayList<>(); } String currentTime = Long.toString(System.currentTimeMillis()); - unEncrypted.add(currentTime); - unEncrypted.add(getRandomStr()); - - Object[] unEncryptedArray = unEncrypted.toArray(); - Arrays.sort(unEncryptedArray); + unSigned.add(currentTime); + unSigned.add(getRandomStr()); + + int r = 0, w = 0; + for (; r < unSigned.size(); r++) { + if (unSigned.get(r) != null) { + unSigned.set(w++, unSigned.get(r)); + } + } + unSigned = unSigned.subList(0, w); + + Object[] unSignedArray = unSigned.toArray(); + Arrays.sort(unSignedArray); try { - encrypted = Md5.sign(unEncryptedArray.toString()); + signed = Md5.md5(unSignedArray.toString()); } catch (AesException e) { e.printStackTrace(); } - return encrypted; + return signed; } public static String getRandomStr() { diff --git a/src/main/java/org/fireply/enter/service/LoginService.java b/src/main/java/org/fireply/enter/service/LoginService.java index 52cd39d..37676be 100644 --- a/src/main/java/org/fireply/enter/service/LoginService.java +++ b/src/main/java/org/fireply/enter/service/LoginService.java @@ -7,17 +7,23 @@ public interface LoginService extends BaseService { - boolean loginByPassword(String userId, String signedPassword, String remoteAddr); + String loginByPassword(String userId, String signedPassword, String remoteAddr); - boolean loginByCookie(String userId, String sequence, String token, String remoteAddr); + String loginByCookie(String userId, String sequence, String token, String remoteAddr); boolean allowsLogin(String userId, String remoteAddr); /** * 是否曾经登陆过 * @param userId 用户 ID - * @return boolean 如果曾经登陆过返回 {@code true}, 否则返回 {@code false} + * @return boolean 如果用户曾经登陆过返回 {@code true}, 否则返回 {@code false} */ - List onceLogined(String userId); + List userLoginHistory(String userId); + /** + * 是否曾经登陆过 + * @param userId 用户 ID + * @return boolean 如果曾经管理员登陆过返回 {@code true}, 否则返回 {@code false} + */ + List adminLoginHistory(String userId); } diff --git a/src/main/java/org/fireply/enter/service/impl/LoginServiceImpl.java b/src/main/java/org/fireply/enter/service/impl/LoginServiceImpl.java index aec1f17..7e9a3d4 100644 --- a/src/main/java/org/fireply/enter/service/impl/LoginServiceImpl.java +++ b/src/main/java/org/fireply/enter/service/impl/LoginServiceImpl.java @@ -1,10 +1,18 @@ package org.fireply.enter.service.impl; +import static org.fireply.enter.constant.ResultConstants.LOGIN_FAILURE; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_ADMIN; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_COOKIE_ADMIN; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_COOKIE_USER; +import static org.fireply.enter.constant.ResultConstants.SUCCESS_USER; + import java.util.List; import org.fireply.enter.dao.Dao; -import org.fireply.enter.model.Authorization; +import org.fireply.enter.model.Admin; +import org.fireply.enter.model.AdminAuthorization; import org.fireply.enter.model.User; +import org.fireply.enter.model.UserAuthorization; import org.fireply.enter.service.LoginService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -18,29 +26,48 @@ public class LoginServiceImpl extends BaseServiceImpl implements LoginService { @Autowired @Qualifier("daoImpl") private Dao dao; - + @Override - public boolean loginByPassword(String userId, String signedPassword, String remoteAddr) { + public String loginByPassword(String userId, String signedPassword, String remoteAddr) { + // 先查找 admin 表,如果密码正确,视为管理员登录(注册时 admin 表 id 与 user 表 id 唯一) + Admin admin = (Admin) dao.get(Admin.class, userId); + if (signedPassword != null && admin != null && signedPassword.equals(admin.getPassword())) { + return SUCCESS_ADMIN; + } + + // 再查找 user 表,如果密码正确,视为普通用户登录 User user = (User) dao.get(User.class, userId); if (signedPassword != null && user != null && signedPassword.equals(user.getPassword())) { - return true; - } else { - return false; + return SUCCESS_USER; } + + // 否则登录失败 + return LOGIN_FAILURE; } + // TODO 暂时只判断 sequence 是否正确,未判断 token, 待完成 @Override - public boolean loginByCookie(String userId, String sequence, String token, String remoteAddr) { - // TODO loginByCookie - /*if (loginService != null && user != null && signedPassword.equals(user.getPassword())) { - List unEncrypted = new ArrayList<>(); - unEncrypted.add(userId); - unEncrypted.add(signedPassword); - - sequence = Sign.encrypt(unEncrypted); - token = Sign.encrypt(unEncrypted); - }*/ - return true; + public String loginByCookie(String userId, String sequence, String token, String remoteAddr) { + // 先查找 admin_authorization 表,如果 sequence 正确,视为管理员登录 + List adminAuths = (List) dao.get(AdminAuthorization.class, "adminId", + userId); + for (AdminAuthorization adminAuth : adminAuths) { + if (adminAuth != null && adminAuth.getSequence().equals(sequence)) { + return SUCCESS_COOKIE_ADMIN; + } + } + + // 再查找 user_authorization 表,如果 sequence 正确,视为普通用户登录 + List userAuths = (List) dao.get(UserAuthorization.class, "userId", + userId); + for (UserAuthorization userAuth : userAuths) { + if (userAuth != null && userAuth.getSequence().equals(sequence)) { + return SUCCESS_COOKIE_USER; + } + } + + // 否则登录失败 + return LOGIN_FAILURE; } @Override @@ -49,10 +76,21 @@ public boolean allowsLogin(String userId, String remoteAddr) { } @Override - public List onceLogined(String userId) { - List list = (List) dao.get(Authorization.class, "userId", userId); + public List userLoginHistory(String userId) { + List list = (List) dao.get(UserAuthorization.class, "userId", userId); + if (list != null && !list.isEmpty()) { + return list; + } else { + return null; + } + } + + @Override + public List adminLoginHistory(String adminId) { + List list = (List) dao.get(AdminAuthorization.class, "adminId", + adminId); if (list != null && !list.isEmpty()) { - return list; + return list; } else { return null; } diff --git a/src/main/java/org/fireply/enter/util/ClumnNameUtil.java b/src/main/java/org/fireply/enter/util/ClumnNameUtil.java index 8fd92e8..f0fb18b 100644 --- a/src/main/java/org/fireply/enter/util/ClumnNameUtil.java +++ b/src/main/java/org/fireply/enter/util/ClumnNameUtil.java @@ -2,12 +2,35 @@ public class ClumnNameUtil { + private static final char SEPARATOR = '_'; + public static String getClumnName(String fieldName) { return getUnderlineCase(fieldName); } - + public static String getUnderlineCase(String camelCase) { - // TODO 实体类属性与数据库列的映射方法 - return "user_id"; + if (camelCase == null) { + return null; + } + + StringBuilder sb = new StringBuilder(); + boolean upperCase = false; + boolean nextUpperCase = false; + char c; + + for (int i = 0; i < camelCase.length(); i++) { + c = camelCase.charAt(i); + sb.append(Character.toLowerCase(c)); + + if (i < (camelCase.length() - 1)) { + upperCase = Character.isUpperCase(camelCase.charAt(i)); + nextUpperCase = Character.isUpperCase(camelCase.charAt(i + 1)); + if (!upperCase && nextUpperCase) { + sb.append(SEPARATOR); + } + } + } + + return sb.toString(); } } diff --git a/src/main/resources/enter/model/Account.hbm.xml b/src/main/resources/enter/model/Account.hbm.xml index f3f6cf6..c724cda 100644 --- a/src/main/resources/enter/model/Account.hbm.xml +++ b/src/main/resources/enter/model/Account.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Admin.hbm.xml b/src/main/resources/enter/model/Admin.hbm.xml index 23a66bf..2aa9c3b 100644 --- a/src/main/resources/enter/model/Admin.hbm.xml +++ b/src/main/resources/enter/model/Admin.hbm.xml @@ -1,7 +1,7 @@ - + @@ -11,5 +11,14 @@ + + + + + + + + + diff --git a/src/main/resources/enter/model/AdminAuthorization.hbm.xml b/src/main/resources/enter/model/AdminAuthorization.hbm.xml new file mode 100644 index 0000000..97152be --- /dev/null +++ b/src/main/resources/enter/model/AdminAuthorization.hbm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/enter/model/Category.hbm.xml b/src/main/resources/enter/model/Category.hbm.xml index 338dde8..0ddbe21 100644 --- a/src/main/resources/enter/model/Category.hbm.xml +++ b/src/main/resources/enter/model/Category.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Commit.hbm.xml b/src/main/resources/enter/model/Commit.hbm.xml index 1f04f65..65b464d 100644 --- a/src/main/resources/enter/model/Commit.hbm.xml +++ b/src/main/resources/enter/model/Commit.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Login.hbm.xml b/src/main/resources/enter/model/Login.hbm.xml index fdbca42..57a6083 100644 --- a/src/main/resources/enter/model/Login.hbm.xml +++ b/src/main/resources/enter/model/Login.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/News.hbm.xml b/src/main/resources/enter/model/News.hbm.xml index c60e5ef..c547c5b 100644 --- a/src/main/resources/enter/model/News.hbm.xml +++ b/src/main/resources/enter/model/News.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Order.hbm.xml b/src/main/resources/enter/model/Order.hbm.xml index b6d343a..514cfc8 100644 --- a/src/main/resources/enter/model/Order.hbm.xml +++ b/src/main/resources/enter/model/Order.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Production.hbm.xml b/src/main/resources/enter/model/Production.hbm.xml index a3a1239..bec2fa3 100644 --- a/src/main/resources/enter/model/Production.hbm.xml +++ b/src/main/resources/enter/model/Production.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/ProductionGallery.hbm.xml b/src/main/resources/enter/model/ProductionGallery.hbm.xml index ae2a4fb..9d12310 100644 --- a/src/main/resources/enter/model/ProductionGallery.hbm.xml +++ b/src/main/resources/enter/model/ProductionGallery.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Proxy.hbm.xml b/src/main/resources/enter/model/Proxy.hbm.xml index 2e58098..9193ff8 100644 --- a/src/main/resources/enter/model/Proxy.hbm.xml +++ b/src/main/resources/enter/model/Proxy.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/Qrcode.hbm.xml b/src/main/resources/enter/model/Qrcode.hbm.xml index 16417c0..313907e 100644 --- a/src/main/resources/enter/model/Qrcode.hbm.xml +++ b/src/main/resources/enter/model/Qrcode.hbm.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/enter/model/User.hbm.xml b/src/main/resources/enter/model/User.hbm.xml index 026b82b..5bfffb4 100644 --- a/src/main/resources/enter/model/User.hbm.xml +++ b/src/main/resources/enter/model/User.hbm.xml @@ -1,7 +1,7 @@ - + @@ -77,11 +77,11 @@ - + - + diff --git a/src/main/resources/enter/model/Authorization.hbm.xml b/src/main/resources/enter/model/UserAuthorization.hbm.xml similarity index 80% rename from src/main/resources/enter/model/Authorization.hbm.xml rename to src/main/resources/enter/model/UserAuthorization.hbm.xml index 28fdff1..30242a3 100644 --- a/src/main/resources/enter/model/Authorization.hbm.xml +++ b/src/main/resources/enter/model/UserAuthorization.hbm.xml @@ -1,9 +1,9 @@ - + - + diff --git a/src/main/resources/struts.xml b/src/main/resources/struts.xml index cb01282..5d4cb94 100644 --- a/src/main/resources/struts.xml +++ b/src/main/resources/struts.xml @@ -24,13 +24,12 @@ - /index.jsp + /index.jsp profile/user.jsp profile/admin.jsp - error/error.jsp diff --git a/src/test/java/org/fireply/enter/test/security/SignTest.java b/src/test/java/org/fireply/enter/test/security/SignTest.java deleted file mode 100644 index 3dbdfea..0000000 --- a/src/test/java/org/fireply/enter/test/security/SignTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.fireply.enter.test.security; - -import java.util.ArrayList; -import java.util.List; - -import org.fireply.enter.security.Sign; -import org.fireply.enter.test.BaseSpringJunit4Test; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; - -public class SignTest { - - @Test - public void signTest() { - List unEncrypt = new ArrayList<>(); - unEncrypt.add("userId"); - unEncrypt.add("userPassword"); - - String token = Sign.encrypt(unEncrypt); - System.out.println(token); - assertNotNull(token); - } -} diff --git a/src/test/java/org/fireply/enter/test/service/AdminServiceTest.java b/src/test/java/org/fireply/enter/test/service/AdminServiceTest.java new file mode 100644 index 0000000..e61e99f --- /dev/null +++ b/src/test/java/org/fireply/enter/test/service/AdminServiceTest.java @@ -0,0 +1,25 @@ +package org.fireply.enter.test.service; + +import static org.junit.Assert.*; + +import org.fireply.enter.model.Admin; +import org.fireply.enter.service.BaseService; +import org.fireply.enter.test.BaseSpringJunit4Test; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; + +public class AdminServiceTest extends BaseSpringJunit4Test { + + @Autowired + @Qualifier("baseServiceImpl") + BaseService baseService; + + @Test + public void getAdminTest() { + String adminId = "admin"; + Admin admin = (Admin) baseService.get(Admin.class, adminId); + assertNotNull(admin); + System.out.println(admin); + } +} diff --git a/src/test/java/org/fireply/enter/test/util/ClumnNameUtilTest.java b/src/test/java/org/fireply/enter/test/util/ClumnNameUtilTest.java new file mode 100644 index 0000000..65ae0cc --- /dev/null +++ b/src/test/java/org/fireply/enter/test/util/ClumnNameUtilTest.java @@ -0,0 +1,22 @@ +package org.fireply.enter.test.util; + +import static org.junit.Assert.assertEquals; + +import org.fireply.enter.util.ClumnNameUtil; +import org.junit.Test; + +public class ClumnNameUtilTest { + + @Test + public void getUnderlineCaseTest() { + assertEquals("user_id", ClumnNameUtil.getUnderlineCase("userId")); + assertEquals("user_id", ClumnNameUtil.getUnderlineCase("UserId")); + assertEquals("userid", ClumnNameUtil.getUnderlineCase("USERID")); + assertEquals("user_id", ClumnNameUtil.getUnderlineCase("USErId")); + assertEquals("user_id", ClumnNameUtil.getUnderlineCase("userID")); + assertEquals("u_ser_id", ClumnNameUtil.getUnderlineCase("uSErId")); + assertEquals("userid", ClumnNameUtil.getUnderlineCase("USERId")); + assertEquals("useri_d", ClumnNameUtil.getUnderlineCase("useriD")); + } + +}