Commit 70f739d7 authored by xiaozhe.chen's avatar xiaozhe.chen

添加修改手机号后台管理接口

parent bb9a9d55
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cn.quantgroup</groupId>
<artifactId>customer-service</artifactId> <artifactId>customer-service</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
...@@ -21,11 +20,10 @@ ...@@ -21,11 +20,10 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<spring-context-support.version>4.1.6.RELEASE</spring-context-support.version> <spring-context-support.version>4.1.6.RELEASE</spring-context-support.version>
<maven.test.skip>true</maven.test.skip> <maven.test.skip>true</maven.test.skip>
<!--temporary-->
<okhttp.version>3.4.2</okhttp.version> <okhttp.version>3.4.2</okhttp.version>
<retrofit.version>2.1.0</retrofit.version> <retrofit.version>2.1.0</retrofit.version>
<rxjava.version>1.2.3</rxjava.version> <rxjava.version>1.2.3</rxjava.version>
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version> <security.version>3.2.7.RELEASE</security.version>
</properties> </properties>
<build> <build>
...@@ -59,16 +57,21 @@ ...@@ -59,16 +57,21 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>commons-spring</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>commons-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -88,7 +91,6 @@ ...@@ -88,7 +91,6 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version> <version>5.1.31</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
...@@ -121,22 +123,22 @@ ...@@ -121,22 +123,22 @@
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId> <artifactId>spring-security-core</artifactId>
<version>${org.springframework.security.version}</version> <version>${security.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId> <artifactId>spring-security-config</artifactId>
<version>${org.springframework.security.version}</version> <version>${security.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId> <artifactId>spring-security-crypto</artifactId>
<version>${org.springframework.security.version}</version> <version>${security.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId> <artifactId>spring-security-web</artifactId>
<version>${org.springframework.security.version}</version> <version>${security.version}</version>
</dependency> </dependency>
<!--security 不兼容. 降级到 1.5.4 完全OK--> <!--security 不兼容. 降级到 1.5.4 完全OK-->
<dependency> <dependency>
...@@ -190,49 +192,11 @@ ...@@ -190,49 +192,11 @@
<artifactId>logback-core</artifactId> <artifactId>logback-core</artifactId>
<version>1.1.4</version> <version>1.1.4</version>
</dependency> </dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>${retrofit.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>adapter-rxjava</artifactId>
<version>${retrofit.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-simplexml</artifactId>
<version>${retrofit.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>${retrofit.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.62</version> <version>1.2.62</version>
</dependency> </dependency>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>commons-spring</artifactId>
</dependency>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>commons-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>shutdown-spring-boot-starter</artifactId> <artifactId>shutdown-spring-boot-starter</artifactId>
...@@ -243,40 +207,4 @@ ...@@ -243,40 +207,4 @@
</dependency> </dependency>
</dependencies> </dependencies>
<profiles>
<profile>
<id>dev</id>
<properties>
<project.environment>dev</project.environment>
</properties>
<build>
<resources>
<resource>
<directory>
${project.basedir}/src/main/resources/config/dev
</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
<profile>
<id>product</id>
<properties>
<project.environment>product</project.environment>
</properties>
<build>
<resources>
<resource>
<directory>
${project.basedir}/src/main/resources/config/product
</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
</profiles>
</project> </project>
\ No newline at end of file
...@@ -7,9 +7,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; ...@@ -7,9 +7,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration @Configuration
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@SpringBootApplication(scanBasePackages = { @SpringBootApplication(scanBasePackages = {"cn.quantgroup.customer"})
"cn.quantgroup.customer"
})
public class Bootstrap { public class Bootstrap {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -35,8 +35,6 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter { ...@@ -35,8 +35,6 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter {
} }
//添加枚举参数转化器
//LocalDate,LocalDateTime转换器也在此添加
@Override @Override
public void addFormatters(FormatterRegistry registry) { public void addFormatters(FormatterRegistry registry) {
registry.addConverterFactory(new IEnumConverterFactory()); registry.addConverterFactory(new IEnumConverterFactory());
......
...@@ -11,7 +11,7 @@ import java.io.IOException; ...@@ -11,7 +11,7 @@ import java.io.IOException;
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration @Configuration
public class CORSFilter implements Filter { public class CorsFilter implements Filter {
private String allowedHeaders; private String allowedHeaders;
@Override @Override
......
...@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component; ...@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
@Component("passwordEncoder") @Component("passwordEncoder")
public class IPasswordEncoder implements PasswordEncoder { public class ParticularPasswordEncoder implements PasswordEncoder {
@Override @Override
public String encode(CharSequence rawPassword) { public String encode(CharSequence rawPassword) {
return PwdUtil.MD5(rawPassword.toString().toLowerCase() + Constant.PASSWORD_SALT); return PwdUtil.MD5(rawPassword.toString().toLowerCase() + Constant.PASSWORD_SALT);
......
package cn.quantgroup.customer.config.http.security;
import cn.quantgroup.customer.rest.JsonResult;
import org.apache.http.HttpStatus;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import static cn.quantgroup.customer.constant.Constant.GSON;
public class RESTAuthenticationEntryPoint implements AuthenticationEntryPoint {
private static final String UN_AUTHORIZED_RESULT = GSON.toJson(new JsonResult("UnAuthorized request", 401L, ""));
@Override
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
httpServletResponse.setStatus(HttpStatus.SC_UNAUTHORIZED);
httpServletResponse.setContentType("application/javascript; charset=utf-8");
PrintWriter out = httpServletResponse.getWriter();
out.println(UN_AUTHORIZED_RESULT);
out.close();
}
}
package cn.quantgroup.customer.config.http.security; package cn.quantgroup.customer.config.http.security;
import cn.quantgroup.customer.config.http.mvc.filter.CsrfHeaderFilter; import cn.quantgroup.customer.config.http.mvc.filter.CsrfHeaderFilter;
import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.service.IUserService; import cn.quantgroup.customer.service.IUserService;
import cn.quantgroup.customer.util.PwdUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -16,13 +14,11 @@ import org.springframework.security.crypto.password.PasswordEncoder; ...@@ -16,13 +14,11 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.csrf.CsrfFilter; import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.security.web.csrf.CsrfTokenRepository; import org.springframework.security.web.csrf.CsrfTokenRepository;
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository; import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
import org.springframework.util.StringUtils;
@Configuration @Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final IUserService userService; private final IUserService userService;
private final PasswordEncoder passwordEncoder; private final PasswordEncoder passwordEncoder;
@Autowired @Autowired
...@@ -58,20 +54,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -58,20 +54,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(new PasswordEncoder() { auth.userDetailsService(userService).passwordEncoder(passwordEncoder);
@Override
public String encode(CharSequence rawPass) {
return PwdUtil.MD5(rawPass.toString().toLowerCase() + Constant.PASSWORD_SALT);
}
@Override
public boolean matches(CharSequence rawPass, String password) {
if (StringUtils.isEmpty(password)) {
return false;
}
return password.equals(PwdUtil.MD5(rawPass.toString().toLowerCase() + Constant.PASSWORD_SALT));
}
});
} }
@Override @Override
......
...@@ -38,10 +38,8 @@ public class HttpRequestRetryHandler extends DefaultHttpRequestRetryHandler { ...@@ -38,10 +38,8 @@ public class HttpRequestRetryHandler extends DefaultHttpRequestRetryHandler {
* @param requestSentRetryEnabled * @param requestSentRetryEnabled
*/ */
public HttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled) { public HttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled) {
super(retryCount, requestSentRetryEnabled, Arrays.asList( super(retryCount, requestSentRetryEnabled, Arrays.asList(UnknownHostException.class, SSLException.class));
UnknownHostException.class, this.idempotentMethods = new ConcurrentHashMap<>();
SSLException.class));
this.idempotentMethods = new ConcurrentHashMap();
this.idempotentMethods.put("GET", Boolean.TRUE); this.idempotentMethods.put("GET", Boolean.TRUE);
this.idempotentMethods.put("HEAD", Boolean.TRUE); this.idempotentMethods.put("HEAD", Boolean.TRUE);
this.idempotentMethods.put("PUT", Boolean.TRUE); this.idempotentMethods.put("PUT", Boolean.TRUE);
...@@ -62,8 +60,8 @@ public class HttpRequestRetryHandler extends DefaultHttpRequestRetryHandler { ...@@ -62,8 +60,8 @@ public class HttpRequestRetryHandler extends DefaultHttpRequestRetryHandler {
@Override @Override
protected boolean handleAsIdempotent(HttpRequest request) { protected boolean handleAsIdempotent(HttpRequest request) {
String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT); String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
Boolean b = (Boolean) this.idempotentMethods.get(method); Boolean b = this.idempotentMethods.get(method);
return b != null && b.booleanValue(); return b != null && b;
} }
/** /**
......
...@@ -27,18 +27,15 @@ import org.springframework.web.client.RestTemplate; ...@@ -27,18 +27,15 @@ import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import java.io.IOException; import java.io.IOException;
import static cn.quantgroup.customer.constant.Constant.HTTP;
import static cn.quantgroup.customer.constant.Constant.HTTPS;
@Configuration @Configuration
public class RestConfig { public class RestConfig {
private final int connect_timeout = 15000;
private final int read_timeout = 30000;
private final int so_timeout = 60000;
private static final String HTTP = "http";
private static final String HTTPS = "https";
@Bean @Bean
public RestTemplate sslRastTemplate() { public RestTemplate sslRestTemplate() {
SSLContext sslContext = null; SSLContext sslContext;
try { try {
sslContext = new SSLContextBuilder() sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, (TrustStrategy) (x509Certificates, s) -> true).build(); .loadTrustMaterial(null, (TrustStrategy) (x509Certificates, s) -> true).build();
...@@ -53,9 +50,11 @@ public class RestConfig { ...@@ -53,9 +50,11 @@ public class RestConfig {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
connectionManager.setMaxTotal(1000); connectionManager.setMaxTotal(1000);
connectionManager.setDefaultMaxPerRoute(1000); connectionManager.setDefaultMaxPerRoute(1000);
int connectTimeout = 15000;
int soTimeout = 60000;
RequestConfig requestConfig = RequestConfig.custom() RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(connect_timeout).setConnectionRequestTimeout(connect_timeout) .setConnectTimeout(connectTimeout).setConnectionRequestTimeout(connectTimeout)
.setSocketTimeout(so_timeout).build(); .setSocketTimeout(soTimeout).build();
HttpClientBuilder clientBuilder = HttpClientBuilder.create(); HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.setSSLSocketFactory(sslsf); clientBuilder.setSSLSocketFactory(sslsf);
...@@ -69,8 +68,9 @@ public class RestConfig { ...@@ -69,8 +68,9 @@ public class RestConfig {
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(); HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
clientHttpRequestFactory.setHttpClient(httpClient); clientHttpRequestFactory.setHttpClient(httpClient);
clientHttpRequestFactory.setConnectTimeout(connect_timeout); clientHttpRequestFactory.setConnectTimeout(connectTimeout);
clientHttpRequestFactory.setReadTimeout(read_timeout); int readTimeout = 30000;
clientHttpRequestFactory.setReadTimeout(readTimeout);
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory); RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
restTemplate.setErrorHandler(new HttpResponseErrorHandler()); restTemplate.setErrorHandler(new HttpResponseErrorHandler());
...@@ -83,13 +83,13 @@ public class RestConfig { ...@@ -83,13 +83,13 @@ public class RestConfig {
*/ */
public static class LogInterceptor implements ClientHttpRequestInterceptor { public static class LogInterceptor implements ClientHttpRequestInterceptor {
private final static Logger log = LoggerFactory.getLogger(RestTemplate.class); private final static Logger log = LoggerFactory.getLogger(RestTemplate.class);
private final static int max_len = 1024; private final static int MAX_LEN = 1024;
@Override @Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
String p = null; String p = null;
if (body != null) { if (body != null) {
if (body.length > max_len) { if (body.length > MAX_LEN) {
p = "Too long."; p = "Too long.";
} else { } else {
p = new String(body); p = new String(body);
......
...@@ -4,13 +4,14 @@ package cn.quantgroup.customer.constant; ...@@ -4,13 +4,14 @@ package cn.quantgroup.customer.constant;
import com.google.gson.Gson; import com.google.gson.Gson;
public interface Constant { public interface Constant {
String HTTP = "http";
String HTTPS = "https";
String PASSWORD_SALT = "_lkb"; String PASSWORD_SALT = "_lkb";
String COOKIE_NAME = "SESSION";
String CUSTOMER_SESSION_NAMESPACE = "CUSTOMER:SESSION_NAMESPACE";
String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT"; String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
int COOKIE_AND_SESSION_EXPIRE_TIMEOUT_SECONDS = 24 * 60 * 60; int COOKIE_AND_SESSION_EXPIRE_TIMEOUT_SECONDS = 24 * 60 * 60;
String LOGIN_SUCCESS = "登录成功"; String LOGIN_SUCCESS = "登录成功";
String LOGOUT_SUCCESS = "登出成功"; String LOGOUT_SUCCESS = "登出成功";
String LOGIN_FAIL = "登录失败"; String LOGIN_FAIL = "登录失败";
......
package cn.quantgroup.customer.entity;
import cn.quantgroup.customer.enums.AuthorityEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "authorities")
@Getter
@Setter
@ToString
public class Authority implements GrantedAuthority {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "authority")
private AuthorityEnum authority;
@Override
public String getAuthority() {
if (Objects.isNull(authority)) {
return null;
}
return authority.getName();
}
public String getAuthorityMessage() {
if (Objects.isNull(authority)) {
return null;
}
return authority.getMessage();
}
}
...@@ -5,7 +5,7 @@ import lombok.Getter; ...@@ -5,7 +5,7 @@ import lombok.Getter;
@Getter @Getter
public enum Role { public enum Role {
/* /*
| 初审|终审|统计|查询|催收|催收减免|修改订单状态 | 初审|终审|统计|查询|催收|催收减免|修改订单状态
——————————————— ———————————————
管理员 |√ |√ |√ |√ |√ |x |x 管理员 |√ |√ |√ |√ |√ |x |x
主管 |√ |√ |√ |√ |√ |x |x 主管 |√ |√ |√ |√ |√ |x |x
...@@ -14,7 +14,7 @@ public enum Role { ...@@ -14,7 +14,7 @@ public enum Role {
催收人员 |x |x |x |x |√ |x |x 催收人员 |x |x |x |x |√ |x |x
催收主管 |x |x |x |x |√ |√ |x 催收主管 |x |x |x |x |√ |√ |x
运营人员 |x |x |x |x |x |x |√ 运营人员 |x |x |x |x |x |x |√
*/ */
ADMINISTRATOR("管理员"), ADMINISTRATOR("管理员"),
SUPERVISOR("主管"), SUPERVISOR("主管"),
......
package cn.quantgroup.customer.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity
@Table(name = "role_authority")
@Getter
@Setter
@ToString
public class RoleAuthority {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "role_id", nullable = false)
private Long roleId;
@Column(name = "authority_id", nullable = false)
private Long authorityId;
@Column(name = "enable")
private Boolean enable;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
}
package cn.quantgroup.customer.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
@Entity
@Table(name = "user_role")
@Getter
@Setter
@ToString
public class UserRole implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id", nullable = false)
private Long userId;
@Column(name = "role_id", nullable = false)
private Long roleId;
@Column(name = "enable")
private Boolean enable;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
}
package cn.quantgroup.customer.enums;
import lombok.Getter;
@Getter
public enum AuthorityEnum {
MODIFY_PHONE("MODIFY_PHONE", "修改手机号", 10);
private String name;
private int value;
private String message;
AuthorityEnum(String name, String message, int value) {
this.name = name;
this.value = value;
this.message = message;
}
}
package cn.quantgroup.customer.enums;
public enum RoleTypeEnum {
}
package cn.quantgroup.customer.repo;
import cn.quantgroup.customer.entity.Authority;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Collection;
import java.util.List;
public interface AuthorityRepo extends JpaRepository<Authority, Long> {
List<Authority> findByIdIn(Collection<Long> idList);
}
package cn.quantgroup.customer.repo;
import cn.quantgroup.customer.entity.RoleAuthority;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Collection;
import java.util.List;
public interface RoleAuthorityRepo extends JpaRepository<RoleAuthority, Long> {
List<RoleAuthority> findByRoleIdIn(Collection<Long> roleIdList);
}
package cn.quantgroup.customer.repo;
import cn.quantgroup.customer.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface UserRoleRepo extends JpaRepository<UserRole, Long> {
List<UserRole> findByUserId(Long userId);
}
package cn.quantgroup.customer.rest; package cn.quantgroup.customer.rest;
import java.io.Serializable; import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Setter
@Getter
public class JsonResult implements Serializable { public class JsonResult implements Serializable {
public static final Long API_INVOKE_UNEXPECTED_RESULT_CODE = 2L; private static final Long API_INVOKE_UNEXPECTED_RESULT_CODE = 2L;
private static final Long SUCCESS_CODE = 0L; private static final Long SUCCESS_CODE = 0L;
private static final Long ERROR_STATE_CODE = 1L; private static final Long ERROR_STATE_CODE = 1L;
private static final Long SUCCESS_BUSSINESS_CODE = 0L; private static final Long SUCCESS_BUSSINESS_CODE = 0L;
private static final Long ERROR_BUSSINESS_CODE = 1L; private static final Long ERROR_BUSSINESS_CODE = 1L;
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
private static final String ZERO_FILL_TEMPLATE = "%04d"; private static final String ZERO_FILL_TEMPLATE = "%04d";
private static final String FLOAT_MONEY_ZERO_FILL = "%.2f";
private String msg = ""; private String msg = "";
// 0成功,1失败 // 0成功,1失败
private String code = "0000"; private String code = "0000";
// 业务错误码 // 业务错误码
private String businessCode = "0000"; private String businessCode = "0000";
// 业务状态码
private String businessFlag = "0000";
private Object data = null; private Object data = null;
public JsonResult() { public JsonResult() {
} }
/**
* @param msg
* @param code
* @param data
*/
public JsonResult(String msg, Long code, Object data) { public JsonResult(String msg, Long code, Object data) {
this.msg = msg; this.msg = msg;
this.code = String.format(ZERO_FILL_TEMPLATE, code); this.code = String.format(ZERO_FILL_TEMPLATE, code);
...@@ -43,25 +41,11 @@ public class JsonResult implements Serializable { ...@@ -43,25 +41,11 @@ public class JsonResult implements Serializable {
this.businessCode = String.format(ZERO_FILL_TEMPLATE, businessCode); this.businessCode = String.format(ZERO_FILL_TEMPLATE, businessCode);
} }
public JsonResult(String msg, Long code, Object data, Long businessFlag, Long businessCode) {
this.msg = msg;
this.code = String.format(ZERO_FILL_TEMPLATE, code);
this.data = data;
this.businessCode = String.format(ZERO_FILL_TEMPLATE, businessCode);
this.businessFlag = String.format(ZERO_FILL_TEMPLATE, businessFlag);
}
public JsonResult(Object data) { public JsonResult(Object data) {
this.data = data; this.data = data;
} }
/**
* 构造成功的JsonResult
*
* @param msg String
* @param data Object
* @return JsonResult
*/
public static JsonResult buildSuccessResult(String msg, Object data) { public static JsonResult buildSuccessResult(String msg, Object data) {
return new JsonResult(msg, SUCCESS_CODE, data, SUCCESS_BUSSINESS_CODE); return new JsonResult(msg, SUCCESS_CODE, data, SUCCESS_BUSSINESS_CODE);
} }
...@@ -70,17 +54,6 @@ public class JsonResult implements Serializable { ...@@ -70,17 +54,6 @@ public class JsonResult implements Serializable {
return new JsonResult(msg, SUCCESS_CODE, data, businessId); return new JsonResult(msg, SUCCESS_CODE, data, businessId);
} }
public static JsonResult buildSuccessResult(String msg, Object data, Long businessFlag, Long businessCode) {
return new JsonResult(msg, SUCCESS_CODE, data, businessFlag, businessCode);
}
/**
* 构造状态不正确的JsonResult
*
* @param msg String
* @param data Object
* @return JsonResult
*/
public static JsonResult buildErrorStateResult(String msg, Object data) { public static JsonResult buildErrorStateResult(String msg, Object data) {
return new JsonResult(msg, ERROR_STATE_CODE, data, ERROR_BUSSINESS_CODE); return new JsonResult(msg, ERROR_STATE_CODE, data, ERROR_BUSSINESS_CODE);
} }
...@@ -101,53 +74,12 @@ public class JsonResult implements Serializable { ...@@ -101,53 +74,12 @@ public class JsonResult implements Serializable {
return new JsonResult(msg, SUCCESS_CODE, data, API_INVOKE_UNEXPECTED_RESULT_CODE); return new JsonResult(msg, SUCCESS_CODE, data, API_INVOKE_UNEXPECTED_RESULT_CODE);
} }
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getBusinessCode() {
return businessCode;
}
public void setBusinessCode(String businessCode) {
this.businessCode = businessCode;
}
public String getBusinessFlag() {
return businessFlag;
}
public void setBusinessFlag(String businessFlag) {
this.businessFlag = businessFlag;
}
@Override @Override
public String toString() { public String toString() {
return "JsonResult{" + return "JsonResult{" +
"businessCode='" + businessCode + '\'' + "businessCode='" + businessCode + '\'' +
", code='" + code + '\'' + ", code='" + code + '\'' +
", data=" + data + ", data=" + data +
",businessFlag=" + businessFlag +
'}'; '}';
} }
......
package cn.quantgroup.customer.rest; package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.service.http.IHttpService;
import com.google.common.collect.Maps;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.Map; import org.springframework.web.bind.annotation.RestController;
import static cn.quantgroup.customer.constant.Constant.LOGOUT_SUCCESS;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/test") @RequestMapping("/test")
public class TestRest { public class TestRest {
@Autowired
private IHttpService httpService;
@GetMapping(value = "/auth")
public JsonResult testAuth() {
return JsonResult.buildSuccessResult(LOGOUT_SUCCESS, null);
}
@RequestMapping(value = "/audit", method = RequestMethod.PUT)
public JsonResult audit(@RequestBody AuditParam auditParam) {
return JsonResult.buildSuccessResult("success", auditParam);
}
@RequestMapping(value = "/put_audit")
public JsonResult putAudit() {
//String url = "http://127.0.0.1:7067/test/audit";
String url = "";
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/json");
Map<String, String> auditParam = Maps.newHashMap();
auditParam.put("applyStatus", "true");
auditParam.put("applyStatusReason", "success");
auditParam.put("id", "rx12308866");
JsonResult result = httpService.put(url, header, auditParam, JsonResult.class);
return result;
}
@RequestMapping(value = "/modify/{id}/feedback", method = RequestMethod.PUT) @RequestMapping(value = "/modify/{id}/feedback", method = RequestMethod.PUT)
public JsonResult feedback(@PathVariable String id) { public JsonResult feedback(@PathVariable String id) {
...@@ -53,12 +18,4 @@ public class TestRest { ...@@ -53,12 +18,4 @@ public class TestRest {
} }
@Setter
@Getter
static class AuditParam {
private boolean applyStatus;
private String applyStatusReason;
private String id;
}
} }
...@@ -53,18 +53,6 @@ public class UserRest { ...@@ -53,18 +53,6 @@ public class UserRest {
return JsonResult.buildErrorStateResult(LOGIN_FAIL, null); return JsonResult.buildErrorStateResult(LOGIN_FAIL, null);
} }
@PostMapping(value = "/logout")
public JsonResult logout() {
return JsonResult.buildSuccessResult(LOGOUT_SUCCESS, null);
}
@GetMapping(value = "/logout-success")
public JsonResult logoutSuccess() {
return JsonResult.buildSuccessResult(LOGOUT_SUCCESS, null);
}
/** /**
* 修改手机号-查询工单 * 修改手机号-查询工单
* *
......
package cn.quantgroup.customer.service; package cn.quantgroup.customer.service;
import cn.quantgroup.customer.entity.Authority;
import cn.quantgroup.customer.entity.RoleAuthority;
import cn.quantgroup.customer.entity.UserRole;
import cn.quantgroup.customer.rest.param.ModifyPhoneAudit; import cn.quantgroup.customer.rest.param.ModifyPhoneAudit;
import cn.quantgroup.customer.rest.param.ModifyPhoneFeedback; import cn.quantgroup.customer.rest.param.ModifyPhoneFeedback;
import cn.quantgroup.customer.rest.param.ModifyPhoneQuery; import cn.quantgroup.customer.rest.param.ModifyPhoneQuery;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public interface IUserService extends UserDetailsService { public interface IUserService extends UserDetailsService {
List<UserRole> findUserRoleByUserId(Long userId);
List<RoleAuthority> findRoleAuthorityByRoleIds(List<Long> roleIdList);
List<Authority> findAuthorityByAuthorityIds(List<Long> authorityIdList);
String modifyPhoneQuery(ModifyPhoneQuery modifyPhoneQuery); String modifyPhoneQuery(ModifyPhoneQuery modifyPhoneQuery);
String modifyPhoneAudit(ModifyPhoneAudit modifyPhoneAudit); String modifyPhoneAudit(ModifyPhoneAudit modifyPhoneAudit);
String modifyPhoneFeedback(ModifyPhoneFeedback modifyPhoneFeedback); String modifyPhoneFeedback(ModifyPhoneFeedback modifyPhoneFeedback);
} }
package cn.quantgroup.customer.service.impl; package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.entity.Authority;
import cn.quantgroup.customer.entity.RoleAuthority;
import cn.quantgroup.customer.entity.User; import cn.quantgroup.customer.entity.User;
import cn.quantgroup.customer.entity.UserRole;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.NetCommunicationException; import cn.quantgroup.customer.exception.NetCommunicationException;
import cn.quantgroup.customer.repo.AuthorityRepo;
import cn.quantgroup.customer.repo.RoleAuthorityRepo;
import cn.quantgroup.customer.repo.UserRepo; import cn.quantgroup.customer.repo.UserRepo;
import cn.quantgroup.customer.repo.UserRoleRepo;
import cn.quantgroup.customer.rest.param.ModifyPhoneAudit; import cn.quantgroup.customer.rest.param.ModifyPhoneAudit;
import cn.quantgroup.customer.rest.param.ModifyPhoneFeedback; import cn.quantgroup.customer.rest.param.ModifyPhoneFeedback;
import cn.quantgroup.customer.rest.param.ModifyPhoneQuery; import cn.quantgroup.customer.rest.param.ModifyPhoneQuery;
...@@ -26,7 +20,6 @@ import org.springframework.security.core.userdetails.UserDetails; ...@@ -26,7 +20,6 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map; import java.util.Map;
import static cn.quantgroup.customer.constant.Constant.GSON; import static cn.quantgroup.customer.constant.Constant.GSON;
...@@ -39,20 +32,12 @@ public class UserServiceImpl implements IUserService { ...@@ -39,20 +32,12 @@ public class UserServiceImpl implements IUserService {
private String userSysUrl; private String userSysUrl;
private final UserRepo userRepo; private final UserRepo userRepo;
private final UserRoleRepo userRoleRepo;
private final AuthorityRepo authorityRepo;
private final RoleAuthorityRepo roleAuthorityRepo;
private final IHttpService httpService; private final IHttpService httpService;
@Autowired @Autowired
public UserServiceImpl(UserRepo userRepo, UserRoleRepo userRoleRepo, public UserServiceImpl(UserRepo userRepo, IHttpService httpService) {
AuthorityRepo authorityRepo, RoleAuthorityRepo roleAuthorityRepo,
IHttpService httpService) {
this.userRepo = userRepo; this.userRepo = userRepo;
this.userRoleRepo = userRoleRepo;
this.authorityRepo = authorityRepo;
this.roleAuthorityRepo = roleAuthorityRepo;
this.httpService = httpService; this.httpService = httpService;
} }
...@@ -65,21 +50,6 @@ public class UserServiceImpl implements IUserService { ...@@ -65,21 +50,6 @@ public class UserServiceImpl implements IUserService {
return new AuthenticationUserDetail(user); return new AuthenticationUserDetail(user);
} }
@Override
public List<UserRole> findUserRoleByUserId(Long userId) {
return userRoleRepo.findByUserId(userId);
}
@Override
public List<RoleAuthority> findRoleAuthorityByRoleIds(List<Long> roleIdList) {
return roleAuthorityRepo.findByRoleIdIn(roleIdList);
}
@Override
public List<Authority> findAuthorityByAuthorityIds(List<Long> authorityIdList) {
return authorityRepo.findByIdIn(authorityIdList);
}
@Override @Override
public String modifyPhoneQuery(ModifyPhoneQuery modifyPhoneQuery) { public String modifyPhoneQuery(ModifyPhoneQuery modifyPhoneQuery) {
String url = userSysUrl + "/v1/user/modify/phone_no"; String url = userSysUrl + "/v1/user/modify/phone_no";
...@@ -114,8 +84,8 @@ public class UserServiceImpl implements IUserService { ...@@ -114,8 +84,8 @@ public class UserServiceImpl implements IUserService {
@Override @Override
public String modifyPhoneFeedback(ModifyPhoneFeedback modifyPhoneFeedback) { public String modifyPhoneFeedback(ModifyPhoneFeedback modifyPhoneFeedback) {
String url = "http://127.0.0.1:7067/test/modify/{id}/feedback"; //String url = "http://127.0.0.1:7067/test/modify/{id}/feedback";
//String url = userSysUrl + "/v1/user/modify/phone_no/{id}/feedback"; String url = userSysUrl + "/v1/user/modify/phone_no/{id}/feedback";
try { try {
String id = modifyPhoneFeedback.getId(); String id = modifyPhoneFeedback.getId();
url = url.replace("{id}", id); url = url.replace("{id}", id);
......
...@@ -19,8 +19,7 @@ public class PwdUtil { ...@@ -19,8 +19,7 @@ public class PwdUtil {
int j = md.length; int j = md.length;
char[] str = new char[j << 1]; char[] str = new char[j << 1];
int k = 0; int k = 0;
for (int i = 0; i < j; i++) { for (byte byte0 : md) {
byte byte0 = md[i];
str[k++] = HEX_DIGITS[byte0 >>> 4 & 0xf]; str[k++] = HEX_DIGITS[byte0 >>> 4 & 0xf];
str[k++] = HEX_DIGITS[byte0 & 0xf]; str[k++] = HEX_DIGITS[byte0 & 0xf];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment