From c63f168ec1c2de3b42299abf18b49c354e9ee8e0 Mon Sep 17 00:00:00 2001 From: Fireply Date: Mon, 23 May 2016 14:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=AF=86=E7=A0=81=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=EF=BC=8C=E5=B0=86=E7=94=9F=E6=88=90=20sequence,=20tok?= =?UTF-8?q?en=20=E5=AD=98=E5=85=A5=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebRoot/profile/user.jsp | 4 ++ .../org/fireply/enter/action/LoginAction.java | 48 ++++++++++++++++++- .../org/fireply/enter/dao/impl/DaoImpl.java | 12 +++-- .../java/org/fireply/enter/model/Account.java | 15 ++---- .../java/org/fireply/enter/model/Admin.java | 36 ++++++++++++++ .../fireply/enter/model/Authorization.java | 11 ++--- .../org/fireply/enter/model/Category.java | 2 +- .../java/org/fireply/enter/model/Commit.java | 14 +++--- .../java/org/fireply/enter/model/Login.java | 16 +++---- .../java/org/fireply/enter/model/News.java | 2 +- .../java/org/fireply/enter/model/Order.java | 15 +++--- .../org/fireply/enter/model/Production.java | 14 +++--- .../enter/model/ProductionGallery.java | 11 ++--- .../java/org/fireply/enter/model/Proxy.java | 2 +- .../java/org/fireply/enter/model/Qrcode.java | 2 +- .../java/org/fireply/enter/model/User.java | 14 +++++- .../fireply/enter/service/BaseService.java | 2 + .../fireply/enter/service/LoginService.java | 10 ++++ .../enter/service/impl/LoginServiceImpl.java | 13 +++++ .../org/fireply/enter/util/ClumnNameUtil.java | 13 +++++ .../resources/enter/model/Account.hbm.xml | 10 ++-- src/main/resources/enter/model/Admin.hbm.xml | 15 ++++++ .../enter/model/Authorization.hbm.xml | 8 ++-- .../resources/enter/model/Category.hbm.xml | 2 +- src/main/resources/enter/model/Commit.hbm.xml | 8 ++-- src/main/resources/enter/model/Login.hbm.xml | 8 ++-- src/main/resources/enter/model/News.hbm.xml | 2 +- src/main/resources/enter/model/Order.hbm.xml | 10 ++-- .../resources/enter/model/Production.hbm.xml | 12 ++--- .../enter/model/ProductionGallery.hbm.xml | 10 ++-- src/main/resources/enter/model/Proxy.hbm.xml | 2 +- src/main/resources/enter/model/Qrcode.hbm.xml | 2 +- src/main/resources/enter/model/User.hbm.xml | 10 +++- 33 files changed, 247 insertions(+), 108 deletions(-) create mode 100644 src/main/java/org/fireply/enter/model/Admin.java create mode 100644 src/main/java/org/fireply/enter/util/ClumnNameUtil.java create mode 100644 src/main/resources/enter/model/Admin.hbm.xml diff --git a/WebRoot/profile/user.jsp b/WebRoot/profile/user.jsp index d23c0de..6f4fb1d 100644 --- a/WebRoot/profile/user.jsp +++ b/WebRoot/profile/user.jsp @@ -1,5 +1,6 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="/struts-tags" prefix="s" %> @@ -18,6 +19,9 @@ 用户主页 + userId: + sequence: + token: diff --git a/src/main/java/org/fireply/enter/action/LoginAction.java b/src/main/java/org/fireply/enter/action/LoginAction.java index 1cfd091..8d03ed6 100644 --- a/src/main/java/org/fireply/enter/action/LoginAction.java +++ b/src/main/java/org/fireply/enter/action/LoginAction.java @@ -3,6 +3,7 @@ import static org.fireply.enter.constant.ResultConstants.*; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -13,6 +14,8 @@ 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.User; import org.fireply.enter.security.Md5; import org.fireply.enter.security.Sign; import org.fireply.enter.service.LoginService; @@ -47,7 +50,48 @@ public String execute() throws Exception { if (userId != null && userPassword != null) { String signedPassword = Md5.sign(userPassword); success = loginService.loginByPassword(userId, signedPassword, remoteAddr); - } else if (cookies != null) { // 使用 Cookie 登录 + 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); + } + } + } + } + } else if (cookies != null) { String cookieUserId = null; String cookieSequence = null; String cookieToken = null; @@ -68,7 +112,7 @@ public String execute() throws Exception { } } - if (found) { + if (found) { // 使用 Cookie 登陆 success = loginService.loginByCookie(cookieUserId, cookieSequence, cookieToken, remoteAddr); } else { return LOGIN; diff --git a/src/main/java/org/fireply/enter/dao/impl/DaoImpl.java b/src/main/java/org/fireply/enter/dao/impl/DaoImpl.java index 6a283df..fcb9704 100644 --- a/src/main/java/org/fireply/enter/dao/impl/DaoImpl.java +++ b/src/main/java/org/fireply/enter/dao/impl/DaoImpl.java @@ -5,6 +5,7 @@ import java.util.Map; import org.fireply.enter.dao.Dao; +import org.fireply.enter.util.ClumnNameUtil; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.SessionFactory; @@ -50,18 +51,18 @@ public Object get(String modelName, Serializable id) { @Override public List get(Class clazz, String fieldName, Object fieldValue) { - String hql = "from" + clazz.getSimpleName() + "where" + fieldName + "'" + fieldValue + "'"; + String hql = "from " + clazz.getSimpleName() + " where " + ClumnNameUtil.getClumnName(fieldName) + "='" + fieldValue + "'"; return executeQuery(hql); } @Override - public List get(Class clazz, Map fieldsMap) { + public List get(String modelName, String fieldName, Object fieldValue) { // TODO Auto-generated method stub return null; } - + @Override - public List get(String modelName, String fieldName, Object fieldValue) { + public List get(Class clazz, Map fieldsMap) { // TODO Auto-generated method stub return null; } @@ -90,7 +91,8 @@ public List executeQuery(String hql, int firstResult, int maxResults) { query.setFirstResult(firstResult); query.setMaxResults(maxResults); } - return query.list(); + List list = query.list(); + return list; } @Override diff --git a/src/main/java/org/fireply/enter/model/Account.java b/src/main/java/org/fireply/enter/model/Account.java index 902f445..c25ad85 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; @@ -9,7 +9,7 @@ */ public class Account implements java.io.Serializable { - private String id; + private Integer id; private String wexinId; private String alipayId; private Set users = new HashSet(0); @@ -17,22 +17,17 @@ public class Account implements java.io.Serializable { public Account() { } - public Account(String id) { - this.id = id; - } - - public Account(String id, String wexinId, String alipayId, Set users) { - this.id = id; + public Account(String wexinId, String alipayId, Set users) { this.wexinId = wexinId; this.alipayId = alipayId; this.users = users; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/Admin.java b/src/main/java/org/fireply/enter/model/Admin.java new file mode 100644 index 0000000..c392122 --- /dev/null +++ b/src/main/java/org/fireply/enter/model/Admin.java @@ -0,0 +1,36 @@ +package org.fireply.enter.model; +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final + +/** + * Admin generated by hbm2java + */ +public class Admin implements java.io.Serializable { + + private String id; + private User user; + + public Admin() { + } + + public Admin(String id, User user) { + this.id = id; + this.user = user; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public User getUser() { + return this.user; + } + + public void setUser(User user) { + this.user = user; + } + +} diff --git a/src/main/java/org/fireply/enter/model/Authorization.java b/src/main/java/org/fireply/enter/model/Authorization.java index 764b651..242e161 100644 --- a/src/main/java/org/fireply/enter/model/Authorization.java +++ b/src/main/java/org/fireply/enter/model/Authorization.java @@ -1,5 +1,5 @@ package org.fireply.enter.model; -// Generated 2016-5-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.Date; @@ -8,7 +8,7 @@ */ public class Authorization implements java.io.Serializable { - private String id; + private Integer id; private User user; private String sequence; private String token; @@ -17,19 +17,18 @@ public class Authorization implements java.io.Serializable { public Authorization() { } - public Authorization(String id, User user, String sequence, String token, Date lastTime) { - this.id = id; + public Authorization(User user, String sequence, String token, Date lastTime) { this.user = user; this.sequence = sequence; this.token = token; this.lastTime = lastTime; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/Category.java b/src/main/java/org/fireply/enter/model/Category.java index dabce78..066bd90 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 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 fe35041..b4aa381 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.Date; @@ -8,7 +8,7 @@ */ public class Commit implements java.io.Serializable { - private String id; + private Integer id; private News news; private User user; private String content; @@ -17,26 +17,24 @@ public class Commit implements java.io.Serializable { public Commit() { } - public Commit(String id, News news, String content, Date createTime) { - this.id = id; + public Commit(News news, String content, Date createTime) { this.news = news; this.content = content; this.createTime = createTime; } - public Commit(String id, News news, User user, String content, Date createTime) { - this.id = id; + public Commit(News news, User user, String content, Date createTime) { this.news = news; this.user = user; this.content = content; this.createTime = createTime; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/Login.java b/src/main/java/org/fireply/enter/model/Login.java index f22cdb1..03723d3 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.Date; @@ -8,7 +8,7 @@ */ public class Login implements java.io.Serializable { - private String id; + private Integer id; private User user; private int ip; private Date lastTime; @@ -22,16 +22,14 @@ public class Login implements java.io.Serializable { public Login() { } - public Login(String id, User user, int ip, Date lastTime) { - this.id = id; + public Login(User user, int ip, Date lastTime) { this.user = user; this.ip = ip; this.lastTime = lastTime; } - public Login(String id, User user, int ip, Date lastTime, Short passwordSuccess, Short passwordFailure, - Short cookieSuccess, Short sequenceFailure, Short multiDeviceFactor, Short ipFactor) { - this.id = id; + public Login(User user, int ip, Date lastTime, Short passwordSuccess, Short passwordFailure, Short cookieSuccess, + Short sequenceFailure, Short multiDeviceFactor, Short ipFactor) { this.user = user; this.ip = ip; this.lastTime = lastTime; @@ -43,11 +41,11 @@ public Login(String id, User user, int ip, Date lastTime, Short passwordSuccess, this.ipFactor = ipFactor; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/News.java b/src/main/java/org/fireply/enter/model/News.java index 3dd8ff4..e980fdc 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 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 ae84257..554353d 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.Date; @@ -8,7 +8,7 @@ */ public class Order implements java.io.Serializable { - private String id; + private Integer id; private Production production; private Proxy proxy; private User user; @@ -19,15 +19,12 @@ public class Order implements java.io.Serializable { public Order() { } - public Order(String id, String price, Date createTime) { - this.id = id; + public Order(String price, Date createTime) { this.price = price; this.createTime = createTime; } - public Order(String id, Production production, Proxy proxy, User user, String price, Date createTime, - String qrcodeId) { - this.id = id; + public Order(Production production, Proxy proxy, User user, String price, Date createTime, String qrcodeId) { this.production = production; this.proxy = proxy; this.user = user; @@ -36,11 +33,11 @@ public Order(String id, Production production, Proxy proxy, User user, String pr this.qrcodeId = qrcodeId; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/Production.java b/src/main/java/org/fireply/enter/model/Production.java index 54f8723..c4e7338 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; @@ -9,7 +9,7 @@ */ public class Production implements java.io.Serializable { - private String id; + private Integer id; private Category category; private String name; private String price; @@ -21,16 +21,14 @@ public class Production implements java.io.Serializable { public Production() { } - public Production(String id, String name, String price, String thumb) { - this.id = id; + public Production(String name, String price, String thumb) { this.name = name; this.price = price; this.thumb = thumb; } - public Production(String id, Category category, String name, String price, String desc, String thumb, + public Production(Category category, String name, String price, String desc, String thumb, Set productionGalleries, Set orders) { - this.id = id; this.category = category; this.name = name; this.price = price; @@ -40,11 +38,11 @@ public Production(String id, Category category, String name, String price, Strin this.orders = orders; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/ProductionGallery.java b/src/main/java/org/fireply/enter/model/ProductionGallery.java index 40328b4..85feb60 100644 --- a/src/main/java/org/fireply/enter/model/ProductionGallery.java +++ b/src/main/java/org/fireply/enter/model/ProductionGallery.java @@ -1,29 +1,28 @@ package org.fireply.enter.model; -// Generated 2016-5-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final /** * ProductionGallery generated by hbm2java */ public class ProductionGallery implements java.io.Serializable { - private String id; + private Integer id; private Production production; private String imageSrc; public ProductionGallery() { } - public ProductionGallery(String id, Production production, String imageSrc) { - this.id = id; + public ProductionGallery(Production production, String imageSrc) { this.production = production; this.imageSrc = imageSrc; } - public String getId() { + public Integer getId() { return this.id; } - public void setId(String id) { + public void setId(Integer id) { this.id = id; } diff --git a/src/main/java/org/fireply/enter/model/Proxy.java b/src/main/java/org/fireply/enter/model/Proxy.java index 7957a6e..4092739 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 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 d5de8f7..1616736 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 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 fad6cdf..f7ec501 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-22 15:15:44 by Hibernate Tools 4.3.1.Final +// Generated 2016-5-23 16:15:06 by Hibernate Tools 4.3.1.Final import java.util.HashSet; import java.util.Set; @@ -26,6 +26,7 @@ public class User implements java.io.Serializable { private Set proxies = new HashSet(0); private Set orders = new HashSet(0); private Set commits = new HashSet(0); + private Set admins = new HashSet(0); private Set authorizations = new HashSet(0); public User() { @@ -38,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 authorizations) { + Set admins, Set authorizations) { this.id = id; this.account = account; this.qrcode = qrcode; @@ -56,6 +57,7 @@ public User(String id, Account account, Qrcode qrcode, String password, String n this.proxies = proxies; this.orders = orders; this.commits = commits; + this.admins = admins; this.authorizations = authorizations; } @@ -195,6 +197,14 @@ public void setCommits(Set commits) { this.commits = commits; } + public Set getAdmins() { + return this.admins; + } + + public void setAdmins(Set admins) { + this.admins = admins; + } + public Set getAuthorizations() { return this.authorizations; } diff --git a/src/main/java/org/fireply/enter/service/BaseService.java b/src/main/java/org/fireply/enter/service/BaseService.java index cf59a61..60a7eba 100644 --- a/src/main/java/org/fireply/enter/service/BaseService.java +++ b/src/main/java/org/fireply/enter/service/BaseService.java @@ -2,6 +2,8 @@ import java.io.Serializable; +import org.springframework.stereotype.Service; + public interface BaseService { void persist(Object object); diff --git a/src/main/java/org/fireply/enter/service/LoginService.java b/src/main/java/org/fireply/enter/service/LoginService.java index 4abbc76..52cd39d 100644 --- a/src/main/java/org/fireply/enter/service/LoginService.java +++ b/src/main/java/org/fireply/enter/service/LoginService.java @@ -1,5 +1,8 @@ package org.fireply.enter.service; +import java.io.Serializable; +import java.util.List; + import javax.servlet.http.Cookie; public interface LoginService extends BaseService { @@ -10,4 +13,11 @@ public interface LoginService extends BaseService { boolean allowsLogin(String userId, String remoteAddr); + /** + * 是否曾经登陆过 + * @param userId 用户 ID + * @return boolean 如果曾经登陆过返回 {@code true}, 否则返回 {@code false} + */ + List onceLogined(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 783e1e0..aec1f17 100644 --- a/src/main/java/org/fireply/enter/service/impl/LoginServiceImpl.java +++ b/src/main/java/org/fireply/enter/service/impl/LoginServiceImpl.java @@ -1,6 +1,9 @@ package org.fireply.enter.service.impl; +import java.util.List; + import org.fireply.enter.dao.Dao; +import org.fireply.enter.model.Authorization; import org.fireply.enter.model.User; import org.fireply.enter.service.LoginService; import org.springframework.beans.factory.annotation.Autowired; @@ -45,4 +48,14 @@ public boolean allowsLogin(String userId, String remoteAddr) { return true; } + @Override + public List onceLogined(String userId) { + List list = (List) dao.get(Authorization.class, "userId", userId); + if (list != null && !list.isEmpty()) { + 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 new file mode 100644 index 0000000..8fd92e8 --- /dev/null +++ b/src/main/java/org/fireply/enter/util/ClumnNameUtil.java @@ -0,0 +1,13 @@ +package org.fireply.enter.util; + +public class ClumnNameUtil { + + public static String getClumnName(String fieldName) { + return getUnderlineCase(fieldName); + } + + public static String getUnderlineCase(String camelCase) { + // TODO 实体类属性与数据库列的映射方法 + return "user_id"; + } +} diff --git a/src/main/resources/enter/model/Account.hbm.xml b/src/main/resources/enter/model/Account.hbm.xml index 23ca318..f3f6cf6 100644 --- a/src/main/resources/enter/model/Account.hbm.xml +++ b/src/main/resources/enter/model/Account.hbm.xml @@ -1,12 +1,12 @@ - + - - - + + + @@ -16,7 +16,7 @@ - + diff --git a/src/main/resources/enter/model/Admin.hbm.xml b/src/main/resources/enter/model/Admin.hbm.xml new file mode 100644 index 0000000..23a66bf --- /dev/null +++ b/src/main/resources/enter/model/Admin.hbm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/enter/model/Authorization.hbm.xml b/src/main/resources/enter/model/Authorization.hbm.xml index 871ae4a..28fdff1 100644 --- a/src/main/resources/enter/model/Authorization.hbm.xml +++ b/src/main/resources/enter/model/Authorization.hbm.xml @@ -1,12 +1,12 @@ - + - - - + + + diff --git a/src/main/resources/enter/model/Category.hbm.xml b/src/main/resources/enter/model/Category.hbm.xml index 1d4dd2c..338dde8 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 3e6c45b..1f04f65 100644 --- a/src/main/resources/enter/model/Commit.hbm.xml +++ b/src/main/resources/enter/model/Commit.hbm.xml @@ -1,12 +1,12 @@ - + - - - + + + diff --git a/src/main/resources/enter/model/Login.hbm.xml b/src/main/resources/enter/model/Login.hbm.xml index 15e20c5..fdbca42 100644 --- a/src/main/resources/enter/model/Login.hbm.xml +++ b/src/main/resources/enter/model/Login.hbm.xml @@ -1,12 +1,12 @@ - + - - - + + + diff --git a/src/main/resources/enter/model/News.hbm.xml b/src/main/resources/enter/model/News.hbm.xml index 1acfd65..c60e5ef 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 a630a0d..b6d343a 100644 --- a/src/main/resources/enter/model/Order.hbm.xml +++ b/src/main/resources/enter/model/Order.hbm.xml @@ -1,15 +1,15 @@ - + - - - + + + - + diff --git a/src/main/resources/enter/model/Production.hbm.xml b/src/main/resources/enter/model/Production.hbm.xml index a6c9e0b..a3a1239 100644 --- a/src/main/resources/enter/model/Production.hbm.xml +++ b/src/main/resources/enter/model/Production.hbm.xml @@ -1,12 +1,12 @@ - + - - - + + + @@ -25,13 +25,13 @@ - + - + diff --git a/src/main/resources/enter/model/ProductionGallery.hbm.xml b/src/main/resources/enter/model/ProductionGallery.hbm.xml index 6954667..ae2a4fb 100644 --- a/src/main/resources/enter/model/ProductionGallery.hbm.xml +++ b/src/main/resources/enter/model/ProductionGallery.hbm.xml @@ -1,15 +1,15 @@ - + - - - + + + - + diff --git a/src/main/resources/enter/model/Proxy.hbm.xml b/src/main/resources/enter/model/Proxy.hbm.xml index 2cb4f04..2e58098 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 cb7a18b..16417c0 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 9888c82..026b82b 100644 --- a/src/main/resources/enter/model/User.hbm.xml +++ b/src/main/resources/enter/model/User.hbm.xml @@ -1,7 +1,7 @@ - + @@ -9,7 +9,7 @@ - + @@ -71,6 +71,12 @@ + + + + + +