From: Tang Cheng Date: Tue, 23 Apr 2019 02:00:16 +0000 (+0800) Subject: 修改了表结构 X-Git-Tag: 1.0.0^2~260 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=923349929aa887a15307b29149bf0dd6c7c4ed7f;p=epayment%2Ffood_payapi.git 修改了表结构 --- diff --git a/config/application-devel-pg-local.properties b/config/application-devel-pg-local.properties index 3602345e..175bb6b0 100644 --- a/config/application-devel-pg-local.properties +++ b/config/application-devel-pg-local.properties @@ -16,3 +16,5 @@ redis.database=0 jwt.secret=Zj5taLomEbrM0lk+NMQZbHfSxaDU1wekjT+kiC3YzDw= # timeout seconds jwt.expiration=3600 +# user password +auth.password.bcrypt.seed= diff --git a/src/main/java/com/supwisdom/dlpay/consume/domain/TAccount.java b/src/main/java/com/supwisdom/dlpay/consume/domain/TAccount.java index 9dd87c10..d4a4d210 100644 --- a/src/main/java/com/supwisdom/dlpay/consume/domain/TAccount.java +++ b/src/main/java/com/supwisdom/dlpay/consume/domain/TAccount.java @@ -7,7 +7,9 @@ import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; @Entity -@Table(name = "TB_ACCOUNT") +@Table(name = "TB_ACCOUNT", + indexes = {@Index(name = "acc_userid_idx", columnList = "userid"), + @Index(name = "acc_status_idx", columnList = "status")}) public class TAccount { @Id @GenericGenerator(name = "idGenerator", strategy = "uuid") @@ -15,52 +17,52 @@ public class TAccount { @Column(name = "ACCNO", nullable = false, length = 32) private String accno; //账号 - @Column(name="ACCNAME", length = 100) + @Column(name = "ACCNAME", length = 100) private String accname; //账户名 - @Column(name="SUBJNO", length = 10) + @Column(name = "SUBJNO", length = 10) private String subjno; //科目号 - @Column(name="USERID", nullable = false, length = 32) + @Column(name = "USERID", nullable = false, length = 32) private String userid; //用户ID - @Column(name="STATUS", nullable = false, length = 20) + @Column(name = "STATUS", nullable = false, length = 20) private String status; //状态:normal-正常;closed-注销;locked-冻结 - @Column(name="BALANCE", nullable = false, precision = 15, scale = 2) + @Column(name = "BALANCE", nullable = false, precision = 15, scale = 2) private Double balance; //总余额 - @Column(name="AVAILBAL", nullable = false, precision = 15, scale = 2) + @Column(name = "AVAILBAL", nullable = false, precision = 15, scale = 2) private Double availbal; //可用余额 - @Column(name="FROZEBAL", nullable = false, precision = 15, scale = 2) + @Column(name = "FROZEBAL", nullable = false, precision = 15, scale = 2) private Double frozebal; //冻结金额 - @Column(name="LOWFREE_FLAG", nullable = false, precision = 1, scale = 0) + @Column(name = "LOWFREE_FLAG", nullable = false, precision = 1, scale = 0) private Boolean lowfreeFlag; //低额免密开关 - @Column(name="LOWFREE_LIMIT", precision = 9, scale = 2) + @Column(name = "LOWFREE_LIMIT", precision = 9, scale = 2) private Double lowfreeLimit; //免密额度 - @Column(name="DAYLIMIT", precision = 9, scale = 2) + @Column(name = "DAY_LIMIT", precision = 9, scale = 2) private Double daylimit; // 日累计消费额度 - @Column(name="MAXBAL", precision = 15, scale = 2) + @Column(name = "MAX_BAL", precision = 15, scale = 2) private Double maxbal; // 最大余额限制 - @Column(name = "LASTTRANSDATE", length = 8) + @Column(name = "LAST_TRANSDATE", length = 8) private String lasttransdate; //最后交易日期 - @Column(name="LASTDAY_TRANSAMT", precision = 9, scale = 2) + @Column(name = "LASTDAY_TRANSAMT", precision = 9, scale = 2) private Double lastdayTransamt; //最后一天消费金额 - @Column(name="LASTDAY_DPSAMT", precision = 9, scale = 2) + @Column(name = "LASTDAY_DPSAMT", precision = 9, scale = 2) private Double lastdayDpsamt; //最后一天充值金额 - @Column(name="TAC", length = 32) + @Column(name = "TAC", length = 32) private String tac; //校验 - @Column(name="OPENDATE", nullable = false, length = 8) + @Column(name = "OPENDATE", nullable = false, length = 8) private String opendate; @Column(name = "CLOSEDATE", length = 8) @@ -233,14 +235,14 @@ public class TAccount { this.closedate = closedate; } - public String generateTac(){ - String data = this.accno+ MoneyUtil.YuanToFen(this.availbal)+MoneyUtil.YuanToFen(this.balance)+MoneyUtil.YuanToFen(this.frozebal); + public String generateTac() { + String data = this.accno + MoneyUtil.YuanToFen(this.availbal) + MoneyUtil.YuanToFen(this.balance) + MoneyUtil.YuanToFen(this.frozebal); return MD5.generatePassword(data, this.accno); } - public boolean tacCheck(){ + public boolean tacCheck() { String tac_c = generateTac(); - if (tac_c.equalsIgnoreCase(this.tac)||this.tac==null) { + if (tac_c.equalsIgnoreCase(this.tac) || this.tac == null) { return true; } return false; @@ -252,9 +254,9 @@ public class TAccount { this.tac = this.generateTac(); } - public boolean checkOverflow(){ - if(null!=this.maxbal && this.maxbal>0){ - if(MoneyUtil.moneyCompare(this.balance,this.maxbal)>0){ + public boolean checkOverflow() { + if (null != this.maxbal && this.maxbal > 0) { + if (MoneyUtil.moneyCompare(this.balance, this.maxbal) > 0) { return true; //超出账户最大值 } } diff --git a/src/main/java/com/supwisdom/dlpay/consume/domain/TPerson.java b/src/main/java/com/supwisdom/dlpay/consume/domain/TPerson.java index c5bceb60..cfe4872c 100644 --- a/src/main/java/com/supwisdom/dlpay/consume/domain/TPerson.java +++ b/src/main/java/com/supwisdom/dlpay/consume/domain/TPerson.java @@ -5,7 +5,8 @@ import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; @Entity -@Table(name = "TB_PERSON") +@Table(name = "TB_PERSON", + indexes = {@Index(name = "person_name_idx", columnList = "name")}) public class TPerson { @Id @GenericGenerator(name = "idGenerator", strategy = "uuid") @@ -19,7 +20,7 @@ public class TPerson { @Column(name = "SEX", length = 10) private String sex; - @Column(name = "STATUS",nullable = false, length = 10) + @Column(name = "STATUS", nullable = false, length = 10) private String status; @Column(name = "IDTYPE", length = 20) @@ -54,7 +55,7 @@ public class TPerson { /** * 第三方唯一标识,可为学工号,银行卡号等 - * */ + */ @Column(name = "THIRD_UNIQUE_IDENTY", length = 32) private String thirdUniqueIdenty; diff --git a/src/main/java/com/supwisdom/dlpay/consume/domain/TUserdtl.java b/src/main/java/com/supwisdom/dlpay/consume/domain/TUserdtl.java index 4b59d981..58260523 100644 --- a/src/main/java/com/supwisdom/dlpay/consume/domain/TUserdtl.java +++ b/src/main/java/com/supwisdom/dlpay/consume/domain/TUserdtl.java @@ -1,12 +1,13 @@ package com.supwisdom.dlpay.consume.domain; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; @Entity -@Table(name = "TB_USERDTL") +@Table(name = "TB_USERDTL", + indexes = {@Index(name = "userdtl_transdate_idx", columnList = "transdate"), + @Index(name = "userdtl_accdate_idx", columnList = "accdate"), + @Index(name = "userdtl_status_idx", columnList = "status"), + @Index(name = "userdtl_reverse_idx", columnList = "REVERSE_FLAG")}) public class TUserdtl { @Id @Column(name = "REFNO", nullable = false, length = 32) diff --git a/src/main/java/com/supwisdom/dlpay/framework/core/PasswordBCryptConfig.java b/src/main/java/com/supwisdom/dlpay/framework/core/PasswordBCryptConfig.java new file mode 100644 index 00000000..1743e2e3 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/framework/core/PasswordBCryptConfig.java @@ -0,0 +1,28 @@ +package com.supwisdom.dlpay.framework.core; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class PasswordBCryptConfig { + @Value("${auth.password.bcrypt.length:10}") + private Integer length; + @Value("${auth.password.bcrypt.seed}") + private String seed = ""; + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public String getSeed() { + return seed; + } + + public void setSeed(String seed) { + this.seed = seed; + } +} diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/OperRoleDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/OperRoleDao.java index 72dc37ad..292a999c 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/dao/OperRoleDao.java +++ b/src/main/java/com/supwisdom/dlpay/framework/dao/OperRoleDao.java @@ -10,6 +10,6 @@ import java.util.List; @Repository public interface OperRoleDao extends JpaRepository { - @Query(value = "select distinct role_code from TB_OPER_ROLE a,TB_ROLE b where a.role_id=b.role_id and a.operid=?1", nativeQuery = true) + @Query(value = "select distinct rolecode from TB_OPER_ROLE a,TB_ROLE b where a.roleid=b.roleid and a.operid=?1", nativeQuery = true) List getRolecodeByOperid(String operid); } diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TFunction.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TFunction.java index 5b7beab8..8c135e80 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TFunction.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TFunction.java @@ -13,22 +13,22 @@ public class TFunction { @Column(name="ID", nullable = false, length = 32) private String id; - @Column(name="PARENT_ID", length = 32) + @Column(name="PARENTID", length = 32) private String parentId; @Column(name="NAME", length = 32) private String name; - @Column(name="MENU_URL", nullable = false, length = 60) + @Column(name="MENUURL", nullable = false, length = 60) private String menuUrl; //菜单url - @Column(name="IS_LEAF", nullable = false, precision = 1) + @Column(name="ISLEAF", nullable = false, precision = 1) private Integer isLeaf; - @Column(name="ORDER_NUM", precision = 9) + @Column(name="ORDERNUM", precision = 9) private Integer orderNum; - @Column(name="MENU_ICON", precision = 9) + @Column(name="MENUICON", precision = 9) private String menuIcon; @Column(name="CREATETIME", length = 14) diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TOperRole.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TOperRole.java index f889fac2..d17c2738 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TOperRole.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TOperRole.java @@ -5,18 +5,19 @@ import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; @Entity -@Table(name = "TB_OPER_ROLE") +@Table(name = "TB_OPER_ROLE", + indexes = {@Index(name = "operrole_operid_idx", columnList = "operid")}) public class TOperRole { @Id @GenericGenerator(name = "idGenerator", strategy = "uuid") @GeneratedValue(generator = "idGenerator") - @Column(name="ID", nullable = false, length = 32) + @Column(name = "ID", nullable = false, length = 32) private String id; - @Column(name="ROLE_ID", nullable = false, length = 32) + @Column(name = "ROLEID", nullable = false, length = 32) private String roleId; - @Column(name="OPERID", nullable = false, length = 32) + @Column(name = "OPERID", nullable = false, length = 32) private String operid; public String getId() { diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TOperator.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TOperator.java index 62853029..520f19a5 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TOperator.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TOperator.java @@ -9,33 +9,34 @@ import javax.persistence.*; import java.util.Collection; @Entity -@Table(name = "TB_OPERATOR") +@Table(name = "TB_OPERATOR", + indexes = {@Index(name = "opercode_idx", columnList = "OPERCODE", unique = true)}) public class TOperator implements UserDetails { @Id @GenericGenerator(name = "idGenerator", strategy = "uuid") @GeneratedValue(generator = "idGenerator") - @Column(name="OPERID", nullable = false, length = 32) + @Column(name = "OPERID", nullable = false, length = 32) private String operid; - @Column(name="OPERCODE", nullable = false, length = 20) + @Column(name = "OPERCODE", nullable = false, length = 20) private String opercode; - @Column(name="OPERTYPE", nullable = false, length = 20) + @Column(name = "OPERTYPE", nullable = false, length = 20) private String opertype; - @Column(name="OPERNAME", nullable = false, length = 100) + @Column(name = "OPERNAME", nullable = false, length = 100) private String opername; - @Column(name="OPERPWD", nullable = false, length = 80) + @Column(name = "OPERPWD", nullable = false, length = 80) private String operpwd; - @Column(name="STATUS", nullable = false, length = 32) + @Column(name = "STATUS", nullable = false, length = 32) private String status; - @Column(name="OPENDATE", length = 8) + @Column(name = "OPENDATE", length = 8) private String opendate; - @Column(name="CLOSEDATE", length = 8) + @Column(name = "CLOSEDATE", length = 8) private String closedate; @Transient diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TRole.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TRole.java index 6be9d78f..31122593 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TRole.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TRole.java @@ -10,16 +10,16 @@ public class TRole { @Id @GenericGenerator(name = "idGenerator", strategy = "uuid") @GeneratedValue(generator = "idGenerator") - @Column(name="ROLE_ID", nullable = false, length = 32) + @Column(name="ROLEID", nullable = false, length = 32) private String roleId; - @Column(name="ROLE_NAME", nullable = false, length = 60) + @Column(name="ROLENAME", nullable = false, length = 60) private String roleName; - @Column(name="ROLE_CODE", nullable = false, length = 20) + @Column(name="ROLECODE", nullable = false, length = 20) private String roleCode; - @Column(name="ROLE_DESC", length = 60) + @Column(name="ROLEDESC", length = 60) private String roleDesc; @Column(name="EDITFLAG", length = 60) diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TRoleFunction.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TRoleFunction.java index 3475cd34..91f43070 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TRoleFunction.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TRoleFunction.java @@ -13,10 +13,10 @@ public class TRoleFunction { @Column(name="ID", nullable = false, length = 32) private String id; - @Column(name="ROLE_ID", nullable = false, length = 32) + @Column(name="ROLEID", nullable = false, length = 32) private String roleId; - @Column(name="FUNCTION_ID", nullable = false, length = 32) + @Column(name="FUNCTIONID", nullable = false, length = 32) private String functionId; public String getId() { diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java index 80895c6c..73dbf10d 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TSettlectl.java @@ -12,10 +12,10 @@ public class TSettlectl { @Column(name="BOOKSETNO", nullable = false, precision = 2) private Integer booksetno; - @Column(name="PERIOD_YEAR", nullable = false, precision = 4) + @Column(name="PERIODYEAR", nullable = false, precision = 4) private Integer periodYear; - @Column(name="PERIOD_MONTH", nullable = false, precision = 2) + @Column(name="PERIODMONTH", nullable = false, precision = 2) private Integer periodMonth; @Column(name="STATDATE", precision = 8) diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java index d2faa89a..7f42c1fb 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java @@ -13,10 +13,10 @@ public class TVoucher { @Column(name="VOUCHERID", nullable = false, length = 32) private String voucherid; - @Column(name="PERIOD_YEAR", precision = 8) + @Column(name="PERIODYEAR", precision = 8) private Integer periodYear; - @Column(name="PERIOD_MONTH", precision = 2) + @Column(name="PERIODMONTH", precision = 2) private Integer periodMonth; @Column(name="VOUCHERNO", precision = 9) diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java index 8b010c4a..24f75c38 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TVouchernoCtl.java @@ -12,7 +12,7 @@ public class TVouchernoCtl { @Column(name="VOUCHERTYPE", nullable = false, precision = 2) private Integer vouchertype; - @Column(name="PERIOD_MONTH", nullable = false, precision = 2) + @Column(name="PERIODMONTH", nullable = false, precision = 2) private Integer periodMonth; @Column(name = "VOUCHERNO", nullable = false, precision = 9) diff --git a/src/main/kotlin/com/supwisdom/dlpay/framework/controller/security_controller.kt b/src/main/kotlin/com/supwisdom/dlpay/framework/controller/security_controller.kt index 147270b4..5bcea3a0 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/framework/controller/security_controller.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/framework/controller/security_controller.kt @@ -15,6 +15,7 @@ import com.supwisdom.dlpay.framework.service.SystemUtilService import com.supwisdom.dlpay.framework.util.HmacUtil import com.supwisdom.dlpay.system.service.CommonService import com.supwisdom.dlpay.system.service.FunctionService +import mu.KotlinLogging import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity @@ -122,10 +123,10 @@ class ValidateCodeController { } -data class LoginForm(val username: String, val password: String, val imageCode: String) - @Controller class WebHomeController { + + private val logger = KotlinLogging.logger {} @Autowired lateinit var functionService: FunctionService @Autowired @@ -137,12 +138,13 @@ class WebHomeController { @GetMapping("/logout") fun logout(request: HttpServletRequest, response: HttpServletResponse): String { SecurityContextHolder.getContext().authentication?.also { + logger.debug { "user logout!!" } SecurityContextLogoutHandler().logout(request, response, it) } return "redirect:/login?logout" } - @GetMapping("/index") + @GetMapping(value = ["/", "/index"]) fun homeView(@AuthenticationPrincipal operUser: UserDetails, model: Model): String { model.addAttribute("loginOper", operUser as TOperator) val funclist = functionService.getFunctionsByOperid(operUser.operid) diff --git a/src/main/kotlin/com/supwisdom/dlpay/security.kt b/src/main/kotlin/com/supwisdom/dlpay/security.kt index 5b375ff0..491cc463 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/security.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/security.kt @@ -2,6 +2,7 @@ package com.supwisdom.dlpay import com.supwisdom.dlpay.framework.core.JwtConfig import com.supwisdom.dlpay.framework.core.JwtTokenUtil +import com.supwisdom.dlpay.framework.core.PasswordBCryptConfig import com.supwisdom.dlpay.framework.security.ValidateCodeSecurityConfig import com.supwisdom.dlpay.framework.service.OperatorDetailService import org.jose4j.jwt.consumer.InvalidJwtException @@ -26,6 +27,7 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl import org.springframework.security.web.util.matcher.AntPathRequestMatcher import org.springframework.web.filter.OncePerRequestFilter +import java.security.SecureRandom import javax.servlet.FilterChain import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletResponse @@ -54,7 +56,6 @@ class ApiJwtAuthenticationFilter(jwt: JwtTokenUtil) : OncePerRequestFilter() { @EnableWebSecurity class WebSecurityConfig { - companion object { @Configuration @Order(1) @@ -94,6 +95,8 @@ class WebSecurityConfig { lateinit var authenticationFailureHandler: AuthenticationFailureHandler @Autowired lateinit var authenticationSuccessHandler: AuthenticationSuccessHandler + @Autowired + lateinit var passwordBCryptConfig: PasswordBCryptConfig @Autowired @@ -113,7 +116,12 @@ class WebSecurityConfig { @Bean fun passwordEncoder(): BCryptPasswordEncoder { - return BCryptPasswordEncoder() + return if (passwordBCryptConfig.seed.isBlank()) { + BCryptPasswordEncoder() + } else { + BCryptPasswordEncoder(passwordBCryptConfig.length, + SecureRandom(passwordBCryptConfig.seed.toByteArray())) + } } @Bean diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 6abc8d8a..b54e7279 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -18,3 +18,8 @@ spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.mode=HTML5 spring.thymeleaf.cache=false spring.thymeleaf.enabled=true + +################################################ +# user password +auth.password.bcrypt.length=10 +