提交 252f07a1 编写于 作者: yongbo.wang's avatar yongbo.wang

Merge branch 'release' into 'master'

Release



See merge request !24
流水线 #25799 已失败 于阶段
in 0 second
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<groupId>com.pica.cloud.account</groupId> <groupId>com.pica.cloud.account</groupId>
<artifactId>pica-cloud-account-client</artifactId> <artifactId>pica-cloud-account-client</artifactId>
<version>1.0.1</version> <version>1.0.3.1</version>
<name>pica-cloud-account-client</name> <name>pica-cloud-account-client</name>
<packaging>jar</packaging> <packaging>jar</packaging>
......
...@@ -3,8 +3,8 @@ package com.pica.cloud.account.account.client; ...@@ -3,8 +3,8 @@ package com.pica.cloud.account.account.client;
import com.pica.cloud.account.account.common.req.AccountInfoReq; import com.pica.cloud.account.account.common.req.AccountInfoReq;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
/** /**
...@@ -20,4 +20,9 @@ public interface AccountInfoClient { ...@@ -20,4 +20,9 @@ public interface AccountInfoClient {
@PostMapping("/account/info/doctorIds") @PostMapping("/account/info/doctorIds")
PicaResponse<List<Integer>> getDoctorIds(@RequestBody AccountInfoReq req); PicaResponse<List<Integer>> getDoctorIds(@RequestBody AccountInfoReq req);
@GetMapping(value = "/account/token/continue")
PicaResponse<String> tokenContinueTime(@RequestHeader(value = "token") String token,
@RequestHeader(value = "sourceType") Integer sourceType,
@RequestParam(value = "seconds", required = false) Integer seconds);
} }
package com.pica.cloud.account.account.client;
import com.pica.cloud.foundation.entity.PicaResponse;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author andong
* @create 2019/7/19
*/
@FeignClient(name = "13201-pica-cloud-account")
public interface CaptchaClient {
@GetMapping("/account/account/acknowledge")
PicaResponse<Boolean> acknowledge(@RequestParam("captchaToken") String captchaToken,
@RequestParam("captchaAnswer") String captchaAnswer);
}
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!--Spring cloud dependencies begin--> <!--Spring cloud dependencies begin-->
...@@ -57,50 +63,41 @@ ...@@ -57,50 +63,41 @@
<dependency> <dependency>
<groupId>com.pica.cloud.foundation</groupId> <groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-service-starter</artifactId> <artifactId>pica-cloud-service-starter</artifactId>
<version>1.2.5-SNAPSHOT</version> <version>1.2.6-SNAPSHOT</version>
<!--<version>1.3.2.5</version>-->
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-redis</artifactId> <artifactId>pica-cloud-redis</artifactId>
<groupId>com.pica.cloud.foundation</groupId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>com.xuxueli</groupId> <artifactId>pica-cloud-entity</artifactId>
<artifactId>xxl-job-core</artifactId> <groupId>com.pica.cloud.foundation</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId> <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>-->
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.17</version>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.pica.cloud.foundation</groupId> <groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-utils</artifactId> <artifactId>pica-cloud-utils</artifactId>
<version>2.0.1-SNAPSHOT</version> <version>1.3.2-OLD</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-entity</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
...@@ -130,6 +127,12 @@ ...@@ -130,6 +127,12 @@
<version>1.0.1</version> <version>1.0.1</version>
</dependency> </dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency> <dependency>
<groupId>net.spy</groupId> <groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId> <artifactId>spymemcached</artifactId>
...@@ -150,6 +153,61 @@ ...@@ -150,6 +153,61 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.pica.cloud.patient</groupId>
<artifactId>pica-cloud-smartcontract-client</artifactId>
<version>1.0.8</version>
</dependency>
<dependency>
<groupId>com.pica.cloud.riskcontrol</groupId>
<artifactId>pica-cloud-riskcontrol-client</artifactId>
<version>1.0.3.1</version>
</dependency>
<!-- apple identifyToken校验 -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>jwks-rsa</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-proof-client</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
...@@ -171,6 +229,7 @@ ...@@ -171,6 +229,7 @@
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
...@@ -219,6 +278,23 @@ ...@@ -219,6 +278,23 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
<configurationFile>src/main/resources/mybatis-generator.xml</configurationFile>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
package com.pica.cloud.account.account.server; package com.pica.cloud.account.account.server;
import com.pica.cloud.foundation.service.starter.XxlJobConfiguration;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
...@@ -9,7 +9,7 @@ import org.springframework.cloud.netflix.feign.EnableFeignClients; ...@@ -9,7 +9,7 @@ import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(scanBasePackages = "com.pica.cloud", exclude = {XxlJobConfiguration.class}) @SpringBootApplication(scanBasePackages = "com.pica.cloud")
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableSwagger2 @EnableSwagger2
@EnableFeignClients(basePackages = "com.pica.cloud") @EnableFeignClients(basePackages = "com.pica.cloud")
......
package com.pica.cloud.account.account.server; package com.pica.cloud.account.account.server;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.PatientReq;
import com.pica.cloud.account.account.server.util.AESUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.RSAUtil; import com.pica.cloud.account.account.server.util.RSAUtil;
import org.springframework.boot.autoconfigure.SpringBootApplication; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import java.util.ArrayList;
public class Test { public class Test {
...@@ -21,7 +22,7 @@ public class Test { ...@@ -21,7 +22,7 @@ public class Test {
//获取验证码参数 //获取验证码参数
BaseRequest request = new BaseRequest(); BaseRequest request = new BaseRequest();
request.setFlag(1); request.setFlag(3);
request.setMobile("13024112070"); request.setMobile("13024112070");
String string = JSONObject.toJSONString(request); String string = JSONObject.toJSONString(request);
System.out.println(string); System.out.println(string);
...@@ -83,15 +84,13 @@ public class Test { ...@@ -83,15 +84,13 @@ public class Test {
String publicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa6j3SJwXr/pLLwb6Pq8pi9StPq+Wvm6vu+LWQB1hNqClWk0jQm5GnF6Kj0ac2gqgsMsutc3hhMaaX2QZvLX+gFQHC/ufGBdBbpPtDeGWsQItsMf/xqqlkLPkc7eVTyfsmrpQM7BG9LVvaPVXPVUcZfJNBaYuR4+Sf6Zi2ayI/hQIDAQAB"; String publicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa6j3SJwXr/pLLwb6Pq8pi9StPq+Wvm6vu+LWQB1hNqClWk0jQm5GnF6Kj0ac2gqgsMsutc3hhMaaX2QZvLX+gFQHC/ufGBdBbpPtDeGWsQItsMf/xqqlkLPkc7eVTyfsmrpQM7BG9LVvaPVXPVUcZfJNBaYuR4+Sf6Zi2ayI/hQIDAQAB";
BaseRequest login = new BaseRequest(); BaseRequest login = new BaseRequest();
login.setMobile("13024112588"); login.setMobile("13024112588");
login.setPassword("d0dcbf0d12a6b1e7fbfa2ce5848f3eff"); login.setPassword("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF"); //qq123456
String con = JSONObject.toJSONString(login); String contentResult = AESUtil.aesEncrypt(JSONObject.toJSONString(login), "YCPQPx4qpQjEjDea");
String contentResult = AESUtil.aesEncrypt(con, "YCPQPx4qpQjEjDea");
String keyResult = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey); String keyResult = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest = new EncryptEntity(); EncryptEntity encryptTest = new EncryptEntity();
encryptTest.setContent(contentResult); encryptTest.setContent(contentResult);
encryptTest.setKey(keyResult); encryptTest.setKey(keyResult);
System.out.println(JSONObject.toJSONString(encryptTest)); System.out.println(JSONObject.toJSONString(encryptTest));
System.out.println("--------------------修改密码接口-------------"); System.out.println("--------------------修改密码接口-------------");
BaseRequest changePwd = new BaseRequest(); BaseRequest changePwd = new BaseRequest();
changePwd.setOldPwd("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF"); changePwd.setOldPwd("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF");
...@@ -107,8 +106,8 @@ public class Test { ...@@ -107,8 +106,8 @@ public class Test {
System.out.println("--------------------获取验证码接口-------------"); System.out.println("--------------------获取验证码接口-------------");
BaseRequest authCode = new BaseRequest(); BaseRequest authCode = new BaseRequest();
authCode.setFlag(3); authCode.setFlag(1);
authCode.setMobile("13024112092"); authCode.setMobile("13024119988");
String authCodeStr = JSONObject.toJSONString(authCode); String authCodeStr = JSONObject.toJSONString(authCode);
System.out.println(authCodeStr); System.out.println(authCodeStr);
String contentResult2 = AESUtil.aesEncrypt(authCodeStr, "YCPQPx4qpQjEjDea"); String contentResult2 = AESUtil.aesEncrypt(authCodeStr, "YCPQPx4qpQjEjDea");
...@@ -122,9 +121,9 @@ public class Test { ...@@ -122,9 +121,9 @@ public class Test {
//获取注册参数 //获取注册参数
BaseRequest register = null; BaseRequest register = null;
register = new BaseRequest(); register = new BaseRequest();
register.setMobile("13024112092"); register.setMobile("13024119988");
register.setPassword("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF"); register.setPassword("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF");
register.setAuthCode("843895"); register.setAuthCode("868578");
String registerString3 = JSONObject.toJSONString(register); String registerString3 = JSONObject.toJSONString(register);
String contentResult3 = AESUtil.aesEncrypt(registerString3, "YCPQPx4qpQjEjDea"); String contentResult3 = AESUtil.aesEncrypt(registerString3, "YCPQPx4qpQjEjDea");
String keyResult3 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey); String keyResult3 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
...@@ -135,15 +134,22 @@ public class Test { ...@@ -135,15 +134,22 @@ public class Test {
System.out.println("--------------------一键登录接口-------------"); System.out.println("--------------------一键登录接口-------------");
BaseRequest loginRegister = null; BaseRequest loginRegister = null;
loginRegister = new BaseRequest(); loginRegister = new BaseRequest();
loginRegister.setMobile("13024112081"); loginRegister.setMobile("13024112588");
loginRegister.setAuthCode("163173"); loginRegister.setAuthCode("529196");
String registerString4 = JSONObject.toJSONString(loginRegister); String registerString4 = JSONObject.toJSONString(loginRegister);
//AES CONTENT
String contentResult4 = AESUtil.aesEncrypt(registerString4, "YCPQPx4qpQjEjDea"); String contentResult4 = AESUtil.aesEncrypt(registerString4, "YCPQPx4qpQjEjDea");
//RSA KEY
String keyResult4 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey); String keyResult4 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest4 = new EncryptEntity(); EncryptEntity encryptTest4 = new EncryptEntity();
encryptTest4.setContent(contentResult4); encryptTest4.setContent(contentResult4);
encryptTest4.setKey(keyResult4); encryptTest4.setKey(keyResult4);
System.out.println(JSONObject.toJSONString(encryptTest4)); System.out.println(JSONObject.toJSONString(encryptTest4));
...@@ -165,8 +171,8 @@ public class Test { ...@@ -165,8 +171,8 @@ public class Test {
System.out.println("--------------------忘记密码-------------"); System.out.println("--------------------忘记密码-------------");
BaseRequest forgetPwd = new BaseRequest(); BaseRequest forgetPwd = new BaseRequest();
forgetPwd.setPassword("0B9A75D6A88721A4BCF94F0FD668C56B"); forgetPwd.setPassword("0B9A75D6A88721A4BCF94F0FD668C56B");
forgetPwd.setMobile("13024112092"); forgetPwd.setMobile("13024112688");
forgetPwd.setAuthCode("095502"); forgetPwd.setAuthCode("997736");
String changePwdStr9 = JSONObject.toJSONString(forgetPwd); String changePwdStr9 = JSONObject.toJSONString(forgetPwd);
System.out.println(changePwdStr9); System.out.println(changePwdStr9);
String contentResult9 = AESUtil.aesEncrypt(changePwdStr9, "YCPQPx4qpQjEjDea"); String contentResult9 = AESUtil.aesEncrypt(changePwdStr9, "YCPQPx4qpQjEjDea");
...@@ -178,8 +184,9 @@ public class Test { ...@@ -178,8 +184,9 @@ public class Test {
System.out.println("--------------------修改手机号-------------"); System.out.println("--------------------修改手机号-------------");
BaseRequest changeMobile = new BaseRequest(); BaseRequest changeMobile = new BaseRequest();
changeMobile.setMobile("13024112092"); changeMobile.setMobile("13024112588");
changeMobile.setAuthCode("623849"); changeMobile.setAuthCode("510312");
changeMobile.setFlag(3);
String string1 = JSONObject.toJSONString(changeMobile); String string1 = JSONObject.toJSONString(changeMobile);
System.out.println(string1); System.out.println(string1);
String changeMobileContent = AESUtil.aesEncrypt(string1, "YCPQPx4qpQjEjDea"); String changeMobileContent = AESUtil.aesEncrypt(string1, "YCPQPx4qpQjEjDea");
...@@ -189,11 +196,28 @@ public class Test { ...@@ -189,11 +196,28 @@ public class Test {
changeMobileEntity.setContent(changeMobileContent); changeMobileEntity.setContent(changeMobileContent);
System.out.println(JSONObject.toJSONString(changeMobileEntity)); System.out.println(JSONObject.toJSONString(changeMobileEntity));
System.out.println("---------------------------------------------------------------");
}
BaseRequest changeMobileu = new BaseRequest();
changeMobileu.setMobile("13024112588");
changeMobileu.setAuthCode("871756");
changeMobileu.setUnionId("o3EP_wNH2g4FGcUNByXJIbQyUVPI");
changeMobileu.setFlag(2);
String string1u= JSONObject.toJSONString(changeMobileu);
System.out.println(string1u);
String changeMobileContentu = AESUtil.aesEncrypt(string1u, "YCPQPx4qpQjEjDea");
String changeMobileKeyu = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity changeMobileEntityu = new EncryptEntity();
changeMobileEntityu.setKey(changeMobileKeyu);
changeMobileEntityu.setContent(changeMobileContentu);
System.out.println(JSONObject.toJSONString(changeMobileEntityu));
}
} }
package com.pica.cloud.account.account.server.configuration;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Created on 2019/11/14 13:44
* author:crs
* Description:JobExecutorConfiguration
*/
@Configuration
public class JobExecutorConfiguration {
private Logger logger = LoggerFactory.getLogger(JobExecutorConfiguration.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info("pica-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
}
package com.pica.cloud.account.account.server.configuration; package com.pica.cloud.account.account.server.configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
@RefreshScope //@RefreshScope
public class PropertiesConfiguration { public class PropertiesConfiguration {
private Logger logger = LoggerFactory.getLogger(PropertiesConfiguration.class);
@Value("${pica.cloud.message.url}") @Value("${pica.cloud.message.url}")
private String messageUrl; private String messageUrl;
@Value("${environment.name}")
private String environment;
public String getMessageUrl() { public String getMessageUrl() {
return messageUrl; return messageUrl;
...@@ -20,4 +25,8 @@ public class PropertiesConfiguration { ...@@ -20,4 +25,8 @@ public class PropertiesConfiguration {
this.messageUrl = messageUrl; this.messageUrl = messageUrl;
} }
public String getEnvironment(){
return environment;
}
} }
package com.pica.cloud.account.account.server.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Description ThreadPoolConfig
* @Author Chongwen.jiang
* @Date 2020/2/27 16:37
* @ModifyDate 2020/2/27 16:37
* @Params
* @Return
*/
@Configuration
public class ThreadPoolConfig {
@Bean(name = "accountThreadPool")
public ThreadPoolTaskExecutor getExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(3);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(100);
executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("account_ThreadPool");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
System.out.println("accountThreadPool init end-");
return executor;
}
}
...@@ -45,4 +45,34 @@ public class Constants { ...@@ -45,4 +45,34 @@ public class Constants {
*/ */
public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/** 密码登录错误次数缓存key */
public static final String PWD_ERROR_NUM_KEY = "pwd-error-{mobile}";
/** 账号锁定缓存key */
public static final String ACCOUNT_LOCK_KEY = "account-lock-{mobile}";
/** 密码登录错误次数缓存时长*/
public static final int PWD_ERROR_NUM_SECONDS = 24 * 60 * 60;
/** 苹果后台获取公钥路径 */
public static final String APPLE_GET_PUBLIC_KEY_URL = "https://appleid.apple.com/auth/keys";
/** 苹果组织官网地址 */
public static final String APPLE_ISSUE_URL = "https://appleid.apple.com";
/** h5端发送短信验证码接口开关缓存key */
public static final String AUTHCODE_H5_SWITCH_KEY = "AUTH-CODE-H5-SWITCH";
/** 验证码缓存key前缀 */
public static final String AUTH_CODE_PREFIX = "authCode-";
/** 注册逻辑幂等处理缓存key */
public static final String REPEAT_REGISTER_PREFIX = "repeat-register—";
/** h5拼图缓存key */
public static final String JIGSAW_CODE_KEY = "jigsaw-code-{mobile}";
/** h5拼图缓存时长*/
public static final int JIGSAW_CODE_EXPIRE_SECONDS = 60;
/** 风控记录过数据 */
public static final String RC_RECORDED_DATA_KEY = "risk-{mobile}-{ip}";
} }
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.configuration.PropertiesConfiguration; import com.pica.cloud.account.account.server.configuration.PropertiesConfiguration;
import com.pica.cloud.account.account.server.constants.Constants; import com.pica.cloud.account.account.server.constants.Constants;
...@@ -9,7 +10,9 @@ import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; ...@@ -9,7 +10,9 @@ import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.util.PICAPSendMsgModel; import com.pica.cloud.account.account.server.util.PICAPSendMsgModel;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.utils.constants.SysCode; import com.pica.cloud.foundation.utils.constants.SysCode;
import com.pica.cloud.foundation.utils.controller.BaseController; import com.pica.cloud.foundation.utils.controller.BaseController;
import com.pica.cloud.foundation.utils.entity.PicaUser; import com.pica.cloud.foundation.utils.entity.PicaUser;
...@@ -32,6 +35,10 @@ import java.util.*; ...@@ -32,6 +35,10 @@ import java.util.*;
*/ */
public abstract class AccountBaseController extends BaseController { public abstract class AccountBaseController extends BaseController {
private static final String KEY_PREFIX = "token-doctor-"; private static final String KEY_PREFIX = "token-doctor-";
private Logger logger = LoggerFactory.getLogger(AccountBaseController.class); private Logger logger = LoggerFactory.getLogger(AccountBaseController.class);
@Autowired @Autowired
...@@ -61,6 +68,19 @@ public abstract class AccountBaseController extends BaseController { ...@@ -61,6 +68,19 @@ public abstract class AccountBaseController extends BaseController {
} }
} }
public String getDeviceInfoLow(String key) {
String deviceInfo = this.getRequest().getHeader("deviceinfo");
if (StringUtils.isBlank(key) || StringUtils.isBlank(deviceInfo)) {
return StringUtils.EMPTY;
}
try {
JSONObject jsonObject = JSONObject.parseObject(deviceInfo);
return jsonObject.toJSONString();
} catch (Exception ex) {
return StringUtils.EMPTY;
}
}
//保存token,并返回token值(web或app,不包含h5) //保存token,并返回token值(web或app,不包含h5)
public String saveToken(String token, PicaUser picaUser) { public String saveToken(String token, PicaUser picaUser) {
if (StringUtils.isNotEmpty(token)) { if (StringUtils.isNotEmpty(token)) {
...@@ -123,12 +143,33 @@ public abstract class AccountBaseController extends BaseController { ...@@ -123,12 +143,33 @@ public abstract class AccountBaseController extends BaseController {
picapSendMsgModel.setSysName(SysCode.APP.sysName()); picapSendMsgModel.setSysName(SysCode.APP.sysName());
String postData = JSON.toJSONString(picapSendMsgModel); String postData = JSON.toJSONString(picapSendMsgModel);
logger.info("sendMobileTo-mobile:{}, senderId-{}",mobile, senderId);
long start = System.currentTimeMillis();
String jsonObj = HttpClientUtil.httpExecute(messageUrl, postData); String jsonObj = HttpClientUtil.httpExecute(messageUrl, postData);
if (StringUtils.isNotBlank(jsonObj)) { long end1 = System.currentTimeMillis();
logger.info("发送短信成功,返回结果:{}", jsonObj); logger.info("sendMobileMessage-send message used {} million seconds", end1-start);
logger.info("sendMobileTo-{}", jsonObj);
if (StringUtils.isEmpty(jsonObj)) {
logger.error("send message fail, response is empty");
throw new PicaWarnException(AccountExceptionEnum.PICA_MESSAGE_SERVICE_CALL_FAIL.getCode(),
AccountExceptionEnum.PICA_MESSAGE_SERVICE_CALL_FAIL.getMessage());
}
try {
PicaResponse resp = JSON.parseObject(jsonObj, PicaResponse.class);
if(Objects.nonNull(resp) && PicaResultCode.SUCCESS.code().equals(resp.getCode())){
logger.info("send message success, the result is: {}", jsonObj);
} else { } else {
logger.error("发送短信失败"); logger.error("send message fail, response code not equals success code");
throw new PicaWarnException(AccountExceptionEnum.PICA_MESSAGE_SERVICE_CALL_FAIL.getCode(),
AccountExceptionEnum.PICA_MESSAGE_SERVICE_CALL_FAIL.getMessage());
} }
} catch (JSONException e) {
logger.error("send message fail, response object is not a json object");
throw new PicaWarnException(AccountExceptionEnum.PICA_MESSAGE_SERVICE_CALL_FAIL.getCode(),
AccountExceptionEnum.PICA_MESSAGE_SERVICE_CALL_FAIL.getMessage());
}
} }
/** /**
...@@ -143,6 +184,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -143,6 +184,7 @@ public abstract class AccountBaseController extends BaseController {
accountUser.setLoginFrom(this.getSourceType()); accountUser.setLoginFrom(this.getSourceType());
accountUser.setLoginPlatform(this.getProductType()); accountUser.setLoginPlatform(this.getProductType());
accountUser.setLoginIp(super.getIpAddr()); accountUser.setLoginIp(super.getIpAddr());
accountUser.setUserTokenTourist(this.getUserTokenTourist());
return accountUser; return accountUser;
} }
...@@ -188,4 +230,9 @@ public abstract class AccountBaseController extends BaseController { ...@@ -188,4 +230,9 @@ public abstract class AccountBaseController extends BaseController {
} }
return null; return null;
} }
public String getUserTokenTourist() {
HttpServletRequest request = super.getRequest();
return request.getHeader("user_token_tourist");
}
} }
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.Account; import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.entity.LoginResult; import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.mapper.AccountMapper; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.req.AccountReq; import com.pica.cloud.account.account.server.req.AccountReq;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountService; import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.CaptchaService; import com.pica.cloud.account.account.server.service.CaptchaService;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil; import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils; import com.pica.cloud.foundation.encryption.util.EncryptUtils;
...@@ -27,7 +29,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -27,7 +29,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date; import java.util.Date;
...@@ -44,24 +45,23 @@ import java.util.UUID; ...@@ -44,24 +45,23 @@ import java.util.UUID;
@RestController @RestController
@RequestMapping("/account") @RequestMapping("/account")
public class AccountController extends AccountBaseController { public class AccountController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
private Logger logger = LoggerFactory.getLogger(AccountController.class); private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;
@Autowired @Autowired
private CaptchaService captchaService; private CaptchaService captchaService;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
@Autowired
private AccountUtils accountUtils;
@GetMapping("/test") @GetMapping("/test")
public String test() { public String test() {
return "test"; return "{\"status\":\"UP\"}";
} }
@ApiOperation("获取登录验证码") @ApiOperation("获取登录验证码(已无人调用)")
@GetMapping("/authCode") @GetMapping("/authCode")
public PicaResponse<String> getAuthCode(@ApiParam(value = "手机号", required = true) @RequestParam("mobilePhone") String mobilePhone, public PicaResponse<String> getAuthCode(@ApiParam(value = "手机号", required = true) @RequestParam("mobilePhone") String mobilePhone,
@ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验") @RequestParam(value = "flag", defaultValue = "0") String flag, @ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验") @RequestParam(value = "flag", defaultValue = "0") String flag,
...@@ -159,7 +159,7 @@ public class AccountController extends AccountBaseController { ...@@ -159,7 +159,7 @@ public class AccountController extends AccountBaseController {
// @PostMapping("/register") // @PostMapping("/register")
public PicaResponse<LoginResult> register(@RequestBody AccountReq req) { public PicaResponse<LoginResult> register(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone()); this.checkMobilePhone(req.getMobilePhone());
this.checkAuthCode(req); accountUtils.checkRegisterMobilePhoneAndAuthCode(req.getMobilePhone(),req.getFlag(),req.getAuthCode());
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account = new Account(); Account account = new Account();
account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE)); account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
...@@ -174,7 +174,7 @@ public class AccountController extends AccountBaseController { ...@@ -174,7 +174,7 @@ public class AccountController extends AccountBaseController {
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_2); //ios account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_2); //ios
break; break;
default: default:
account.setRegisterSource(7); //H5注册 account.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_H5.getCode()); //H5注册
} }
//创建账号 //创建账号
accountService.createAccount(account); accountService.createAccount(account);
...@@ -189,20 +189,23 @@ public class AccountController extends AccountBaseController { ...@@ -189,20 +189,23 @@ public class AccountController extends AccountBaseController {
@ApiOperation("H5端一键登录功能,无需完善信息") @ApiOperation("H5端一键登录功能,无需完善信息")
@PostMapping("/login-register/v1") @PostMapping("/login-register/v1")
// @RepeatForbidden(uniqueKey = "content") 当前版本存在性能问题 luo优化后上
public PicaResponse loginRegister(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse loginRegister(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
this.checkMobilePhone(request.getMobile()); this.checkMobilePhone(request.getMobile());
AccountReq req = new AccountReq(); AccountReq req = new AccountReq();
req.setMobilePhone(request.getMobile()); req.setMobilePhone(request.getMobile());
req.setPassword(null);//登录或注册,只能使用验证码 // 登录或注册,只能使用验证码
req.setPassword(null);
req.setAuthCode(request.getAuthCode()); req.setAuthCode(request.getAuthCode());
req.setFlag("0"); req.setFlag("0");
req.setUnionid(request.getUnionId()); req.setUnionid(request.getUnionId());
//判断账号是否已经存在 // 判断账号是否已经存在
Account account = accountService.getByMobilePhone(req.getMobilePhone()); Account account = accountService.getByMobilePhone(req.getMobilePhone());
if (account != null) { if (account != null) {
PicaResponse response = this.login(req); //登录 // 登录
PicaResponse response = this.login(req);
if (response.getData() != null) { if (response.getData() != null) {
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setToken(response.getData().toString()); result.setToken(response.getData().toString());
...@@ -210,7 +213,9 @@ public class AccountController extends AccountBaseController { ...@@ -210,7 +213,9 @@ public class AccountController extends AccountBaseController {
} }
return response; return response;
} else { } else {
return this.register(req); //注册 // 注册
PicaResponse<LoginResult> result = this.register(req);
return result;
} }
} }
...@@ -223,8 +228,8 @@ public class AccountController extends AccountBaseController { ...@@ -223,8 +228,8 @@ public class AccountController extends AccountBaseController {
//获取验证码redis key //获取验证码redis key
private String getAuthCodeKey(String mobilePhone, String flag) { private String getAuthCodeKey(String mobilePhone, String flag) {
logger.info(AUTH_CODE_PREFIX + flag + "-" + EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE)); logger.info(Constants.AUTH_CODE_PREFIX + flag + "-" + EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE));
return AUTH_CODE_PREFIX + flag + "-" + EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE); return Constants.AUTH_CODE_PREFIX + flag + "-" + EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE);
} }
//校验验证码 //校验验证码
...@@ -265,8 +270,6 @@ public class AccountController extends AccountBaseController { ...@@ -265,8 +270,6 @@ public class AccountController extends AccountBaseController {
redisClient.set(tokenKey, tokenValue, expiredSeconds); redisClient.set(tokenKey, tokenValue, expiredSeconds);
redisClient.set(tokenValue + "-h5", tokenKey, expiredSeconds); redisClient.set(tokenValue + "-h5", tokenKey, expiredSeconds);
//用户数据放入缓存 //用户数据放入缓存
String userData = redisClient.hget(tokenValue, "id");
if (StringUtils.isEmpty(userData)) {
PicaUser picaUser = new PicaUser(); PicaUser picaUser = new PicaUser();
picaUser.setToken(newToken); picaUser.setToken(newToken);
picaUser.setId(account.getId().intValue()); picaUser.setId(account.getId().intValue());
...@@ -279,7 +282,6 @@ public class AccountController extends AccountBaseController { ...@@ -279,7 +282,6 @@ public class AccountController extends AccountBaseController {
value = value == null ? "" : value; value = value == null ? "" : value;
redisClient.hset(tokenValue, key, value); redisClient.hset(tokenValue, key, value);
}); });
}
} catch (Exception ex) { } catch (Exception ex) {
logger.error("生成H5 token异常:{}" + ex.getMessage(), ex); logger.error("生成H5 token异常:{}" + ex.getMessage(), ex);
} }
...@@ -310,44 +312,44 @@ public class AccountController extends AccountBaseController { ...@@ -310,44 +312,44 @@ public class AccountController extends AccountBaseController {
* @param req * @param req
* @return * @return
*/ */
@ApiOperation("H5端一键登录功能,无需完善信息 旧接口") // @ApiOperation("H5端一键登录功能,无需完善信息 旧接口")
@PostMapping("/login-register") // @PostMapping("/login-register")
public PicaResponse<String> loginRegister(@RequestBody AccountReq req) { // public PicaResponse<String> loginRegister(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone()); // this.checkMobilePhone(req.getMobilePhone());
req.setPassword(null); //登录或注册,只能使用验证码 // req.setPassword(null); //登录或注册,只能使用验证码
//
//判断账号是否已经存在 // //判断账号是否已经存在
Account account = accountService.getByMobilePhone(req.getMobilePhone()); // Account account = accountService.getByMobilePhone(req.getMobilePhone());
if (account != null) { // if (account != null) {
return this.login(req); //登录 // return this.login(req); //登录
} else { // } else {
return this.registerOld(req); //注册 // return this.registerOld(req); //注册
} // }
} // }
public PicaResponse<String> registerOld(@RequestBody AccountReq req) { // public PicaResponse<String> registerOld(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone()); // this.checkMobilePhone(req.getMobilePhone());
this.checkAuthCode(req); // this.checkAuthCode(req);
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios // String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account = new Account(); // Account account = new Account();
account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE)); // account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
switch (deviceType) { //注册来源 // switch (deviceType) { //注册来源
case "1": // case "1":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_3); //pc // account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_3); //pc
break; // break;
case "2": // case "2":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_1); //android // account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_1); //android
break; // break;
case "3": // case "3":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_2); //ios // account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_2); //ios
break; // break;
default: // default:
account.setRegisterSource(7); //H5注册 // account.setRegisterSource(4); //H5注册
} // }
//创建账号 // //创建账号
accountService.createAccount(account); // accountService.createAccount(account);
//生成token并返回 // //生成token并返回
String newToken = this.generateToken(account, deviceType); // String newToken = this.generateToken(account, deviceType);
return PicaResponse.toResponse(newToken); // return PicaResponse.toResponse(newToken);
} // }
} }
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.Account; import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.configuration.PropertiesConfiguration;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.AccountUnionEntity; import com.pica.cloud.account.account.server.entity.AccountUnionEntity;
import com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeReq;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.entity.LogLoginAes;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountService; import com.pica.cloud.account.account.server.service.*;
import com.pica.cloud.account.account.server.service.AccountUnionService; import com.pica.cloud.account.account.server.util.*;
import com.pica.cloud.account.account.server.service.CaptchaService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
...@@ -23,27 +21,20 @@ import com.pica.cloud.foundation.utils.utils.CommonUtil; ...@@ -23,27 +21,20 @@ import com.pica.cloud.foundation.utils.utils.CommonUtil;
import com.pica.cloud.foundation.utils.utils.ValidateUtils; import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.logging.Log;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@Api(description = "短信验证码资源") @Api(description = "短信验证码资源")
@RestController @RestController
public class AutoCodeController extends AccountBaseController { public class AutoCodeController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
private Logger logger = LoggerFactory.getLogger(AccountController.class); private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired @Autowired
private AccountUnionService accountUnionService; private AccountUnionService accountUnionService;
...@@ -54,23 +45,149 @@ public class AutoCodeController extends AccountBaseController { ...@@ -54,23 +45,149 @@ public class AutoCodeController extends AccountBaseController {
private AccountService accountService; private AccountService accountService;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient; private ICacheClient cacheClient;
@Autowired
private AuthCodeService authCodeService;
@Autowired
private LoginService loginService;
@Autowired
private PropertiesConfiguration propertiesConfiguration;
/*@GetMapping("/ip")
public PicaResponse getIp(HttpServletRequest request) {
return PicaResponse.toResponse(IPUtil.getIpAdrress(request));
}*/
/*@ApiOperation("数据加密-方便测试")
@PostMapping("/encryptedParams")
public String getEncryptedParams(@RequestBody BaseRequest request) throws Exception {
if ("dev".equals(propertiesConfiguration.getEnvironment()) ||
"test1".equals(propertiesConfiguration.getEnvironment())) {
String publicKey = "1234567890123456";
String content = AESUtil.aesEncrypt(JSON.toJSONString(request), publicKey);
String encryptKey = RSAUtil.encrypt(publicKey);
Map<String, Object> map = new HashMap<>(2);
map.put("key", encryptKey);
map.put("content", content);
return JSON.toJSONString(map);
}
return null;
}
@ApiOperation("数据解密-方便测试")
@PostMapping("/decryptedParams")
public String getDecryptedParams(@RequestBody EncryptEntity entity) throws Exception {
if("dev".equals(propertiesConfiguration.getEnvironment()) ||
"test1".equals(propertiesConfiguration.getEnvironment())) {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
return JSON.toJSONString(request);
}
return null;
}*/
/**
* @Description native获取验证码,新老版本兼容
* @Author peijun.zhao
* @Date 2020/2/28 9:55
* @ModifyDate 2020/2/28 9:55
* @Params [entity, req]
* @Return com.pica.cloud.foundation.entity.PicaResponse EncryptEntity
*/
@ApiOperation("获取短信验证码,无需图形验证码,如app端") @ApiOperation("获取短信验证码,无需图形验证码,如app端")
@PostMapping(value = "/authCode") @PostMapping(value = "/authCode")
public PicaResponse getAuthCode(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse getAuthCode(@RequestBody AesAuthCodeReq authCodeReq, HttpServletRequest req) throws Exception {
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())){
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(authCodeReq);
logger.info("AesAuthCodeReq getAuthCode:" + JSONObject.toJSONString(authCodeReq));
logger.info("AesAuthCodeReq getAuthCode encrypt:" + JSONObject.toJSONString(entity));
//个别报错数据记流水
LogLoginAes loginAes = new LogLoginAes();
loginAes.setChannel(1);
loginAes.setDeviceToken(authCodeReq.getDevice_token());
loginAes.setSourceType(null == super.getSourceType() ? 0 : super.getSourceType());
loginAes.setMobile(authCodeReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
//执行原逻辑
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
}
//added by joy end
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setSourceType(super.getSourceType());
AccountUtils.checkMobilePhone(request.getMobile());
if (request.getBizType() != null && request.getBizType().equals(1)) {
logger.info("app-rcValidate-start");
// 调用风控接口
authCodeService.rcValidate(req, request, super.getDeviceInfo(), super.getSourceType());
// 发送短信验证码
processSysCode(request.getMobile(), request.getFlag());
return PicaResponse.toResponse();
} else {
// 老版本业务(发送短信验证码)
processSysCode(request.getMobile(), request.getFlag());
// 记录风控数据
authCodeService.recordRcData(req, request, super.getDeviceInfo("device_ip"));
return PicaResponse.toResponse();
}
}
@ApiOperation("获取短信验证码,无需图形验证码,如h5端")
@PostMapping(value = "/H5/authCode")
public PicaResponse getH5AuthCode(@RequestBody EncryptEntity entity, HttpServletRequest req) throws Exception {
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
if (super.getSourceType() != null) {
request.setSourceType(super.getSourceType());
}
AccountUtils.checkMobilePhone(request.getMobile()); AccountUtils.checkMobilePhone(request.getMobile());
// 拼图验证
int recordData = authCodeService.validateJigsawCode(req, request);
// 发送短信验证码
processSysCode(request.getMobile(), request.getFlag()); processSysCode(request.getMobile(), request.getFlag());
if (recordData != -1) {
// 记录风控数据(记录是h5端)
authCodeService.recordRcData(req, request, super.getDeviceInfo("device_ip"));
}
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} }
/**
* @Description web获取效验码-老版,记录风控行为
* @Author peijun.zhao
* @Date 2020/2/28 9:52
* @ModifyDate 2020/2/28 9:52
* @Params [entity]
* @Return com.pica.cloud.foundation.entity.PicaResponse<java.lang.String>
*/
@ApiOperation("获取短信验证码,需要图形验证码,如H5端和PC端;验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机 4重置密码 5忘记密码 7患者招募提交问卷(效验)") @ApiOperation("获取短信验证码,需要图形验证码,如H5端和PC端;验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机 4重置密码 5忘记密码 7患者招募提交问卷(效验)")
@PostMapping("/account/authCode") @PostMapping("/account/authCode")
public PicaResponse<String> getAuthCodeWithCaptcha(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse<String> getAuthCodeWithCaptcha(@RequestBody EncryptEntity entity,
HttpServletRequest req) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
if (super.getSourceType() != null) {
request.setSourceType(super.getSourceType());
}
String mobilePhone = request.getMobile(); String mobilePhone = request.getMobile();
String flag = request.getFlag() + ""; String flag = request.getFlag() + "";
String captchaToken = request.getCaptchaToken(); String captchaToken = request.getCaptchaToken();
...@@ -87,12 +204,26 @@ public class AutoCodeController extends AccountBaseController { ...@@ -87,12 +204,26 @@ public class AutoCodeController extends AccountBaseController {
long senderId = accountIdByMobilePhone == null ? 0L : accountIdByMobilePhone; long senderId = accountIdByMobilePhone == null ? 0L : accountIdByMobilePhone;
//验证码保存到redis,失效时间10分钟 //验证码保存到redis,失效时间10分钟
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag), authCode, 600); cacheClient.set(this.getAuthCodeKey(mobilePhone, flag), authCode, 600);
//处理验证码原子性的问题
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone,authCode), 100, 600);
logger.info(this.getAuthCodeKey(mobilePhone, flag)); logger.info(this.getAuthCodeKey(mobilePhone, flag));
//发送短信 //发送短信
super.sendMobileMessage(mobilePhone, message, senderId); super.sendMobileMessage(mobilePhone, message, senderId);
// 记录风控数据
authCodeService.recordRcData(req, request, super.getDeviceInfo("device_ip"));
return PicaResponse.toResponse(StringUtils.EMPTY); return PicaResponse.toResponse(StringUtils.EMPTY);
} }
@ApiOperation("获取拼图码校验")
@PostMapping("/jigsawCode")
public PicaResponse getJigsawCode(@RequestBody EncryptEntity entity,
HttpServletRequest req) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
return PicaResponse.toResponse(authCodeService.getJigsawCode(req, super.getSourceType(), request.getMobile()));
}
@ApiOperation("微信获取验证码") @ApiOperation("微信获取验证码")
@PostMapping(value = "/authCode/wechat") @PostMapping(value = "/authCode/wechat")
public PicaResponse getWChatSysCode(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse getWChatSysCode(@RequestBody EncryptEntity entity) throws Exception {
...@@ -147,19 +278,29 @@ public class AutoCodeController extends AccountBaseController { ...@@ -147,19 +278,29 @@ public class AutoCodeController extends AccountBaseController {
* @param authCodeKeySecure * @param authCodeKeySecure
*/ */
private void processSendAuthCode(String mobilePhone, Integer flag, String authCodeKeySecure) { private void processSendAuthCode(String mobilePhone, Integer flag, String authCodeKeySecure) {
long start = System.currentTimeMillis();
String authCode = CommonUtil.createValidateCode(); String authCode = CommonUtil.createValidateCode();
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!"; String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
Integer accountIdByMobilePhone = accountService.getAccountIdByMobilePhone(mobilePhone); Integer accountIdByMobilePhone = accountService.getAccountIdByMobilePhone(mobilePhone);
long senderId = accountIdByMobilePhone == null ? 0L : accountIdByMobilePhone; long senderId = accountIdByMobilePhone == null ? 0L : accountIdByMobilePhone;
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag.toString()), authCode, 600); String authCodeKey = getAuthCodeKey(mobilePhone, flag.toString());
logger.info("验证码缓存信息----->:"+this.getAuthCodeKey(mobilePhone, flag.toString())); boolean set = cacheClient.set(authCodeKey, authCode, 600);
logger.info(cacheClient.get(authCodeKey));
logger.info("验证码缓存是否成功----->:"+set);
logger.info("验证码缓存信息----->:"+authCodeKey);
cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60); cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60);
//处理验证码原子性的问题
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone,authCode), 100, 600);
long end1 = System.currentTimeMillis();
logger.info("processSendAuthCode-1 used {} million seconds", end1-start);
super.sendMobileMessage(mobilePhone, message, senderId); super.sendMobileMessage(mobilePhone, message, senderId);
long end2 = System.currentTimeMillis();
logger.info("processSendAuthCode-2 used {} million seconds", end2-start);
} }
//获取验证码redis key //获取验证码redis key
private String getAuthCodeKey(String mobilePhone, String flag) { private String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone); return Constants.AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone);
} }
//手机格式校验 //手机格式校验
...@@ -168,4 +309,14 @@ public class AutoCodeController extends AccountBaseController { ...@@ -168,4 +309,14 @@ public class AutoCodeController extends AccountBaseController {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
} }
} }
@ApiOperation("微信获取验证码")
@PostMapping(value = "/authCode/get")
public PicaResponse getAuthCode(){
String cacheCode = cacheClient.get("authCode-j1VrU5MSc1uuZaEa82ZKfQ==");
return PicaResponse.toResponse(cacheCode);
}
} }
...@@ -34,14 +34,14 @@ public class CaptchaController { ...@@ -34,14 +34,14 @@ public class CaptchaController {
return PicaResponse.toResponse(captchaToken); return PicaResponse.toResponse(captchaToken);
} }
/*
@ApiOperation("校验图形验证码") @ApiOperation("校验图形验证码")
@GetMapping("/acknowledge") @GetMapping("/acknowledge")
public PicaResponse<Boolean> acknowledge(@ApiParam("token") @RequestParam("token") String token, public PicaResponse<Boolean> acknowledge(@ApiParam("captchaToken") @RequestParam("captchaToken") String captchaToken,
@ApiParam("answer") @RequestParam("answer") String answer) { @ApiParam("captchaAnswer") @RequestParam("captchaAnswer") String captchaAnswer) {
boolean valid = captchaService.acknowledge(token, answer); boolean valid = captchaService.acknowledge(captchaToken, captchaAnswer);
return PicaResponse.toResponse(valid); return PicaResponse.toResponse(valid);
} }
*/
} }
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.RSAUtil; import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -7,6 +8,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -7,6 +8,8 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
...@@ -24,7 +27,24 @@ public class CipherController { ...@@ -24,7 +27,24 @@ public class CipherController {
@ApiOperation("获取公钥Key接口") @ApiOperation("获取公钥Key接口")
@GetMapping(value = "/cipher/key") @GetMapping(value = "/cipher/key")
public PicaResponse<String> getPublicKey() { public PicaResponse<String> getPublicKey() {
return PicaResponse.toResponse(rsaPublicKey); //提高qps 100 8失败率至 300 1 失败率
String testPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa6j3SJwXr/pLLwb6Pq8pi9StPq+Wvm6vu+LWQB1hNqClWk0jQm5GnF6Kj0ac2gqgsMsutc3hhMaaX2QZvLX+gFQHC/ufGBdBbpPtDeGWsQItsMf/xqqlkLPkc7eVTyfsmrpQM7BG9LVvaPVXPVUcZfJNBaYuR4+Sf6Zi2ayI/hQIDAQAB";
String prodPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnVzDlG6DJBwTsn7jFriKOmzqfm+d4vy6DtKqMfrEPg6hU3bfbR9XRfwqAFrS4+QowybpuyWCa7DFyKl0JyEa/GSrfjbXSpalFHhmWH0z0hCF1m/UvlPA0BaiYFy9ucXF9Uh8RaHkZGVmV+RbVISk4pjlZdRcK5EQ5hciBFGtgGwIDAQAB";
// return PicaResponse.toResponse(rsaPublicKey);
return PicaResponse.toResponse(rsaPublicKey); //
} }
// /**
// *
// * @param key
// * @return
// * @throws Exception
// */
// @ApiOperation("解密操作")
// @GetMapping(value = "/cipher/decrypt")
// public PicaResponse<String> decryptPublicKey(@RequestParam String key) throws Exception {
// return PicaResponse.toResponse(RSAUtil.decrypt(key, AESUtil.privateKey));
// }
} }
...@@ -48,7 +48,7 @@ public class DoctorController extends AccountBaseController { ...@@ -48,7 +48,7 @@ public class DoctorController extends AccountBaseController {
@ApiOperation("修改医生信息接口") @ApiOperation("修改医生信息接口")
@PutMapping(value = "/info", produces = "application/json;charset=utf-8") @PutMapping(value = "/info", produces = "application/json;charset=utf-8")
public PicaResponse modifyDoctorInfo(@RequestBody Doctor doctor) { public PicaResponse modifyDoctorInfo(@RequestBody Doctor doctor) {
doctorService.modifyDoctorInfo(doctor); doctorService.modifyDoctorInfo(doctor,super.getDoctorIdByToken());
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} }
...@@ -64,7 +64,7 @@ public class DoctorController extends AccountBaseController { ...@@ -64,7 +64,7 @@ public class DoctorController extends AccountBaseController {
if (doctor != null && doctor.getMobilePhone() != null) { if (doctor != null && doctor.getMobilePhone() != null) {
AccountUtils.checkMobilePhone(doctor.getMobilePhone()); AccountUtils.checkMobilePhone(doctor.getMobilePhone());
AccountUtils.checkPassword(doctor.getPassword()); AccountUtils.checkPassword(doctor.getPassword());
Integer userId = doctorService.addDoctorInfo(doctor); Integer userId = doctorService.addDoctorInfo(doctor,super.getDoctorIdByToken());
return PicaResponse.toResponse(userId); return PicaResponse.toResponse(userId);
} else { } else {
throw new AccountException(AccountExceptionEnum.PICA_PARAMS_ERROR); throw new AccountException(AccountExceptionEnum.PICA_PARAMS_ERROR);
...@@ -75,7 +75,7 @@ public class DoctorController extends AccountBaseController { ...@@ -75,7 +75,7 @@ public class DoctorController extends AccountBaseController {
@ApiOperation("客服系统删除医生信息") @ApiOperation("客服系统删除医生信息")
@DeleteMapping(value = "/delete/{id}") @DeleteMapping(value = "/delete/{id}")
public PicaResponse deleteDoctor(@PathVariable("id") Integer id) { public PicaResponse deleteDoctor(@PathVariable("id") Integer id) {
doctorService.deleteDoctorInfo(id); doctorService.deleteDoctorInfo(id,super.getDoctorIdByToken());
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} }
} }
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.*; import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeReq;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.log.AccountLogEntityUtils; import com.pica.cloud.account.account.server.log.AccountLogEntityUtils;
import com.pica.cloud.account.account.server.log.AccountLogUtils; import com.pica.cloud.account.account.server.log.AccountLogUtils;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.OneClickLoginReq;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.service.LoginService; import com.pica.cloud.account.account.server.service.LoginService;
import com.pica.cloud.account.account.server.service.TokenService; import com.pica.cloud.account.account.server.service.TokenService;
import com.pica.cloud.account.account.server.util.AccountUtils; import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil; import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Api(description = "登录资源") @Api(description = "登录资源")
@RestController @RestController
public class LoginController extends AccountBaseController { public class LoginController extends AccountBaseController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired @Autowired
private LoginService loginService; private LoginService loginService;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
@Autowired @Autowired
private AccountLogUtils picaLogUtils; private AccountLogUtils picaLogUtils;
@Autowired
private AccountUtils accountUtils;
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired @Autowired
private DoctorService doctorService; private DoctorService doctorService;
@Autowired
private CacheClient cacheClient;
private String cache_prifix = "cache-";
/** /**
* 密码登录接口 * 密码登录接口
* *
* @param entity * @param authCodeReq
* @return * @return
* @throws Exception * @throws Exception
*/ */
@ApiOperation("密码登录接口") @ApiOperation("密码登录接口")
@PostMapping("/login") @PostMapping("/login")
public PicaResponse<LoginResult> loginByPassword(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse<LoginResult> loginByPassword(@RequestBody AesAuthCodeReq authCodeReq) throws Exception {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())){
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(authCodeReq);
logger.info("AesAuthCodeReq loginByPassword:" + JSONObject.toJSONString(authCodeReq));
logger.info("AesAuthCodeReq loginByPassword encrypt:" + JSONObject.toJSONString(entity));
//个别报错数据记流水
LogLoginAes loginAes = new LogLoginAes();
loginAes.setChannel(4);
loginAes.setDeviceToken(authCodeReq.getDevice_token());
loginAes.setSourceType(null == super.getSourceType() ? 0 : super.getSourceType());
loginAes.setMobile(authCodeReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
//执行原逻辑
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
}
//added by joy end
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType()); request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType()); Integer sourceType = super.getSourceType();
request.setSourceType(sourceType == null ? 0 : sourceType);
request.setLoginIp(super.getIpAddr()); request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
AccountUtils.checkMobilePhone(request.getMobile()); AccountUtils.checkMobilePhone(request.getMobile());
AccountUtils.checkPassword(request.getPassword()); AccountUtils.checkPassword(request.getPassword());
LoginResult login = loginService.login(request); LoginResult login = loginService.login(request);
if (SourceTypeEnum.SAAS.getCode().equals(sourceType)) {
login.setDoctorId("");
} else {
login.setUserId(null);
}
return PicaResponse.toResponse(login); return PicaResponse.toResponse(login);
} }
/** /**
* 一键登录 * 一键登录-验证码登录
* *
* @param entity * @param authCodeReq
* @return * @return
* @throws Exception * @throws Exception
*/ */
@ApiOperation("PC,App端一键登录接口,需要完善信息") @ApiOperation("PC,App端验证码登录接口,需要完善信息")
@PostMapping(value = "/login-register") @PostMapping(value = "/login-register")
public PicaResponse<LoginResult> loginAndRegister(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse<LoginResult> loginAndRegister(@RequestBody AesAuthCodeReq authCodeReq) throws Exception {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())){
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(authCodeReq);
logger.info("AesAuthCodeReq loginAndRegister:" + JSONObject.toJSONString(authCodeReq));
logger.info("AesAuthCodeReq loginAndRegister encrypt:" + JSONObject.toJSONString(entity));
//个别报错数据记流水
LogLoginAes loginAes = new LogLoginAes();
loginAes.setChannel(5);
loginAes.setDeviceToken(authCodeReq.getDevice_token());
loginAes.setSourceType(null == super.getSourceType() ? 0 : super.getSourceType());
loginAes.setMobile(authCodeReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
//执行原逻辑
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
}
//added by joy end
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), AccountTypeEnum.SYSCODE_TYPE_LOGIN.getCode() + "",request.getAuthCode());
request.setProductType(super.getProductType()); request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType()); Integer sourceType = super.getSourceType();
request.setSourceType(sourceType == null ? 0 : sourceType);
request.setLoginIp(super.getIpAddr()); request.setLoginIp(super.getIpAddr());
LoginResult login =loginService.loginAndRegister(request); request.setUserTokenTourist(super.getUserTokenTourist());
LoginResult login = loginService.loginAndRegister(request);
if (SourceTypeEnum.SAAS.getCode().equals(sourceType)) {
login.setDoctorId("");
} else {
login.setUserId(null);
}
return PicaResponse.toResponse(login); return PicaResponse.toResponse(login);
} }
...@@ -93,6 +160,7 @@ public class LoginController extends AccountBaseController { ...@@ -93,6 +160,7 @@ public class LoginController extends AccountBaseController {
request.setProductType(super.getProductType()); request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType()); request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr()); request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
LoginResult result = loginService.loginByWeChat(request); LoginResult result = loginService.loginByWeChat(request);
return PicaResponse.toResponse(result); return PicaResponse.toResponse(result);
} }
...@@ -101,10 +169,10 @@ public class LoginController extends AccountBaseController { ...@@ -101,10 +169,10 @@ public class LoginController extends AccountBaseController {
@PostMapping(value = "/login/wechat/step2") @PostMapping(value = "/login/wechat/step2")
public PicaResponse<LoginResult> loginByWeChatStep(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse<LoginResult> loginByWeChatStep(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "", request.getAuthCode());
request.setProductType(super.getProductType()); request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType()); request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr()); request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
LoginResult result = loginService.loginByWeChatStep(request); LoginResult result = loginService.loginByWeChatStep(request);
return PicaResponse.toResponse(result); return PicaResponse.toResponse(result);
} }
...@@ -120,16 +188,34 @@ public class LoginController extends AccountBaseController { ...@@ -120,16 +188,34 @@ public class LoginController extends AccountBaseController {
@PostMapping("/login/wechat/bind") @PostMapping("/login/wechat/bind")
public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setAccId(super.getAcctId()); request.setUserTokenTourist(super.getUserTokenTourist());
loginService.bindWeChat(request); Long result = cacheClient.setnx(cache_prifix + request.getWeChatCode(), request.getWeChatCode());
return PicaResponse.toResponse(); if (result == 1) {
try {
cacheClient.expire(cache_prifix + request.getWeChatCode(), 60);
long doctorId = super.getDoctorIdByToken();
String nickname = loginService.bindWeChat(doctorId, request);
Map<String, String> map = new HashMap();
map.put("nickname", nickname);
//成功以后释放锁
cacheClient.del(cache_prifix + request.getWeChatCode());
return PicaResponse.toResponse(map);
} catch (Exception e) {
cacheClient.del(cache_prifix + request.getWeChatCode());
logger.error("bindWeChat-" + e.getMessage(), e);
throw new PicaWarnException(AccountExceptionEnum.PICA_BIND_WECHAT_FAIL.getCode(), AccountExceptionEnum.PICA_BIND_WECHAT_FAIL.getMessage());
}
} else {
return PicaResponse.toResponse(null, AccountExceptionEnum.PICA_WECHAT_UNBIND_CURRENT.getCode(),
AccountExceptionEnum.PICA_WECHAT_UNBIND_CURRENT.getMessage());
}
} }
@ApiOperation("微信解除绑定接口") @ApiOperation("微信解除绑定接口")
@PutMapping("/login/wechat/unbind") @PutMapping("/login/wechat/unbind")
public PicaResponse unbindWeChat() { public PicaResponse unbindWeChat() {
Integer acctId = super.getAcctId(); long doctorId = super.getDoctorIdByToken();
loginService.unbindWeChat(acctId); loginService.unbindWeChat(doctorId);
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} }
...@@ -151,7 +237,8 @@ public class LoginController extends AccountBaseController { ...@@ -151,7 +237,8 @@ public class LoginController extends AccountBaseController {
Map<String, Object> headersMap = super.getHeaders(); Map<String, Object> headersMap = super.getHeaders();
String newToken = tokenService.getToken(headersMap); String newToken = tokenService.getToken(headersMap);
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, super.getProductType(), super.getSourceType(), LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, super.getProductType(), super.getSourceType(),
AccountTypeEnum.LOGIN_OUT.getCode(), super.getIpAddr(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode()); AccountTypeEnum.LOGIN_OUT.getCode(), super.getIpAddr(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),
newToken,0,super.getUserTokenTourist());
picaLogUtils.info(entity); picaLogUtils.info(entity);
return PicaResponse.toResponse(newToken); return PicaResponse.toResponse(newToken);
} else { } else {
...@@ -176,4 +263,95 @@ public class LoginController extends AccountBaseController { ...@@ -176,4 +263,95 @@ public class LoginController extends AccountBaseController {
} }
return PicaResponse.toResponse(resultWeb); return PicaResponse.toResponse(resultWeb);
} }
@ApiOperation(value = "统一校验(传空则不会校验)")
@PostMapping("/unifiedVerification")
public PicaResponse unifiedVerification(@RequestBody AesAuthCodeReq req) throws Exception{
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(req.getKey()) && StringUtils.isEmpty(req.getContent())){
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(req);
logger.info("AesAuthCodeReq unifiedVerification:" + JSONObject.toJSONString(req));
logger.info("AesAuthCodeReq unifiedVerification encrypt:" + JSONObject.toJSONString(entity));
//个别报错数据记流水
LogLoginAes loginAes = new LogLoginAes();
loginAes.setChannel(2);
loginAes.setDeviceToken(req.getDevice_token());
loginAes.setSourceType(null == super.getSourceType() ? 0 : super.getSourceType());
loginAes.setMobile(req.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
//执行原逻辑
entity.setKey(req.getKey());
entity.setContent(req.getContent());
}
//added by joy end
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setSourceType(super.getSourceType());
loginService.preLoginValidate(request);
return PicaResponse.toResponse();
}
@ApiOperation(value = "苹果授权登录")
@PostMapping("/login/apple")
public PicaResponse appleAuth(@RequestBody EncryptEntity entity) throws Exception{
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
return PicaResponse.toResponse(loginService.loginByApple(request));
}
@ApiOperation(value = "苹果登录绑定手机号")
@PostMapping("/login/apple/step2")
public PicaResponse appleAuthBind(@RequestBody EncryptEntity entity) throws Exception{
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
return PicaResponse.toResponse(loginService.loginByAppleStep(request));
}
@ApiOperation(value = "app端手机号码一键登录")
@PostMapping("/login/one-click")
public PicaResponse<LoginResult> oneClickLogin(@RequestBody AesAuthCodeReq aesReq) throws Exception {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(aesReq.getKey()) && StringUtils.isEmpty(aesReq.getContent())){
//明文时处理
entity = RSAUtil.getOneClickEncrypt(aesReq);
logger.info("AesAuthCodeReq oneClickLogin:" + JSONObject.toJSONString(aesReq));
logger.info("AesAuthCodeReq oneClickLogin encrypt:" + JSONObject.toJSONString(entity));
//个别报错数据记流水
LogLoginAes loginAes = new LogLoginAes();
loginAes.setChannel(3);
loginAes.setDeviceToken(aesReq.getDevice_token());
loginAes.setSourceType(null == super.getSourceType() ? 0 : super.getSourceType());
loginAes.setOneToken(aesReq.getToken());
loginAes.setMobile(aesReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
//执行原逻辑
entity.setKey(aesReq.getKey());
entity.setContent(aesReq.getContent());
}
//added by joy end
OneClickLoginReq req = CryptoUtil.decrypt(entity, OneClickLoginReq.class);
req.setProductType(super.getProductType());
req.setSourceType(super.getSourceType());
req.setLoginIp(super.getIpAddr());
req.setUserTokenTourist(super.getUserTokenTourist());
LoginResult oneClickLoginResultVo = loginService.oneClickLogin(req);
return PicaResponse.toResponse(oneClickLoginResultVo);
}
} }
...@@ -45,14 +45,17 @@ public class ModifyMobileController extends AccountBaseController { ...@@ -45,14 +45,17 @@ public class ModifyMobileController extends AccountBaseController {
public PicaResponse modifyMobile(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse modifyMobile(@RequestBody EncryptEntity entity) throws Exception {
Long doctorId = super.getDoctorIdByToken(); Long doctorId = super.getDoctorIdByToken();
Doctor doctorInfo = doctorService.getDoctorInfo(doctorId.intValue()); Doctor doctorInfo = doctorService.getDoctorInfo(doctorId.intValue());
//旧的手机号
String mobilePhone = doctorInfo.getMobilePhone(); String mobilePhone = doctorInfo.getMobilePhone();
Integer acctId = modifyMobileService.getAcctIdByMobile(mobilePhone); Integer acctId = modifyMobileService.getAcctIdByMobile(mobilePhone);
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
//新的手机号
String mobile = request.getMobile(); String mobile = request.getMobile();
accountUtils.checkMobilePhoneAndAuthCode(mobile, AccountTypeEnum.SYSCODE_TYPE_MODIFY_MOBILE.getCode() + "", request.getAuthCode()); accountUtils.checkMobilePhoneAndAuthCode(mobile, AccountTypeEnum.SYSCODE_TYPE_MODIFY_MOBILE.getCode() + "", request.getAuthCode());
//判断当前手机号是否已经注册过 //判断当前手机号是否已经注册过
AccountInfoEntity accountInfoEntity = accountService.getAccountByMobilePhone(mobile); AccountInfoEntity accountInfoEntity = accountService.getAccountByMobilePhone(mobile);
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
modifyMobileService.recodeMobileModify(acctId,mobilePhone,mobile);
modifyMobileService.modify(acctId, mobile); modifyMobileService.modify(acctId, mobile);
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} else { } else {
......
...@@ -3,18 +3,20 @@ package com.pica.cloud.account.account.server.controller; ...@@ -3,18 +3,20 @@ package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.Doctor; import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.service.PasswordService; import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.account.account.server.service.RegisterService;
import com.pica.cloud.account.account.server.util.AESUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils; import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil; import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -38,9 +40,11 @@ public class PasswordController extends AccountBaseController { ...@@ -38,9 +40,11 @@ public class PasswordController extends AccountBaseController {
@Autowired @Autowired
private DoctorService doctorService; private DoctorService doctorService;
@Autowired
private RegisterService registerService;
/** /**
* 修改密码 * 重置密码
* *
* @return * @return
*/ */
...@@ -78,11 +82,71 @@ public class PasswordController extends AccountBaseController { ...@@ -78,11 +82,71 @@ public class PasswordController extends AccountBaseController {
@PostMapping(value = "/reset") @PostMapping(value = "/reset")
public PicaResponse forgetPassword(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse forgetPassword(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), AccountTypeEnum.SYSCODE_TYPE_RESET_PASSWORD.getCode() + "", request.getAuthCode()); if (request.getBizType() != null &&
request.getBizType().equals(1)) {
AccountInfoEntity account = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
request.setProductType(super.getProductType());
if (account == null) {
if (SourceTypeEnum.APPLE.getCode().equals(super.getSourceType())) {
// 验证码校验
accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_FORGET_PASSWORD.getCode() + "",
request.getAuthCode());
} else {
// 验证码校验
accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_RESET_PASSWORD.getCode() + "",
request.getAuthCode());
}
if (StringUtils.isEmpty(request.getPassword())) {
throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_ERROR);
}
// 新版-未注册-则默认注册
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
LoginResult result = registerService.register(request);
// 已补全密码
result.setEntireFlag(3);
return PicaResponse.toResponse(result);
} else {
// 新版-已注册了的则找回密码
reSetPwd(request, account);
// 后台生成token返回,删除账号锁定缓存
return PicaResponse.toResponse(passwordService.findPwdLogin(request, account));
}
} else {
// 老版
return reSetPwd(request, null);
}
}
/**
* @Description 找回密码
* @Author Chongwen.jiang
* @Date 2020/2/21 20:07
* @ModifyDate 2020/2/21 20:07
* @Params [request, entity]
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
private PicaResponse reSetPwd(BaseRequest request, AccountInfoEntity entity) {
// 4重置密码 5忘记密码
if (SourceTypeEnum.APPLE.getCode().equals(super.getSourceType())) {
// ios
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), "5", request.getAuthCode());
if (StringUtils.isEmpty(request.getPassword())) { if (StringUtils.isEmpty(request.getPassword())) {
throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_ERROR); throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_ERROR);
} }
passwordService.forgetPassword(request); passwordService.forgetPassword(request, entity);
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} else {
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), "4", request.getAuthCode());
if (StringUtils.isEmpty(request.getPassword())) {
throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_ERROR);
}
passwordService.forgetPassword(request, entity);
return PicaResponse.toResponse();
}
} }
} }
//package com.pica.cloud.account.account.server.controller;
//
//import com.alibaba.fastjson.JSON;
//import com.pica.cloud.foundation.entity.PicaResponse;
//import com.pica.cloud.foundation.entity.PicaUser;
//import com.pica.cloud.foundation.redis.ICacheClient;
//
//import com.pica.cloud.foundation.service.starter.common.BaseController;
//import com.pica.cloud.foundation.service.starter.interceptor.LoginPermission;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//import redis.clients.jedis.Jedis;
//import redis.clients.jedis.JedisSentinelPool;
//
//import java.util.*;
//
//@RestController
//public class RedisTestController extends BaseController {
// @Autowired
// private ICacheClient redisClient;
//
// @RequestMapping(value = "/redis", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
// @LoginPermission
// public PicaResponse<Map<String, String>> redis() {
// // http://localhost:11501/hospital/hospitals/redis
// // cluster
// String token = getTokenFromHeader();
// Map<String, String> map = new HashMap<>();
// map.put("id", "1111111");
// map.put("token", token);
// map.put("sysCode", getSysCodeFromHeader());
//
// try {
// token = redisClient.saveToken(map, 3600);
// } catch (Exception ex) {
// // nothing to do
// }
// System.out.println(token);
// Map<String, String> map1 = redisClient.getToken(token);
// System.out.println(JSON.toJSON(map1));
// PicaUser user = fetchPicaUser();
// System.out.println(JSON.toJSON(user));
//
// // sentinel
// Set<String> set1 = new HashSet<>();
// set1.add("192.168.140.27:17000");
// set1.add("192.168.140.28:17000");
// set1.add("192.168.140.29:17000");
// JedisSentinelPool pool1 = new JedisSentinelPool("master01", set1, "Uu49Kz1olY85HQBu");
// Jedis jedis1 = pool1.getResource();
// System.out.println("sentinel dev - " + jedis1.get("token-" + token));
//
// Set<String> set2 = new HashSet<>();
// set2.add("192.168.110.68:17000");
// set2.add("192.168.110.69:17001");
// set2.add("192.168.110.70:17002");
// JedisSentinelPool pool2 = new JedisSentinelPool("master01", set2, "Uu49Kz1olY85HQBu");
// Jedis jedis2 = pool2.getResource();
// System.out.println("sentinel test - " + jedis2.get("token-" + token));
//
// Set<String> set3 = new HashSet<>();
// set3.add("192.168.110.177:17000");
// set3.add("192.168.110.178:17000");
// set3.add("192.168.110.179:17000");
// JedisSentinelPool pool3 = new JedisSentinelPool("master01", set3, "Uu49Kz1olY85HQBu");
// Jedis jedis3 = pool3.getResource();
// System.out.println("sentinel uat - " + jedis3.get("token-" + token));
//
// redisClient.deleteToken(token);
//
// try {
// PicaUser user1 = fetchPicaUser();
// } catch (Exception ex) {
// System.out.println("Exception -> the user has been deleted");
// }
//
// Map<String, String> map2 = new HashMap<>();
// map2.put("id", "1111111");
// map2.put("token", token);
// map2.put("sysCode", getSysCodeFromHeader());
// try {
// token = redisClient.saveToken(map2, 3600);
// } catch (Exception ex) {
// // nothing to do
// }
//
// String clusterKey = "cluster-key-001";
// String clusterValue = "cluster-value-001";
//
// redisClient.set(clusterKey, clusterValue);
// System.out.println("cluster -> " + redisClient.get(clusterKey));
// System.out.println("dev get cluster value -> " + pool1.getResource().get(clusterKey));
// System.out.println("test1 get cluster value -> " + pool2.getResource().get(clusterKey));
// System.out.println("uat get cluster value -> " + pool3.getResource().get(clusterKey));
//
// String sentKey = "sent-key-001";
// String sentValue = "sent-value-001";
// pool1.getResource().set(sentKey, sentValue);
// System.out.println("dev sentinel -> " + pool1.getResource().get(sentKey));
//
// pool2.getResource().set(sentKey, sentValue);
// System.out.println("test1 sentinel -> " + pool2.getResource().get(sentKey));
//
// pool3.getResource().set(sentKey, sentValue);
// System.out.println("uat sentinel -> " + pool3.getResource().get(sentKey));
//
// return PicaResponse.toResponse(token);
// }
//}
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.common.req.OCINRequest;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.entity.LoginResult; import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.common.req.OCINRequest;
import com.pica.cloud.account.account.server.service.RegisterService; import com.pica.cloud.account.account.server.service.RegisterService;
import com.pica.cloud.account.account.server.util.AccountUtils; import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil; import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -28,9 +24,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -28,9 +24,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/register") @RequestMapping("/register")
public class RegisterController extends AccountBaseController { public class RegisterController extends AccountBaseController {
@Autowired @Autowired
private RegisterService registerService; private RegisterService registerService;
...@@ -38,7 +31,6 @@ public class RegisterController extends AccountBaseController { ...@@ -38,7 +31,6 @@ public class RegisterController extends AccountBaseController {
private AccountUtils accountUtils; private AccountUtils accountUtils;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
@ApiOperation("PC端,移动端注册接口") @ApiOperation("PC端,移动端注册接口")
...@@ -49,15 +41,20 @@ public class RegisterController extends AccountBaseController { ...@@ -49,15 +41,20 @@ public class RegisterController extends AccountBaseController {
//接口幂等性处理(redis中没有就进行注册逻辑,如果已经存在,就不处理) //接口幂等性处理(redis中没有就进行注册逻辑,如果已经存在,就不处理)
String authCode = request.getAuthCode(); String authCode = request.getAuthCode();
String flag = AccountTypeEnum.SYSCODE_TYPE_REGISTER.getCode() + ""; String flag = AccountTypeEnum.SYSCODE_TYPE_REGISTER.getCode() + "";
accountUtils.checkMobilePhoneAndAuthCode(mobile, flag, authCode); //验证码验证的原子操作
accountUtils.checkRegisterMobilePhoneAndAuthCode(mobile, flag, authCode);
accountUtils.checkPassword(request.getPassword()); accountUtils.checkPassword(request.getPassword());
LoginResult result = null; LoginResult result = null;
request.setFlag(AccountTypeEnum.SYSCODE_TYPE_REGISTER.getCode()); request.setFlag(AccountTypeEnum.SYSCODE_TYPE_REGISTER.getCode());
request.setProductType(super.getProductType()); request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType()); Integer sourceType = super.getSourceType();
request.setSourceType(sourceType);
request.setLoginIp(super.getIpAddr()); request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
result = registerService.register(request); result = registerService.register(request);
if (sourceType==3){
result.setDoctorId("");
}
return PicaResponse.toResponse(result); return PicaResponse.toResponse(result);
} }
......
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.foundation.entity.PicaResponse;
import io.swagger.annotations.Api;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created on 2020/1/20 15:03
* author:crs
* Description:性能测试需要
*/
@Api(description = "性能测试接口")
@RequestMapping("/function")
@RestController
public class TestMobileController {
@GetMapping("/encry")
public PicaResponse getEncryMobile(String mobile) {
if (StringUtils.isNotEmpty(mobile)) {
return PicaResponse.toResponse(AESUtil.encryptV0(mobile));
} else {
return PicaResponse.toResponse(null, "数据为空");
}
}
}
...@@ -6,6 +6,8 @@ import io.swagger.annotations.Api; ...@@ -6,6 +6,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
...@@ -30,6 +32,16 @@ public class TokenController extends AccountBaseController { ...@@ -30,6 +32,16 @@ public class TokenController extends AccountBaseController {
return PicaResponse.toResponse(token); return PicaResponse.toResponse(token);
} }
@ApiOperation(value = "token续时")
@GetMapping(value = "/token/continue")
public PicaResponse tokenContinueTime(
@RequestHeader(value = "token") String token,
@RequestHeader(value = "sourceType") Integer sourceType,
@RequestParam(value = "seconds", required = false) Integer seconds) throws Exception {
tokenService.tokenContinueTime(token, sourceType, seconds);
return PicaResponse.toResponse();
}
} }
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AccountAppleInfo {
private Integer id;
private String appleUserId;
private String appleId;
private String info;
private Integer deleteFlag;
private Integer createdId;
private Date createdTime;
private Integer modifiedId;
private Date modifiedTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAppleUserId() {
return appleUserId;
}
public void setAppleUserId(String appleUserId) {
this.appleUserId = appleUserId == null ? null : appleUserId.trim();
}
public String getAppleId() {
return appleId;
}
public void setAppleId(String appleId) {
this.appleId = appleId == null ? null : appleId.trim();
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info == null ? null : info.trim();
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatedId() {
return createdId;
}
public void setCreatedId(Integer createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Integer getModifiedId() {
return modifiedId;
}
public void setModifiedId(Integer modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
...@@ -15,6 +15,17 @@ public class AccountUser extends PicaUser { ...@@ -15,6 +15,17 @@ public class AccountUser extends PicaUser {
//登录ip //登录ip
private String loginIp; private String loginIp;
//用户本地token
private String userTokenTourist;
public String getUserTokenTourist() {
return userTokenTourist;
}
public void setUserTokenTourist(String userTokenTourist) {
this.userTokenTourist = userTokenTourist;
}
public Integer getAcctId() { public Integer getAcctId() {
return acctId; return acctId;
} }
......
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.entity.AesBean;
/**
* @ClassName AesAuthCodeReq
* @Description TODO
* @Author peijun.zhao
* @Date 2020/4/21 18:33
* @ModifyDate 2020/4/21 18:33
* @Version 1.0
*/
public class AesAuthCodeReq {
private Integer bizType;
private String device_token;
private String mobile;
private Integer flag;
private String token;
private String authCode;
private String password;
/**
* 加密后的密文
*/
private String key;
/**
* 加密后的数据
*/
private String content;
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getDevice_token() {
return device_token;
}
public void setDevice_token(String device_token) {
this.device_token = device_token;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public Integer getFlag() {
return flag;
}
public void setFlag(Integer flag) {
this.flag = flag;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getAuthCode() {
return authCode;
}
public void setAuthCode(String authCode) {
this.authCode = authCode;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class Hospital {
private Integer id;
private Integer provinceId;
private String provinceName;
private Long cityId;
private String cityName;
private Long countyId;
private String countyName;
private Long townId;
private String townName;
private Long villageId;
private String villageName;
private String name;
private String hospitalAddress;
private Integer type;
private Integer orgType;
private Integer levelGrade;
private String contacts;
private String tel;
private Integer sourceType;
private Integer enable;
private Integer deleteFlag;
private Integer creatId;
private Date creatTime;
private Integer modifyId;
private Date modifyTime;
private Integer hospitalStatisticsType;
private Integer hospitalRank;
private String hospitalAlias;
private Integer parentId;
private String hospitalClass;
private String hospitalLevel;
private String hospitalGrade;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getProvinceId() {
return provinceId;
}
public void setProvinceId(Integer provinceId) {
this.provinceId = provinceId;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName == null ? null : provinceName.trim();
}
public Long getCityId() {
return cityId;
}
public void setCityId(Long cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName == null ? null : cityName.trim();
}
public Long getCountyId() {
return countyId;
}
public void setCountyId(Long countyId) {
this.countyId = countyId;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName == null ? null : countyName.trim();
}
public Long getTownId() {
return townId;
}
public void setTownId(Long townId) {
this.townId = townId;
}
public String getTownName() {
return townName;
}
public void setTownName(String townName) {
this.townName = townName == null ? null : townName.trim();
}
public Long getVillageId() {
return villageId;
}
public void setVillageId(Long villageId) {
this.villageId = villageId;
}
public String getVillageName() {
return villageName;
}
public void setVillageName(String villageName) {
this.villageName = villageName == null ? null : villageName.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getHospitalAddress() {
return hospitalAddress;
}
public void setHospitalAddress(String hospitalAddress) {
this.hospitalAddress = hospitalAddress == null ? null : hospitalAddress.trim();
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getOrgType() {
return orgType;
}
public void setOrgType(Integer orgType) {
this.orgType = orgType;
}
public Integer getLevelGrade() {
return levelGrade;
}
public void setLevelGrade(Integer levelGrade) {
this.levelGrade = levelGrade;
}
public String getContacts() {
return contacts;
}
public void setContacts(String contacts) {
this.contacts = contacts == null ? null : contacts.trim();
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel == null ? null : tel.trim();
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getEnable() {
return enable;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatId() {
return creatId;
}
public void setCreatId(Integer creatId) {
this.creatId = creatId;
}
public Date getCreatTime() {
return creatTime;
}
public void setCreatTime(Date creatTime) {
this.creatTime = creatTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Integer getHospitalStatisticsType() {
return hospitalStatisticsType;
}
public void setHospitalStatisticsType(Integer hospitalStatisticsType) {
this.hospitalStatisticsType = hospitalStatisticsType;
}
public Integer getHospitalRank() {
return hospitalRank;
}
public void setHospitalRank(Integer hospitalRank) {
this.hospitalRank = hospitalRank;
}
public String getHospitalAlias() {
return hospitalAlias;
}
public void setHospitalAlias(String hospitalAlias) {
this.hospitalAlias = hospitalAlias == null ? null : hospitalAlias.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getHospitalClass() {
return hospitalClass;
}
public void setHospitalClass(String hospitalClass) {
this.hospitalClass = hospitalClass == null ? null : hospitalClass.trim();
}
public String getHospitalLevel() {
return hospitalLevel;
}
public void setHospitalLevel(String hospitalLevel) {
this.hospitalLevel = hospitalLevel == null ? null : hospitalLevel.trim();
}
public String getHospitalGrade() {
return hospitalGrade;
}
public void setHospitalGrade(String hospitalGrade) {
this.hospitalGrade = hospitalGrade == null ? null : hospitalGrade.trim();
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class LogLoginAes {
private Integer id;
private Integer channel;
private String mobile;
private Integer sourceType;
private String deviceToken;
private String deviceInfo;
private String oneToken;
private Integer createId;
private Date createTime;
private Integer modifyId;
private Date modifyTime;
private Integer deleteFlag;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getChannel() {
return channel;
}
public void setChannel(Integer channel) {
this.channel = channel;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile == null ? null : mobile.trim();
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getDeviceToken() {
return deviceToken;
}
public void setDeviceToken(String deviceToken) {
this.deviceToken = deviceToken == null ? null : deviceToken.trim();
}
public String getDeviceInfo() {
return deviceInfo;
}
public void setDeviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo == null ? null : deviceInfo.trim();
}
public String getOneToken() {
return oneToken;
}
public void setOneToken(String oneToken) {
this.oneToken = oneToken == null ? null : oneToken.trim();
}
public Integer getCreateId() {
return createId;
}
public void setCreateId(Integer createId) {
this.createId = createId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
}
\ No newline at end of file
...@@ -38,6 +38,38 @@ public class LogLoginEntity extends AccountLogEntity { ...@@ -38,6 +38,38 @@ public class LogLoginEntity extends AccountLogEntity {
private int deleteFlag; private int deleteFlag;
private String token;
private int isLogin;
private String userTokenTourist;
public int getIsLogin() {
return isLogin;
}
public void setIsLogin(int isLogin) {
this.isLogin = isLogin;
}
public String getUserTokenTourist() {
return userTokenTourist;
}
public void setUserTokenTourist(String userTokenTourist) {
this.userTokenTourist = userTokenTourist;
}
private QueryMobileEntity queryMobileEntity;
public QueryMobileEntity getQueryMobileEntity() {
return queryMobileEntity;
}
public void setQueryMobileEntity(QueryMobileEntity queryMobileEntity) {
this.queryMobileEntity = queryMobileEntity;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }
...@@ -149,4 +181,12 @@ public class LogLoginEntity extends AccountLogEntity { ...@@ -149,4 +181,12 @@ public class LogLoginEntity extends AccountLogEntity {
public void setDeleteFlag(int deleteFlag) { public void setDeleteFlag(int deleteFlag) {
this.deleteFlag = deleteFlag; this.deleteFlag = deleteFlag;
} }
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
} }
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class LogLoginOnekey {
private Integer id;
private Integer logLoginId;
private Integer deviceType;
private String mobile;
private String tradeNo;
private Integer fanqizha;
private String tag;
private String info;
private Integer deleteFlag;
private Integer createId;
private Date createTime;
private Integer modifyId;
private Date modifyTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getLogLoginId() {
return logLoginId;
}
public void setLogLoginId(Integer logLoginId) {
this.logLoginId = logLoginId;
}
public Integer getDeviceType() {
return deviceType;
}
public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile == null ? null : mobile.trim();
}
public String getTradeNo() {
return tradeNo;
}
public void setTradeNo(String tradeNo) {
this.tradeNo = tradeNo == null ? null : tradeNo.trim();
}
public Integer getFanqizha() {
return fanqizha;
}
public void setFanqizha(Integer fanqizha) {
this.fanqizha = fanqizha;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag == null ? null : tag.trim();
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info == null ? null : info.trim();
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreateId() {
return createId;
}
public void setCreateId(Integer createId) {
this.createId = createId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class LogMobileModify {
private Integer id;
private Integer acctId;
private String mobilePhoneNew;
private String mobilePhoneOld;
private Date modifiedTime;
private Integer modifiedId;
private Integer deleteFlag;
private Integer createdId;
private Date createdTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAcctId() {
return acctId;
}
public void setAcctId(Integer acctId) {
this.acctId = acctId;
}
public String getMobilePhoneNew() {
return mobilePhoneNew;
}
public void setMobilePhoneNew(String mobilePhoneNew) {
this.mobilePhoneNew = mobilePhoneNew == null ? null : mobilePhoneNew.trim();
}
public String getMobilePhoneOld() {
return mobilePhoneOld;
}
public void setMobilePhoneOld(String mobilePhoneOld) {
this.mobilePhoneOld = mobilePhoneOld == null ? null : mobilePhoneOld.trim();
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
public Integer getModifiedId() {
return modifiedId;
}
public void setModifiedId(Integer modifiedId) {
this.modifiedId = modifiedId;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatedId() {
return createdId;
}
public void setCreatedId(Integer createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity; package com.pica.cloud.account.account.server.entity;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.pica.cloud.account.account.server.util.AESUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty;
public class LoginResult { public class LoginResult {
@ApiModelProperty("token") @ApiModelProperty("token")
private String token; private String token;
@ApiModelProperty("用户id") @ApiModelProperty("用户id,未加密处理Web需要")
private Long userId; private Long userId;
@ApiModelProperty("是否绑定") @ApiModelProperty("是否绑定")
private String bindFlag; private String bindFlag;
...@@ -22,6 +23,11 @@ public class LoginResult { ...@@ -22,6 +23,11 @@ public class LoginResult {
private String unionId; private String unionId;
@ApiModelProperty("是否完善过信息,1.信息未补全, 2信息已补全,3已补全密码") @ApiModelProperty("是否完善过信息,1.信息未补全, 2信息已补全,3已补全密码")
private int entireFlag; private int entireFlag;
@ApiModelProperty("未加密手机号")
private String mobile;
@ApiModelProperty("用户id,已经加密处理")
private String doctorId;
public String getToken() { public String getToken() {
return token; return token;
...@@ -62,4 +68,21 @@ public class LoginResult { ...@@ -62,4 +68,21 @@ public class LoginResult {
public void setEntireFlag(int entireFlag) { public void setEntireFlag(int entireFlag) {
this.entireFlag = entireFlag; this.entireFlag = entireFlag;
} }
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getDoctorId() {
return doctorId;
}
public void setDoctorId(String doctorId) {
this.doctorId = doctorId;
}
} }
package com.pica.cloud.account.account.server.entity;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-12 17:09
*/
public class MobileDataEntity {
private String mobileName;
private String tradeNo;
private Integer fanqizha;
private String tag;
public String getMobileName() {
return mobileName;
}
public void setMobileName(String mobileName) {
this.mobileName = mobileName;
}
public String getTradeNo() {
return tradeNo;
}
public void setTradeNo(String tradeNo) {
this.tradeNo = tradeNo;
}
public Integer getFanqizha() {
return fanqizha;
}
public void setFanqizha(Integer fanqizha) {
this.fanqizha = fanqizha;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
@Override
public String toString() {
return "MobileDataEntity{" +
"mobileName='" + mobileName + '\'' +
", tradeNo='" + tradeNo + '\'' +
", fanqizha=" + fanqizha +
", tag='" + tag + '\'' +
'}';
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
/**
* @author andong
* @create 2019/11/18
*/
public class PProtocolLog {
private Integer id;
private String userId;
private Integer protocolId;
private Short status;
private Integer type;
private Integer userType;
private Integer deleteFlag;
private Integer createdId;
private Date createdTime;
private Integer modifiedId;
private Date modifiedTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Integer getProtocolId() {
return protocolId;
}
public void setProtocolId(Integer protocolId) {
this.protocolId = protocolId;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getUserType() {
return userType;
}
public void setUserType(Integer userType) {
this.userType = userType;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatedId() {
return createdId;
}
public void setCreatedId(Integer createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Integer getModifiedId() {
return modifiedId;
}
public void setModifiedId(Integer modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class PUserRole {
private Integer id;
private Integer systemId;
private Integer userRoleId;
private Integer userId;
private Integer userType;
private String param1;
private String param2;
private String param3;
private String param4;
private String param5;
private Integer status;
private Integer deleteFlag;
private Integer creatId;
private Date creatTime;
private Integer modifyId;
private Date modifyTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSystemId() {
return systemId;
}
public void setSystemId(Integer systemId) {
this.systemId = systemId;
}
public Integer getUserRoleId() {
return userRoleId;
}
public void setUserRoleId(Integer userRoleId) {
this.userRoleId = userRoleId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getUserType() {
return userType;
}
public void setUserType(Integer userType) {
this.userType = userType;
}
public String getParam1() {
return param1;
}
public void setParam1(String param1) {
this.param1 = param1 == null ? null : param1.trim();
}
public String getParam2() {
return param2;
}
public void setParam2(String param2) {
this.param2 = param2 == null ? null : param2.trim();
}
public String getParam3() {
return param3;
}
public void setParam3(String param3) {
this.param3 = param3 == null ? null : param3.trim();
}
public String getParam4() {
return param4;
}
public void setParam4(String param4) {
this.param4 = param4 == null ? null : param4.trim();
}
public String getParam5() {
return param5;
}
public void setParam5(String param5) {
this.param5 = param5 == null ? null : param5.trim();
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatId() {
return creatId;
}
public void setCreatId(Integer creatId) {
this.creatId = creatId;
}
public Date getCreatTime() {
return creatTime;
}
public void setCreatTime(Date creatTime) {
this.creatTime = creatTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class PermissionDoctorRole {
private Long id;
private Long doctorId;
private Long hospitalId;
private Long roleId;
private Integer deleteFlag;
private Long createdId;
private Date createdTime;
private Long modifiedId;
private Date modifiedTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDoctorId() {
return doctorId;
}
public void setDoctorId(Long doctorId) {
this.doctorId = doctorId;
}
public Long getHospitalId() {
return hospitalId;
}
public void setHospitalId(Long hospitalId) {
this.hospitalId = hospitalId;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Long getCreatedId() {
return createdId;
}
public void setCreatedId(Long createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Long getModifiedId() {
return modifiedId;
}
public void setModifiedId(Long modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-12 17:06
*/
public class QueryMobileEntity {
private String code;
private String message;
private Integer chargeStatus;
private MobileDataEntity data;
private String mobile;
private Integer sourceType;
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Integer getChargeStatus() {
return chargeStatus;
}
public void setChargeStatus(Integer chargeStatus) {
this.chargeStatus = chargeStatus;
}
public MobileDataEntity getData() {
return data;
}
public void setData(MobileDataEntity data) {
this.data = data;
}
@Override
public String toString() {
return "QueryMobileEntity{" +
"code='" + code + '\'' +
", message='" + message + '\'' +
", chargeStatus=" + chargeStatus +
", data=" + data +
", mobile='" + mobile + '\'' +
", sourceType=" + sourceType +
'}';
}
}
...@@ -25,7 +25,39 @@ public enum AccountExceptionEnum { ...@@ -25,7 +25,39 @@ public enum AccountExceptionEnum {
PICA_PARAMS_ERROR("216517", "传递参数有误"), PICA_PARAMS_ERROR("216517", "传递参数有误"),
PICA_SYSCODE_RETRY("216518", "请X秒后重试"), PICA_SYSCODE_RETRY("216518", "请X秒后重试"),
PICA_NOT_EXIST("216519", "该用户不存在"), PICA_NOT_EXIST("216519", "该用户不存在"),
PICA_REGISTER_FAIL("216520", "注册失败"); PICA_REGISTER_FAIL("216520", "注册失败"),
PICA_WECHAT_CODE_ERROR("216521", "微信登录授权code不正确"),
PICA_WECHAT_UNBIND("216522", "该微信号已绑定其他云鹊医账户,你可以使用微信登录云鹊医,在「设置」页解除绑定"),
PICA_WECHAT_BIND_OTHER("216524", "该手机号已绑定其他微信号,你可以在「设置」页解除绑定"),
PICA_WECHAT_UNBIND_CURRENT("216523", "正在绑定中,请稍等"),
PICA_PASSWORD_RULE_ERROR("216525","该手机号{mobile}尚未设置密码,请先设置密码。"),
PICA_PWD_MISMATCH_4("216526", "密码错误,请重试"),
PICA_PWD_MISMATCH_5("216527", "该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码"),
PICA_APPLE_TOKEN_ERROR("216528", "Apple登录授权token不正确"),
PICA_APPLE_BIND_OTHER("216529", "该Apple账号已绑定其他账户"),
PICA_MOBILE_BIND_OTHER("216530", "该手机号已绑定其他Apple账号"),
PICA_MOBILE_REG_FALSE("216531", "请输入正确的手机号"),
PICA_MOBILE_NOT_REGIST("216533", "该手机号{mobile}尚未设置密码,请先设置密码。"),
PICA_MOBILE_NOT_SETED_PASSWORD("216534", "该手机号{mobile}尚未设置密码,请先设置密码。"),
// 风控禁止发送
PICA_RC_SEND_FAIL("216536", "发送异常"),
PICA_RC_TRIGGER("216537", "需要触发风控滑动验证"),
// 账号、IP、设备在黑名单内,前端提示发送成功,后端不发送短信
PICA_RC_BLACKLIST("216538", "发送成功"),
PICA_RC_DAY_LIMIT("216539", "今日获取验证码次数已超过上限,请使用账户密码登录"),
PICA_RC_60_SECOND_LIMIT("216540", "验证码发送频率过高,请{remainTime}秒后再试"),
PICA_MESSAGE_SERVICE_CALL_FAIL("216542", "短信发送失败"),
PICA_BIND_WECHAT_FAIL("216543", "绑定微信失败"),
PICA_CAP_CODE_ERROR("216544", "拼图验证失败"),
PICA_CAP_GET_INVOKE_ERROR("216545", "拼图获取失败"),
PICA_RC_BUSINESS_ERROR("216546", "参数格式错误"),
PICA_MOBILE_NOT_REGIST_H5("216547", "该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。"),
PICA_MOBILE_NOT_SETED_PASSWORD_H5("216548", "该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。"),
PICA_PWD_MISMATCH_5_H5("216549", "该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式"),
xxx_xxx("","");
private String code; private String code;
......
...@@ -13,6 +13,8 @@ public enum AccountTypeEnum { ...@@ -13,6 +13,8 @@ public enum AccountTypeEnum {
LOGIN_WE_CHAT(3, "微信登录"), LOGIN_WE_CHAT(3, "微信登录"),
LOGIN_OUT(4, "退出登录"), LOGIN_OUT(4, "退出登录"),
LOGIN_REGISTER(5, "注册登录"), LOGIN_REGISTER(5, "注册登录"),
LOGIN_APPLE(6, "Apple登录"),
LOGIN_ONE_CLICK(7, "一键登录"),
//登录态相关枚举 //登录态相关枚举
LOGIN_STATUS_SUCCESS(1, "登录成功"), LOGIN_STATUS_SUCCESS(1, "登录成功"),
...@@ -30,18 +32,23 @@ public enum AccountTypeEnum { ...@@ -30,18 +32,23 @@ public enum AccountTypeEnum {
DEVICE_TYPE_ADMIN(5, "admin"), DEVICE_TYPE_ADMIN(5, "admin"),
//验证码获取类型: flag:0登录(默认)1注册 2微信登录绑定手机 3修改手机 4重置密码 //验证码获取类型: flag:0登录(默认)1注册 2微信登录绑定手机 3修改手机 4重置密码
//5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
SYSCODE_TYPE_LOGIN(0, "登录"), SYSCODE_TYPE_LOGIN(0, "登录"),
SYSCODE_TYPE_REGISTER(1, "注册"), SYSCODE_TYPE_REGISTER(1, "注册"),
SYSCODE_TYPE_WE_CHAT(2, "微信登录绑定手机"), SYSCODE_TYPE_WE_CHAT(2, "微信登录绑定手机"),
SYSCODE_TYPE_MODIFY_MOBILE(3, "修改手机号"), SYSCODE_TYPE_MODIFY_MOBILE(3, "修改手机号"),
SYSCODE_TYPE_RESET_PASSWORD(4, "重置密码"), SYSCODE_TYPE_RESET_PASSWORD(4, "重置密码"),
SYSCODE_TYPE_FORGET_PASSWORD(5, "重置密码"),
SYSCODE_TYPE_SMO_COMIIT_QUESTIONNAIRE(6, "患者招募提交问卷"),
SYSCODE_TYPE_APPLE(8, "Appe登录绑定手机"),
//联合登录类型 //联合登录类型
UNION_LOGIN_WE_CHAT(1, "微信"), UNION_LOGIN_WE_CHAT(1, "微信"),
UNION_LOGIN_QQ(2, "QQ"), UNION_LOGIN_QQ(2, "QQ"),
union_login_blog(3, "微博"), union_login_blog(3, "微博"),
UNION_LOGIN_APPLE(4, "苹果"),
//微信绑定状态 //微信/apple绑定状态
BIND_STATUS_SUCCESS(1, "已绑定"), BIND_STATUS_SUCCESS(1, "已绑定"),
BIND_STATUS_FAILURE(0, "未绑定"), BIND_STATUS_FAILURE(0, "未绑定"),
......
package com.pica.cloud.account.account.server.enums;
/**
* @Description 统一校验响应枚举类
* @Author Chongwen.jiang
* @Date 2020/2/20 18:19
* @ModifyDate 2020/2/20 18:19
* @Params
* @Return
*/
public enum RcRepTypeEnum {
// 风控禁止发送
RC_ALLOW_SEND_MSG("1", "允许发送"),
RC_SEND_FAIL("2", "发送失败"),
RC_TRIGGER("3", "需要触发风控滑动验证"),
// 账号、IP、设备在黑名单内,前端提示发送成功,后端不发送短信
RC_BLACKLIST("4", "发送成功"),
RC_DAY_LIMIT("5", "今日获取验证码次数已超过上限,请使用账户密码登录"),
RC_60_SECOND_LIMIT("6", "验证码发送频率过高,请{remainTime}秒后再试"),
XXX("0", "xxxxxx");
private String code;
private String msg;
RcRepTypeEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setType(String msg) {
this.msg = msg;
}
}
package com.pica.cloud.account.account.server.enums;
/**
* @Description 统一校验业务类型枚举类
* @Author Chongwen.jiang
* @Date 2020/2/20 18:19
* @ModifyDate 2020/2/20 18:19
* @Params
* @Return
*/
public enum SourceTypeEnum {
ANDROID(1, "安卓"),
APPLE(2, "ios"),
SAAS(3, "saas"),
H5(4, "h5"),
ADMIN(5, "admin"),
XXX(10, "xxxxxx");
private Integer code;
private String type;
SourceTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.pica.cloud.account.account.server.job;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created on 2019/10/29 15:37
* author:crs
* Description:doctor表重复记录处理
*/
@JobHandler(value = "AccountRepeatDataJob")
@Component
public class AccountRepeatDataJob extends IJobHandler {
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Override
public ReturnT<String> execute(String s) throws Exception {
accountInfoDetailMapper.processAccountRepeatData();
XxlJobLogger.log("repeat date-----");
return SUCCESS;
}
}
package com.pica.cloud.account.account.server.job;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created on 2019/12/16 17:53
* author:crs
* Description:记录doctor修改记录日志
*/
//@JobHandler(value = "DoctorLogHandler")
//@Component
//public class DoctorLogHandler extends IJobHandler {
//
// @Autowired
// private DoctorMapper doctorMapper;
//
// @Override
// public ReturnT<String> execute(String s) throws Exception {
// XxlJobLogger.log("doctorLogRecord start-----");
// Integer rows = doctorMapper.updateDoctorModifyRecord();
// XxlJobLogger.log("doctorLogRecord end-----"+rows);
// return SUCCESS;
// }
//}
...@@ -15,41 +15,41 @@ import org.springframework.stereotype.Component; ...@@ -15,41 +15,41 @@ import org.springframework.stereotype.Component;
* author:crs * author:crs
* Description:doctor表重复记录处理 * Description:doctor表重复记录处理
*/ */
@Component //@Component
public class DoctorRepeatDataJob { //public class DoctorRepeatDataJob {
private final String KEY = "cache_process_doctor_repeat"; // private final String KEY = "cacheProcessDoctorRepeat";
//
private Logger logger = LoggerFactory.getLogger(this.getClass()); // private Logger logger = LoggerFactory.getLogger(this.getClass());
//
@Autowired // @Autowired
@Qualifier("cacheMigrateClient") //
private ICacheClient cacheClient; // private ICacheClient cacheClient;
//
@Autowired // @Autowired
private DoctorMapper doctorMapper; // private DoctorMapper doctorMapper;
//
/** // /**
* 1、使用分布式锁保证一个微服务执行; // * 1、使用分布式锁保证一个微服务执行;
* 2、定时任务; // * 2、定时任务;
*/ // */
@Scheduled(cron = "0 0 0 1/1 * ?") // @Scheduled(cron = "0 0 0/1 * * ?")
public void processDoctorRepeatData() { // public void processDoctorRepeatData() {
Long result = cacheClient.setnx(KEY, "1"); // //通过接口幂等性逻辑处理
//如果为1说明获取到分布式锁 // String exist = cacheClient.get(KEY);
if (result == 1) { // if (exist==null){
//10分钟后锁过期 // cacheClient.set(KEY,"1");
cacheClient.expire(KEY, 60 * 10); // cacheClient.expire(KEY, 60 * 10);
logger.info("开始执行刷新doctor表中重复的记录"); // logger.info("DoctorRepeatDataJob:开始执行刷新doctor表中重复的记录");
int row = doctorMapper.processDoctorRepeatData(); // int row = doctorMapper.processDoctorRepeatData();
logger.info("此次数据刷新影响的行数:{}", row); // logger.info("此次数据刷新影响的行数:{}", row);
try { // try {
//防止任务一秒跑完,其他机器的时间晚了几秒 // //防止任务一秒跑完,其他机器的时间晚了几秒
Thread.sleep(30*1000); // Thread.sleep(30*1000);
} catch (InterruptedException ex) { // } catch (InterruptedException ex) {
logger.error(ex.getMessage(), ex); // logger.error(ex.getMessage(), ex);
} // }
//释放锁 // //释放锁
cacheClient.del(KEY); // cacheClient.del(KEY);
} // }
} // }
} //}
package com.pica.cloud.account.account.server.job;
import com.pica.cloud.account.account.server.mapper.HospitalMapper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created on 2019/12/16 17:53
* author:crs
* Description:记录doctor修改记录日志
*/
//@JobHandler(value = "HospitalLogHandler")
//@Component
//public class HospitalLogHandler extends IJobHandler {
//
// @Autowired
// private HospitalMapper hospitalMapper;
//
// @Override
// public ReturnT<String> execute(String s) throws Exception {
// XxlJobLogger.log("hospitalLogRecord start-----");
// Integer rows = hospitalMapper.updateDoctorModifyRecord();
// XxlJobLogger.log("hospitalLogRecord end-----"+rows);
// return SUCCESS;
// }
//}
package com.pica.cloud.account.account.server.job;
import com.pica.cloud.account.account.server.mapper.PermissionDoctorRoleMapper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created on 2019/12/16 17:53
* author:crs
* Description:记录doctor修改记录日志
*/
@JobHandler(value = "PermissionRoleLogHandler")
@Component
public class PermissionRoleLogHandler extends IJobHandler {
@Autowired
private PermissionDoctorRoleMapper permissionDoctorRoleMapper;
@Override
public ReturnT<String> execute(String s) throws Exception {
XxlJobLogger.log("permissionRoleLogRecord start-----");
Integer rows = permissionDoctorRoleMapper.updatePermissionModifyRecord();
XxlJobLogger.log("permissionLogRecord end-----"+rows);
return SUCCESS;
}
}
...@@ -21,7 +21,7 @@ public class AccountLogEntityUtils { ...@@ -21,7 +21,7 @@ public class AccountLogEntityUtils {
* @return * @return
*/ */
public static LogLoginEntity getLogLoginEntity(Integer acctId, Integer productType, Integer sourceType, public static LogLoginEntity getLogLoginEntity(Integer acctId, Integer productType, Integer sourceType,
int code, String ipAddr, int code1, int code2) { int code, String ipAddr, int code1, int code2,String token,int isLogin,String userTokenTourist) {
LogLoginEntity entity = new LogLoginEntity(); LogLoginEntity entity = new LogLoginEntity();
Date currentTime = new Date(); Date currentTime = new Date();
entity.setAcctId(acctId); entity.setAcctId(acctId);
...@@ -37,6 +37,9 @@ public class AccountLogEntityUtils { ...@@ -37,6 +37,9 @@ public class AccountLogEntityUtils {
entity.setLoginIp(ipAddr); entity.setLoginIp(ipAddr);
entity.setLoginStatus(code1); entity.setLoginStatus(code1);
entity.setLogType(code2); entity.setLogType(code2);
entity.setToken(token);
entity.setIsLogin(isLogin);
entity.setUserTokenTourist(userTokenTourist);
return entity; return entity;
} }
......
...@@ -4,11 +4,13 @@ package com.pica.cloud.account.account.server.log; ...@@ -4,11 +4,13 @@ package com.pica.cloud.account.account.server.log;
import com.pica.cloud.account.account.server.entity.LogLoginEntity; import com.pica.cloud.account.account.server.entity.LogLoginEntity;
import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity; import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity;
import com.pica.cloud.account.account.server.entity.LogUserInfoEntity; import com.pica.cloud.account.account.server.entity.LogUserInfoEntity;
import com.pica.cloud.account.account.server.entity.QueryMobileEntity;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.mapper.LogLoginMapper; import com.pica.cloud.account.account.server.mapper.LogLoginMapper;
import com.pica.cloud.account.account.server.mapper.LogPWDModifyMapper; import com.pica.cloud.account.account.server.mapper.LogPWDModifyMapper;
import com.pica.cloud.account.account.server.mapper.LogUserInfoMapper; import com.pica.cloud.account.account.server.mapper.LogUserInfoMapper;
import com.pica.cloud.account.account.server.model.OneClickProcessor;
import com.pica.cloud.account.account.server.util.BeanUtil; import com.pica.cloud.account.account.server.util.BeanUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -28,6 +30,8 @@ public class AccountLogTask implements Runnable { ...@@ -28,6 +30,8 @@ public class AccountLogTask implements Runnable {
private LogUserInfoMapper logUserInfoMapper; private LogUserInfoMapper logUserInfoMapper;
private OneClickProcessor oneClickProcessor;
/** /**
* 日志类型 * 日志类型
*/ */
...@@ -44,6 +48,8 @@ public class AccountLogTask implements Runnable { ...@@ -44,6 +48,8 @@ public class AccountLogTask implements Runnable {
loginLogMapper = BeanUtil.getBean(LogLoginMapper.class); loginLogMapper = BeanUtil.getBean(LogLoginMapper.class);
logPWDModifyMapper = BeanUtil.getBean(LogPWDModifyMapper.class); logPWDModifyMapper = BeanUtil.getBean(LogPWDModifyMapper.class);
logUserInfoMapper = BeanUtil.getBean(LogUserInfoMapper.class); logUserInfoMapper = BeanUtil.getBean(LogUserInfoMapper.class);
oneClickProcessor = BeanUtil.getBean(OneClickProcessor.class);
} }
@Override @Override
...@@ -53,6 +59,11 @@ public class AccountLogTask implements Runnable { ...@@ -53,6 +59,11 @@ public class AccountLogTask implements Runnable {
if (type == AccountTypeEnum.LOG_TYPE_LOGIN.getCode()) { if (type == AccountTypeEnum.LOG_TYPE_LOGIN.getCode()) {
logger.info("login record......"); logger.info("login record......");
loginLogMapper.insert((LogLoginEntity) picaLogEntity); loginLogMapper.insert((LogLoginEntity) picaLogEntity);
QueryMobileEntity queryMobileEntity = ((LogLoginEntity) picaLogEntity).getQueryMobileEntity();
if(queryMobileEntity != null){
// 记录一键登录日志
oneClickProcessor.savelogLoginOnekey(queryMobileEntity,((LogLoginEntity) picaLogEntity).getId());
}
} else if (type == AccountTypeEnum.LOG_TYPE_PASSWORD.getCode()) { } else if (type == AccountTypeEnum.LOG_TYPE_PASSWORD.getCode()) {
logPWDModifyMapper.insert((LogPWDModifyEntity) picaLogEntity); logPWDModifyMapper.insert((LogPWDModifyEntity) picaLogEntity);
} else if (type == AccountTypeEnum.LOG_TYPE_USER_INFO.getCode()) { } else if (type == AccountTypeEnum.LOG_TYPE_USER_INFO.getCode()) {
......
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountAppleInfo;
import org.apache.ibatis.annotations.Param;
public interface AccountAppleInfoMapper {
int insert(AccountAppleInfo record);
int insertSelective(AccountAppleInfo record);
AccountAppleInfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AccountAppleInfo record);
int updateByPrimaryKey(AccountAppleInfo record);
AccountAppleInfo selectByUserId(@Param("id") String appleUserId);
}
\ No newline at end of file
...@@ -2,6 +2,9 @@ package com.pica.cloud.account.account.server.mapper; ...@@ -2,6 +2,9 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
public interface AccountInfoDetailMapper { public interface AccountInfoDetailMapper {
/** /**
...@@ -58,5 +61,8 @@ public interface AccountInfoDetailMapper { ...@@ -58,5 +61,8 @@ public interface AccountInfoDetailMapper {
int insertSelective(AccountInfoEntity record); int insertSelective(AccountInfoEntity record);
void updateDeleteByPrimaryKey(Integer acctId); void updateDeleteByPrimaryKey(@Param("map") HashMap<String, Long> map);
void processAccountRepeatData();
} }
...@@ -3,15 +3,17 @@ package com.pica.cloud.account.account.server.mapper; ...@@ -3,15 +3,17 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountUnionEntity; import com.pica.cloud.account.account.server.entity.AccountUnionEntity;
import java.util.Map;
public interface AccountUnionMapper { public interface AccountUnionMapper {
/** /**
* 解除绑定关系 * 解除绑定关系
* *
* @param acctId 账户id * @param map
* @return * @return
*/ */
int updateUnbindByAcctId(Integer acctId); int updateUnbindByAcctId(Map<String, Object> map);
/** /**
* 是否绑定过手机号 * 是否绑定过手机号
...@@ -21,8 +23,7 @@ public interface AccountUnionMapper { ...@@ -21,8 +23,7 @@ public interface AccountUnionMapper {
*/ */
AccountUnionEntity selectByUnionId(String unionId); AccountUnionEntity selectByUnionId(String unionId);
AccountUnionEntity selectByAcctId(Map<String, Object> map);
int deleteByPrimaryKey(Integer id);
int insert(AccountUnionEntity record); int insert(AccountUnionEntity record);
...@@ -34,5 +35,9 @@ public interface AccountUnionMapper { ...@@ -34,5 +35,9 @@ public interface AccountUnionMapper {
int updateByPrimaryKey(AccountUnionEntity record); int updateByPrimaryKey(AccountUnionEntity record);
/**
* 通过unionid更新记录信息
* @param unionId
*/
void updateUnionStatus(String unionId);
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.pica.cloud.account.account.server.mapper; ...@@ -2,6 +2,7 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AgreementLogEntity; import com.pica.cloud.account.account.server.entity.AgreementLogEntity;
import com.pica.cloud.account.account.server.entity.PProtocolLog;
public interface AgreementLogEntityMapper { public interface AgreementLogEntityMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
...@@ -15,4 +16,10 @@ public interface AgreementLogEntityMapper { ...@@ -15,4 +16,10 @@ public interface AgreementLogEntityMapper {
int updateByPrimaryKeySelective(AgreementLogEntity record); int updateByPrimaryKeySelective(AgreementLogEntity record);
int updateByPrimaryKey(AgreementLogEntity record); int updateByPrimaryKey(AgreementLogEntity record);
Integer getLatestProtocolId(int type);
int insertProtocolLog(PProtocolLog record);
int updateSignNum(Integer id);
} }
\ No newline at end of file
...@@ -6,6 +6,8 @@ import com.pica.cloud.account.account.server.entity.DoctorEntity; ...@@ -6,6 +6,8 @@ import com.pica.cloud.account.account.server.entity.DoctorEntity;
import com.pica.cloud.account.account.server.entity.PICAPDoctor; import com.pica.cloud.account.account.server.entity.PICAPDoctor;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
public interface DoctorMapper { public interface DoctorMapper {
/** /**
* 获取医生信息 * 获取医生信息
...@@ -83,13 +85,26 @@ public interface DoctorMapper { ...@@ -83,13 +85,26 @@ public interface DoctorMapper {
PICAPDoctor queryDoctor(long doctorId); PICAPDoctor queryDoctor(long doctorId);
void updateDeleteByPrimaryKey(Integer id); void updateDeleteByPrimaryKey(@Param("map") HashMap<String, Long> map);
/** /**
* 通过手机号获取用户id * 通过手机号获取用户id
*
* @param mobile * @param mobile
* @return * @return
*/ */
//Long selectDoctorIdByMobile(String mobile); //Long selectDoctorIdByMobile(String mobile);
Integer getAcctIdByDoctorId(long id);
/**
* 更新p_doctor表的修改记录
*
* @return
*/
Integer updateDoctorModifyRecord();
} }
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.Hospital;
public interface HospitalMapper {
int deleteByPrimaryKey(Integer id);
int insert(Hospital record);
int insertSelective(Hospital record);
Hospital selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Hospital record);
int updateByPrimaryKey(Hospital record);
Integer updateDoctorModifyRecord();
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LogLoginAes;
public interface LogLoginAesMapper {
int deleteByPrimaryKey(Integer id);
int insert(LogLoginAes record);
int insertSelective(LogLoginAes record);
LogLoginAes selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(LogLoginAes record);
int updateByPrimaryKey(LogLoginAes record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LogLoginOnekey;
public interface LogLoginOnekeyMapper {
int deleteByPrimaryKey(Integer id);
int insert(LogLoginOnekey record);
int insertSelective(LogLoginOnekey record);
LogLoginOnekey selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(LogLoginOnekey record);
int updateByPrimaryKey(LogLoginOnekey record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LogMobileModify;
public interface LogMobileModifyMapper {
int deleteByPrimaryKey(Integer id);
int insert(LogMobileModify record);
int insertSelective(LogMobileModify record);
LogMobileModify selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(LogMobileModify record);
int updateByPrimaryKey(LogMobileModify record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.PUserRole;
public interface PUserRoleMapper {
int deleteByPrimaryKey(Integer id);
int insert(PUserRole record);
int insertSelective(PUserRole record);
PUserRole selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(PUserRole record);
int updateByPrimaryKey(PUserRole record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.PermissionDoctorRole;
public interface PermissionDoctorRoleMapper {
int deleteByPrimaryKey(Long id);
int insert(PermissionDoctorRole record);
int insertSelective(PermissionDoctorRole record);
PermissionDoctorRole selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(PermissionDoctorRole record);
int updateByPrimaryKey(PermissionDoctorRole record);
/**
* 记录用户权限修改记录
*
* @return
*/
Integer updatePermissionModifyRecord();
}
\ No newline at end of file
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName AuthCodeReq
* @Description h5拼图对象
* @Author Chongwen.jiang
* @Date 2020/3/23 13:29
* @ModifyDate 2020/3/23 13:29
* @Version 1.0
*/
@ApiModel(value = "JigsawCodeModel", description = "h5拼图对象")
public class JigsawCodeModel {
@ApiModelProperty(value = "背景图")
private String backImage;
@ApiModelProperty(value = "滑动图")
private String slidingImage;
@ApiModelProperty(value = "y坐标")
private Integer yHeight;
@ApiModelProperty(value = "时间戳")
private String capCode;
public String getBackImage() {
return backImage;
}
public void setBackImage(String backImage) {
this.backImage = backImage;
}
public String getSlidingImage() {
return slidingImage;
}
public void setSlidingImage(String slidingImage) {
this.slidingImage = slidingImage;
}
public Integer getyHeight() {
return yHeight;
}
public void setyHeight(Integer yHeight) {
this.yHeight = yHeight;
}
public String getCapCode() {
return capCode;
}
public void setCapCode(String capCode) {
this.capCode = capCode;
}
}
package com.pica.cloud.account.account.server.model;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.LogLoginOnekey;
import com.pica.cloud.account.account.server.entity.MobileDataEntity;
import com.pica.cloud.account.account.server.entity.QueryMobileEntity;
import com.pica.cloud.account.account.server.mapper.LogLoginOnekeyMapper;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.HttpUtil;
import com.pica.cloud.account.account.server.util.MD5;
import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.account.account.server.util.SignUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-24 13:57
*/
@Component
public class OneClickProcessor {
private static final String DEFAULT_ENCRYPT_TYPE = "0";
private Logger logger = LoggerFactory.getLogger(this.getClass());
//手机号加解密方式 0 AES 1 RSA , 可以不传,不传则手机号解密直接使用AES解密
private String aesEncryptType = DEFAULT_ENCRYPT_TYPE;
private String rsaEncryptType = "1";
private String encryptType = DEFAULT_ENCRYPT_TYPE;
private static final String SHANYAN_SUCCESS_CODE = "200000";
//创建应用时填入的rsa公钥对应的私钥字符串
public static final String privateKey = "";
public static final Integer TYPE_IOS = 2;
public static final Integer TYPE_ANDROID = 1;
private static final String TOKEN = "token";
private static final String APPID = "appId";
private static final String ENCRYPT_TYPE = "encryptType";
private static final String SIGN = "sign";
@Value("${shanyan.url.mobilequery}")
private String mobileQueryUrl;
@Value("${shanyan.android.appId}")
private String androidAppId;
@Value("${shanyan.android.appKey}")
private String androidAppKey;
@Value("${shanyan.ios.appId}")
private String iosAppId;
@Value("${shanyan.ios.appKey}")
private String iosAppKey;
@Autowired
private LogLoginOnekeyMapper logLoginOnekeyMapper;
public QueryMobileEntity tokenExchangeMobile(String token, Integer type) {
if (type == null || StringUtils.isEmpty(token)) {
return null;
}
String appId;
String appKey;
if (type.equals(TYPE_ANDROID)) {
appId = androidAppId;
appKey = androidAppKey;
} else if (type.equals(TYPE_IOS)) {
appId = iosAppId;
appKey = iosAppKey;
} else {
return null;
}
//从SDK获取的token参数
QueryMobileEntity queryMobileEntity = null;
try {
Map<String, String> params = new HashMap<>();
params.put(TOKEN, token);
params.put(APPID, appId);
params.put(ENCRYPT_TYPE, encryptType);//可以不传,不传则解密直接使用AES解密
params.put(SIGN, SignUtils.getSign(params, appKey));
queryMobileEntity = HttpUtil.postForm(mobileQueryUrl, params, QueryMobileEntity.class);
if (null != queryMobileEntity) {
logger.info("一键登录token换取手机号结果:{}", queryMobileEntity);
String code = queryMobileEntity.getCode(); //返回码 200000为成功
if (SHANYAN_SUCCESS_CODE.equals(code)) {
MobileDataEntity mobileDataEntity = queryMobileEntity.getData();
String mobile = mobileDataEntity.getMobileName();
if (aesEncryptType.equals(encryptType)) {
String key = MD5.getMD5Code(appKey);
mobile = AESUtil.decrypt(mobile, key.substring(0, 16), key.substring(16));
} else if (rsaEncryptType.equals(encryptType)) {
mobile = RSAUtil.decryptByPrivateKeyForLongStr(mobile, privateKey);
}
queryMobileEntity.setMobile(mobile);
}
}
} catch (Exception e) {
logger.error(e.getMessage());
}
return queryMobileEntity;
}
@Async
public void savelogLoginOnekey(QueryMobileEntity queryMobileEntity,Integer logLoginId) {
LogLoginOnekey l = new LogLoginOnekey();
l.setDeviceType(queryMobileEntity.getSourceType());
MobileDataEntity data = queryMobileEntity.getData();
l.setFanqizha(data.getFanqizha());
l.setTradeNo(data.getTradeNo());
l.setMobile(AESUtil.encryptV0(queryMobileEntity.getMobile()));
l.setLogLoginId(logLoginId);
l.setInfo(JSONObject.toJSONString(queryMobileEntity));
Date d = new Date();
l.setCreateId(-1);
l.setCreateTime(d);
l.setModifyId(-1);
l.setModifyTime(d);
logLoginOnekeyMapper.insertSelective(l);
}
}
package com.pica.cloud.account.account.server.queue; package com.pica.cloud.account.account.server.queue;
import org.springframework.amqp.core.*; //import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; //import org.springframework.context.annotation.Configuration;
/** /**
...@@ -10,40 +10,40 @@ import org.springframework.context.annotation.Configuration; ...@@ -10,40 +10,40 @@ import org.springframework.context.annotation.Configuration;
* author:crs * author:crs
* Description:消息队列配置 * Description:消息队列配置
*/ */
@Configuration //@Configuration
public class QueueConfig { //public class QueueConfig {
//
public final static String QUEUE_NAME = "register_queue_account_13201"; // public final static String QUEUE_NAME = "register_queue_account_13201";
public final static String EXCHANGE_NAME = "register_exchange"; // public final static String EXCHANGE_NAME = "register_exchange";
public final static String ROUTE_KEY_NAME = "register_finish"; // public final static String ROUTE_KEY_NAME = "register_finish";
//
/** // /**
* 创建一个消息队列 // * 创建一个消息队列
* // *
* @return // * @return
*/ // */
@Bean // @Bean
public Queue queue() { // public Queue queue() {
return new Queue(QUEUE_NAME, true, false, true); // return new Queue(QUEUE_NAME, true, false, true);
} // }
//
/** // /**
* 创建交换机 // * 创建交换机
* // *
* @return // * @return
*/ // */
@Bean // @Bean
public TopicExchange directExchange() { // public TopicExchange directExchange() {
return new TopicExchange(EXCHANGE_NAME); // return new TopicExchange(EXCHANGE_NAME);
} // }
//
/** // /**
* 把消息队里和交换机进行绑定 // * 把消息队里和交换机进行绑定
* // *
* @return // * @return
*/ // */
@Bean // @Bean
public Binding binding() { // public Binding binding() {
return BindingBuilder.bind(queue()).to(directExchange()).with(ROUTE_KEY_NAME); // return BindingBuilder.bind(queue()).to(directExchange()).with(ROUTE_KEY_NAME);
} // }
} //}
package com.pica.cloud.account.account.server.queue; package com.pica.cloud.account.account.server.queue;
import org.springframework.amqp.core.AmqpTemplate; //import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
/** /**
* Created on 2019/9/11 17:37 * Created on 2019/9/11 17:37
* author:crs * author:crs
* Description:消息生产者 * Description:消息生产者
*/ */
@Component //@Component
public class QueueProducer { //public class QueueProducer {
//
@Autowired // @Autowired
private AmqpTemplate amqpTemplate; // private AmqpTemplate amqpTemplate;
//
/** // /**
* 发送消息 // * 发送消息
* // *
* @param message // * @param message
*/ // */
public void send(byte[] message) { // public void send(byte[] message) {
amqpTemplate.convertAndSend(QueueConfig.EXCHANGE_NAME, QueueConfig.ROUTE_KEY_NAME, message); // amqpTemplate.convertAndSend(QueueConfig.EXCHANGE_NAME, QueueConfig.ROUTE_KEY_NAME, message);
} // }
} //}
...@@ -34,6 +34,34 @@ public class BaseRequest { ...@@ -34,6 +34,34 @@ public class BaseRequest {
private String captchaToken; private String captchaToken;
@ApiModelProperty("图片验证码答案") @ApiModelProperty("图片验证码答案")
private String captchaAnswer; private String captchaAnswer;
@ApiModelProperty("业务类型,1-新老业务区分标识,2-手机号格式校验业务,3-密码登录校验业务")
private Integer bizType;
@ApiModelProperty("设备id")
private String device_token;
@ApiModelProperty("苹果身份token")
private String identifyToken;
@ApiModelProperty("苹果用户id")
private String appleUserId;
@ApiModelProperty("appleId")
private String appleId;
@ApiModelProperty("apple用户信息(json字符串)")
private String info;
@ApiModelProperty("capCode")
private String capCode;
@ApiModelProperty("滑动图片的x位置")
private Integer xPos;
@ApiModelProperty("h5端适配缩放后背景图实际宽度")
private Integer imageW;
@ApiModelProperty("用户本地token")
private String userTokenTourist;
public String getUserTokenTourist() {
return userTokenTourist;
}
public void setUserTokenTourist(String userTokenTourist) {
this.userTokenTourist = userTokenTourist;
}
public String getCaptchaToken() { public String getCaptchaToken() {
return captchaToken; return captchaToken;
...@@ -146,4 +174,76 @@ public class BaseRequest { ...@@ -146,4 +174,76 @@ public class BaseRequest {
public void setWeChatLoginType(Integer weChatLoginType) { public void setWeChatLoginType(Integer weChatLoginType) {
this.weChatLoginType = weChatLoginType; this.weChatLoginType = weChatLoginType;
} }
public String getAppleUserId() {
return appleUserId;
}
public void setAppleUserId(String appleUserId) {
this.appleUserId = appleUserId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getIdentifyToken() {
return identifyToken;
}
public void setIdentifyToken(String identifyToken) {
this.identifyToken = identifyToken;
}
public String getAppleId() {
return appleId;
}
public void setAppleId(String appleId) {
this.appleId = appleId;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public String getDevice_token() {
return device_token;
}
public void setDevice_token(String device_token) {
this.device_token = device_token;
}
public String getCapCode() {
return capCode;
}
public void setCapCode(String capCode) {
this.capCode = capCode;
}
public Integer getxPos() {
return xPos;
}
public void setxPos(Integer xPos) {
this.xPos = xPos;
}
public Integer getImageW() {
return imageW;
}
public void setImageW(Integer imageW) {
this.imageW = imageW;
}
} }
package com.pica.cloud.account.account.server.req;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-12 15:58
*/
public class OneClickLoginReq {
private Integer sourceType;
private String token = "";
private String loginIp;
private Integer productType = 0;
private String userTokenTourist;
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
public Integer getProductType() {
return productType;
}
public void setProductType(Integer productType) {
this.productType = productType;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getUserTokenTourist() {
return userTokenTourist;
}
public void setUserTokenTourist(String userTokenTourist) {
this.userTokenTourist = userTokenTourist;
}
}
package com.pica.cloud.account.account.server.req;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-12 17:11
*/
public class QueryMobileReq {
private String token;
private String appId;
private String clientIp;
private String encryptType;
private String outId;
private String sign;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public String getEncryptType() {
return encryptType;
}
public void setEncryptType(String encryptType) {
this.encryptType = encryptType;
}
public String getOutId() {
return outId;
}
public void setOutId(String outId) {
this.outId = outId;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModel;
/**
* @ClassName UnifiedVerificationResp
* @Description 统一验证响应类
* @Author Chongwen.jiang
* @Date 2020/2/20 20:48
* @ModifyDate 2020/2/20 20:48
* @Version 1.0
*/
@ApiModel(value = "UnifiedVerificationResp", description = "统一验证响应类")
public class UnifiedVerificationResp {
private Integer bizCode;
private String bizMsg;
public Integer getBizCode() {
return bizCode;
}
public void setBizCode(Integer bizCode) {
this.bizCode = bizCode;
}
public String getBizMsg() {
return bizMsg;
}
public void setBizMsg(String bizMsg) {
this.bizMsg = bizMsg;
}
}
package com.pica.cloud.account.account.server.service; package com.pica.cloud.account.account.server.service;
import ch.qos.logback.core.rolling.helper.IntegerTokenConverter;
import com.pica.cloud.account.account.server.entity.Account; import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
......
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.model.JigsawCodeModel;
import com.pica.cloud.account.account.server.req.BaseRequest;
import javax.servlet.http.HttpServletRequest;
/**
* @ClassName AuthCodeService
* @Description 验证码业务
* @Author Chongwen.jiang
* @Date 2020/3/5 17:01
* @ModifyDate 2020/3/5 17:01
* @Version 1.0
*/
public interface AuthCodeService {
int rcValidate(HttpServletRequest request, BaseRequest baseRequest, String deviceInfoStr, Integer sourceType);
void recordRcData(HttpServletRequest req, BaseRequest baseRequest, String deviceIp);
int validateJigsawCode(HttpServletRequest request, BaseRequest req);
JigsawCodeModel getJigsawCode(HttpServletRequest request, Integer sourceType, String mobile);
}
...@@ -22,21 +22,21 @@ public interface DoctorService { ...@@ -22,21 +22,21 @@ public interface DoctorService {
* *
* @param doctor 待修改数据 * @param doctor 待修改数据
*/ */
void modifyDoctorInfo(Doctor doctor); void modifyDoctorInfo(Doctor doctor,Long doctorId);
/** /**
* 修改医生信息 * 修改医生信息
* *
* @param id 待修改数据 * @param id 待修改数据
*/ */
void deleteDoctorInfo(Integer id); void deleteDoctorInfo(Integer id,Long modifyId);
/** /**
* 客服系统新增医生用户 * 客服系统新增医生用户
* *
* @param doctor 新的医生数据 * @param doctor 新的医生数据
*/ */
Integer addDoctorInfo(Doctor doctor); Integer addDoctorInfo(Doctor doctor,Long doctorId);
/** /**
* doctor绑定微信 * doctor绑定微信
......
package com.pica.cloud.account.account.server.service; package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.LogLoginAes;
import com.pica.cloud.account.account.server.entity.LoginResult; import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.entity.PICAPDoctor; import com.pica.cloud.account.account.server.entity.PICAPDoctor;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.resp.UnifiedVerificationResp;
import com.pica.cloud.foundation.entity.PicaResponse;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import com.pica.cloud.account.account.server.req.OneClickLoginReq;
import com.pica.cloud.account.account.server.vo.OneClickLoginResultVo;
public interface LoginService { public interface LoginService {
/** /**
...@@ -39,9 +47,9 @@ public interface LoginService { ...@@ -39,9 +47,9 @@ public interface LoginService {
/** /**
* 解除绑定 * 解除绑定
* *
* @param acctId 账户id * @param doctorId 账户id
*/ */
void unbindWeChat(Integer acctId); void unbindWeChat(long doctorId);
/** /**
...@@ -49,7 +57,41 @@ public interface LoginService { ...@@ -49,7 +57,41 @@ public interface LoginService {
* *
* @param request 参数模型 * @param request 参数模型
*/ */
void bindWeChat(BaseRequest request); String bindWeChat(long doctorId, BaseRequest request);
PICAPDoctor queryDoctor(long doctorId); PICAPDoctor queryDoctor(long doctorId);
/**
* @Description 统一校验(传空则不会校验)
* @Author Chongwen.jiang
* @Date 2020/2/20 16:55
* @ModifyDate 2020/2/20 16:55
* @Params [request]
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
void preLoginValidate(BaseRequest request);
LoginResult oneClickLogin(OneClickLoginReq req);
/**
* @Description 苹果登录授权
* @Author Chongwen.jiang
* @Date 2020/2/24 10:10
* @ModifyDate 2020/2/24 10:10
* @Params [baseRequest]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
LoginResult loginByApple(BaseRequest baseRequest);
/**
* @Description 苹果登录绑定手机号
* @Author Chongwen.jiang
* @Date 2020/2/24 10:10
* @ModifyDate 2020/2/24 10:10
* @Params [request]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
LoginResult loginByAppleStep(BaseRequest request);
int insertLoginAesLog(LogLoginAes aes);
} }
...@@ -13,4 +13,14 @@ public interface ModifyMobileService { ...@@ -13,4 +13,14 @@ public interface ModifyMobileService {
Integer getAcctIdByMobile(String phone); Integer getAcctIdByMobile(String phone);
/**
* 记录手机号的变更记录
* @param acctId
* @param mobilePhone
* @param mobile
*/
void recodeMobileModify(Integer acctId, String mobilePhone, String mobile);
} }
package com.pica.cloud.account.account.server.service; package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
public interface PasswordService { public interface PasswordService {
...@@ -18,5 +20,7 @@ public interface PasswordService { ...@@ -18,5 +20,7 @@ public interface PasswordService {
* *
* @param request 参数模型 * @param request 参数模型
*/ */
void forgetPassword(BaseRequest request); void forgetPassword(BaseRequest request, AccountInfoEntity entity);
LoginResult findPwdLogin(BaseRequest request, AccountInfoEntity accountInfo);
} }
package com.pica.cloud.account.account.server.service; package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.LoginResult; import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.entity.QueryMobileEntity;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.common.req.OCINRequest; import com.pica.cloud.account.account.common.req.OCINRequest;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
...@@ -25,4 +26,6 @@ public interface RegisterService { ...@@ -25,4 +26,6 @@ public interface RegisterService {
void ocinRegister(OCINRequest request); void ocinRegister(OCINRequest request);
LoginResult register(BaseRequest baseRequest, QueryMobileEntity queryMobileEntity);
} }
...@@ -10,4 +10,7 @@ import java.util.Map; ...@@ -10,4 +10,7 @@ import java.util.Map;
public interface TokenService { public interface TokenService {
String getToken(Map<String, Object> map); String getToken(Map<String, Object> map);
void tokenContinueTime(String token, Integer sourceType, Integer seconds);
} }
...@@ -2,12 +2,14 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -2,12 +2,14 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.Account; import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.AccountMapper; import com.pica.cloud.account.account.server.mapper.AccountMapper;
import com.pica.cloud.account.account.server.service.AccountService; import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils; import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -18,10 +20,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -18,10 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author andong * @author andong
...@@ -39,7 +38,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -39,7 +38,7 @@ public class AccountServiceImpl implements AccountService {
@Autowired @Autowired
private AccountInfoDetailMapper accountInfoDetailMapper; private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient; private ICacheClient cacheClient;
@Value("${doubleWritingMode}") @Value("${doubleWritingMode}")
...@@ -91,8 +90,8 @@ public class AccountServiceImpl implements AccountService { ...@@ -91,8 +90,8 @@ public class AccountServiceImpl implements AccountService {
accountInfo.setRegTime(currentTime); accountInfo.setRegTime(currentTime);
accountInfo.setDeleteFlag(1); accountInfo.setDeleteFlag(1);
accountInfo.setSex(0); accountInfo.setSex(0);
accountInfo.setRegisterProduct(1); accountInfo.setRegisterProduct(AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode());
accountInfo.setRegisterSource(5); accountInfo.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_H5.getCode());
accountInfoDetailMapper.insertSelective(accountInfo); accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId(); Integer acctId = accountInfo.getId();
//doctor表,存入用户id //doctor表,存入用户id
...@@ -103,6 +102,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -103,6 +102,7 @@ public class AccountServiceImpl implements AccountService {
account.setModifyId(0L); account.setModifyId(0L);
account.setAcctId(acctId); account.setAcctId(acctId);
account.setCreatTime(currentTime); account.setCreatTime(currentTime);
account.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_H5.getCode());
account.setModifyTime(currentTime); account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime); account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime); account.setLastLoginTime(currentTime);
...@@ -124,6 +124,17 @@ public class AccountServiceImpl implements AccountService { ...@@ -124,6 +124,17 @@ public class AccountServiceImpl implements AccountService {
map.put("id", cacheClient.hget(key, "id")); map.put("id", cacheClient.hget(key, "id"));
map.put("hospital_id", cacheClient.hget(key, "hospital_id")); map.put("hospital_id", cacheClient.hget(key, "hospital_id"));
map.put("hospital", cacheClient.hget(key, "hospital")); map.put("hospital", cacheClient.hget(key, "hospital"));
map.put("name", cacheClient.hget(key, "name"));
// Map<String, String> result = cacheClient.hgetall(key);
// Iterator<Map.Entry<String, String>> iterator = result.entrySet().iterator();
// while(iterator.hasNext()){
// Map.Entry<String, String> next = iterator.next();
// String key1 = next.getKey();
// String value = next.getValue();
// logger.info("更新用户缓存信息已完成数量:{}", key1 + "------>"+value);
// }
// PicaUser picaUser = cacheClient.getToken("F64279B337EA4AE3965853A7CCFDF5A3", PicaUser.class);
// logger.info("更新用户缓存信息已完成数量:", picaUser.toString());
return map; return map;
} }
...@@ -160,21 +171,57 @@ public class AccountServiceImpl implements AccountService { ...@@ -160,21 +171,57 @@ public class AccountServiceImpl implements AccountService {
} }
} }
//更新缓存中hospital_id,hospital信息 //更新缓存中hospital_id,hospital信息
//成功返回0,失败返回1 //成功返回0,失败返回1
private int refresh(Map<String, Object> doctorMap) { private int refresh(Map<String, Object> doctorMap) {
String doctorId = doctorMap.get("id").toString(); String doctorId = doctorMap.get("id").toString();
/*
String hospitalId = doctorMap.get("hospital_id") == null ? StringUtils.EMPTY : doctorMap.get("hospital_id").toString(); String hospitalId = doctorMap.get("hospital_id") == null ? StringUtils.EMPTY : doctorMap.get("hospital_id").toString();
String hospital = doctorMap.get("hospital") == null ? StringUtils.EMPTY : doctorMap.get("hospital").toString(); String hospital = doctorMap.get("hospital") == null ? StringUtils.EMPTY : doctorMap.get("hospital").toString();
String mobile = doctorMap.get("mobile_phone") == null ? StringUtils.EMPTY : doctorMap.get("mobile_phone").toString();
String status = doctorMap.get("status") == null ? StringUtils.EMPTY : doctorMap.get("status").toString();
String avatar_image_url = doctorMap.get("avatar_image_url") == null ? StringUtils.EMPTY : doctorMap.get("avatar_image_url").toString();
String email = doctorMap.get("email") == null ? StringUtils.EMPTY : doctorMap.get("email").toString();
String province = doctorMap.get("province") == null ? StringUtils.EMPTY : doctorMap.get("province").toString();
String province_name = doctorMap.get("province") == null ? StringUtils.EMPTY : doctorMap.get("province_name").toString();
String city = doctorMap.get("city") == null ? StringUtils.EMPTY : doctorMap.get("city").toString();
String city_name = doctorMap.get("city_name") == null ? StringUtils.EMPTY : doctorMap.get("city_name").toString();
String county = doctorMap.get("county") == null ? StringUtils.EMPTY : doctorMap.get("county").toString();
String county_name = doctorMap.get("county_name") == null ? StringUtils.EMPTY : doctorMap.get("county_name").toString();
String town = doctorMap.get("town") == null ? StringUtils.EMPTY : doctorMap.get("town").toString();
String town_name = doctorMap.get("town_name") == null ? StringUtils.EMPTY : doctorMap.get("town_name").toString();
String title = doctorMap.get("title") == null ? StringUtils.EMPTY : doctorMap.get("title").toString();
String title_id = doctorMap.get("title_id") == null ? StringUtils.EMPTY : doctorMap.get("title_id").toString();
*/
String name = doctorMap.get("name") == null ? StringUtils.EMPTY : doctorMap.get("name").toString();
String key = KEY_PREFIX + doctorId; String key = KEY_PREFIX + doctorId;
try { try {
String cacheId = cacheClient.hget(key, "id"); String cacheId = cacheClient.hget(key, "id");
if (StringUtils.isBlank(cacheId)) { if (StringUtils.isBlank(cacheId)) {
return 0; //未找到用户缓存数据,不做更新 return 0; //未找到用户缓存数据,不做更新
} }
/**
cacheClient.hset(key, "hospital_id", StringUtils.isEmpty(hospitalId) ? "0" : hospitalId); cacheClient.hset(key, "hospital_id", StringUtils.isEmpty(hospitalId) ? "0" : hospitalId);
cacheClient.hset(key, "hospital", hospital); cacheClient.hset(key, "hospital", hospital);
cacheClient.hset(key, "province_name", province_name);
cacheClient.hset(key, "city_name", city_name);
cacheClient.hset(key, "county_name", county_name);
cacheClient.hset(key, "town_name", town_name);
cacheClient.hset(key, "province_id", province);
cacheClient.hset(key, "city_id", city);
cacheClient.hset(key, "county_id", county);
cacheClient.hset(key, "town_id", town);
cacheClient.hset(key, "mobile", mobile);
cacheClient.hset(key, "status", status);
cacheClient.hset(key, "avatar_image_url", avatar_image_url);
cacheClient.hset(key, "email", email);
cacheClient.hset(key, "title_id", title_id);
cacheClient.hset(key, "title", title);
*/
cacheClient.hset(key, "name", name);
return 0; return 0;
} catch (Exception ex) { } catch (Exception ex) {
return 1; return 1;
......
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.RcRepTypeEnum;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.model.JigsawCodeModel;
import com.pica.cloud.account.account.server.service.AuthCodeService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.IPUtil;
import com.pica.cloud.account.account.server.util.PICAPDeviceInfo;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.StringUtil;
import com.pica.cloud.proof.client.SliderImageService;
import com.pica.cloud.proof.contract.request.SliderImageRequest;
import com.pica.cloud.riskcontrol.riskcontrol.client.CheckCodeClient;
import com.pica.cloud.riskcontrol.riskcontrol.common.req.CheckcodeRiskReq;
import com.pica.cloud.riskcontrol.riskcontrol.common.resp.CheckcodeRiskResp;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* @ClassName AuthCodeServiceImpl
* @Description
* @Author Chongwen.jiang
* @Date 2020/3/5 17:01
* @ModifyDate 2020/3/5 17:01
* @Version 1.0
*/
@Service
public class AuthCodeServiceImpl implements AuthCodeService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private CheckCodeClient rcClient;
@Autowired
private ICacheClient cacheClient;
@Autowired
@Qualifier("accountThreadPool")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Autowired
private SliderImageService sliderImageService;
/**
* @Description 调用风控接口
* @Author Chongwen.jiang
* @Date 2020/2/21 17:12
* @ModifyDate 2020/2/21 17:12
* @Params [mobile]
* @Return com.pica.cloud.account.account.server.resp.UnifiedVerificationResp
*/
@Override
public int rcValidate(HttpServletRequest request, BaseRequest baseRequest, String deviceInfoStr, Integer sourceType) {
int needCheck = 1;
// 调用风控接口
PicaResponse picaResponse = null;
try {
PICAPDeviceInfo deviceInfo = JSON.parseObject(deviceInfoStr, PICAPDeviceInfo.class);
String publicIp = IPUtil.getIpAdrress(request);
String deviceToken = baseRequest.getDevice_token();
CheckcodeRiskReq rcReq = new CheckcodeRiskReq();
if (StringUtils.isNotEmpty(baseRequest.getMobile())) {
rcReq.setMobile(baseRequest.getMobile());
}
if (StringUtils.isNotEmpty(publicIp)) {
rcReq.setIp(publicIp);
}
if (StringUtils.isNotEmpty(deviceInfo.getDevice_ip())) {
rcReq.setDeviceIp(deviceInfo.getDevice_ip());
}
if (StringUtils.isNotEmpty(deviceToken)) {
rcReq.setDeviceId(deviceToken);
}
rcReq.setSourceType(sourceType);
logger.info("rc-checkcodeRisk-req:{}", rcReq.toString());
picaResponse = rcClient.checkcodeRisk(rcReq);
logger.info("rc-checkcodeRisk-{}-resp:{}", baseRequest.getMobile(), JSON.toJSONString(picaResponse));
} catch (JSONException e) {
logger.error("rc-checkcodeRisk-JSONException", e);
} catch (Exception e) {
logger.error("rc-checkcodeRisk-invoke-exception", e);
}
if (picaResponse != null &&
PicaResultCode.SUCCESS.code().equals(picaResponse.getCode())) {
Object data = picaResponse.getData();
if (Objects.nonNull(data)) {
CheckcodeRiskResp respData = JSON.parseObject(
JSON.toJSONString(data), CheckcodeRiskResp.class);
if (StringUtils.isNotEmpty(respData.getProcessCode())) {
String processCode = respData.getProcessCode();
if (StringUtils.isNotEmpty(processCode)) {
// 请求返回正常
if (processCode.equals(RcRepTypeEnum.RC_SEND_FAIL.getCode())) {
throw new PicaWarnException(AccountExceptionEnum.PICA_RC_SEND_FAIL.getCode(),
AccountExceptionEnum.PICA_RC_SEND_FAIL.getMessage());
} else if (processCode.equals(RcRepTypeEnum.RC_TRIGGER.getCode())) {
if(SourceTypeEnum.H5.getCode().equals(sourceType)) {
// h5端需要触发拼图验证,后台去获取拼图数据返给前端
} else {
throw new PicaWarnException(AccountExceptionEnum.PICA_RC_TRIGGER.getCode(),
AccountExceptionEnum.PICA_RC_TRIGGER.getMessage());
}
} else if (processCode.equals(RcRepTypeEnum.RC_BLACKLIST.getCode())) {
throw new PicaWarnException(AccountExceptionEnum.PICA_RC_BLACKLIST.getCode(),
AccountExceptionEnum.PICA_RC_BLACKLIST.getMessage());
} else if (processCode.equals(RcRepTypeEnum.RC_DAY_LIMIT.getCode())) {
throw new PicaWarnException(AccountExceptionEnum.PICA_RC_DAY_LIMIT.getCode(),
AccountExceptionEnum.PICA_RC_DAY_LIMIT.getMessage());
} else if (processCode.equals(RcRepTypeEnum.RC_60_SECOND_LIMIT.getCode())) {
// 获取剩余秒数
String authCodeKey = Constants.AUTH_CODE_PREFIX + baseRequest.getFlag() + "-" + AESUtil.encryptV0(baseRequest.getMobile()) + "-secure";
Long time = cacheClient.get(authCodeKey, Long.class);
if (Objects.nonNull(time)) {
int remainTime = 59 - (int) (System.currentTimeMillis() - time) / 1000;
if (remainTime > 0) {
throw new PicaWarnException(AccountExceptionEnum.PICA_RC_60_SECOND_LIMIT.getCode(),
AccountExceptionEnum.PICA_RC_60_SECOND_LIMIT.getMessage().replace("{remainTime}", String.valueOf(remainTime)));
} else {
needCheck = 0;
}
} else {
// 刚好60秒缓存时间过去了,也允许发送短信验证码
needCheck = 0;
}
} else if (RcRepTypeEnum.RC_ALLOW_SEND_MSG.getCode().equals(processCode)) {
// processCode equals "1" (允许发送短信验证码)
needCheck = -1;
} else {
throw new PicaWarnException(AccountExceptionEnum.PICA_RC_BUSINESS_ERROR.getCode(),
AccountExceptionEnum.PICA_RC_BUSINESS_ERROR.getMessage());
}
}
}
}
}
return needCheck;
}
public static void main(String[] args) {
CheckcodeRiskReq rcReq = new CheckcodeRiskReq();
rcReq.setMobile("1232");
rcReq.setIp("134.192.123.23");
rcReq.setDeviceIp(null);
rcReq.setDeviceId(null);
rcReq.setSourceType(4);
System.out.println("rc-checkcodeRisk-req2:{}"+rcReq.toString());
System.out.println(rcReq.getDeviceId());
System.out.println("rc-checkcodeRisk-req:{}"+JSON.toJSONString(rcReq));
}
/**
* @Description 记录风控数据
* @Author Chongwen.jiang
* @Date 2020/2/27 16:53
* @ModifyDate 2020/2/27 16:53
* @Params [req, request]
* @Return void
*/
@Override
public void recordRcData(HttpServletRequest request, BaseRequest baseRequest, String deviceIp) {
CheckcodeRiskReq rec = new CheckcodeRiskReq();
rec.setMobile(baseRequest.getMobile());
rec.setIp(IPUtil.getIpAdrress(request));
rec.setDeviceIp(deviceIp);
rec.setDeviceId(baseRequest.getDevice_token());
rec.setSourceType(baseRequest.getSourceType());
try {
threadPoolTaskExecutor.execute(() -> {
logger.info("recordRcData-execute-{}", JSON.toJSONString(rec));
PicaResponse resp = rcClient.logSend(rec);
logger.info("recordRcData-resp-{}", JSON.toJSONString(resp));
});
} catch (Exception e) {
logger.error("recordRcData invoke error", e.getMessage());
}
}
/**
* @Description 拼图验证
* @Author Chongwen.jiang
* @Date 2020/3/23 15:04
* @ModifyDate 2020/3/23 15:04
* @Params [capCode, xPos]
* @Return void
*/
@Override
public int validateJigsawCode(HttpServletRequest request, BaseRequest paramReq) {
if(!SourceTypeEnum.H5.getCode().equals(paramReq.getSourceType())) {
logger.error("validateJigsawCode-h5 sourceType error");
throw new PicaWarnException(PicaResultCode.PARAM_IS_INVALID.code(), PicaResultCode.PARAM_IS_INVALID.message());
}
// 1、调用风控服务,是否需要触发拼图验证
/*int needCheck = this.rcValidate(request, rcReq, "{}", paramReq.getSourceType());
if (needCheck <= 0) {
// 不需要拼图验证,直接去发短信
return needCheck;
}*/
BaseRequest rcReq = new BaseRequest();
rcReq.setMobile(paramReq.getMobile());
String ip = IPUtil.getIpAdrress(request);
String rcRecordedKey = Constants.RC_RECORDED_DATA_KEY.replace("{mobile}", paramReq.getMobile())
.replace("{ip}", ip);
logger.info("validateJigsawCode-rcRecordedKey-ip:{}, mobile:{}, key:{}", ip, paramReq.getMobile(), rcRecordedKey);
int needCheck = 1;
Long num = cacheClient.decr(rcRecordedKey);
if (num != null && num.intValue() == 99) {
// 不需要拼图验证,直接去发短信, 不用记录风控数据(在调用获取拼图码时已经校验过,记录了数据)
return -1;
}
String capCode = paramReq.getCapCode();
int xPos = paramReq.getxPos() == null ? 0 : paramReq.getxPos();
if (StringUtils.isEmpty(capCode) || xPos <= 0) {
String key = Constants.JIGSAW_CODE_KEY.replace("{mobile}", paramReq.getMobile());
Long count = cacheClient.decr(key);
if (count != null && count.intValue() == 99) {
// a、不需要拼图验证,可直接去发送短信
// b、本应需要拼图验证,但是在调用获取拼图数据接口时报错了,也直接去发送短信
return needCheck;
}
}
// 2、调用拼图验证接口
PicaResponse resp = null;
try {
SliderImageRequest req = new SliderImageRequest();
req.setCapcode(capCode);
req.setXpos(xPos);
req.setClientBackImageWidth(paramReq.getImageW() == null ? 1 : paramReq.getImageW());
resp = sliderImageService.checkcapcode(req);
logger.info("validateJigsawCode-resp:{}", JSON.toJSONString(resp));
} catch (Exception e) {
logger.error("validateJigsawCode-sliderImageService.checkcapcode invoke exception", e.getMessage());
}
if (Objects.nonNull(resp)) {
if (!PicaResultCode.SUCCESS.code().equals(resp.getCode())) {
logger.error("validateJigsawCode-code exception");
}
JSONObject respData = JSON.parseObject(JSON.toJSONString(resp.getData()), JSONObject.class);
if (Objects.nonNull(respData)) {
Object codeObj = respData.get("code");
if (Objects.nonNull(codeObj)) {
String code = String.valueOf(codeObj);
if (StringUtil.equals(code, "2") ||
StringUtil.equals(code, "3")) {
// 3超期 2验证失败 1成功
throw new PicaWarnException(AccountExceptionEnum.PICA_CAP_CODE_ERROR.getCode(),
AccountExceptionEnum.PICA_CAP_CODE_ERROR.getMessage());
}
}
}
}
return needCheck;
}
/**
* @Description 获取拼图码校验
* @Author Chongwen.jiang
* @Date 2020/3/23 15:29
* @ModifyDate 2020/3/23 15:29
* @Params [mobile]
* @Return com.pica.cloud.account.account.server.model.JigsawCodeModel
*/
@Override
public JigsawCodeModel getJigsawCode(HttpServletRequest request, Integer sourceType, String mobile) {
if(!SourceTypeEnum.H5.getCode().equals(sourceType)) {
logger.error("getJigsawCode-h5 sourceType error");
throw new PicaWarnException(PicaResultCode.PARAM_IS_INVALID.code(), PicaResultCode.PARAM_IS_INVALID.message());
}
AccountUtils.checkMobilePhone(mobile);
// 调用风控服务,是否需要触发拼图验证
BaseRequest req = new BaseRequest();
req.setMobile(mobile);
int needCheck = this.rcValidate(request, req, "{}", sourceType);
// 调用proof服务获取拼图数据
JigsawCodeModel data = new JigsawCodeModel();
PicaResponse picResp = null;
String key = Constants.JIGSAW_CODE_KEY.replace("{mobile}", mobile);
if (needCheck > 0) {
try {
picResp = sliderImageService.getPic();
logger.info("getJigsawCode-getPic-code:{}", picResp.getCode());
} catch (Exception e) {
logger.error("getJigsawCode-sliderImageService.getPic invoke exception", e.getMessage());
// 记录该手机号调用接口获取拼图时接口报错
cacheClient.set(key, 100, Constants.JIGSAW_CODE_EXPIRE_SECONDS);
}
if (Objects.nonNull(picResp)) {
if (!PicaResultCode.SUCCESS.code().equals(picResp.getCode())) {
logger.info("getJigsawCode-getPic-code exception");
cacheClient.set(key, 100, Constants.JIGSAW_CODE_EXPIRE_SECONDS);
}
JSONObject respData = JSON.parseObject(JSON.toJSONString(picResp.getData()), JSONObject.class);
if (Objects.nonNull(respData)) {
logger.info("getJigsawCode-capcode:{}, yHeight:{}",
respData.getString("capcode"),
respData.getString("yHeight"));
data.setCapCode(respData.getString("capcode"));
data.setBackImage(respData.getString("backImage"));
data.setSlidingImage(respData.getString("slidingImage"));
data.setyHeight(respData.getInteger("yHeight"));
}
}
} else {
logger.info("getJigsawCode-don't need jigsaw code");
cacheClient.set(key, 100, Constants.JIGSAW_CODE_EXPIRE_SECONDS);
if (needCheck == -1) {
// 不需要拼图验证, 风控允许直接发送验证码记录缓存
String ip = IPUtil.getIpAdrress(request);
String key2 = Constants.RC_RECORDED_DATA_KEY.replace("{mobile}", mobile)
.replace("{ip}", ip);
logger.info("getJigsawCode-rcRecordedKey- rc recorded data-ip:{},mobile:{}, rcRecordedKey:{}", ip, mobile, key2);
cacheClient.set(key2, 100, Constants.JIGSAW_CODE_EXPIRE_SECONDS);
}
}
return data;
}
}
...@@ -3,6 +3,7 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -3,6 +3,7 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.Doctor; import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
/** /**
* Created on 2019/9/11 11:02 * Created on 2019/9/11 11:02
...@@ -38,8 +40,9 @@ public class DoctorServiceImpl implements DoctorService { ...@@ -38,8 +40,9 @@ public class DoctorServiceImpl implements DoctorService {
return doctorMapper.selectByPrimaryKey(id); return doctorMapper.selectByPrimaryKey(id);
} }
@Transactional
@Override @Override
public void modifyDoctorInfo(Doctor doctor) { public void modifyDoctorInfo(Doctor doctor,Long doctorId) {
Integer id = doctor.getId(); Integer id = doctor.getId();
if (id == null) { if (id == null) {
throw new AccountException(AccountExceptionEnum.PICA_PARAMS_ERROR); throw new AccountException(AccountExceptionEnum.PICA_PARAMS_ERROR);
...@@ -55,17 +58,30 @@ public class DoctorServiceImpl implements DoctorService { ...@@ -55,17 +58,30 @@ public class DoctorServiceImpl implements DoctorService {
doctor.setMobilePhone(AESUtil.encryptV0(mobilePhone)); doctor.setMobilePhone(AESUtil.encryptV0(mobilePhone));
doctor.setModifyTime(new Date()); doctor.setModifyTime(new Date());
doctorMapper.updateByPrimaryKeySelective(doctor); doctorMapper.updateByPrimaryKeySelective(doctor);
Integer acctId = entity.getAcctId();
AccountInfoEntity accountInfoEntity = new AccountInfoEntity();
accountInfoEntity.setMobilePhone(AESUtil.encryptV0(mobilePhone));
accountInfoEntity.setId(acctId);
accountInfoEntity.setModifiedId(doctorId.intValue());
accountInfoEntity.setModifiedTime(new Date());
accountInfoDetailMapper.updateByPrimaryKeySelective(accountInfoEntity);
} }
@Transactional() @Transactional
@Override @Override
public void deleteDoctorInfo(Integer id) { public void deleteDoctorInfo(Integer id,Long modifyId) {
//p_doctor表修改记录状态 //p_doctor表修改记录状态
Doctor doctor = doctorMapper.selectByPrimaryKey(id); Doctor doctor = doctorMapper.selectByPrimaryKey(id);
if (doctor != null) { if (doctor != null) {
Integer acctId = doctor.getAcctId(); Integer acctId = doctor.getAcctId();
doctorMapper.updateDeleteByPrimaryKey(id); HashMap<String, Long> map = new HashMap<>();
accountInfoDetailMapper.updateDeleteByPrimaryKey(acctId); map.put("id",id.longValue());
map.put("modifyId",modifyId);
doctorMapper.updateDeleteByPrimaryKey(map);
HashMap<String, Long> acctMap = new HashMap<>();
acctMap.put("modifyId",modifyId);
acctMap.put("acctId",acctId.longValue());
accountInfoDetailMapper.updateDeleteByPrimaryKey(acctMap);
} else { } else {
throw new AccountException(AccountExceptionEnum.PICA_NOT_REGISTER); throw new AccountException(AccountExceptionEnum.PICA_NOT_REGISTER);
} }
...@@ -82,7 +98,7 @@ public class DoctorServiceImpl implements DoctorService { ...@@ -82,7 +98,7 @@ public class DoctorServiceImpl implements DoctorService {
*/ */
@Override @Override
@Transactional @Transactional
public Integer addDoctorInfo(Doctor doctor) { public Integer addDoctorInfo(Doctor doctor,Long doctorId) {
String mobilePhone = doctor.getMobilePhone(); String mobilePhone = doctor.getMobilePhone();
String mobileEncrypt = AESUtil.encryptV0(mobilePhone); String mobileEncrypt = AESUtil.encryptV0(mobilePhone);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
...@@ -96,11 +112,12 @@ public class DoctorServiceImpl implements DoctorService { ...@@ -96,11 +112,12 @@ public class DoctorServiceImpl implements DoctorService {
entity.setPassword(password); entity.setPassword(password);
entity.setCreatedTime(currentTime); entity.setCreatedTime(currentTime);
entity.setModifiedTime(currentTime); entity.setModifiedTime(currentTime);
entity.setModifiedId(0); entity.setModifiedId(doctorId.intValue());
entity.setRegisterProduct(1); entity.setRegisterProduct(AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode());
entity.setRegTime(currentTime); entity.setRegTime(currentTime);
entity.setRegisterSource(3); //客服系统新增医生
entity.setCreatedId(0); entity.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_ADMIN.getCode());
entity.setCreatedId(doctorId.intValue());
entity.setDeleteFlag(1); entity.setDeleteFlag(1);
entity.setSex(doctor.getSex()); entity.setSex(doctor.getSex());
entity.setName(doctor.getName()); entity.setName(doctor.getName());
...@@ -110,10 +127,11 @@ public class DoctorServiceImpl implements DoctorService { ...@@ -110,10 +127,11 @@ public class DoctorServiceImpl implements DoctorService {
accountInfoDetailMapper.insertSelective(entity); accountInfoDetailMapper.insertSelective(entity);
doctor.setAcctId(entity.getId()); doctor.setAcctId(entity.getId());
doctor.setMobilePhone(mobileEncrypt); doctor.setMobilePhone(mobileEncrypt);
doctor.setModifyId(0); doctor.setModifyId(doctorId.intValue());
doctor.setCreatId(0); doctor.setCreatId(doctorId.intValue());
doctor.setCreatTime(currentTime); doctor.setCreatTime(currentTime);
doctor.setModifyTime(new Date()); doctor.setModifyTime(new Date());
doctor.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_ADMIN.getCode());
doctor.setDeleteFlag(1); doctor.setDeleteFlag(1);
doctorMapper.insertSelective(doctor); doctorMapper.insertSelective(doctor);
return doctor.getId(); return doctor.getId();
......
package com.pica.cloud.account.account.server.service.impl; package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.auth0.jwk.Jwk;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.*; import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
import com.pica.cloud.account.account.server.log.AccountLogEntityUtils; import com.pica.cloud.account.account.server.log.AccountLogEntityUtils;
import com.pica.cloud.account.account.server.log.AccountLogUtils; import com.pica.cloud.account.account.server.log.AccountLogUtils;
import com.pica.cloud.account.account.server.mapper.*; import com.pica.cloud.account.account.server.mapper.*;
import com.pica.cloud.account.account.server.model.OneClickProcessor;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.OneClickLoginReq;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.service.LoginService; import com.pica.cloud.account.account.server.service.LoginService;
import com.pica.cloud.account.account.server.service.RegisterService; import com.pica.cloud.account.account.server.service.RegisterService;
...@@ -15,16 +23,26 @@ import com.pica.cloud.account.account.server.util.AESUtil; ...@@ -15,16 +23,26 @@ import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils; import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.TokenUtils; import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.account.account.server.util.WeChatUtils; import com.pica.cloud.account.account.server.util.WeChatUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import com.pica.cloud.patient.smartcontract.common.utils.HttpClientCloudUtils;
import io.jsonwebtoken.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.security.PublicKey;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -65,9 +83,17 @@ public class LoginServiceImpl implements LoginService { ...@@ -65,9 +83,17 @@ public class LoginServiceImpl implements LoginService {
private DoctorService doctorService; private DoctorService doctorService;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
@Autowired
private AccountAppleInfoMapper accountAppleInfoMapper;
@Autowired
private OneClickProcessor oneClickProcessor;
@Autowired
private LogLoginAesMapper logLoginAesMapper;
@Value("${doubleWritingMode}") @Value("${doubleWritingMode}")
private boolean doubleWritingMode; private boolean doubleWritingMode;
...@@ -77,9 +103,14 @@ public class LoginServiceImpl implements LoginService { ...@@ -77,9 +103,14 @@ public class LoginServiceImpl implements LoginService {
private String appSecret; private String appSecret;
@Value("${weChatURL}") @Value("${weChatURL}")
private String weChatURL; private String weChatURL;
@Value("${weChatAppIDH5}")
private String appIdH5;
@Value("${weChatAppSecretH5}")
private String appSecretH5;
private static final String DEFAULT_DOCTOR_PICTURE_URL = "/File/doctor_default.png"; private static final String DEFAULT_DOCTOR_PICTURE_URL = "/File/doctor_default.png";
public static Map<String, String> PIC_TYPE_MAP = new HashMap(); public static Map<String, String> PIC_TYPE_MAP = new HashMap();
static { static {
PIC_TYPE_MAP.put("jpg", "FFD8FF"); PIC_TYPE_MAP.put("jpg", "FFD8FF");
PIC_TYPE_MAP.put("jpeg", "FFD8FF"); PIC_TYPE_MAP.put("jpeg", "FFD8FF");
...@@ -95,17 +126,110 @@ public class LoginServiceImpl implements LoginService { ...@@ -95,17 +126,110 @@ public class LoginServiceImpl implements LoginService {
@Override @Override
public LoginResult login(BaseRequest request) { public LoginResult login(BaseRequest request) {
String mobile = request.getMobile(); String mobile = request.getMobile();
Integer sourceType = request.getSourceType();
String encrypt = AESUtil.encryptV0(mobile); String encrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt);
logger.info("bizType:{}, account not null:{}", request.getBizType(), accountInfoEntity != null);
if (accountInfoEntity != null) { if (accountInfoEntity != null) {
String oldPwd = accountInfoEntity.getPassword(); String oldPwd = accountInfoEntity.getPassword();
String password = request.getPassword(); String password = request.getPassword();
if (null != request.getBizType() &&
request.getBizType().equals(1)) {
// 新版-未设置密码
if (StringUtils.isEmpty(oldPwd)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage());
} else {
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(),
AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage()
.replace("{mobile}", mobile));
}
} else {
// 判断账号是否已锁
logger.info("new login failure:" + mobile);
String lockKey = Constants.ACCOUNT_LOCK_KEY.replace("{mobile}", mobile);
if (redisClient.exists(lockKey)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage());
} else {
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
}
}
if (password.equals(oldPwd)) {
return pwdLoginCorrect(request, mobile, encrypt, accountInfoEntity);
} else {
String errorKey = Constants.PWD_ERROR_NUM_KEY.replace("{mobile}", mobile);
if (redisClient.exists(errorKey)) {
int errorCount = Integer.parseInt(redisClient.get(errorKey));
errorCount = errorCount + 1;
redisClient.set(errorKey, errorCount, Constants.PWD_ERROR_NUM_SECONDS);
if (errorCount <= 4) {
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
} else {
// 设置账号锁定24h
redisClient.set(lockKey, mobile, Constants.PWD_ERROR_NUM_SECONDS);
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage());
} else {
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
}
}
} else {
redisClient.set(errorKey, 1, Constants.PWD_ERROR_NUM_SECONDS);
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
}
}
}
} else {
// 旧版本
if (password.equals(oldPwd)) { if (password.equals(oldPwd)) {
return pwdLoginCorrect(request, mobile, encrypt, accountInfoEntity);
} else {
logger.info("login failure:" + mobile);
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_ERROR.getCode(), AccountExceptionEnum.PICA_PASSWORD_ERROR.getMessage());
}
}
} else {
if (null != request.getBizType() &&
request.getBizType().equals(1)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage());
} else {
// 新版-未注册
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(),
AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage()
.replace("{mobile}", mobile));
}
} else {
throw new PicaException(AccountExceptionEnum.PICA_NOT_REGISTER.getCode(), AccountExceptionEnum.PICA_NOT_REGISTER.getMessage());
}
}
}
/**
* @Description 密码登录-密码正确逻辑
* @Author Chongwen.jiang
* @Date 2020/2/21 19:13
* @ModifyDate 2020/2/21 19:13
* @Params [request, mobile, encrypt, accountInfoEntity]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
private LoginResult pwdLoginCorrect(BaseRequest request, String mobile, String encrypt, AccountInfoEntity accountInfoEntity) {
Date currentTime = new Date(); Date currentTime = new Date();
Integer acctId = accountInfoEntity.getId(); Integer acctId = accountInfoEntity.getId();
int productType = request.getProductType(); int productType = request.getProductType();
int sourceType = request.getSourceType(); int sourceType = request.getSourceType();
Doctor doctorInfo=doctorInfoMapper.getDoctorInfoByMobile(encrypt); Doctor doctorInfo = doctorInfoMapper.getDoctorInfoByMobile(encrypt);
Integer userId = 0; Integer userId = 0;
if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) { if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
userId = doctorInfo.getId(); userId = doctorInfo.getId();
...@@ -123,42 +247,53 @@ public class LoginServiceImpl implements LoginService { ...@@ -123,42 +247,53 @@ public class LoginServiceImpl implements LoginService {
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setToken(newToken); result.setToken(newToken);
result.setUserId(userId.longValue()); result.setUserId(userId.longValue());
result.setMobile(mobile);
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) { if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
result.setEntireFlag(doctorInfo.getEntireFlag()); result.setEntireFlag(doctorInfo.getEntireFlag());
}
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, sourceType, LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, sourceType,
AccountTypeEnum.LOGIN_PWD.getCode(), request.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOGIN_PWD.getCode(), request.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode()); AccountTypeEnum.LOG_TYPE_LOGIN.getCode(), newToken, 1, request.getUserTokenTourist());
picaLogUtils.info(entity); picaLogUtils.info(entity);
return result; // 密码登录成功以后,清除错误次数记录
} else { String pwdErrorNum = Constants.PWD_ERROR_NUM_KEY.replace("{mobile}", mobile);
logger.info("login failure:" + mobile); if (redisClient.exists(pwdErrorNum)) {
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_ERROR.getCode(), AccountExceptionEnum.PICA_PASSWORD_ERROR.getMessage()); redisClient.del(pwdErrorNum);
} }
} else {
throw new PicaException(AccountExceptionEnum.PICA_NOT_REGISTER.getCode(), AccountExceptionEnum.PICA_NOT_REGISTER.getMessage());
} }
return result;
} }
@Override @Override
public LoginResult loginAndRegister(BaseRequest baseRequest) { public LoginResult loginAndRegister(BaseRequest baseRequest) {
String mobile = baseRequest.getMobile(); String mobile = baseRequest.getMobile();
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile)); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
logger.info("loginAndRegister-accountInfoEntity is null {}, clientIp:{}", (accountInfoEntity == null), baseRequest.getLoginIp());
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
//说明是注册功能
accountUtils.checkRegisterMobilePhoneAndAuthCode(baseRequest.getMobile(), baseRequest.getFlag() + "", baseRequest.getAuthCode());
return registerService.register(baseRequest); return registerService.register(baseRequest);
} else { } else {
//登录功能
accountUtils.checkMobilePhoneAndAuthCode(baseRequest.getMobile(), AccountTypeEnum.SYSCODE_TYPE_LOGIN.getCode() + "", baseRequest.getAuthCode());
return processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_CODE.getCode()); return processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_CODE.getCode());
} }
} }
/** /**
* 登录逻辑处理
* 登录逻辑处理 * 登录逻辑处理
* *
* @param baseRequest * @param baseRequest
*/ */
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType) { private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType) {
return processLogin(baseRequest, acctId, loginType, null);
}
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType, QueryMobileEntity queryMobileEntity) {
Date currentTime = new Date(); Date currentTime = new Date();
Long userId = accountUtils.getUserIdByAcctId(baseRequest.getProductType(), acctId); Long userId = accountUtils.getUserIdByAcctId(baseRequest.getProductType(), acctId);
Account account = new Account(); Account account = new Account();
...@@ -171,6 +306,8 @@ public class LoginServiceImpl implements LoginService { ...@@ -171,6 +306,8 @@ public class LoginServiceImpl implements LoginService {
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setToken(newToken); result.setToken(newToken);
result.setUserId(userId); result.setUserId(userId);
result.setMobile(baseRequest.getMobile());
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
//是否完善过个人信息(云鹊医app才需要) //是否完善过个人信息(云鹊医app才需要)
if (baseRequest.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) { if (baseRequest.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue()); Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue());
...@@ -178,16 +315,30 @@ public class LoginServiceImpl implements LoginService { ...@@ -178,16 +315,30 @@ public class LoginServiceImpl implements LoginService {
} }
//记录登录日志 //记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, baseRequest.getProductType(), baseRequest.getSourceType(), LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, baseRequest.getProductType(), baseRequest.getSourceType(),
loginType, baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode()); loginType, baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,baseRequest.getUserTokenTourist());
; if (queryMobileEntity != null) {
entity.setQueryMobileEntity(queryMobileEntity);
}
picaLogUtils.info(entity); picaLogUtils.info(entity);
return result; return result;
} }
@Override @Override
@Transactional
public LoginResult loginByWeChat(BaseRequest request) { public LoginResult loginByWeChat(BaseRequest request) {
WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode()); WeChatEntity weChatEntity = null;
//todo:微信登录获取个人信息 if (null != request.getBizType() &&
request.getBizType().equals(1)) {
// h5微信登录 TODO 下次单独拆分出去一个新接口
weChatEntity = WeChatUtils.getAuthorizationInfo(appIdH5, appSecretH5, request.getWeChatCode());
} else {
// 原生微信登录
weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
}
if (weChatEntity == null || StringUtils.isEmpty(weChatEntity.getOpenid()) || StringUtils.isEmpty(weChatEntity.getAccess_token())) {
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getCode(), AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getMessage());
}
// 微信登录获取个人信息
Map map = new HashMap(); Map map = new HashMap();
map.put("access_token", weChatEntity.getAccess_token()); map.put("access_token", weChatEntity.getAccess_token());
map.put("openid", weChatEntity.getOpenid()); map.put("openid", weChatEntity.getOpenid());
...@@ -195,8 +346,8 @@ public class LoginServiceImpl implements LoginService { ...@@ -195,8 +346,8 @@ public class LoginServiceImpl implements LoginService {
WeChatUserInfoEntity weChatUserInfoEntity = WeChatUtils.mergeWechatUserInfo(weChatUserInfo, weChatEntity.getOpenid()); WeChatUserInfoEntity weChatUserInfoEntity = WeChatUtils.mergeWechatUserInfo(weChatUserInfo, weChatEntity.getOpenid());
String unionId = weChatUserInfoEntity.getUnionid(); String unionId = weChatUserInfoEntity.getUnionid();
AccountUnionEntity accountUnionEntity = accountUnionMapper.selectByUnionId(unionId); AccountUnionEntity accountUnionEntity = accountUnionMapper.selectByUnionId(unionId);
if (accountUnionEntity != null) {
//是否绑定逻辑的判断 //是否绑定逻辑的判断
if (accountUnionEntity != null) {
Long acctId = accountUnionEntity.getAcctId(); Long acctId = accountUnionEntity.getAcctId();
Long userId = accountUtils.getUserIdByAcctId(request.getProductType(), acctId.intValue()); Long userId = accountUtils.getUserIdByAcctId(request.getProductType(), acctId.intValue());
Account account = new Account(); Account account = new Account();
...@@ -210,16 +361,34 @@ public class LoginServiceImpl implements LoginService { ...@@ -210,16 +361,34 @@ public class LoginServiceImpl implements LoginService {
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setToken(newToken); result.setToken(newToken);
result.setUserId(userId); result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode()+""); result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (request.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
result.setEntireFlag(doctor.getEntire_flag());
result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(
Integer.valueOf(String.valueOf(acctId)),
request.getProductType(), request.getSourceType(),
AccountTypeEnum.LOGIN_WE_CHAT.getCode(),
request.getLoginIp(),
AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,request.getUserTokenTourist());
picaLogUtils.info(entity);
return result; return result;
} else { } else {
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId); AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
//如果微信信息表数据不存在,就把用户信息存储到微信信息表中。
if (entity == null) { if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType()); processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
} }
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setUnionId(unionId); result.setUnionId(unionId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode()+""); result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
return result; return result;
} }
} }
...@@ -228,13 +397,17 @@ public class LoginServiceImpl implements LoginService { ...@@ -228,13 +397,17 @@ public class LoginServiceImpl implements LoginService {
public LoginResult loginByWeChatStep(BaseRequest request) { public LoginResult loginByWeChatStep(BaseRequest request) {
//判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作 //判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile())); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
logger.info("loginByWeChatStep-accountInfoEntity is null {}, clientIp:{}", (accountInfoEntity == null), request.getLoginIp());
LoginResult result; LoginResult result;
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "",
request.getAuthCode());
result = registerService.register(request); result = registerService.register(request);
if (doubleWritingMode) { if (doubleWritingMode) {
//双写模式下,要在doctor表存储unionId //双写模式下,要在doctor表存储unionId
if (result.getUserId() != null) {
if (result.getUserId()!=null) {
Doctor doctor = new Doctor(); Doctor doctor = new Doctor();
doctor.setId(result.getUserId().intValue()); doctor.setId(result.getUserId().intValue());
doctor.setUnionid(request.getUnionId()); doctor.setUnionid(request.getUnionId());
...@@ -242,18 +415,27 @@ public class LoginServiceImpl implements LoginService { ...@@ -242,18 +415,27 @@ public class LoginServiceImpl implements LoginService {
} }
} }
} else { } else {
accountUtils.checkMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "",
request.getAuthCode());
result = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode()); result = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
} }
result.setMobile(request.getMobile());
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile())); AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId(); Integer acctId = accountInfo.getId();
processAccountUnion(acctId, request.getUnionId()); processAccountUnion(acctId, request.getUnionId(), request.getProductType());
return result; return result;
} }
@Override @Override
@Transactional @Transactional
public void unbindWeChat(Integer acctId) { public void unbindWeChat(long doctorId) {
accountUnionMapper.updateUnbindByAcctId(acctId); Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
Map<String, Object> map = new HashedMap(2);
map.put("acctId", acctId);
map.put("unionType", AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
accountUnionMapper.updateUnbindByAcctId(map);
if (doubleWritingMode) { if (doubleWritingMode) {
doctorService.unbindWeChat(acctId); doctorService.unbindWeChat(acctId);
} }
...@@ -261,7 +443,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -261,7 +443,7 @@ public class LoginServiceImpl implements LoginService {
@Override @Override
@Transactional @Transactional
public void bindWeChat(BaseRequest request) { public String bindWeChat(long doctorId, BaseRequest request) {
WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode()); WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
Map map = new HashMap(); Map map = new HashMap();
map.put("access_token", weChatEntity.getAccess_token()); map.put("access_token", weChatEntity.getAccess_token());
...@@ -272,8 +454,12 @@ public class LoginServiceImpl implements LoginService { ...@@ -272,8 +454,12 @@ public class LoginServiceImpl implements LoginService {
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId); AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
if (entity == null) { if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType()); processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
} else {
updateWechatInfoUser(entity, weChatUserInfoEntity);
} }
processAccountUnion(request.getAccId(), unionId); Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
processAccountUnion(acctId, unionId, request.getProductType());
return weChatUserInfoEntity.getNickname();
} }
/** /**
...@@ -282,7 +468,19 @@ public class LoginServiceImpl implements LoginService { ...@@ -282,7 +468,19 @@ public class LoginServiceImpl implements LoginService {
* @param acctId * @param acctId
* @param unionId * @param unionId
*/ */
private void processAccountUnion(Integer acctId, String unionId) { private void processAccountUnion(Integer acctId, String unionId, Integer productType) {
//先查询当前产品线是否有记录?如果有就更新成delete_flag=2; 然后在插入新的绑定记录
AccountUnionEntity accountUnionResult = accountUnionMapper.selectByUnionId(unionId);
if (accountUnionResult != null) {
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_UNBIND.getCode(), AccountExceptionEnum.PICA_WECHAT_UNBIND.getMessage());
}
Map<String, Object> map = new HashedMap(2);
map.put("acctId", acctId);
map.put("unionType", AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(map);
if (accountUnionEntityAccount != null) {
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_BIND_OTHER.getCode(), AccountExceptionEnum.PICA_WECHAT_BIND_OTHER.getMessage());
}
AccountUnionEntity accountUnionEntity = new AccountUnionEntity(); AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue()); accountUnionEntity.setAcctId(acctId.longValue());
accountUnionEntity.setDeleteFlag(1); accountUnionEntity.setDeleteFlag(1);
...@@ -325,6 +523,17 @@ public class LoginServiceImpl implements LoginService { ...@@ -325,6 +523,17 @@ public class LoginServiceImpl implements LoginService {
accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity); accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity);
} }
private void updateWechatInfoUser(AccountWeChatInfoEntity entity, WeChatUserInfoEntity weChatUserInfoEntity) {
String nickname = weChatUserInfoEntity.getNickname();
if (StringUtils.isNotEmpty(nickname) && !nickname.equals(entity.getNickname())) {
AccountWeChatInfoEntity info = new AccountWeChatInfoEntity();
info.setId(entity.getId());
info.setNickname(nickname);
accountWeChatInfoMapper.updateByPrimaryKeySelective(info);
}
}
@Override
public PICAPDoctor queryDoctor(long doctorId) { public PICAPDoctor queryDoctor(long doctorId) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId); PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId);
if (doctor == null) { if (doctor == null) {
...@@ -334,6 +543,32 @@ public class LoginServiceImpl implements LoginService { ...@@ -334,6 +543,32 @@ public class LoginServiceImpl implements LoginService {
return doctor; return doctor;
} }
@Override
public LoginResult oneClickLogin(OneClickLoginReq req) {
QueryMobileEntity queryMobileEntity = oneClickProcessor.tokenExchangeMobile(req.getToken(), req.getSourceType());
if (queryMobileEntity == null || StringUtils.isBlank(queryMobileEntity.getMobile()) || !ValidateUtils.isMobile(queryMobileEntity.getMobile())) {
throw new PicaException(PicaResultCode.INTERFACE_INVOKE_EXCEPTION.code(), "获取手机号失败!");
}
queryMobileEntity.setSourceType(req.getSourceType());
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(queryMobileEntity.getMobile()));
BaseRequest baseRequest = new BaseRequest();
baseRequest.setMobile(queryMobileEntity.getMobile());
baseRequest.setSourceType(req.getSourceType());
baseRequest.setProductType(req.getProductType());
baseRequest.setLoginIp(req.getLoginIp());
baseRequest.setUserTokenTourist(req.getUserTokenTourist());
LoginResult result;
if (accountInfoEntity == null) {
//说明是注册功能
result = registerService.register(baseRequest, queryMobileEntity);
} else {
//登录功能
result = processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_ONE_CLICK.getCode(), queryMobileEntity);
}
return result;
}
private String processDoctorAvatar(String avatar_image_url) { private String processDoctorAvatar(String avatar_image_url) {
if (StringUtils.isEmpty(avatar_image_url)) { if (StringUtils.isEmpty(avatar_image_url)) {
return DEFAULT_DOCTOR_PICTURE_URL; return DEFAULT_DOCTOR_PICTURE_URL;
...@@ -347,4 +582,350 @@ public class LoginServiceImpl implements LoginService { ...@@ -347,4 +582,350 @@ public class LoginServiceImpl implements LoginService {
} }
} }
} }
}
/**
* @Description 统一校验(传空则不会校验)
* @Author Chongwen.jiang
* @Date 2020/2/20 16:55
* @ModifyDate 2020/2/20 16:55
* @Params [request]
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
@Override
public void preLoginValidate(BaseRequest request) {
Integer bizType = request.getBizType();
String mobile = request.getMobile();
Integer sourceType = request.getSourceType();
if (null == bizType) {
logger.info("bizType is null");
throw new PicaWarnException(PicaResultCode.PARAM_IS_BLANK.code(),
PicaResultCode.PARAM_IS_BLANK.message());
}
if (bizType.equals(2)) {
// 手机号规则校验
if (StringUtils.isNotEmpty(mobile) &&
!ValidateUtils.isMobile(mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getCode(),
AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getMessage());
}
} else if (bizType.equals(3)) {
// 手机号规则校验
if (StringUtils.isNotEmpty(mobile) &&
!ValidateUtils.isMobile(mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getCode(),
AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getMessage());
}
// 手机号是否注册
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfo == null) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage());
} else {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST.getMessage().replace("{mobile}", mobile));
}
}
// 手机号是否设置了密码
if (StringUtils.isEmpty(accountInfo.getPassword())) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage());
} else {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD.getMessage().replace("{mobile}", mobile));
}
}
}
}
/**
* @Description 苹果登录授权
* @Author Chongwen.jiang
* @Date 2020/2/24 19:21
* @ModifyDate 2020/2/24 19:21
* @Params [request]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
@Transactional
@Override
public LoginResult loginByApple(BaseRequest request) {
long start = System.currentTimeMillis();
// 入参非空判断
if (StringUtils.isEmpty(request.getIdentifyToken())) {
throw new PicaException(AccountExceptionEnum.PICA_PARAMS_ERROR.getCode(),
AccountExceptionEnum.PICA_PARAMS_ERROR.getMessage());
}
// identifyToken校验
if(!checkIdentifyToken(request)){
throw new PicaException(
AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getCode(),
AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getMessage());
}
// apple授权登录用户信息入库
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(request.getAppleUserId());
//是否绑定逻辑的判断
if (accountUnion != null) {
Long acctId = accountUnion.getAcctId();
Long userId = accountUtils.getUserIdByAcctId(null, acctId.intValue());
Account account = new Account();
account.setId(userId);
account.setAcctId(acctId.intValue());
account.setCreatTime(new Date());
account.setMobilePhone("");
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (request.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
result.setEntireFlag(doctor.getEntire_flag());
result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(
Integer.valueOf(String.valueOf(acctId)),
request.getProductType(), request.getSourceType(),
AccountTypeEnum.LOGIN_APPLE.getCode(),
request.getLoginIp(),
AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,request.getUserTokenTourist());
picaLogUtils.info(entity);
long end1 = System.currentTimeMillis();
logger.info("loginByApple1-duration {} millionSeconds", (end1-start));
return result;
} else {
AccountAppleInfo entity = accountAppleInfoMapper.selectByUserId(request.getAppleUserId());
//如果apple信息表数据不存在,就把用户信息存储到apple信息表中。
if (entity == null) {
processAppleInfoUser(request);
}
LoginResult result = new LoginResult();
result.setUnionId(request.getAppleUserId());
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
long end1 = System.currentTimeMillis();
logger.info("loginByApple2-duration {} millionSeconds", (end1-start));
return result;
}
}
/**
* @Description apple登录--identifyToken校验
* @Author Chongwen.jiang
* @Date 2020/2/24 19:28
* @ModifyDate 2020/2/24 19:28
* @Params [identifyToekn]
* @Return boolean false:未通过token校验,true:通过校验
*/
private boolean checkIdentifyToken(BaseRequest request) {
String identifyToken = request.getIdentifyToken();
logger.info("checkIdentifyToken-identifyToken:{}", identifyToken);
// 向苹果后台获取公钥参数
String appleResp = null;
try {
appleResp = HttpClientCloudUtils.getHttpExecute(Constants.APPLE_GET_PUBLIC_KEY_URL);
logger.info("checkIdentifyToken-appleResp:{}", appleResp);
} catch (Exception e) {
logger.info("checkIdentifyToken-get apple public key fail " + e.getMessage());
throw new PicaException("get apple public key fail Exception", "get apple public key fail");
}
JSONObject appleRespJson = JSONObject.parseObject(appleResp);
String keys = appleRespJson.getString("keys");
JSONArray keysArr = JSONObject.parseArray(keys);
if (identifyToken.split("\\.").length < 2) {
throw new PicaException("get identifyToken fail Exception", "get identifyToken format Exception");
}
JSONObject useAppleAuth = new JSONObject();
String inAuth = new String(Base64.decodeBase64(identifyToken.split("\\.")[0]));
String inKid = JSONObject.parseObject(inAuth).get("kid").toString();
for(Object obj : keysArr){
JSONObject appleAuth = JSONObject.parseObject(obj.toString());
if(inKid.equals(appleAuth.getString("kid"))){
useAppleAuth = appleAuth;
logger.info("checkIdentifyToken-jsonObject1:{}", useAppleAuth);
break;
}
}
// 通过jar生成publicKey
PublicKey publicKey;
try {
Jwk jwa = Jwk.fromValues(useAppleAuth);
publicKey = jwa.getPublicKey();
} catch (Exception e) {
logger.info("checkIdentifyToken-generate publicKey fail " + e.getMessage());
throw new PicaException("checkIdentifyToken-generate publicKey fail", "generate publicKey fail");
}
// 分割前台传过来的identifyToken(jwt格式的token)用base64解码使用
String aud;
String sub;
try {
String claim = new String(Base64.decodeBase64(identifyToken.split("\\.")[1]));
//logger.info("checkIdentifyToken-claim:{}", claim);
aud = JSONObject.parseObject(claim).get("aud").toString();
sub = JSONObject.parseObject(claim).get("sub").toString();
// appleUserId从token中解码取出后赋值
request.setAppleUserId(sub);
} catch (Exception e) {
logger.info("checkIdentifyToken-token decode fail " + e.getMessage());
throw new PicaException("checkIdentifyToken-token decode fail Exception", "token decode fail");
}
return this.verify(publicKey, identifyToken, aud, sub, request);
}
/**
* @Description 验证苹果公钥
* @Author Chongwen.jiang
* @Date 2020/2/24 19:49
* @ModifyDate 2020/2/24 19:49
* @Params [key, jwt, audience, subject]
* @Return boolean
*/
private boolean verify(PublicKey key, String jwt, String audience, String subject, BaseRequest request) {
JwtParser jwtParser = Jwts.parser().setSigningKey(key);
jwtParser.requireIssuer(Constants.APPLE_ISSUE_URL);
jwtParser.requireAudience(audience);
jwtParser.requireSubject(subject);
try {
logger.info("checkIdentifyToken-apple-verify-starting");
Jws<Claims> claim = jwtParser.parseClaimsJws(jwt);
logger.info("acheckIdentifyToken-apple-verify-claim:{}", JSON.toJSONString(claim));
//logger.info("apple-verify-claim.getBody:{}", JSON.toJSONString(claim.getBody()));
if (claim != null && claim.getBody().containsKey("auth_time")) {
request.setInfo(JSON.toJSONString(claim.getBody()));
JSONObject claimBody = JSONObject.parseObject(JSON.toJSONString(claim.getBody()), JSONObject.class);
request.setAppleId(claimBody.getString("email"));
return true;
}
return false;
} catch (ExpiredJwtException e) {
logger.info("checkIdentifyToken-apple token expired " + e.getMessage());
throw new PicaException("apple token expired Exception", "apple token expired");
} catch (Exception e) {
logger.info("checkIdentifyToken-apple token illegal " + e.getMessage());
throw new PicaException("apple token illegal Exception", "apple token illegal");
}
}
/**
* @Description apple用户信息入表
* @Author Chongwen.jiang
* @Date 2020/2/24 11:00
* @ModifyDate 2020/2/24 11:00
* @Params [request]
* @Return void
*/
private void processAppleInfoUser(BaseRequest request) {
AccountAppleInfo appleInfo = new AccountAppleInfo();
appleInfo.setCreatedId(0);
appleInfo.setModifiedId(0);
appleInfo.setAppleUserId(request.getAppleUserId());
appleInfo.setAppleId(request.getAppleId());
appleInfo.setInfo(request.getInfo());
accountAppleInfoMapper.insertSelective(appleInfo);
}
/**
* @Description 苹果登录绑定手机号
* @Author Chongwen.jiang
* @Date 2020/2/24 11:40
* @ModifyDate 2020/2/24 11:40
* @Params [request]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
@Override
public LoginResult loginByAppleStep(BaseRequest request) {
// 判断当前手机号是否注册过: 没有注册过,进行注册操操作, 注册过,直接登录;
AccountInfoEntity accountInfoDb = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
logger.info("loginByAppleStep-account is null {}, request:{}", accountInfoDb == null, JSON.toJSONString(request));
LoginResult result;
if (accountInfoDb == null) {
// 验证码校验
accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
result = registerService.register(request);
logger.info("loginByAppleStep-register");
} else {
// 验证码校验
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
result = processLogin(request, accountInfoDb.getId(),
AccountTypeEnum.LOGIN_APPLE.getCode());
logger.info("loginByAppleStep-processLogin");
}
result.setMobile(request.getMobile());
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId();
// insert account_apple_info表数据
logger.info("loginByAppleStep-insert-account_apple_info-start");
processAccountUnionApple(acctId, request.getAppleUserId());
logger.info("loginByAppleStep-insert-account_apple_info-end");
return result;
}
/**
* @Description account_apple_info insert
* @Author Chongwen.jiang
* @Date 2020/2/24 11:34
* @ModifyDate 2020/2/24 11:34
* @Params [acctId, appleUserId]
* @Return void
*/
private void processAccountUnionApple(Integer acctId, String appleUserId) {
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(appleUserId);
if (accountUnion != null) {
throw new PicaException(
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getCode(),
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getMessage());
}
Map<String, Object> map = new HashedMap(2);
map.put("acctId", acctId);
map.put("unionType", AccountTypeEnum.UNION_LOGIN_APPLE.getCode());
AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(map);
if (accountUnionEntityAccount != null) {
throw new PicaException(
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getCode(),
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getMessage());
}
AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue());
accountUnionEntity.setUnionId(appleUserId);
accountUnionEntity.setCreatedId(acctId);
accountUnionEntity.setModifiedId(acctId);
accountUnionEntity.setUnionType(AccountTypeEnum.UNION_LOGIN_APPLE.getCode());
accountUnionMapper.insertSelective(accountUnionEntity);
}
/**
* @Description TODO
* @Author peijun.zhao
* @Date 2020/4/22 17:14
* @ModifyDate 2020/4/22 17:14
* @Params [aes]
* @Return int
*/
@Override
public int insertLoginAesLog(LogLoginAes aes){
aes.setDeleteFlag(1);
aes.setCreateId(999999);
aes.setModifyId(999999);
aes.setCreateTime(new Date());
aes.setModifyTime(new Date());
return logLoginAesMapper.insert(aes);
}
}
...@@ -2,12 +2,16 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -2,12 +2,16 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.Doctor; import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.LogMobileModify;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.mapper.LogMobileModifyMapper;
import com.pica.cloud.account.account.server.service.ModifyMobileService; import com.pica.cloud.account.account.server.service.ModifyMobileService;
import com.pica.cloud.account.account.server.util.AESUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -25,6 +29,9 @@ public class ModifyMobileServiceImpl implements ModifyMobileService { ...@@ -25,6 +29,9 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
@Autowired @Autowired
private DoctorMapper doctorMapper; private DoctorMapper doctorMapper;
@Autowired
private LogMobileModifyMapper logMobileModifyMapper;
@Value("${doubleWritingMode}") @Value("${doubleWritingMode}")
private boolean doubleWritingMode; private boolean doubleWritingMode;
...@@ -64,4 +71,26 @@ public class ModifyMobileServiceImpl implements ModifyMobileService { ...@@ -64,4 +71,26 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(phone); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(phone);
return accountInfoEntity.getId(); return accountInfoEntity.getId();
} }
/**
* 记录账号对应的手机号的变更信息
*
* @param acctId
* @param mobilePhone
* @param mobile
*/
@Override
public void recodeMobileModify(Integer acctId, String mobilePhone, String mobile) {
Date date = new Date();
LogMobileModify logMobileModify = new LogMobileModify();
logMobileModify.setAcctId(acctId);
logMobileModify.setDeleteFlag(1);
logMobileModify.setCreatedId(acctId);
logMobileModify.setCreatedTime(date);
logMobileModify.setModifiedId(acctId);
logMobileModify.setModifiedTime(date);
logMobileModify.setMobilePhoneNew(EncryptUtils.encryptContent(mobile,EncryptConstants.ENCRYPT_TYPE_MOBILE));
logMobileModify.setMobilePhoneOld(mobilePhone);
logMobileModifyMapper.insert(logMobileModify);
}
} }
package com.pica.cloud.account.account.server.service.impl; package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.Doctor; import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
...@@ -13,6 +12,11 @@ import com.pica.cloud.account.account.server.mapper.DoctorMapper; ...@@ -13,6 +12,11 @@ import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.PasswordService; import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.account.account.server.util.AESUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.redis.ICacheClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -35,6 +39,19 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -35,6 +39,19 @@ public class PasswordServiceImpl implements PasswordService {
@Value("${doubleWritingMode}") @Value("${doubleWritingMode}")
private boolean doubleWritingMode; private boolean doubleWritingMode;
@Autowired
private AccountUtils accountUtils;
@Autowired
private TokenUtils tokenUtils;
@Autowired
private DoctorMapper doctorInfoMapper;
@Autowired
private ICacheClient cacheClient;
@Override @Override
@Transactional @Transactional
public void modifyPassword(String mobile, String oldPwd, String pwd) { public void modifyPassword(String mobile, String oldPwd, String pwd) {
...@@ -65,8 +82,10 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -65,8 +82,10 @@ public class PasswordServiceImpl implements PasswordService {
@Override @Override
@Transactional @Transactional
public void forgetPassword(BaseRequest request) { public void forgetPassword(BaseRequest request, AccountInfoEntity entity) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile())); if (entity == null) {
entity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
}
if (entity != null) { if (entity != null) {
String password = request.getPassword(); String password = request.getPassword();
Integer accId = entity.getId(); Integer accId = entity.getId();
...@@ -90,6 +109,48 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -90,6 +109,48 @@ public class PasswordServiceImpl implements PasswordService {
} }
} }
/**
* @Description 重置密码-自动登录(生成token),删除账号锁定缓存
* @Author Chongwen.jiang
* @Date 2020/3/3 17:44
* @ModifyDate 2020/3/3 17:44
* @Params [request, accountInfo]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
@Override
public LoginResult findPwdLogin(BaseRequest request, AccountInfoEntity accountInfo) {
Long userId = accountUtils.getUserIdByAcctId(request.getProductType(), accountInfo.getId());
Account account2 = new Account();
account2.setId(userId);
account2.setAcctId(accountInfo.getId());
account2.setCreatTime(new Date());
account2.setMobilePhone(request.getMobile());
account2.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account2);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setMobile(request.getMobile());
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
// 是否完善过个人信息(云鹊医app才需要)
if (request.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue());
result.setEntireFlag(doctorEntity.getEntireFlag());
}
// 删除账号锁定缓存
String lockKey = Constants.ACCOUNT_LOCK_KEY.replace("{mobile}", request.getMobile());
if(cacheClient.exists(lockKey)) {
cacheClient.del(lockKey);
}
// 删除账号错误次数缓存
String errorKey = Constants.PWD_ERROR_NUM_KEY.replace("{mobile}", request.getMobile());
if(cacheClient.exists(errorKey)) {
cacheClient.del(errorKey);
}
return result;
}
/** /**
* 双写模式,把密码存储到p_doctor表 * 双写模式,把密码存储到p_doctor表
* *
......
package com.pica.cloud.account.account.server.service.impl; package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.common.req.OCINRequest; import com.pica.cloud.account.account.common.req.OCINRequest;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.*; import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.AccountAgreementEnum;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.log.AccountLogEntityUtils; import com.pica.cloud.account.account.server.log.AccountLogEntityUtils;
import com.pica.cloud.account.account.server.log.AccountLogUtils; import com.pica.cloud.account.account.server.log.AccountLogUtils;
import com.pica.cloud.account.account.server.mapper.*; import com.pica.cloud.account.account.server.mapper.*;
import com.pica.cloud.account.account.server.queue.QueueProducer;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.RegisterService; import com.pica.cloud.account.account.server.service.RegisterService;
import com.pica.cloud.account.account.server.util.AESUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils; import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.ExecutorServiceUtils; import com.pica.cloud.account.account.server.util.ExecutorServiceUtils;
import com.pica.cloud.account.account.server.util.TokenUtils; import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -24,25 +24,20 @@ import org.slf4j.LoggerFactory; ...@@ -24,25 +24,20 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@Service @Service
public class RegisterServiceImpl implements RegisterService { public class RegisterServiceImpl implements RegisterService {
private final String REPEAT_REGISTER_PREFIX = "repeat-register—";
private Logger logger = LoggerFactory.getLogger(this.getClass()); private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired @Autowired
private AccountInfoDetailMapper accountInfoDetailMapper; private PUserRoleMapper pUserRoleMapper;
@Autowired @Autowired
private AccountPatientInfoMapper accountUserInfoMapper; private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired @Autowired
private AccountMapper accountMapper; private AccountMapper accountMapper;
...@@ -56,17 +51,11 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -56,17 +51,11 @@ public class RegisterServiceImpl implements RegisterService {
@Autowired @Autowired
private TokenUtils tokenUtils; private TokenUtils tokenUtils;
@Autowired
private QueueProducer queueProducer;
@Autowired
private AgreementEntityMapper agreementEntityMapper;
@Autowired @Autowired
private AgreementLogEntityMapper agreementLogEntityMapper; private AgreementLogEntityMapper agreementLogEntityMapper;
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
/** /**
...@@ -77,17 +66,24 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -77,17 +66,24 @@ public class RegisterServiceImpl implements RegisterService {
* @param baseRequest 参数模型 * @param baseRequest 参数模型
* @return * @return
*/ */
@Transactional
@Override @Override
public LoginResult register(BaseRequest baseRequest) { public LoginResult register(BaseRequest baseRequest) {
return register(baseRequest,null);
}
@Override
public LoginResult register(BaseRequest baseRequest,QueryMobileEntity queryMobileEntity) {
String mobile = baseRequest.getMobile(); String mobile = baseRequest.getMobile();
//对注册接口做幂等性处理:注册成功,删除缓存,注册失败提示用户 //对注册接口做幂等性处理:注册成功,删除缓存,注册失败提示用户
String exist = redisClient.get(REPEAT_REGISTER_PREFIX + mobile); String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
if (StringUtils.isBlank(exist)) { Long resultNx = redisClient.setnx(nxKey, mobile);
if(resultNx == 1) {
try {
String mobileEncrypt = AESUtil.encryptV0(mobile); String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
redisClient.set(REPEAT_REGISTER_PREFIX + mobile, mobile, 30); redisClient.expire(nxKey, 30);
try {
Date currentTime = new Date(); Date currentTime = new Date();
int productType = baseRequest.getProductType(); int productType = baseRequest.getProductType();
int sourceType = baseRequest.getSourceType(); int sourceType = baseRequest.getSourceType();
...@@ -110,16 +106,6 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -110,16 +106,6 @@ public class RegisterServiceImpl implements RegisterService {
accountInfoDetailMapper.insertSelective(accountInfo); accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId(); Integer acctId = accountInfo.getId();
accountInfoDetailMapper.updateCreateInfo(acctId); accountInfoDetailMapper.updateCreateInfo(acctId);
if (productType == AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
AccountPatientInfoEntity accountPatientInfoEntity = new AccountPatientInfoEntity();
accountPatientInfoEntity.setAcctId(acctId);
accountPatientInfoEntity.setDeleteFlag(1);
accountPatientInfoEntity.setCreateId(acctId);
accountPatientInfoEntity.setModifyId(acctId);
accountPatientInfoEntity.setCreateTime(currentTime);
accountPatientInfoEntity.setModifyTime(currentTime);
accountUserInfoMapper.insertSelective(accountPatientInfoEntity);
} else {
Account account = new Account(); Account account = new Account();
account.setAcctId(acctId); account.setAcctId(acctId);
account.setMobilePhone(mobileEncrypt); account.setMobilePhone(mobileEncrypt);
...@@ -130,50 +116,85 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -130,50 +116,85 @@ public class RegisterServiceImpl implements RegisterService {
account.setModifyTime(currentTime); account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime); account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime); account.setLastLoginTime(currentTime);
account.setRegisterSource(sourceType);
account.setPassword(password); account.setPassword(password);
accountMapper.insertSelective(account); if (!StringUtils.isBlank(password)) {
account.setEntireFlag(3);
} }
Long userId = accountUtils.getUserIdByAcctId(productType, acctId); logger.info("register-add-doctor-start");
Account account = new Account(); accountMapper.insertSelective(account);
account.setId(userId); Long userId = account.getId();
account.setAcctId(acctId); Account accountToken = new Account();
account.setCreatTime(currentTime); accountToken.setId(userId);
account.setMobilePhone(mobile); accountToken.setAcctId(acctId);
account.setRegisterSource(sourceType); accountToken.setCreatTime(currentTime);
String newToken = tokenUtils.generateToken(account); accountToken.setMobilePhone(mobile);
accountToken.setRegisterSource(sourceType);
String newToken = tokenUtils.generateToken(accountToken);
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setToken(newToken); result.setToken(newToken);
result.setUserId(userId); result.setUserId(userId);
result.setEntireFlag(1); result.setEntireFlag(1);
/* ByteArrayOutputStream bos = new ByteArrayOutputStream(); result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
DataOutputStream dos = new DataOutputStream(bos); result.setMobile(mobile);
try {
dos.writeLong(userId);
} catch (IOException e) {
e.printStackTrace();
}
queueProducer.send(bos.toByteArray());*/
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, baseRequest.getSourceType(), LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, baseRequest.getSourceType(),
AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode()); AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,baseRequest.getUserTokenTourist());
if(queryMobileEntity != null){
entity.setQueryMobileEntity(queryMobileEntity);
}
picaLogUtils.info(entity); picaLogUtils.info(entity);
processAgreement(userId); processAgreement(userId);
redisClient.del(REPEAT_REGISTER_PREFIX + mobile); processRoleMap(userId);
redisClient.del(nxKey);
return result; return result;
} else {
logger.info("register-account is exists");
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
}
} catch (Exception e) { } catch (Exception e) {
//向上抛出异常,让异常处理框架捕获到 //向上抛出异常,让异常处理框架捕获到
logger.error("registerException-" + e.getMessage(), e);
throw new AccountException(AccountExceptionEnum.PICA_REGISTER_FAIL); throw new AccountException(AccountExceptionEnum.PICA_REGISTER_FAIL);
} finally { } finally {
//如果在注册过程中抛出异常,就删除redis中的注册标记 //如果在注册过程中抛出异常,就删除redis中的注册标记
redisClient.del(REPEAT_REGISTER_PREFIX + mobile); logger.info("register-finally-del-nxKey");
redisClient.del(nxKey);
} }
} else { } else {
logger.info("register-nxKey is exists");
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER); throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
} }
} else {
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
} }
/**
* 异步处理用户角色
*
* @param userId
*/
private void processRoleMap(Long userId) {
ExecutorServiceUtils.getExecutor().submit(new Runnable() {
@Override
public void run() {
Date date = new Date();
PUserRole pUserRole = new PUserRole();
pUserRole.setSystemId(5);
pUserRole.setUserRoleId(2);
pUserRole.setUserId(userId.intValue());
pUserRole.setUserType(1);
pUserRole.setStatus(2);
pUserRole.setDeleteFlag(1);
pUserRole.setCreatId(userId.intValue());
pUserRole.setCreatTime(date);
pUserRole.setModifyId(userId.intValue());
pUserRole.setModifyTime(date);
pUserRoleMapper.insertSelective(pUserRole);
pUserRole.setSystemId(1);
pUserRoleMapper.insertSelective(pUserRole);
pUserRole.setSystemId(3);
pUserRoleMapper.insertSelective(pUserRole);
}
});
} }
/** /**
...@@ -184,6 +205,7 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -184,6 +205,7 @@ public class RegisterServiceImpl implements RegisterService {
@Override @Override
public void ocinRegister(OCINRequest request) { public void ocinRegister(OCINRequest request) {
String mobile = request.getMobile(); String mobile = request.getMobile();
String name = request.getName();
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobile); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobile);
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
Date currentTime = new Date(); Date currentTime = new Date();
...@@ -199,6 +221,7 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -199,6 +221,7 @@ public class RegisterServiceImpl implements RegisterService {
accountInfo.setRegTime(currentTime); accountInfo.setRegTime(currentTime);
accountInfo.setDeleteFlag(1); accountInfo.setDeleteFlag(1);
accountInfo.setSex(0); accountInfo.setSex(0);
accountInfo.setName(name);
accountInfo.setRegisterProduct(productType); accountInfo.setRegisterProduct(productType);
accountInfo.setRegisterSource(sourceType); accountInfo.setRegisterSource(sourceType);
accountInfoDetailMapper.insertSelective(accountInfo); accountInfoDetailMapper.insertSelective(accountInfo);
...@@ -215,7 +238,9 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -215,7 +238,9 @@ public class RegisterServiceImpl implements RegisterService {
account.setModifyTime(currentTime); account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime); account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime); account.setLastLoginTime(currentTime);
account.setRegisterSource(sourceType);
account.setPassword(""); account.setPassword("");
account.setName(name);
accountMapper.insertSelective(account); accountMapper.insertSelective(account);
Long userId = accountUtils.getUserIdByAcctId(productType, acctId); Long userId = accountUtils.getUserIdByAcctId(productType, acctId);
processAgreement(userId); processAgreement(userId);
...@@ -238,31 +263,23 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -238,31 +263,23 @@ public class RegisterServiceImpl implements RegisterService {
private void processAgreement(Long userId) { private void processAgreement(Long userId) {
ExecutorService executor = ExecutorServiceUtils.getExecutor(); ExecutorService executor = ExecutorServiceUtils.getExecutor();
executor.submit(() -> { executor.submit(() -> {
//用户协议 Integer protocolId = agreementLogEntityMapper.getLatestProtocolId(2); //获取最新用户协议ID
Date currentTime = new Date(); PProtocolLog log = new PProtocolLog();
Integer userVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.USER_AGREEMENT.getCode()); log.setUserId(userId.toString());
AgreementLogEntity userAgreementLogEntity = new AgreementLogEntity(); log.setProtocolId(protocolId);
userAgreementLogEntity.setAgreement_type(AccountAgreementEnum.USER_AGREEMENT.getCode()); log.setUserType(2);
userAgreementLogEntity.setDoctor_id(userId); log.setType(2);
userAgreementLogEntity.setVersion(userVersion.toString()); log.setStatus((short) 1);
userAgreementLogEntity.setCreated_id(userId); log.setCreatedId(userId.intValue());
userAgreementLogEntity.setCreated_time(currentTime); log.setModifiedId(userId.intValue());
userAgreementLogEntity.setModified_id(userId); agreementLogEntityMapper.insertProtocolLog(log);
userAgreementLogEntity.setModified_time(currentTime); agreementLogEntityMapper.updateSignNum(protocolId); //更新用户协议签署数量
userAgreementLogEntity.setDelete_flag(1);
agreementLogEntityMapper.insert(userAgreementLogEntity); protocolId = agreementLogEntityMapper.getLatestProtocolId(3); //获取最新隐私协议ID
//隐私协议 log.setProtocolId(protocolId);
Integer privateVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode()); log.setType(3);
AgreementLogEntity privateAgreementLogEntity = new AgreementLogEntity(); agreementLogEntityMapper.insertProtocolLog(log);
privateAgreementLogEntity.setAgreement_type(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode()); agreementLogEntityMapper.updateSignNum(protocolId); //更新隐私协议签署数量
privateAgreementLogEntity.setDoctor_id(userId);
privateAgreementLogEntity.setVersion(privateVersion.toString());
privateAgreementLogEntity.setCreated_id(userId);
privateAgreementLogEntity.setCreated_time(currentTime);
privateAgreementLogEntity.setModified_id(userId);
privateAgreementLogEntity.setModified_time(currentTime);
privateAgreementLogEntity.setDelete_flag(1);
agreementLogEntityMapper.insert(privateAgreementLogEntity);
}); });
} }
} }
...@@ -2,14 +2,18 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -2,14 +2,18 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.constants.Constants; import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.service.TokenService; import com.pica.cloud.account.account.server.service.TokenService;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.entity.PicaUser; import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.CommonUtil; import com.pica.cloud.foundation.utils.utils.CommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
...@@ -24,11 +28,18 @@ import static com.pica.cloud.foundation.utils.utils.json.Object2Map.objectToMapS ...@@ -24,11 +28,18 @@ import static com.pica.cloud.foundation.utils.utils.json.Object2Map.objectToMapS
*/ */
@Service @Service
public class TokenServiceImpl implements TokenService { public class TokenServiceImpl implements TokenService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
@Autowired
private TokenUtils tokenUtils;
@Autowired
@Qualifier("accountThreadPool")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override @Override
public String getToken(Map<String, Object> headersMap) { public String getToken(Map<String, Object> headersMap) {
String mobile = new StringBuilder("9").append(CommonUtil.getRandom(10)).toString(); String mobile = new StringBuilder("9").append(CommonUtil.getRandom(10)).toString();
...@@ -56,4 +67,27 @@ public class TokenServiceImpl implements TokenService { ...@@ -56,4 +67,27 @@ public class TokenServiceImpl implements TokenService {
} }
return null; return null;
} }
/**
* @Description token续时
* @Author Chongwen.jiang
* @Date 2020/2/26 14:06
* @ModifyDate 2020/2/26 14:06
* @Params [token, sourceType] sourceType: 1.android 2.ios 3.web 4.h5 5.admin
* @Return java.lang.String
*/
@Override
public void tokenContinueTime(String token, Integer sourceType, Integer seconds) {
if (StringUtils.isEmpty(token) || null == sourceType) {
return;
}
threadPoolTaskExecutor.execute(() -> {
if (tokenUtils.tokenContinueTime(token, sourceType, seconds)) {
logger.info("tokenContinueTime finish");
}
});
return;
}
} }
package com.pica.cloud.account.account.server.util; package com.pica.cloud.account.account.server.util;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil; import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -7,8 +9,11 @@ import sun.misc.BASE64Decoder; ...@@ -7,8 +9,11 @@ import sun.misc.BASE64Decoder;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.KeyGenerator; import javax.crypto.KeyGenerator;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created on 2019/10/21 13:20 * Created on 2019/10/21 13:20
...@@ -22,16 +27,9 @@ public class AESUtil { ...@@ -22,16 +27,9 @@ public class AESUtil {
//算法 //算法
private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding"; private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding";
public static final String privateKey="MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJrqPdInBev+ksvBvo+rymL1K0+r5" + public static final String privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAKdXMOUboMkHBOyfuMWuIo6bOp+b53i/LoO0qox+sQ+DqFTdt9tH1dF/CoAWtLj5CjDJum7JYJrsMXIqXQnIRr8ZKt+NtdKlqUUeGZYfTPSEIXWb9S+U8DQFqJgXL25xcX1SHxFoeRkZWZX5FtUhKTimOVl1FwrkRDmFyIEUa2AbAgMBAAECgYEAlEZHxtoiL74OePRVrqNLb3zQBxkHkxAj0QPGktK3ZP3Nq9UB0kTmisi8rx5vZ+8TPoOgtAWvmdZrQbOT2NUjCUYKkGS+Wi1fXpP0Az2UJwDIQK4aQTZtNbM04f3Rmi5i24eASmSdl1svjHEv0YS6IC6sR1cbElZs94uDFshUeqECQQDTrmZda8fo6ZNsHVYWcjTwr8JKTIgjaD/hPi0JP6hhL0GVEAVwb2rsfJf5o2TR5RsNT8ANUYgFPRaAymLLe+5zAkEAymA9V55K6IJhnSp7HmWfGVmxvTrwZFJIzPv7DLi/RAS3yFPfTpyJGLirAnBQfKO/vwjxhAuwD21aDYHMTrj1uQJBAJdAikw+cz1tiLU70QOA32sLaxyDytLh7qMXNj7hiYLHrWjBZeGM+y23aTArHCMOPWIpleTuWO7FU4r7EdSr3RkCQQCliu4CwyhRY33H210U81memgFLYnAMEEce7qxgrqs+T4Gqa/lJy8BVqZGxkAA2xJfwA7fUJN9i7zdvvxJJ/wB5AkA+OKfnTXTp8qF4lZiVMrGl3d5sgg87q1DhC5XruviH6a3u6JOLlRNQy2+TGxzWMYaJ1RwEfygqBYOgyvoqNR3Q";
"a+bq+74tZAHWE2oKVaTSNCbkacXoqPRpzaCqCwyy61zeGExppfZBm8tf6AVAcL+58YF0Fuk+0N4ZaxAi2wx//GqqWQs+Rzt5VPJ+yaulAzs" +
"Eb0tW9o9Vc9VRxl8k0Fpi5Hj5J/pmLZrIj+FAgMBAAECgYAj+0A8rZ+sfsat2ORgDnDFp1hV+wEwVqIKsW3KdEpIT0S6vR7uhRPBkbXPAwU" +
"pnhNdoLa6JNXTDWs6XcgmzpSTx32WS3450+h1QNdLL+doiEinWxGijvp+UN7CadoeFBnLml3gGjPpTMeDheialQExwwvVKKe4+0VjO4zPDG" +
"nrAQJBAM3luGYrweNcFxvVsfQG6cpR/C0DeykyojN0Kbq+3/S+wG1y53Ak1HKz4OHftC4liYNXWy9W1fQ/MSbdVaSka+UCQQDAnJmYwmJ64" +
"I35T+GmgA0r505BCuYZG9pNyrjdko7n5+DaalRWSXuAwXb2SJbFHvWmVEgZOnVRhPdFgZUGP4shAkAjmG1SrInuhoMwOrdzGqbcZWQVXB60" +
"tp44CwMT19/b7gZSZaUBTDy2P8bHBeeeerrVTArlmjuO6EXVFDq0JgDJAkBLlCdhHcVu2fZbwdCVeOGyPI0kUJaBe8BpjgaESyHwNbixe8+" +
"kHCluGHwJn+opZ0CVB7VS0PGAD2DH0VUcooqBAkEAvLBZTnNcM/I2xbV6euw9gpEw7uLkT/94McLQOuZjKPWPHKDQOqa+y+CRPYuxIhQsFK" +
"mlTze7cR+/4QUANvGAow==";
private static final String charset = "UTF-8";
/** /**
* aes解密 * aes解密
* @param encrypt 内容 * @param encrypt 内容
...@@ -162,13 +160,41 @@ public class AESUtil { ...@@ -162,13 +160,41 @@ public class AESUtil {
return EncryptCreateUtil.dencrypt(data); return EncryptCreateUtil.dencrypt(data);
} }
public static String decrypt(String sSrc, String sKey, String siv) throws Exception {
try {
if (sSrc == null || sSrc.length() == 0) {
return null;
}
if (sKey == null) {
throw new Exception("decrypt key is null");
}
if (sKey.length() != 16) {
throw new Exception("decrypt key length error");
}
byte[] Decrypt = ByteFormat.hexToBytes(sSrc);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec skeySpec = new SecretKeySpec(sKey.getBytes(charset), "AES");
IvParameterSpec iv = new IvParameterSpec(siv.getBytes(charset));//new IvParameterSpec(getIV());
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);//使用解密模式初始化 密
return new String(cipher.doFinal(Decrypt), charset);
} catch (Exception ex) {
throw new Exception("decrypt errot", ex);
}
}
/** /**
* 测试 * 测试
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String KEY="zJJ$c5md3$yuuhWW"; String KEY="zJJ$c5md3$yuuhWW";
System.out.println("-------------加密---------"); System.out.println("-------------加密---------");
String content = "13024112588"; String content = "18709744120";
System.out.println("加密前:" + content); System.out.println("加密前:" + content);
System.out.println("加密密钥和解密密钥:" + KEY); System.out.println("加密密钥和解密密钥:" + KEY);
...@@ -178,33 +204,49 @@ public class AESUtil { ...@@ -178,33 +204,49 @@ public class AESUtil {
String decrypt = aesDecrypt(encrypt, KEY); String decrypt = aesDecrypt(encrypt, KEY);
System.out.println("解密后:" + decrypt); System.out.println("解密后:" + decrypt);
//请求参数解密处理
// String encrypt="DC7Sc7ydClKJztuIz/E/5fXuQ8hqdr4W8mxL/XACtqT2wzK3jBiRXnoPOvR9lANIinXInrdbY5rCIwTiI9DeWFiwPP7cSF0cjnQOY11oJLjVg9qV9VZQXbFyDYVhRv8bbto5hD4evryzbdPTq6A23fD5LmXFYnWKdbSzZfFUl/w=";
// String decrypt = RSAUtil.decrypt(encrypt,privateKey); // List<String> list = new ArrayList<>();
//
// String str="13330782565,13638247234,15208346780,13665702440,13171898394,13526001352,15637729989,18282702080,17839157550,13733479385,13873347938,18192022131,17868481983,13389208740,15130643581,18743289267,15025550691,18706903023,15153299810,13400213017,13400213014,13809393727,15082898689,15181524146,13067777147,15936327251,13982581989,13055116890,13183128853,13526235120,13620258773,13470126432,15379993781,15612968111,15930496256,13504498834,13328506266,13405379887,18636815186,18638124991,18997577751,18742986968,13737844850,15249387846,13890801202,18294832224,15329652816,13453947981,17393142302,18219810087,15031950900,18670808468,18670508468,18670508568,15566394123,18719884109,13789221826,13939497532,13939925847,13791830377,18919411543,18893835167,18194329526,13207866808,13082126549,15802548543,15879451129,15390381641,13132431383,18279911958,13827920609,15209825253,15509825253,18184482231,13325225232,15908034636,15352111767,18709744120,15807269519,19971489100,13721734937,13765575183,15329652819,13883396206,18085581329,15090694439,15090694436,13782477033,13207995156,13630682016,15607241351,13830780802";
// String[] arr = str.split(",");
// for (int i = 0; i < arr.length; i++) {
// String KEY="zJJ$c5md3$yuuhWW";
// System.out.println("-------------加密---------");
// String content = arr[i];
// System.out.println("加密前:" + content);
// System.out.println("加密密钥和解密密钥:" + KEY);
//
// System.out.println("-------------解密---------");
// String encrypt = aesEncrypt(content, KEY);
// System.out.println("加密后:" + encrypt);
// String decrypt = aesDecrypt(encrypt, KEY);
// System.out.println("解密后:" + decrypt);
// list.add(encrypt);
// }
//
// for (int i = 0; i < list.size(); i++) {
// System.out.println(list.get(i));
// }
// 请求参数解密处理
// String key="HSBPIMChYBYHKMb/wmq0dYIKnUU5UvlzeWrWkmxWUJ0RI2cgEf9jcISPHfLsJurCjj5xwTz6KjPnm0Z+ylaiVDpiLT55vKWHC0HnPqVePSR6Sn6cdaESDCMMGbNdJb+crnjvfTo0v4zQwqvjUJBDR9KRc5C3Dr07dITbPQbJXJk=";
// String decrypt = RSAUtil.decrypt(key,privateKey);
// System.out.println(decrypt); // System.out.println(decrypt);
// //System.out.println("YCPQPx4qpQjEjDea"); // String content="L/05P603DA9u/as3uHbzsF+LqYhfxJonT80u0oH0YobLCta/wR1xEH//NccyJlQ";
// String content="z9zZyUYwKkYy08l0s1qH9CSnoNnXZbbhHVbAUwGIsOXKPGeTkZFnbL1HYJQXBdKqGzKZt8E5lDzdTGUiUVkkK8GO27fsSrRMewY5T6ndSuo=";
// String result = AESUtil.aesDecrypt(content, decrypt); // String result = AESUtil.aesDecrypt(content, decrypt);
// System.out.println(result); // System.out.println(result);
// ArrayList<String> list = new ArrayList<>();
// int[] a = {99857217,99857231,99884890,99885124,99887349,99888816,99888820,99888821,99888822,99888830,99888831,99888837,99888842,99888847,99888851,99888855,99888860,99888867,99888876,99888879,99888884,99888896,99888897,99888900,99888901,99888923,99888930,99888943,99888983,99889000,99889032,99889043,99889046,99889104,99889142,99889158,99889165,99889177,99889184,99889218,99889230,99889236,99889250,99889304,99889380,99889401,99889426,99889435,99889508,99889510,99889538,99889719,99889723,99889731,99889922,99889931,99890029,99890043,99890137,99890152,99890157,99890163,99890237,99890461,99890473,99890485,99890495,99890656,99890658,99890662,99890663,99890670,99890774,99891395,99891410,99891424,99891432,99891439,99891480,99891517};
// for (int i = 0; i <a .length ; i++) {
// Integer id = a[i];
// list.add(EncryptUtils.encryptContent(id.toString(), EncryptConstants.ENCRYPT_TYPE_ID));
// }
// System.out.println(list.toArray());
} }
} }
package com.pica.cloud.account.account.server.util; package com.pica.cloud.account.account.server.util;
import com.alibaba.fastjson.JSONObject; import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.controller.AccountController;
import com.pica.cloud.account.account.server.entity.AccountPatientInfoEntity;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
...@@ -15,7 +11,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -15,7 +11,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
...@@ -23,102 +18,80 @@ import org.springframework.stereotype.Component; ...@@ -23,102 +18,80 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
public class AccountUtils { public class AccountUtils {
private Logger logger = LoggerFactory.getLogger(AccountUtils.class);
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient; private ICacheClient cacheClient;
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
private AccountPatientInfoMapper accountPatientInfoMapper;
@Autowired @Autowired
private DoctorMapper doctorInfoMapper; private DoctorMapper doctorInfoMapper;
private static final String AUTH_CODE_PREFIX = "authCode-"; //手机非空和格式校验
private static final String AUTH_CODE_COUNT_PREFIX = "authCode-count-";
//手机格式校验
public static void checkMobilePhone(String mobilePhone) { public static void checkMobilePhone(String mobilePhone) {
if (StringUtils.isBlank(mobilePhone) || !ValidateUtils.isMobile(mobilePhone)) { if (StringUtils.isBlank(mobilePhone) || !ValidateUtils.isMobile(mobilePhone)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
} }
} }
//手机格式校验 //密码非空判断
public static void checkPassword(String password) { public static void checkPassword(String password) {
if (StringUtils.isBlank(password)) { if (StringUtils.isBlank(password)) {
throw new PicaException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), AccountExceptionEnum.PICA_NOT_EMPTY.getMessage()); throw new PicaException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), AccountExceptionEnum.PICA_NOT_EMPTY.getMessage());
} }
} }
public static boolean checkPasswordRule(String password){
String regex = "^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,16})$";
boolean pass = password.matches(regex);
if(password.length() < 6 || password.length() > 16 || !pass){
return false;
}
return true;
}
//获取验证码redis key //获取验证码redis key
public static String getAuthCodeKey(String mobilePhone, String flag) { public String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone); return Constants.AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone);
} }
//校验验证码 //手机号和验证码校验
public void checkAuthCode(String mobile, String type, String sysCode) { public void checkMobilePhoneAndAuthCode(String mobile, String type, String sysCode) {
if (StringUtils.isBlank(mobile) || !ValidateUtils.isMobile(mobile)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
}
String flag = org.apache.commons.lang.StringUtils.isBlank(type) ? "0" : type; String flag = org.apache.commons.lang.StringUtils.isBlank(type) ? "0" : type;
if (org.apache.commons.lang.StringUtils.isBlank(sysCode)) { if (org.apache.commons.lang.StringUtils.isBlank(sysCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
} }
String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag); String authCodeKey = getAuthCodeKey(mobile, flag);
logger.info("验证码缓存信息----->:" + this.getAuthCodeKey(mobile, flag));
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码 String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码
if (org.apache.commons.lang.StringUtils.isBlank(cacheCode)) {
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取");
}
if (!org.apache.commons.lang.StringUtils.equals(sysCode, cacheCode)) { if (!org.apache.commons.lang.StringUtils.equals(sysCode, cacheCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "验证码错误,请重新输入");
} }
//清除验证码
cacheClient.del(authCodeKey); cacheClient.del(authCodeKey);
} }
//手机号和验证码校验
public void checkMobilePhoneAndAuthCode(String mobile, String type, String sysCode) { public void checkRegisterMobilePhoneAndAuthCode(String mobile, String type, String sysCode) {
if (StringUtils.isBlank(mobile) || !ValidateUtils.isMobile(mobile)) { if (StringUtils.isBlank(mobile) || !ValidateUtils.isMobile(mobile)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
} }
String flag = org.apache.commons.lang.StringUtils.isBlank(type) ? "0" : type;
if (org.apache.commons.lang.StringUtils.isBlank(sysCode)) { if (org.apache.commons.lang.StringUtils.isBlank(sysCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码为空");
} }
String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag); String authCodeKey = RegisterCodeKeyUtils.getRegisterKey(mobile, sysCode);
//验证码3次校验测试不通过,直接删除 Long num = cacheClient.decr(authCodeKey);
String authCodeCount = AUTH_CODE_COUNT_PREFIX + flag + "-" + AESUtil.encryptV0(mobile); logger.info("success" + num);
if (num <= -1) {
logger.info("验证码缓存信息----->:"+this.getAuthCodeKey(mobile, flag)); throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "验证码错误,请重新输入");
if (cacheClient.exists(authCodeCount) && Integer.parseInt(cacheClient.get(authCodeCount)) > 2) {
cacheClient.del(authCodeKey);
} }
if (num > 0 && num < 99) {
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码 throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "您已注册成功,请直接登录");
if (org.apache.commons.lang.StringUtils.isBlank(cacheCode)) {
//第四次删除计数器
cacheClient.del(authCodeCount);
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已失效,请重新获取");
}
if (!org.apache.commons.lang.StringUtils.equals(sysCode, cacheCode)) {
cacheClient.incr(authCodeCount);
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
} }
//验证成功以后删除验证码
cacheClient.del(authCodeKey); cacheClient.del(authCodeKey);
}
/**
* 请求参数解密、反序列化
*
* @param params
* @param zClass
* @param <T>
* @return
*/
public static <T> T getRequestEntity(String params, Class<T> zClass) throws Exception {
String json = AESUtil.decryptV0(params);
return JSONObject.parseObject(json, zClass);
} }
/** /**
...@@ -153,25 +126,7 @@ public class AccountUtils { ...@@ -153,25 +126,7 @@ public class AccountUtils {
* @return * @return
*/ */
public Long getUserIdByAcctId(Integer productType, Integer AcctId) { public Long getUserIdByAcctId(Integer productType, Integer AcctId) {
Long userId = null; return doctorInfoMapper.selectUserIdByAcctId(AcctId);
if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
userId = doctorInfoMapper.selectUserIdByAcctId(AcctId);
} else if (productType == AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
AccountPatientInfoEntity accountPatientInfoEntity = accountPatientInfoMapper.selectByAcctId(AcctId);
userId = accountPatientInfoEntity.getId().longValue();
}
return userId;
} }
/**
* 校验手机号是否注册过
*
* @param mobile
*/
// public boolean checkRegisterMobile(String mobile) {
// String encrypt = AESUtil.encryptV0(mobile);
// AccountContact accountContact = accountContactServer.selectByMobile(encrypt);
// return (accountContact != null && accountContact.getAcctId() != null);
// }
} }
package com.pica.cloud.account.account.server.util;
public final class Base64 {
/**
* Base64编码表。
*/
private static final char[] BASE64CODE = { 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', '+', '/', };
/**
* Base64解码表。
*/
private static final byte[] BASE64DECODE = { -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1,
-1,
-1, // 注意两个63,为兼容SMP,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 63,
-1,
63, // “/”和“-”都翻译成63。
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, // 注意两个0:
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1,
-1, // “A”和“=”都翻译成0。
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, };
private static final int HEX_255 = 0x0000ff;
private static final int HEX_16515072 = 0xfc0000;
private static final int HEX_258048 = 0x3f000;
private static final int HEX_4032 = 0xfc0;
private static final int HEX_63 = 0x3f;
private static final int HEX_16711680 = 0xff0000;
private static final int HEX_65280 = 0x00ff00;
private static final int NUMBER_TWO = 2;
private static final int NUMBER_THREE = 3;
private static final int NUMBER_FOUR = 4;
private static final int NUMBER_SIX = 6;
private static final int NUMBER_EIGHT = 8;
private static final int NUMBER_TWELVE = 12;
private static final int NUMBER_SIXTEEN = 16;
private static final int NUMBER_EIGHTEEN = 18;
/**
* 构造方法私有化,防止实例化。
*/
private Base64() {
}
/**
* Base64编码。将字节数组中字节3个一组编码成4个可见字符。
*
* @param b
* 需要被编码的字节数据。
* @return 编码后的Base64字符串。
*/
public static String encode(byte[] b) {
int code = 0;
// 按实际编码后长度开辟内存,加快速度
StringBuffer sb = new StringBuffer(
((b.length - 1) / NUMBER_THREE) << NUMBER_TWO + NUMBER_FOUR);
// 进行编码
for (int i = 0; i < b.length; i++) {
code |= (b[i] << (NUMBER_SIXTEEN - i % NUMBER_THREE * NUMBER_EIGHT))
& (HEX_255 << (NUMBER_SIXTEEN - i % NUMBER_THREE
* NUMBER_EIGHT));
if (i % NUMBER_THREE == NUMBER_TWO || i == b.length - 1) {
sb.append(BASE64CODE[(code & HEX_16515072) >>> NUMBER_EIGHTEEN]);
sb.append(BASE64CODE[(code & HEX_258048) >>> NUMBER_TWELVE]);
sb.append(BASE64CODE[(code & HEX_4032) >>> NUMBER_SIX]);
sb.append(BASE64CODE[code & HEX_63]);
code = 0;
}
}
// 对于长度非3的整数倍的字节数组,编码前先补0,编码后结尾处编码用=代替,
// =的个数和短缺的长度一致,以此来标识出数据实际长度
if (b.length % NUMBER_THREE > 0) {
sb.setCharAt(sb.length() - 1, '=');
}
if (b.length % NUMBER_THREE == 1) {
sb.setCharAt(sb.length() - NUMBER_TWO, '=');
}
return sb.toString();
}
/**
* Base64解码。
*
* @param code
* 用Base64编码的ASCII字符串
* @return 解码后的字节数据
*/
public static byte[] decode(String code) {
// 检查参数合法性
if (code == null) {
return null;
}
int len = code.length();
if (len % NUMBER_FOUR != 0) {
throw new IllegalArgumentException(
"Base64 string length must be 4*n");
}
if (code.length() == 0) {
return new byte[0];
}
// 统计填充的等号个数
int pad = 0;
if (code.charAt(len - 1) == '=') {
pad++;
}
if (code.charAt(len - NUMBER_TWO) == '=') {
pad++;
}
// 根据填充等号的个数来计算实际数据长度
int retLen = len / NUMBER_FOUR * NUMBER_THREE - pad;
// 分配字节数组空间
byte[] ret = new byte[retLen];
// 查表解码
char ch1, ch2, ch3, ch4;
int i;
for (i = 0; i < len; i += NUMBER_FOUR) {
int j = i / NUMBER_FOUR * NUMBER_THREE;
ch1 = code.charAt(i);
ch2 = code.charAt(i + 1);
ch3 = code.charAt(i + NUMBER_TWO);
ch4 = code.charAt(i + NUMBER_THREE);
int tmp = (BASE64DECODE[ch1] << NUMBER_EIGHTEEN)
| (BASE64DECODE[ch2] << NUMBER_TWELVE)
| (BASE64DECODE[ch3] << NUMBER_SIX) | (BASE64DECODE[ch4]);
ret[j] = (byte) ((tmp & HEX_16711680) >> NUMBER_SIXTEEN);
if (i < len - NUMBER_FOUR) {
ret[j + 1] = (byte) ((tmp & HEX_65280) >> NUMBER_EIGHT);
ret[j + NUMBER_TWO] = (byte) ((tmp & HEX_255));
} else {
if (j + 1 < retLen) {
ret[j + 1] = (byte) ((tmp & HEX_65280) >> NUMBER_EIGHT);
}
if (j + NUMBER_TWO < retLen) {
ret[j + NUMBER_TWO] = (byte) ((tmp & HEX_255));
}
}
}
return ret;
}
}
package com.pica.cloud.account.account.server.util;
/**
* 格式化操作类
*/
public class ByteFormat {
private static final char[] HEX = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public ByteFormat() {
}
public static final String bytesToHexString(byte[] bArray) {
StringBuffer sb = new StringBuffer(bArray.length);
for (int i = 0; i < bArray.length; ++i) {
String sTemp = Integer.toHexString(255 & bArray[i]);
if (sTemp.length() < 2) {
sb.append(0);
}
sb.append(sTemp.toUpperCase());
}
return sb.toString();
}
public static byte[] hexToBytes(String str) {
if (str == null) {
return null;
} else {
char[] hex = str.toCharArray();
int length = hex.length / 2;
byte[] raw = new byte[length];
for (int i = 0; i < length; ++i) {
int high = Character.digit(hex[i * 2], 16);
int low = Character.digit(hex[i * 2 + 1], 16);
int value = high << 4 | low;
if (value > 127) {
value -= 256;
}
raw[i] = (byte) value;
}
return raw;
}
}
public static void main(String[] args) {
byte[] data = new byte[65536];
for (int i = 0; i < data.length; ++i) {
data[i] = (byte) i;
}
}
}
package com.pica.cloud.account.account.server.util; package com.pica.cloud.account.account.server.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.req.BaseRequest;
import java.util.HashMap;
import java.util.Map;
/** /**
...@@ -32,6 +35,29 @@ public class CryptoUtil { ...@@ -32,6 +35,29 @@ public class CryptoUtil {
// return encryptEntity; // return encryptEntity;
// } // }
public static void aa(String data) throws Exception{
//1、产生AES密钥
String keyString = "1234567890123456";
//2、用AES法加密数据
String content = AESUtil.aesEncrypt(data, keyString);
//3、用RSA加密AES密钥
String finalKey = RSAUtil.encrypt(keyString);
Map<String, Object> param = new HashMap<>(2);
param.put("key", finalKey);
param.put("content", content);
System.out.println(JSON.toJSONString(param));
}
public static void main(String[] args) throws Exception {
Map<String, Object> param = new HashMap<>(6);
param.put("identifyToken", "eyJraWQiOiI4NkQ4OEtmIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLnl1bnF1ZXlpLkRvY3RvciIsImV4cCI6MTU4MjcwMjg1NCwiaWF0IjoxNTgyNzAyMjU0LCJzdWIiOiIwMDExMzAuMmI4NzE0NjVmZDFmNDVmZmFmNWRjMjg3ZTQ4OWVlZjEuMDMxNSIsImNfaGFzaCI6InBpYjJScFAyc2U1eFJ4VlM1a0NRUlEiLCJlbWFpbCI6IjdnZ2E1cmo1dGNAcHJpdmF0ZXJlbGF5LmFwcGxlaWQuY29tIiwiZW1haWxfdmVyaWZpZWQiOiJ0cnVlIiwiaXNfcHJpdmF0ZV9lbWFpbCI6InRydWUiLCJhdXRoX3RpbWUiOjE1ODI3MDIyNTQsIm5vbmNlX3N1cHBvcnRlZCI6dHJ1ZX0.bLpPuyD_UJ2Pi7O2QSYSmUKy8wfssLdgOU3lztokJ-FVfTC7N_I183lyVW2C0BWRZURtGtUeqJRqEeKyMapPzgPd98PMOJn5wly_sTxSXKExR62gzcYmk0yY1rFYiiBsj9cbqvzUrqOlFvCi-h52MyimojK2XQx4DSvY69btjmdA0trjneH0HGmvvWGkU8jr1hv0ZkfD4WRAMA2AkeN8fbGHnnY6-_B0a6l_q_Id9eIWTqR2brDfrFGg7FZq_tc6hAC_Lrv6SvceD7UTk-MOXvBjzDrqqKVD-iP0pqyzyW1DjawG3AQuZRLIFN-qaYRzVMotdPeLxUqWEUDGriV9hg");
//param.put("weChatLoginType", 1);
//param.put("weChatCode", "071KMzjM1ge35a1oDekM1zptjM1KMzjO");
aa(JSON.toJSONString(param));
}
/** /**
* 解密数据 * 解密数据
* *
......
package com.pica.cloud.account.account.server.util;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.foundation.utils.utils.HttpClientUtil;
import com.pica.cloud.foundation.utils.utils.StringUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.Map;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-12 17:45
*/
public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(HttpClientUtil.class);
private static final CloseableHttpClient hc;
static {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setDefaultMaxPerRoute(20);
cm.setMaxTotal(200);
hc = HttpClients.custom().setConnectionManager(cm).build();
}
public static <T> T postForm(String url, Map<String, String> params, Class<T> clazz) throws IOException, URISyntaxException {
URIBuilder builder = new URIBuilder(url);
if (params != null && params.size() > 0) {
params.forEach((k, v) -> {
builder.setParameter(k, v);
});
}
HttpPost post = new HttpPost(builder.build());
CloseableHttpResponse resp = null;
T data;
try {
resp = hc.execute(post);
String buf = IOUtils.toString(resp.getEntity().getContent(), "utf-8");
data = StringUtil.isNotNull(buf) ? JSON.parseObject(buf, clazz) : null;
} finally {
if (resp != null) {
try {
resp.close();
} catch (IOException var12) {
logger.error(var12.getMessage());
}
}
}
return data;
}
}
package com.pica.cloud.account.account.server.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
public class IPUtil {
private static Logger logger = LoggerFactory.getLogger(IPUtil.class);
/**
* @Description 获取请求的外网ip
* @Author Chongwen.jiang
* @Date 2020/2/25 9:34
* @ModifyDate 2020/2/25 9:34
* @Params [request]
* @Return java.lang.String
*/
public static String getIpAdrress(HttpServletRequest request) {
String ip = null;
//X-Forwarded-For:Squid 服务代理
String ipAddresses = request.getHeader("X-Forwarded-For");
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
//打印所有头信息
String s = headerNames.nextElement();
String header = request.getHeader(s);
// System.out.println(s+"::::"+header);
}
// System.out.println("headerNames:"+ JSON.toJSONString(headerNames));
// System.out.println("RemoteHost:"+request.getRemoteHost());
// System.out.println("RemoteAddr:"+request.getRemoteAddr());
String unknown = "unknown";
if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) {
//Proxy-Client-IP:apache 服务代理
ipAddresses = request.getHeader("Proxy-Client-IP");
}
if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) {
//WL-Proxy-Client-IP:weblogic 服务代理
ipAddresses = request.getHeader("WL-Proxy-Client-IP");
}
if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) {
//HTTP_CLIENT_IP:有些代理服务器
ipAddresses = request.getHeader("HTTP_CLIENT_IP");
}
if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) {
//X-Real-IP:nginx服务代理
ipAddresses = request.getHeader("X-Real-IP");
}
//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
if (ipAddresses != null && ipAddresses.length() != 0) {
ip = ipAddresses.split(",")[0];
}
//还是不能获取到,最后再通过request.getRemoteAddr();获取
if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) {
ip = request.getRemoteAddr();
}
if("0:0:0:0:0:0:0:1".equalsIgnoreCase(ip)){
ip = "127.0.0.1";
}
return ip;
}
}
package com.pica.cloud.account.account.server.util;
import java.security.MessageDigest;
public class MD5 {
// 全局数组
private final static String[] strDigits = { "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f","g","h","j","?","~" };
// 返回形式为数字跟字符串
private static String byteToArrayString(byte bByte) {
int iRet = bByte;
if (iRet < 0) {
iRet += 256;
}
int iD1 = iRet / 16;
int iD2 = iRet % 16;
return strDigits[iD1] + strDigits[iD2];
}
// 转换字节数组为16进制字串
private static String byteToString(byte[] bByte) {
StringBuffer sBuffer = new StringBuffer();
for (int i = 0; i < bByte.length; i++) {
sBuffer.append(byteToArrayString(bByte[i]));
}
return sBuffer.toString();
}
public static String getMD5Code(String strObj) {
String resultString = null;
try {
resultString = new String(strObj);
MessageDigest md = MessageDigest.getInstance("MD5");
// md.digest() 该函数返回值为存放哈希值结果的byte数组
resultString = byteToString(md.digest(strObj.getBytes("UTF-8")));
} catch (Exception ex) {
ex.printStackTrace();
}
return resultString;
}
}
package com.pica.cloud.account.account.server.util; package com.pica.cloud.account.account.server.util;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeReq;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.OneClickLoginReq;
import org.apache.tomcat.util.codec.binary.Base64; import org.apache.tomcat.util.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.security.*; import java.security.*;
import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
...@@ -16,7 +21,6 @@ import java.security.spec.X509EncodedKeySpec; ...@@ -16,7 +21,6 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* RSA加解密工具类 * RSA加解密工具类
*/ */
...@@ -37,8 +41,28 @@ public class RSAUtil { ...@@ -37,8 +41,28 @@ public class RSAUtil {
public void init() { public void init() {
RSAUtil.rsaprivatekey = rsaprivatekeyTemp; RSAUtil.rsaprivatekey = rsaprivatekeyTemp;
RSAUtil.rsapublickey = rsapublickeyTemp; RSAUtil.rsapublickey = rsapublickeyTemp;
// prd 配置
// RSAUtil.rsapublickey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnVzDlG6DJBwTsn7jFriKOmzqfm+d4vy6DtKqMfrEPg6hU3bfbR9XRfwqAFrS4+QowybpuyWCa7DFyKl0JyEa/GSrfjbXSpalFHhmWH0z0hCF1m/UvlPA0BaiYFy9ucXF9Uh8RaHkZGVmV+RbVISk4pjlZdRcK5EQ5hciBFGtgGwIDAQAB";
// RSAUtil.rsaprivatekey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAKdXMOUboMkHBOyfuMWuIo6bOp+b53i/LoO0qox+sQ+DqFTdt9tH1dF/CoAWtLj5CjDJum7JYJrsMXIqXQnIRr8ZKt+NtdKlqUUeGZYfTPSEIXWb9S+U8DQFqJgXL25xcX1SHxFoeRkZWZX5FtUhKTimOVl1FwrkRDmFyIEUa2AbAgMBAAECgYEAlEZHxtoiL74OePRVrqNLb3zQBxkHkxAj0QPGktK3ZP3Nq9UB0kTmisi8rx5vZ+8TPoOgtAWvmdZrQbOT2NUjCUYKkGS+Wi1fXpP0Az2UJwDIQK4aQTZtNbM04f3Rmi5i24eASmSdl1svjHEv0YS6IC6sR1cbElZs94uDFshUeqECQQDTrmZda8fo6ZNsHVYWcjTwr8JKTIgjaD/hPi0JP6hhL0GVEAVwb2rsfJf5o2TR5RsNT8ANUYgFPRaAymLLe+5zAkEAymA9V55K6IJhnSp7HmWfGVmxvTrwZFJIzPv7DLi/RAS3yFPfTpyJGLirAnBQfKO/vwjxhAuwD21aDYHMTrj1uQJBAJdAikw+cz1tiLU70QOA32sLaxyDytLh7qMXNj7hiYLHrWjBZeGM+y23aTArHCMOPWIpleTuWO7FU4r7EdSr3RkCQQCliu4CwyhRY33H210U81memgFLYnAMEEce7qxgrqs+T4Gqa/lJy8BVqZGxkAA2xJfwA7fUJN9i7zdvvxJJ/wB5AkA+OKfnTXTp8qF4lZiVMrGl3d5sgg87q1DhC5XruviH6a3u6JOLlRNQy2+TGxzWMYaJ1RwEfygqBYOgyvoqNR3Q";
} }
/**
* 加密算法RSA
*/
public static final String KEY_ALGORITHM = "RSA";
/**
* RSA最大加密明文大小
*/
private static final int MAX_ENCRYPT_BLOCK = 117;
/**
* RSA最大解密密文大小
*/
private static final int MAX_DECRYPT_BLOCK = 128;
/** /**
* 加密方法 * 加密方法
* *
...@@ -121,9 +145,102 @@ public class RSAUtil { ...@@ -121,9 +145,102 @@ public class RSAUtil {
return outStr; return outStr;
} }
/**
* 私钥解密
*
* @param encryptedStr 已加密数据
* @param privateKey 私钥(BASE64编码)
* @return
* @throws Exception
*/
public static String decryptByPrivateKeyForLongStr(String encryptedStr, String privateKey) throws Exception {
byte[] encryptedData = ByteFormat.hexToBytes(encryptedStr);
byte[] keyBytes = com.pica.cloud.account.account.server.util.Base64.decode(privateKey);
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
cipher.init(Cipher.DECRYPT_MODE, privateK);
int inputLen = encryptedData.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
// 对数据分段解密
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
} else {
cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_DECRYPT_BLOCK;
}
byte[] decryptedData = out.toByteArray();
out.close();
return new String(decryptedData);
}
// 获取验证码-加密
public static EncryptEntity getAuthCodeEncrypt(AesAuthCodeReq req){
BaseRequest authCode = new BaseRequest();
authCode.setFlag(req.getFlag() == null ? 0 : req.getFlag());
authCode.setMobile(req.getMobile());
authCode.setDevice_token(req.getDevice_token());
authCode.setBizType(req.getBizType());
authCode.setPassword(req.getPassword());
authCode.setAuthCode(req.getAuthCode());
String authCodeStr = JSONObject.toJSONString(authCode);
// System.out.println(authCodeStr);
String contentResult = null;
try {
contentResult = AESUtil.aesEncrypt(authCodeStr, "YCPQPx4qpQjEjDea");
} catch (Exception e) {
e.printStackTrace();
}
String keyResult = null;
try {
keyResult = RSAUtil.encrypt("YCPQPx4qpQjEjDea",rsapublickey);
} catch (Exception e) {
e.printStackTrace();
}
EncryptEntity encryptTest = new EncryptEntity();
encryptTest.setContent(contentResult);
encryptTest.setKey(keyResult);
return encryptTest;
// System.out.println(JSONObject.toJSONString(encryptTest2));
}
// oneclick-加密
public static EncryptEntity getOneClickEncrypt(AesAuthCodeReq req){
OneClickLoginReq oneReq = new OneClickLoginReq();
oneReq.setToken(req.getToken());
String authCodeStr = JSONObject.toJSONString(oneReq);
// System.out.println(authCodeStr);
String contentResult = null;
try {
contentResult = AESUtil.aesEncrypt(authCodeStr, "YCPQPx4qpQjEjDea");
} catch (Exception e) {
e.printStackTrace();
}
String keyResult = null;
try {
keyResult = RSAUtil.encrypt("YCPQPx4qpQjEjDea",rsapublickey);
} catch (Exception e) {
e.printStackTrace();
}
EncryptEntity encryptTest = new EncryptEntity();
encryptTest.setContent(contentResult);
encryptTest.setKey(keyResult);
return encryptTest;
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//生成公钥和私钥 //生成公钥和私钥
//genKeyPair(); // genKeyPair();
// keyMap.put(0, publicKey); // keyMap.put(0, publicKey);
// keyMap.put(1, privateKey); // keyMap.put(1, privateKey);
// //加密字符串 // //加密字符串
...@@ -136,12 +253,16 @@ public class RSAUtil { ...@@ -136,12 +253,16 @@ public class RSAUtil {
// System.out.println("还原后的字符串为:" + messageDe); // System.out.println("还原后的字符串为:" + messageDe);
genKeyPair(); genKeyPair();
String s = keyMap.get(0); String publicKey = keyMap.get(0);
System.out.println(s); System.out.println(publicKey);
String s1 = keyMap.get(1); String privateKey = keyMap.get(1);
System.out.println(s1); System.out.println(privateKey);
String messageEn = encrypt("{\"bizType\":1,\"device_token\":\"120c83f760bd0420c78\",\"mobile\":\"17868481983\",\"flag\":0}", publicKey);
System.out.println(messageEn);
String key1 = ""; String encryptMsg = "{\"key\":\"n2MyzrptkOsYE5c0lDn+5HU8x22DJTT49uad0+zeTt4Nj6RDrv3mJzKcc8LweYF5D7i4o812h9Gwn4drGJP+9Y8UOLNNRMx4+Au/V3TqOQFjve4jfUV8aewJK9Mildvsdk71ITe4YWd+8pQjuaQ4EkgAziFWEEuKiNnTEZjO8mE=\",\"content\":\"IRwE4SYrDk5RVpyycJy86n8Bu85FuQWt0Xb6wW+ITKObah0pkxKym+xwRwHMwMm5+UPmqNYhLsu5Dt39N14ZduwNDbktRaoAzvU6BHkdX4bWbkrPB7tw71J9k9zy7O/zaAzgo3SLUlj/xWB3KuOKcg==\"}";
System.out.println(decrypt(encryptMsg,privateKey));
String key2 = ""; String key2 = "";
......
package com.pica.cloud.account.account.server.util;
import com.pica.cloud.account.account.server.constants.Constants;
/**
* Created on 2020/1/9 16:18
* author:crs
* Description:注册验证码的key规则
*/
public class RegisterCodeKeyUtils {
/**
* 获取注册验证码的key
*
* @param mobilePhone
* @param authCode
* @return
*/
public static String getRegisterKey(String mobilePhone, String authCode) {
return Constants.AUTH_CODE_PREFIX + AESUtil.encryptV0(mobilePhone) +"-"+ authCode;
}
}
package com.pica.cloud.account.account.server.util;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Arrays;
import java.util.Map;
/**
* Description:签名工具类
* User: liutao
* Date: 2019-09-11
* Time: 10:29
*/
public class SignUtils {
public static String getSign(Map<String, String> requestMap, String appKey) {
return hmacSHA256Encrypt(requestMap2Str(requestMap), appKey);
}
private static String hmacSHA256Encrypt(String encryptText, String encryptKey) {
byte[] result = null;
try {
//根据给定的字节数组构造一个密钥,第二参数指定一个密钥算法的名称
SecretKeySpec signinKey = new SecretKeySpec(encryptKey.getBytes("UTF-8"), "HmacSHA256");
//生成一个指定 Mac 算法 的 Mac 对象
Mac mac = Mac.getInstance("HmacSHA256");
//用给定密钥初始化 Mac 对象
mac.init(signinKey);
//完成 Mac 操作
byte[] rawHmac = mac.doFinal(encryptText.getBytes("UTF-8"));
return ByteFormat.bytesToHexString(rawHmac);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static String requestMap2Str(Map<String, String> requestMap) {
String[] keys = requestMap.keySet().toArray(new String[0]);
Arrays.sort(keys);
StringBuilder stringBuilder = new StringBuilder();
for (String str : keys) {
if (!str.equals("sign")) {
stringBuilder.append(str).append(requestMap.get(str));
}
}
return stringBuilder.toString();
}
}
package com.pica.cloud.account.account.server.util; package com.pica.cloud.account.account.server.util;
import com.pica.cloud.account.account.server.entity.Account; import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.HashMap;
...@@ -20,13 +23,13 @@ import java.util.UUID; ...@@ -20,13 +23,13 @@ import java.util.UUID;
*/ */
@Component @Component
public class TokenUtils { public class TokenUtils {
private Logger logger = LoggerFactory.getLogger(this.getClass()); private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired @Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient; private ICacheClient cacheClient;
@Autowired
private DoctorMapper doctorMapper;
/** /**
* 校验token的状态 * 校验token的状态
...@@ -39,6 +42,55 @@ public class TokenUtils { ...@@ -39,6 +42,55 @@ public class TokenUtils {
return StringUtils.isBlank(str); return StringUtils.isBlank(str);
} }
/**
* @Description token续时
* @Author Chongwen.jiang
* @Date 2020/2/26 13:07
* @ModifyDate 2020/2/26 13:07
* @Params [token, sourceType]
* @Return boolean
*/
public boolean tokenContinueTime(String token, Integer sourceType, Integer seconds) {
logger.info("tokenContinueTime-token-{}, sourceType-{}, seconds-{}", token, sourceType, seconds);
// 非游客token才去执行token续时代码
Map<String, String> map = cacheClient.getToken(token);
if (!CollectionUtils.isEmpty(map)) {
String id = map.get("id");
logger.info("tokenContinueTime-start-userId-{}", id);
if (StringUtils.isNotEmpty(id) && Integer.parseInt(id) > 0) {
// 根据不同的产品线设置token有效期(web/admin token有效期30天,ios/android/h5 token有效期24小时)
int expiredSeconds = 24 * 60 * 60;
if (!SourceTypeEnum.SAAS.getCode().equals(sourceType) &&
!SourceTypeEnum.ADMIN.getCode().equals(sourceType)) {
expiredSeconds = expiredSeconds * 30;
}
String sourceTypeRedis = AccountUtils.getSourceType(sourceType);
String key = "token-" + token;
// value = "token-doctor-{doctorId}";
if (!cacheClient.exists(key)) {
logger.info("tokenContinueTime-key not exists");
return false;
}
String value = cacheClient.get(key);
if (!cacheClient.exists(value + "-" + sourceTypeRedis)) {
logger.info("tokenContinueTime-value not exists");
return false;
}
try {
cacheClient.set(key, value, expiredSeconds);
cacheClient.set(value + "-" + sourceTypeRedis, key, expiredSeconds);
return true;
} catch (Exception e) {
logger.error("tokenContinueTime-Exception-{}" + e.getMessage(), e);
return false;
}
}
}
return false;
}
/** /**
* 获取新的token * 获取新的token
* *
...@@ -49,8 +101,14 @@ public class TokenUtils { ...@@ -49,8 +101,14 @@ public class TokenUtils {
Integer registerSource = account.getRegisterSource(); Integer registerSource = account.getRegisterSource();
String newToken = ""; String newToken = "";
try { try {
//用户id //先清除旧token
String value = "token-doctor-" + account.getId().toString(); String value = "token-doctor-" + account.getId().toString();
String sourceType = AccountUtils.getSourceType(registerSource);
String oldToken = cacheClient.get(value + "-"+sourceType);
if (StringUtils.isNotBlank(oldToken)) {
Long del = cacheClient.del(oldToken);
logger.info("num:---->"+del);
}
// 根据不同的产品线设置token有效期 // 根据不同的产品线设置token有效期
int expiredSeconds = 24 * 60 * 60; int expiredSeconds = 24 * 60 * 60;
if (registerSource != 3 && registerSource != 5) { if (registerSource != 3 && registerSource != 5) {
...@@ -61,19 +119,42 @@ public class TokenUtils { ...@@ -61,19 +119,42 @@ public class TokenUtils {
//存储token对应的用户id,数据结构如:(token-FF9FCB0D93A642328A01C279701B7607:token-doctor-1) //存储token对应的用户id,数据结构如:(token-FF9FCB0D93A642328A01C279701B7607:token-doctor-1)
cacheClient.set(Key, value, expiredSeconds); cacheClient.set(Key, value, expiredSeconds);
//存储不同终端对应的token,数据结构如:(token-doctor-12345678-app:token-FF9FCB0D93A642328A01C279701B7607) //存储不同终端对应的token,数据结构如:(token-doctor-12345678-app:token-FF9FCB0D93A642328A01C279701B7607)
String sourceType = AccountUtils.getSourceType(registerSource); //String sourceType = AccountUtils.getSourceType(registerSource);
cacheClient.set(value + "-" + sourceType, Key, expiredSeconds); cacheClient.set(value + "-" + sourceType, Key, expiredSeconds);
//用户数据放入redis缓存
String userData = cacheClient.hget(value, "id");
if (org.apache.commons.lang3.StringUtils.isEmpty(userData)) {
Map<String, String> data = new HashMap<>(); Map<String, String> data = new HashMap<>();
data.put("token", newToken); data.put("token", newToken);
data.put("id", account.getId() + ""); data.put("id", account.getId() + "");
data.put("acctId", account.getAcctId() + ""); data.put("acctId", account.getAcctId() + "");
data.put("mobile", account.getMobilePhone()); if (!StringUtils.isBlank(account.getMobilePhone())) {
data.put("mobile", AESUtil.encryptV0(account.getMobilePhone()));
} else {
data.put("mobile", "");
}
data.put("name", account.getMobilePhone().replaceAll("(\\d{3})\\d{4}(\\w{4})", "$1****$2")); data.put("name", account.getMobilePhone().replaceAll("(\\d{3})\\d{4}(\\w{4})", "$1****$2"));
data.put("created_time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(account.getCreatTime())); data.put("created_time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(account.getCreatTime()));
data.put("sysCode", sourceType); data.put("sysCode", sourceType);
if (account.getId() != null) {
Doctor doctor = doctorMapper.selectByPrimaryKey(account.getId().intValue());
data.put("avatar_image_url", doctor.getAvatarImageUrl() + "");
data.put("town_id", doctor.getTown() + "");
data.put("town_name", doctor.getTownName() + "");
data.put("county_id", doctor.getCounty() + "");
data.put("county_name", doctor.getCountyName() + "");
data.put("city_id", doctor.getCity() + "");
data.put("city_name", doctor.getCityName() + "");
data.put("province_id", doctor.getProvince() + "");
data.put("province_name", doctor.getProvinceName() + "");
data.put("hospital", doctor.getHospital() + "");
data.put("hospital_id", doctor.getHospitalId() + "");
data.put("department", doctor.getDepartment() + "");
data.put("department_id", doctor.getDepartmentId() + "");
data.put("title", doctor.getTitle() + "");
data.put("title_id", doctor.getTitleId() + "");
data.put("status", doctor.getStatus() + "");
if (!StringUtils.isBlank(doctor.getName())){
data.put("name", doctor.getName() + "");
}
}
Iterator<Map.Entry<String, String>> iterator = data.entrySet().iterator(); Iterator<Map.Entry<String, String>> iterator = data.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, String> map = iterator.next(); Map.Entry<String, String> map = iterator.next();
...@@ -82,9 +163,9 @@ public class TokenUtils { ...@@ -82,9 +163,9 @@ public class TokenUtils {
//存储token:(token-doctor-1:用户数据) //存储token:(token-doctor-1:用户数据)
cacheClient.hset(value, key, valueInfo); cacheClient.hset(value, key, valueInfo);
} }
} else { // } else {
cacheClient.hset(value, "token", newToken); // cacheClient.hset(value, "token", newToken);
} // }
} catch (Exception ex) { } catch (Exception ex) {
logger.error("生成token异常:{}" + ex.getMessage(), ex); logger.error("生成token异常:{}" + ex.getMessage(), ex);
} }
......
package com.pica.cloud.account.account.server.vo;
import com.pica.cloud.account.account.server.entity.QueryMobileEntity;
/**
* @program: pica-cloud-account
* @description:
* @author: wfy
* @create: 2020-02-12 16:01
*/
public class OneClickLoginResultVo {
private QueryMobileEntity queryMobileEntity;
public QueryMobileEntity getQueryMobileEntity() {
return queryMobileEntity;
}
public void setQueryMobileEntity(QueryMobileEntity queryMobileEntity) {
this.queryMobileEntity = queryMobileEntity;
}
}
...@@ -33,12 +33,15 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss ...@@ -33,12 +33,15 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8 spring.jackson.time-zone=GMT+8
#spring.jackson.default-property-inclusion=non_null #spring.jackson.default-property-inclusion=non_null
memcached.url=192.168.130.230:11211 memcached.url=192.168.130.230:11211
#微信登陆 #\u5FAE\u4FE1\u767B\u9646
weChatAppID=wx5103ed453ef2dbe8 weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38 weChatAppSecret=6faa9bef3302786c08b2baf278613f38
#h5\u4F7F\u7528\u7684\u4E91\u9E4A\u533B\u516C\u4F17\u53F7
weChatAppIDH5=wx08b383d002c73f26
weChatAppSecretH5=b3a6be25c9f62423b88a3d0611f060d1
weChatURL=https://api.weixin.qq.com/sns/userinfo? weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据 #\u662F\u5426\u5F00\u542F\u53CC\u5199\u6A21\u5F0F\uFF0C\u662F\u5426\u9700\u8981\u5411p_doctor\u8868\u5199\u6570\u636E
doubleWritingMode=true doubleWritingMode=true
#rabbitmq settings #rabbitmq settings
...@@ -51,3 +54,23 @@ spring.rabbitmq.virtual-host=account-register-vhost ...@@ -51,3 +54,23 @@ spring.rabbitmq.virtual-host=account-register-vhost
management.security.enabled=false management.security.enabled=false
management.endpoint.health.show-details=always management.endpoint.health.show-details=always
# Job config begin
# \u63A7\u5236\u5668\u5730\u5740\uFF1A\u670D\u52A1\u542F\u52A8\u81EA\u52A8\u6CE8\u518C\u5230\u63A7\u5236\u5668\u4E2D
xxl.job.admin.addresses=http://192.168.110.124:7899/job
#\u6267\u884C\u5668\u547D\u540D\u89C4\u5219job-exec-<\u7533\u8BF7Port>
xxl.job.executor.appname=job-exec-7906
xxl.job.executor.ip=
xxl.job.executor.port=7906
### xxl-job, access token
xxl.job.accessToken=
### \u786E\u4FDD\u6539\u76EE\u5F55\u53EF\u5199/opt/xxl-job-logs/jobhandler
xxl.job.executor.logpath=/opt/xxl-job-logs/jobhandler
### xxl-job log retention days
xxl.job.executor.logretentiondays=-1
pica.cloud.message.url=https://dev-sc.yunqueyi.com/message
\ No newline at end of file
...@@ -40,6 +40,8 @@ memcached.url=172.19.121.31:11211 ...@@ -40,6 +40,8 @@ memcached.url=172.19.121.31:11211
#微信登陆 #微信登陆
weChatAppID=wx5103ed453ef2dbe8 weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38 weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatAppIDH5=wx2c577552a2d28550
weChatAppSecretH5=397a92bda46180efa2c2a235b74a409a
weChatURL=https://api.weixin.qq.com/sns/userinfo? weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据 #是否开启双写模式,是否需要向p_doctor表写数据
...@@ -48,3 +50,23 @@ doubleWritingMode=true ...@@ -48,3 +50,23 @@ doubleWritingMode=true
management.security.enabled=false management.security.enabled=false
management.endpoint.health.show-details=always management.endpoint.health.show-details=always
# Job config begin
# 控制器地址:服务启动自动注册到控制器中
xxl.job.admin.addresses=http://172.19.137.74:7899/job,http://172.19.137.75:7899/job
#执行器命名规则job-exec-<申请Port>
xxl.job.executor.appname=job-exec-7906
xxl.job.executor.ip=
xxl.job.executor.port=7906
### xxl-job, access token
xxl.job.accessToken=
### 确保改目录可写/opt/xxl-job-logs/jobhandler
xxl.job.executor.logpath=/opt/xxl-job-logs/jobhandler
### xxl-job log retention days
xxl.job.executor.logretentiondays=-1
pica.cloud.message.url=https://sc.yunqueyi.com/message
...@@ -39,6 +39,8 @@ memcached.url=192.168.130.230:11211 ...@@ -39,6 +39,8 @@ memcached.url=192.168.130.230:11211
#微信登陆 #微信登陆
weChatAppID=wx5103ed453ef2dbe8 weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38 weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatAppIDH5=wxcaad75b7fff5659c
weChatAppSecretH5=3d6eea715bc34489b49925b3dbde9c8b
weChatURL=https://api.weixin.qq.com/sns/userinfo? weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据 #是否开启双写模式,是否需要向p_doctor表写数据
...@@ -50,3 +52,24 @@ spring.rabbitmq.port=5672 ...@@ -50,3 +52,24 @@ spring.rabbitmq.port=5672
spring.rabbitmq.username=appuser spring.rabbitmq.username=appuser
spring.rabbitmq.password=AqLfvyWOvLQEUzdI spring.rabbitmq.password=AqLfvyWOvLQEUzdI
spring.rabbitmq.virtual-host=account-register-vhost spring.rabbitmq.virtual-host=account-register-vhost
# Job config begin
# 控制器地址:服务启动自动注册到控制器中
xxl.job.admin.addresses=http://192.168.110.133:7899/job
#执行器命名规则job-exec-<申请Port>
xxl.job.executor.appname=job-exec-7906
xxl.job.executor.ip=
xxl.job.executor.port=7906
### xxl-job, access token
xxl.job.accessToken=
### 确保改目录可写/opt/xxl-job-logs/jobhandler
xxl.job.executor.logpath=/opt/xxl-job-logs/jobhandler
### xxl-job log retention days
xxl.job.executor.logretentiondays=-1
pica.cloud.message.url=https://test1-sc.yunqueyi.com/message
...@@ -50,3 +50,20 @@ spring.rabbitmq.port=5672 ...@@ -50,3 +50,20 @@ spring.rabbitmq.port=5672
spring.rabbitmq.username=appuser spring.rabbitmq.username=appuser
spring.rabbitmq.password=AqLfvyWOvLQEUzdI spring.rabbitmq.password=AqLfvyWOvLQEUzdI
spring.rabbitmq.virtual-host=account-register-vhost spring.rabbitmq.virtual-host=account-register-vhost
# Job config begin
# 控制器地址:服务启动自动注册到控制器中
xxl.job.admin.addresses=http://192.168.110.124:7899/job
#执行器命名规则job-exec-<申请Port>
xxl.job.executor.appname=job-exec-7906
xxl.job.executor.ip=
xxl.job.executor.port=7906
### xxl-job, access token
xxl.job.accessToken=
### 确保改目录可写/opt/xxl-job-logs/jobhandler
xxl.job.executor.logpath=/opt/xxl-job-logs/jobhandler
### xxl-job log retention days
xxl.job.executor.logretentiondays=-1
...@@ -39,6 +39,8 @@ memcached.url=192.168.130.230:11211 ...@@ -39,6 +39,8 @@ memcached.url=192.168.130.230:11211
#微信登陆 #微信登陆
weChatAppID=wx5103ed453ef2dbe8 weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38 weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatAppIDH5=wx342ef0e5afee54a7
weChatAppSecretH5=3859052f07d3f87cda644bf073927ef1
weChatURL=https://api.weixin.qq.com/sns/userinfo? weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据 #是否开启双写模式,是否需要向p_doctor表写数据
...@@ -50,3 +52,24 @@ spring.rabbitmq.port=5672 ...@@ -50,3 +52,24 @@ spring.rabbitmq.port=5672
spring.rabbitmq.username=appuser spring.rabbitmq.username=appuser
spring.rabbitmq.password=AqLfvyWOvLQEUzdI spring.rabbitmq.password=AqLfvyWOvLQEUzdI
spring.rabbitmq.virtual-host=account-register-vhost spring.rabbitmq.virtual-host=account-register-vhost
# Job config begin
# 控制器地址:服务启动自动注册到控制器中
xxl.job.admin.addresses=http://192.168.110.141:7899/job
#执行器命名规则job-exec-<申请Port>
xxl.job.executor.appname=job-exec-7906
xxl.job.executor.ip=
xxl.job.executor.port=7906
### xxl-job, access token
xxl.job.accessToken=
### 确保改目录可写/opt/xxl-job-logs/jobhandler
xxl.job.executor.logpath=/opt/xxl-job-logs/jobhandler
### xxl-job log retention days
xxl.job.executor.logretentiondays=-1
pica.cloud.message.url=https://uat-sc.yunqueyi.com/message
spring.profiles.active=dev spring.profiles.active=dev
# \u95EA\u9A8C\u4E00\u952E\u767B\u5F55\u914D\u7F6E
shanyan.url.mobilequery=https://api.253.com/open/flashsdk/mobile-query
shanyan.android.appId=s0Iauo2D
shanyan.android.appKey=HRbjBatK
shanyan.ios.appId=w8VjljyP
shanyan.ios.appKey=RmjmLSJo
spring.datasource.tomcat.init-s-q-l=SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" monitorInterval="30">
<properties>
<property name="logPath" value="${sys:LOG_PATH:-/opt/tomcat-log}"/>
<property name="logPatternLayout"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%t] %class{36}.%M - %msg%xEx%n"/>
<property name="logRolloverSize" value="100M"/>
<property name="logKeepDays" value="15d"/>
<property name="logDirNumberOfFiles" value="300"/>
</properties>
<Appenders>
<!--CONSOLE-->
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout charset="UTF-8" pattern="${logPatternLayout}"/>
</Console>
<!--TRACE-->
<RollingFile name="TRACE" filename="${logPath}/trace.log"
filepattern="${logPath}/$${date:yyyy-MM-dd}/trace-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="${logPatternLayout}"/>
<Filters>
<ThresholdFilter level="debug" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="trace" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="${logRolloverSize}"/>
</Policies>
<DefaultRolloverStrategy max="${logDirNumberOfFiles}">
<Delete basePath="${logPath}" maxDepth="3">
<IfFileName glob="*/trace*.log"/>
<IfLastModified age="${logKeepDays}"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!--DEBUG-->
<RollingFile name="DEBUG" filename="${logPath}/debug.log"
filepattern="${logPath}/$${date:yyyy-MM-dd}/debug-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="${logPatternLayout}"/>
<Filters>
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="${logRolloverSize}"/>
</Policies>
<DefaultRolloverStrategy max="${logDirNumberOfFiles}">
<Delete basePath="${logPath}" maxDepth="3">
<IfFileName glob="*/debug*.log"/>
<IfLastModified age="${logKeepDays}"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!--INFO-->
<RollingFile name="INFO" filename="${logPath}/info.log"
filepattern="${logPath}/$${date:yyyy-MM-dd}/info-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="${logPatternLayout}"/>
<Filters>
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="${logRolloverSize}"/>
</Policies>
<DefaultRolloverStrategy max="${logDirNumberOfFiles}">
<Delete basePath="${logPath}" maxDepth="3">
<IfFileName glob="*/info*.log"/>
<IfLastModified age="${logKeepDays}"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!--WARN-->
<RollingFile name="WARN" filename="${logPath}/warn.log"
filepattern="${logPath}/$${date:yyyy-MM-dd}/warn-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="${logPatternLayout}"/>
<Filters>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="${logRolloverSize}"/>
</Policies>
<DefaultRolloverStrategy max="${logDirNumberOfFiles}">
<Delete basePath="${logPath}" maxDepth="3">
<IfFileName glob="*/warn*.log"/>
<IfLastModified age="${logKeepDays}"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!--ERROR-->
<RollingFile name="ERROR" filename="${logPath}/error.log"
filepattern="${logPath}/$${date:yyyy-MM-dd}/error-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="${logPatternLayout}"/>
<Filters>
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="${logRolloverSize}"/>
</Policies>
<DefaultRolloverStrategy max="${logDirNumberOfFiles}">
<Delete basePath="${logPath}" maxDepth="3">
<IfFileName glob="*/error*.log"/>
<IfLastModified age="${logKeepDays}"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<CatAppender name="CatAppender"/>
</Appenders>
<Loggers>
<Root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="TRACE"/>
<appender-ref ref="DEBUG"/>
<appender-ref ref="INFO"/>
<appender-ref ref="WARN"/>
<appender-ref ref="ERROR"/>
<appender-ref ref="CatAppender"/>
</Root>
  
<Logger name="org.apache.catalina.startup.DigesterFactory" level="error"/>
        
<Logger name="org.apache.catalina.util.LifecycleBase" level="error"/>
        
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="warn"/>
        
<logger name="org.apache.sshd.common.util.SecurityUtils" level="warn"/>
        
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn"/>
        
<Logger name="org.crsh.plugin" level="warn"/>
        
<logger name="org.crsh.ssh" level="warn"/>
        
<Logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="error"/>
        
<Logger name="org.hibernate.validator.internal.util.Version" level="warn"/>
        
<logger name="org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration" level="warn"/>
        
<logger name="org.springframework.boot.actuate.endpoint.jmx" level="warn"/>
        
<logger name="org.thymeleaf" level="warn"/>
</Loggers>
</Configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true" scanPeriod="30 seconds">
<property name="encoder.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{req.xForwardedFor} %X{req.method} %X{req.requestURL} %X{req.queryString} %X{req.userAgent} %-5level %logger{36} - %msg%n"/>
<property name="rollingPolicy.maxFileSize" value="5MB"/>
<property name="rollingPolicy.maxHistory" value="30"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<Target>System.out</Target>
<encoder>
<pattern>${encoder.pattern}</pattern>
</encoder>
</appender>
<appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${encoder.pattern}</pattern>
<charset>GBK</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/trace.%i.log</fileNamePattern>
<maxHistory>${rollingPolicy.maxHistory}</maxHistory>
<maxFileSize>${rollingPolicy.maxFileSize}</maxFileSize>
</rollingPolicy>
</appender>
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${encoder.pattern}</pattern>
<charset>GBK</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/info.%i.log</fileNamePattern>
<maxHistory>${rollingPolicy.maxHistory}</maxHistory>
<maxFileSize>${rollingPolicy.maxFileSize}</maxFileSize>
</rollingPolicy>
</appender>
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${encoder.pattern}</pattern>
<charset>GBK</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/debug.%i.log</fileNamePattern>
<maxHistory>${rollingPolicy.maxHistory}</maxHistory>
<maxFileSize>${rollingPolicy.maxFileSize}</maxFileSize>
</rollingPolicy>
</appender>
<appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${encoder.pattern}</pattern>
<charset>GBK</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/warn.%i.log</fileNamePattern>
<maxHistory>${rollingPolicy.maxHistory}</maxHistory>
<maxFileSize>${rollingPolicy.maxFileSize}</maxFileSize>
</rollingPolicy>
</appender>
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${encoder.pattern}</pattern>
<charset>GBK</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/error.%i.log</fileNamePattern>
<maxHistory>${rollingPolicy.maxHistory}</maxHistory>
<maxFileSize>${rollingPolicy.maxFileSize}</maxFileSize>
</rollingPolicy>
</appender>
<!--logger-->
<logger name="com.ibatis" level="DEBUG" />
<logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" />
<logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" />
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG" />
<logger name="java.sql.Statement" level="DEBUG" />
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<!--root-->
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="INFO" />
<appender-ref ref="ERROR" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<classPathEntry location="D:\programer\reponsitory\maven\mysql\mysql-connector-java\5.1.39\mysql-connector-java-5.1.39.jar"/>
<!--<classPathEntry location="E:\mysql_jar/mysql-connector-java-5.1.39.jar"/>-->
<context id="tableEntity" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
<property name="addRemarkComments" value="true"/>
<property name="dateFormat" value="false"/>
<property name="suppressDate" value="false"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.130.200:3306/pica"
userId="pica" password="Joa5@73&amp;8yAYJ2fe">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.pica.cloud.account.account.server.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="mybatis" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.pica.cloud.account.account.server.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="account_apple_info" domainObjectName="AccountAppleInfo" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.AccountAppleInfoMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="apple_user_id" property="appleUserId" jdbcType="VARCHAR" />
<result column="apple_id" property="appleId" jdbcType="VARCHAR" />
<result column="info" property="info" jdbcType="VARCHAR" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="created_id" property="createdId" jdbcType="INTEGER" />
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modifiedId" jdbcType="INTEGER" />
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, apple_user_id, apple_id, info, delete_flag, created_id, created_time, modified_id,
modified_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from account_apple_info
where id = #{id,jdbcType=INTEGER}
</select>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
insert into account_apple_info (id, apple_user_id, apple_id,
info, delete_flag, created_id,
created_time, modified_id, modified_time
)
values (#{id,jdbcType=INTEGER}, #{appleUserId,jdbcType=VARCHAR}, #{appleId,jdbcType=VARCHAR},
#{info,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=INTEGER},
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=INTEGER}, #{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
insert into account_apple_info
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="appleUserId != null" >
apple_user_id,
</if>
<if test="appleId != null" >
apple_id,
</if>
<if test="info != null" >
info,
</if>
delete_flag,
<if test="createdId != null" >
created_id,
</if>
created_time,
<if test="modifiedId != null" >
modified_id,
</if>
modified_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="appleUserId != null" >
#{appleUserId,jdbcType=VARCHAR},
</if>
<if test="appleId != null" >
#{appleId,jdbcType=VARCHAR},
</if>
<if test="info != null" >
#{info,jdbcType=VARCHAR},
</if>
1,
<if test="createdId != null" >
#{createdId,jdbcType=INTEGER},
</if>
now(),
<if test="modifiedId != null" >
#{modifiedId,jdbcType=INTEGER},
</if>
now()
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
update account_apple_info
<set >
<if test="appleUserId != null" >
apple_user_id = #{appleUserId,jdbcType=VARCHAR},
</if>
<if test="appleId != null" >
apple_id = #{appleId,jdbcType=VARCHAR},
</if>
<if test="info != null" >
info = #{info,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
created_id = #{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null" >
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
modified_id = #{modifiedId,jdbcType=INTEGER},
</if>
<if test="modifiedTime != null" >
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
update account_apple_info
set apple_user_id = #{appleUserId,jdbcType=VARCHAR},
apple_id = #{appleId,jdbcType=VARCHAR},
info = #{info,jdbcType=VARCHAR},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=INTEGER},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=INTEGER},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<!--通过appleUserId获取apple信息-->
<select id="selectByUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
id
from account_apple_info
where apple_user_id = #{id} and delete_flag = 1
limit 1
</select>
</mapper>
\ No newline at end of file
...@@ -50,9 +50,15 @@ ...@@ -50,9 +50,15 @@
update account_info set created_id=#{acctId}, modified_id=#{acctId} where id=#{acctId} update account_info set created_id=#{acctId}, modified_id=#{acctId} where id=#{acctId}
</update> </update>
<update id="processAccountRepeatData">
update account_info set delete_flag=2, modified_id=101432928, modified_time=now() where id in (select id from (select pd.id from account_info pd
inner JOIN (SELECT mobile_phone,MIN(id) as id FROM account_info WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn
on pd.id != inn.id and pd.mobile_phone = inn.mobile_phone) ttt);
</update>
<!--逻辑删除用户--> <!--逻辑删除用户-->
<update id="updateDeleteByPrimaryKey" parameterType="java.lang.Integer"> <update id="updateDeleteByPrimaryKey" >
update account_info set delete_flag=2,modified_time=now(), modified_id=#{acctId} where id=#{acctId} update account_info set delete_flag=2,modified_time=now(), modified_id=#{map.modifyId} where id=#{map.acctId}
</update> </update>
<!--更新用户的手机号--> <!--更新用户的手机号-->
...@@ -61,6 +67,12 @@ ...@@ -61,6 +67,12 @@
update account_info set modified_id=#{id}, modified_time=#{modifiedTime},mobile_phone=#{mobilePhone} where id=#{id} and delete_flag=1 update account_info set modified_id=#{id}, modified_time=#{modifiedTime},mobile_phone=#{mobilePhone} where id=#{id} and delete_flag=1
</update> </update>
<!--<update id="processAccountRepeatData">-->
<!--update account_info set delete_flag=2, modified_id=101432928, modified_time=now() where id in (select id from (select pd.id from account_info pd-->
<!--inner JOIN (SELECT mobile_phone,MIN(id) as id FROM account_info WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn-->
<!--on pd.id != inn.id and pd.mobile_phone = inn.mobile_phone) ttt);-->
<!--</update>-->
<!--修改用户的密码--> <!--修改用户的密码-->
<update id="updatePasswordByPrimaryKey" <update id="updatePasswordByPrimaryKey"
parameterType="com.pica.cloud.account.account.server.entity.AccountInfoEntity"> parameterType="com.pica.cloud.account.account.server.entity.AccountInfoEntity">
......
...@@ -308,7 +308,10 @@ ...@@ -308,7 +308,10 @@
</select> </select>
<select id="getHospitalInfoByPage" resultType="map"> <select id="getHospitalInfoByPage" resultType="map">
select id, hospital_id, hospital select id, hospital_id, hospital,mobile_phone,name,
status, avatar_image_url, email,
province, province_name,city, city_name, county, county_name,town, town_name,
title,title_id
from p_doctor from p_doctor
where delete_flag = 1 where delete_flag = 1
<if test="id != null"> <if test="id != null">
......
...@@ -29,20 +29,36 @@ ...@@ -29,20 +29,36 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from account_union from account_union
where union_id = #{unionId} where union_id = #{unionId} and delete_flag = 1
limit 1
</select>
<!--通过unionId查询用户信息-->
<select id="selectByAcctId" resultMap="BaseResultMap" parameterType="java.util.Map">
select
<include refid="Base_Column_List"/>
from account_union
where acct_id = #{acctId,jdbcType=INTEGER}
and union_type = #{unionType}
and delete_flag = 1
limit 1
</select> </select>
<!--解除绑定关系--> <!--解除绑定关系-->
<update id="updateUnbindByAcctId" parameterType="java.lang.Integer"> <update id="updateUnbindByAcctId" parameterType="java.util.Map">
update account_union update account_union
set delete_flag = 2 set delete_flag = 2, modified_time=NOW()
where acct_id = #{acctId,jdbcType=INTEGER} where acct_id = #{acctId,jdbcType=INTEGER}
and union_type = #{unionType}
and delete_flag = 1
</update> </update>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <!--更新以前的unionId状态-->
delete from account_union <update id="updateUnionStatus" parameterType="java.lang.String">
where id = #{id,jdbcType=INTEGER} update account_union
</delete> set delete_flag = 2,modified_time=NOW()
where union_id = #{unionId} and delete_flag = 1
</update>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountUnionEntity"> <insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountUnionEntity">
insert into account_union (id, acct_id, union_type, insert into account_union (id, acct_id, union_type,
...@@ -69,21 +85,15 @@ ...@@ -69,21 +85,15 @@
<if test="unionId != null"> <if test="unionId != null">
union_id, union_id,
</if> </if>
<if test="deleteFlag != null">
delete_flag, delete_flag,
</if>
<if test="createdId != null"> <if test="createdId != null">
created_id, created_id,
</if> </if>
<if test="createdTime != null">
created_time, created_time,
</if>
<if test="modifiedId != null"> <if test="modifiedId != null">
modified_id, modified_id,
</if> </if>
<if test="modifiedTime != null"> modified_time
modified_time,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
...@@ -98,21 +108,15 @@ ...@@ -98,21 +108,15 @@
<if test="unionId != null"> <if test="unionId != null">
#{unionId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR},
</if> </if>
<if test="deleteFlag != null"> 1,
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null"> <if test="createdId != null">
#{createdId,jdbcType=INTEGER}, #{createdId,jdbcType=INTEGER},
</if> </if>
<if test="createdTime != null"> now(),
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null"> <if test="modifiedId != null">
#{modifiedId,jdbcType=INTEGER}, #{modifiedId,jdbcType=INTEGER},
</if> </if>
<if test="modifiedTime != null"> now()
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" <update id="updateByPrimaryKeySelective"
......
...@@ -40,11 +40,12 @@ ...@@ -40,11 +40,12 @@
</select> </select>
<!--通过UnionId获取微信信息--> <!--通过UnionId获取微信信息-->
<select id="selectByUnionId" resultMap="BaseResultMap" parameterType="java.lang.Integer"> <select id="selectByUnionId" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from account_wechat_info from account_wechat_info
where unionid = #{id} where unionid = #{id} and delete_flag = 1
limit 1
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
......
...@@ -140,4 +140,72 @@ ...@@ -140,4 +140,72 @@
modified_time = #{modified_time,jdbcType=TIMESTAMP} modified_time = #{modified_time,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<select id="getLatestProtocolId" resultType="java.lang.Integer" parameterType="java.lang.Integer">
select id
from p_protocol
where type = #{type} and delete_flag = 1
order by id desc
limit 1
</select>
<insert id="insertProtocolLog" parameterType="com.pica.cloud.account.account.server.entity.PProtocolLog" >
insert into p_protocol_log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="userId != null" >
user_id,
</if>
<if test="protocolId != null" >
protocol_id,
</if>
<if test="status != null" >
status,
</if>
<if test="type != null" >
type,
</if>
<if test="userType != null" >
user_type,
</if>
delete_flag,
<if test="createdId != null" >
created_id,
</if>
created_time,
<if test="modifiedId != null" >
modified_id,
</if>
modified_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="userId != null" >
#{userId,jdbcType=VARCHAR},
</if>
<if test="protocolId != null" >
#{protocolId,jdbcType=INTEGER},
</if>
<if test="status != null" >
#{status,jdbcType=SMALLINT},
</if>
<if test="type != null" >
#{type,jdbcType=INTEGER},
</if>
<if test="userType != null" >
#{userType,jdbcType=INTEGER},
</if>
1,
<if test="createdId != null" >
#{createdId,jdbcType=INTEGER},
</if>
now(),
<if test="modifiedId != null" >
#{modifiedId,jdbcType=INTEGER},
</if>
now()
</trim>
</insert>
<update id="updateSignNum" parameterType="java.lang.Integer">
update p_protocol set sign_num = sign_num + 1 where id = #{id}
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -84,12 +84,27 @@ ...@@ -84,12 +84,27 @@
<!--刷新重复的记录--> <!--刷新重复的记录-->
<update id="processDoctorRepeatData"> <update id="processDoctorRepeatData">
update p_doctor set delete_flag=2, modify_id=101432928, modify_time=now() where id in ( update p_doctor set delete_flag=2, modify_id=101432928, modify_time=now() where id in (select id from (select pd.id from p_doctor pd
select id from (select pd.id from account_info pd inner JOIN (SELECT mobile_phone,MIN(id) as id FROM p_doctor WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn
inner JOIN (SELECT mobile_phone,MIN(id) as id FROM account_info WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn on pd.id != inn.id and pd.mobile_phone = inn.mobile_phone) ttt);
on pd.id <![CDATA[!= ]]> inn.id and pd.mobile_phone = inn.mobile_phone) ttt )
</update> </update>
<insert id="updateDoctorModifyRecord">
insert into log_p_doctor(`doctor_id`, `sex`, `name`, `mobile_phone`, `tel`, `status`, `type`, `hospital_id`,
`department_id`, `title_id`, `hospital`, `department`, `title`, `cert_image_url`, `avatar_image_url`,
`auth_time`,
`honor`, `skills`, `thumb_up_num`, `email`, `qrcode`, `nickname`, `personal_sign`, `delete_flag`, `creat_id`,
`creat_time`, `modify_id`, `modify_time`, `praise_num`, `password`, `info`, `rank`, `province`, `province_name`,
`city`, `city_name`, `county`, `county_name`, `town`, `town_name`, `invite_code`, `invite_start_time`,
`gaoxueya_password`, `sms_send_num`, `total_sms_send_num`, `entire_flag`, `doctor_project_type`, `reg_time`,
`last_login_time`, `unionid`, `register_source`, `comment`, `administer_title_id`, `administer_title`,
`register_type`,
`first_login_time`, `card`, `birthday`, `show_flag`, `acct_id`)
SELECT * FROM p_doctor where modify_time &gt; DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d %H:00:00'),INTERVAL 1 hour)
and modify_time &lt; DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00')
</insert>
<!--通过手机号查询用户id--> <!--通过手机号查询用户id-->
<select id="selectDoctorIdByMobile" parameterType="java.lang.String" resultType="java.lang.Long"> <select id="selectDoctorIdByMobile" parameterType="java.lang.String" resultType="java.lang.Long">
SELECT id SELECT id
...@@ -111,12 +126,12 @@ ...@@ -111,12 +126,12 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from p_doctor from p_doctor
where id = #{id,jdbcType=INTEGER} and delete_flag=1 where id = #{id} and delete_flag=1
</select> </select>
<!--删除用户--> <!--删除用户-->
<update id="updateDeleteByPrimaryKey" parameterType="java.lang.Integer"> <update id="updateDeleteByPrimaryKey" parameterType="map">
update p_doctor set delete_flag=2,modify_time=now(), modify_id=#{id} where id=#{id} limit 1 update p_doctor set delete_flag=2,modify_time=now(), modify_id=#{map.modifyId} where id=#{map.id} limit 1
</update> </update>
<!--根据手机号获取数据--> <!--根据手机号获取数据-->
...@@ -760,7 +775,6 @@ ...@@ -760,7 +775,6 @@
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.Doctor"> <update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.Doctor">
update p_doctor update p_doctor
<set> <set>
...@@ -830,9 +844,6 @@ ...@@ -830,9 +844,6 @@
<if test="personalSign != null"> <if test="personalSign != null">
personal_sign = #{personalSign,jdbcType=VARCHAR}, personal_sign = #{personalSign,jdbcType=VARCHAR},
</if> </if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null"> <if test="creatId != null">
creat_id = #{creatId,jdbcType=INTEGER}, creat_id = #{creatId,jdbcType=INTEGER},
</if> </if>
...@@ -848,9 +859,6 @@ ...@@ -848,9 +859,6 @@
<if test="praiseNum != null"> <if test="praiseNum != null">
praise_num = #{praiseNum,jdbcType=INTEGER}, praise_num = #{praiseNum,jdbcType=INTEGER},
</if> </if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="info != null"> <if test="info != null">
info = #{info,jdbcType=VARCHAR}, info = #{info,jdbcType=VARCHAR},
</if> </if>
...@@ -938,9 +946,7 @@ ...@@ -938,9 +946,7 @@
<if test="showFlag != null"> <if test="showFlag != null">
show_flag = #{showFlag,jdbcType=INTEGER}, show_flag = #{showFlag,jdbcType=INTEGER},
</if> </if>
<if test="acctId != null">
acct_id = #{acctId,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
...@@ -1035,4 +1041,8 @@ ...@@ -1035,4 +1041,8 @@
FROM p_doctor aa FROM p_doctor aa
where aa.id = #{doctorId} and aa.delete_flag = 1 where aa.id = #{doctorId} and aa.delete_flag = 1
</select> </select>
<select id="getAcctIdByDoctorId" resultType="java.lang.Integer" parameterType="java.lang.Long">
select acct_id from p_doctor where id = #{id}
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.HospitalMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.Hospital" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="province_id" property="provinceId" jdbcType="INTEGER" />
<result column="province_name" property="provinceName" jdbcType="VARCHAR" />
<result column="city_id" property="cityId" jdbcType="BIGINT" />
<result column="city_name" property="cityName" jdbcType="VARCHAR" />
<result column="county_id" property="countyId" jdbcType="BIGINT" />
<result column="county_name" property="countyName" jdbcType="VARCHAR" />
<result column="town_id" property="townId" jdbcType="BIGINT" />
<result column="town_name" property="townName" jdbcType="VARCHAR" />
<result column="village_id" property="villageId" jdbcType="BIGINT" />
<result column="village_name" property="villageName" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="hospital_address" property="hospitalAddress" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="org_type" property="orgType" jdbcType="INTEGER" />
<result column="level_grade" property="levelGrade" jdbcType="INTEGER" />
<result column="contacts" property="contacts" jdbcType="VARCHAR" />
<result column="tel" property="tel" jdbcType="VARCHAR" />
<result column="source_type" property="sourceType" jdbcType="INTEGER" />
<result column="enable" property="enable" jdbcType="INTEGER" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="creat_id" property="creatId" jdbcType="INTEGER" />
<result column="creat_time" property="creatTime" jdbcType="TIMESTAMP" />
<result column="modify_id" property="modifyId" jdbcType="INTEGER" />
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
<result column="hospital_statistics_type" property="hospitalStatisticsType" jdbcType="INTEGER" />
<result column="hospital_rank" property="hospitalRank" jdbcType="INTEGER" />
<result column="hospital_alias" property="hospitalAlias" jdbcType="VARCHAR" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="hospital_class" property="hospitalClass" jdbcType="VARCHAR" />
<result column="hospital_level" property="hospitalLevel" jdbcType="VARCHAR" />
<result column="hospital_grade" property="hospitalGrade" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, province_id, province_name, city_id, city_name, county_id, county_name, town_id,
town_name, village_id, village_name, name, hospital_address, type, org_type, level_grade,
contacts, tel, source_type, enable, delete_flag, creat_id, creat_time, modify_id,
modify_time, hospital_statistics_type, hospital_rank, hospital_alias, parent_id,
hospital_class, hospital_level, hospital_grade
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from p_hospital
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_hospital
where id = #{id,jdbcType=INTEGER}
</delete>
<!--刷新hospital表的数据-->
<insert id="updateDoctorModifyRecord">
insert into log_p_hospital(`hospital_id`, `province_id`, `province_name`, `city_id`, `city_name`, `county_id`, `county_name`, `town_id`, `town_name`, `village_id`, `village_name`,
`name`, `hospital_address`, `type`, `org_type`, `level_grade`, `contacts`, `tel`, `source_type`, `enable`, `delete_flag`, `creat_id`, `creat_time`, `modify_id`, `modify_time`,
`hospital_statistics_type`, `hospital_rank`, `hospital_alias`, `parent_id`, `hospital_class`, `hospital_level`, `hospital_grade`)
SELECT * FROM p_hospital
where modify_time &gt; DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d %H:00:00'),INTERVAL 1 hour)
and modify_time &lt; DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00')
</insert>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.Hospital" >
insert into p_hospital (id, province_id, province_name,
city_id, city_name, county_id,
county_name, town_id, town_name,
village_id, village_name, name,
hospital_address, type, org_type,
level_grade, contacts, tel,
source_type, enable, delete_flag,
creat_id, creat_time, modify_id,
modify_time, hospital_statistics_type, hospital_rank,
hospital_alias, parent_id, hospital_class,
hospital_level, hospital_grade)
values (#{id,jdbcType=INTEGER}, #{provinceId,jdbcType=INTEGER}, #{provinceName,jdbcType=VARCHAR},
#{cityId,jdbcType=BIGINT}, #{cityName,jdbcType=VARCHAR}, #{countyId,jdbcType=BIGINT},
#{countyName,jdbcType=VARCHAR}, #{townId,jdbcType=BIGINT}, #{townName,jdbcType=VARCHAR},
#{villageId,jdbcType=BIGINT}, #{villageName,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{hospitalAddress,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{orgType,jdbcType=INTEGER},
#{levelGrade,jdbcType=INTEGER}, #{contacts,jdbcType=VARCHAR}, #{tel,jdbcType=VARCHAR},
#{sourceType,jdbcType=INTEGER}, #{enable,jdbcType=INTEGER}, #{deleteFlag,jdbcType=INTEGER},
#{creatId,jdbcType=INTEGER}, #{creatTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER},
#{modifyTime,jdbcType=TIMESTAMP}, #{hospitalStatisticsType,jdbcType=INTEGER}, #{hospitalRank,jdbcType=INTEGER},
#{hospitalAlias,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{hospitalClass,jdbcType=VARCHAR},
#{hospitalLevel,jdbcType=VARCHAR}, #{hospitalGrade,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.Hospital" >
insert into p_hospital
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="provinceId != null" >
province_id,
</if>
<if test="provinceName != null" >
province_name,
</if>
<if test="cityId != null" >
city_id,
</if>
<if test="cityName != null" >
city_name,
</if>
<if test="countyId != null" >
county_id,
</if>
<if test="countyName != null" >
county_name,
</if>
<if test="townId != null" >
town_id,
</if>
<if test="townName != null" >
town_name,
</if>
<if test="villageId != null" >
village_id,
</if>
<if test="villageName != null" >
village_name,
</if>
<if test="name != null" >
name,
</if>
<if test="hospitalAddress != null" >
hospital_address,
</if>
<if test="type != null" >
type,
</if>
<if test="orgType != null" >
org_type,
</if>
<if test="levelGrade != null" >
level_grade,
</if>
<if test="contacts != null" >
contacts,
</if>
<if test="tel != null" >
tel,
</if>
<if test="sourceType != null" >
source_type,
</if>
<if test="enable != null" >
enable,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="creatId != null" >
creat_id,
</if>
<if test="creatTime != null" >
creat_time,
</if>
<if test="modifyId != null" >
modify_id,
</if>
<if test="modifyTime != null" >
modify_time,
</if>
<if test="hospitalStatisticsType != null" >
hospital_statistics_type,
</if>
<if test="hospitalRank != null" >
hospital_rank,
</if>
<if test="hospitalAlias != null" >
hospital_alias,
</if>
<if test="parentId != null" >
parent_id,
</if>
<if test="hospitalClass != null" >
hospital_class,
</if>
<if test="hospitalLevel != null" >
hospital_level,
</if>
<if test="hospitalGrade != null" >
hospital_grade,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="provinceId != null" >
#{provinceId,jdbcType=INTEGER},
</if>
<if test="provinceName != null" >
#{provinceName,jdbcType=VARCHAR},
</if>
<if test="cityId != null" >
#{cityId,jdbcType=BIGINT},
</if>
<if test="cityName != null" >
#{cityName,jdbcType=VARCHAR},
</if>
<if test="countyId != null" >
#{countyId,jdbcType=BIGINT},
</if>
<if test="countyName != null" >
#{countyName,jdbcType=VARCHAR},
</if>
<if test="townId != null" >
#{townId,jdbcType=BIGINT},
</if>
<if test="townName != null" >
#{townName,jdbcType=VARCHAR},
</if>
<if test="villageId != null" >
#{villageId,jdbcType=BIGINT},
</if>
<if test="villageName != null" >
#{villageName,jdbcType=VARCHAR},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="hospitalAddress != null" >
#{hospitalAddress,jdbcType=VARCHAR},
</if>
<if test="type != null" >
#{type,jdbcType=INTEGER},
</if>
<if test="orgType != null" >
#{orgType,jdbcType=INTEGER},
</if>
<if test="levelGrade != null" >
#{levelGrade,jdbcType=INTEGER},
</if>
<if test="contacts != null" >
#{contacts,jdbcType=VARCHAR},
</if>
<if test="tel != null" >
#{tel,jdbcType=VARCHAR},
</if>
<if test="sourceType != null" >
#{sourceType,jdbcType=INTEGER},
</if>
<if test="enable != null" >
#{enable,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null" >
#{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null" >
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="hospitalStatisticsType != null" >
#{hospitalStatisticsType,jdbcType=INTEGER},
</if>
<if test="hospitalRank != null" >
#{hospitalRank,jdbcType=INTEGER},
</if>
<if test="hospitalAlias != null" >
#{hospitalAlias,jdbcType=VARCHAR},
</if>
<if test="parentId != null" >
#{parentId,jdbcType=INTEGER},
</if>
<if test="hospitalClass != null" >
#{hospitalClass,jdbcType=VARCHAR},
</if>
<if test="hospitalLevel != null" >
#{hospitalLevel,jdbcType=VARCHAR},
</if>
<if test="hospitalGrade != null" >
#{hospitalGrade,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.Hospital" >
update p_hospital
<set >
<if test="provinceId != null" >
province_id = #{provinceId,jdbcType=INTEGER},
</if>
<if test="provinceName != null" >
province_name = #{provinceName,jdbcType=VARCHAR},
</if>
<if test="cityId != null" >
city_id = #{cityId,jdbcType=BIGINT},
</if>
<if test="cityName != null" >
city_name = #{cityName,jdbcType=VARCHAR},
</if>
<if test="countyId != null" >
county_id = #{countyId,jdbcType=BIGINT},
</if>
<if test="countyName != null" >
county_name = #{countyName,jdbcType=VARCHAR},
</if>
<if test="townId != null" >
town_id = #{townId,jdbcType=BIGINT},
</if>
<if test="townName != null" >
town_name = #{townName,jdbcType=VARCHAR},
</if>
<if test="villageId != null" >
village_id = #{villageId,jdbcType=BIGINT},
</if>
<if test="villageName != null" >
village_name = #{villageName,jdbcType=VARCHAR},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="hospitalAddress != null" >
hospital_address = #{hospitalAddress,jdbcType=VARCHAR},
</if>
<if test="type != null" >
type = #{type,jdbcType=INTEGER},
</if>
<if test="orgType != null" >
org_type = #{orgType,jdbcType=INTEGER},
</if>
<if test="levelGrade != null" >
level_grade = #{levelGrade,jdbcType=INTEGER},
</if>
<if test="contacts != null" >
contacts = #{contacts,jdbcType=VARCHAR},
</if>
<if test="tel != null" >
tel = #{tel,jdbcType=VARCHAR},
</if>
<if test="sourceType != null" >
source_type = #{sourceType,jdbcType=INTEGER},
</if>
<if test="enable != null" >
enable = #{enable,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null" >
creat_id = #{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null" >
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="hospitalStatisticsType != null" >
hospital_statistics_type = #{hospitalStatisticsType,jdbcType=INTEGER},
</if>
<if test="hospitalRank != null" >
hospital_rank = #{hospitalRank,jdbcType=INTEGER},
</if>
<if test="hospitalAlias != null" >
hospital_alias = #{hospitalAlias,jdbcType=VARCHAR},
</if>
<if test="parentId != null" >
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="hospitalClass != null" >
hospital_class = #{hospitalClass,jdbcType=VARCHAR},
</if>
<if test="hospitalLevel != null" >
hospital_level = #{hospitalLevel,jdbcType=VARCHAR},
</if>
<if test="hospitalGrade != null" >
hospital_grade = #{hospitalGrade,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.Hospital" >
update p_hospital
set province_id = #{provinceId,jdbcType=INTEGER},
province_name = #{provinceName,jdbcType=VARCHAR},
city_id = #{cityId,jdbcType=BIGINT},
city_name = #{cityName,jdbcType=VARCHAR},
county_id = #{countyId,jdbcType=BIGINT},
county_name = #{countyName,jdbcType=VARCHAR},
town_id = #{townId,jdbcType=BIGINT},
town_name = #{townName,jdbcType=VARCHAR},
village_id = #{villageId,jdbcType=BIGINT},
village_name = #{villageName,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
hospital_address = #{hospitalAddress,jdbcType=VARCHAR},
type = #{type,jdbcType=INTEGER},
org_type = #{orgType,jdbcType=INTEGER},
level_grade = #{levelGrade,jdbcType=INTEGER},
contacts = #{contacts,jdbcType=VARCHAR},
tel = #{tel,jdbcType=VARCHAR},
source_type = #{sourceType,jdbcType=INTEGER},
enable = #{enable,jdbcType=INTEGER},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
creat_id = #{creatId,jdbcType=INTEGER},
creat_time = #{creatTime,jdbcType=TIMESTAMP},
modify_id = #{modifyId,jdbcType=INTEGER},
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
hospital_statistics_type = #{hospitalStatisticsType,jdbcType=INTEGER},
hospital_rank = #{hospitalRank,jdbcType=INTEGER},
hospital_alias = #{hospitalAlias,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=INTEGER},
hospital_class = #{hospitalClass,jdbcType=VARCHAR},
hospital_level = #{hospitalLevel,jdbcType=VARCHAR},
hospital_grade = #{hospitalGrade,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.LogLoginAesMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.LogLoginAes" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="channel" property="channel" jdbcType="INTEGER" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="source_type" property="sourceType" jdbcType="INTEGER" />
<result column="device_token" property="deviceToken" jdbcType="VARCHAR" />
<result column="device_info" property="deviceInfo" jdbcType="VARCHAR" />
<result column="one_token" property="oneToken" jdbcType="VARCHAR" />
<result column="create_id" property="createId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="modify_id" property="modifyId" jdbcType="INTEGER" />
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, channel, mobile, source_type, device_token, device_info, one_token, create_id,
create_time, modify_id, modify_time, delete_flag
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from log_login_aes
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from log_login_aes
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogLoginAes" >
insert into log_login_aes (id, channel, mobile,
source_type, device_token, device_info,
one_token, create_id, create_time,
modify_id, modify_time, delete_flag
)
values (#{id,jdbcType=INTEGER}, #{channel,jdbcType=INTEGER}, #{mobile,jdbcType=VARCHAR},
#{sourceType,jdbcType=INTEGER}, #{deviceToken,jdbcType=VARCHAR}, #{deviceInfo,jdbcType=VARCHAR},
#{oneToken,jdbcType=VARCHAR}, #{createId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{modifyId,jdbcType=INTEGER}, #{modifyTime,jdbcType=TIMESTAMP}, #{deleteFlag,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.LogLoginAes" >
insert into log_login_aes
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="channel != null" >
channel,
</if>
<if test="mobile != null" >
mobile,
</if>
<if test="sourceType != null" >
source_type,
</if>
<if test="deviceToken != null" >
device_token,
</if>
<if test="deviceInfo != null" >
device_info,
</if>
<if test="oneToken != null" >
one_token,
</if>
<if test="createId != null" >
create_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="modifyId != null" >
modify_id,
</if>
<if test="modifyTime != null" >
modify_time,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="channel != null" >
#{channel,jdbcType=INTEGER},
</if>
<if test="mobile != null" >
#{mobile,jdbcType=VARCHAR},
</if>
<if test="sourceType != null" >
#{sourceType,jdbcType=INTEGER},
</if>
<if test="deviceToken != null" >
#{deviceToken,jdbcType=VARCHAR},
</if>
<if test="deviceInfo != null" >
#{deviceInfo,jdbcType=VARCHAR},
</if>
<if test="oneToken != null" >
#{oneToken,jdbcType=VARCHAR},
</if>
<if test="createId != null" >
#{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.LogLoginAes" >
update log_login_aes
<set >
<if test="channel != null" >
channel = #{channel,jdbcType=INTEGER},
</if>
<if test="mobile != null" >
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="sourceType != null" >
source_type = #{sourceType,jdbcType=INTEGER},
</if>
<if test="deviceToken != null" >
device_token = #{deviceToken,jdbcType=VARCHAR},
</if>
<if test="deviceInfo != null" >
device_info = #{deviceInfo,jdbcType=VARCHAR},
</if>
<if test="oneToken != null" >
one_token = #{oneToken,jdbcType=VARCHAR},
</if>
<if test="createId != null" >
create_id = #{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.LogLoginAes" >
update log_login_aes
set channel = #{channel,jdbcType=INTEGER},
mobile = #{mobile,jdbcType=VARCHAR},
source_type = #{sourceType,jdbcType=INTEGER},
device_token = #{deviceToken,jdbcType=VARCHAR},
device_info = #{deviceInfo,jdbcType=VARCHAR},
one_token = #{oneToken,jdbcType=VARCHAR},
create_id = #{createId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
modify_id = #{modifyId,jdbcType=INTEGER},
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
delete_flag = #{deleteFlag,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
...@@ -33,16 +33,19 @@ ...@@ -33,16 +33,19 @@
</delete> </delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogLoginEntity" > <insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogLoginEntity" >
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>
insert into log_login ( acct_id, acct_name, insert into log_login ( acct_id, acct_name,
product_type, source_type, login_type, product_type, source_type, login_type,
login_ip, login_time, login_status, login_ip, login_time, login_status,
create_id, create_time, modify_id, create_id, create_time, modify_id,
modify_time, delete_flag) modify_time, delete_flag,token,is_login,user_token_tourist)
values (#{acctId,jdbcType=INTEGER}, #{acctName,jdbcType=VARCHAR}, values (#{acctId,jdbcType=INTEGER}, #{acctName,jdbcType=VARCHAR},
#{productType,jdbcType=TINYINT}, #{sourceType,jdbcType=TINYINT}, #{loginType,jdbcType=TINYINT}, #{productType,jdbcType=TINYINT}, #{sourceType,jdbcType=TINYINT}, #{loginType,jdbcType=TINYINT},
#{loginIp,jdbcType=VARCHAR}, #{loginTime,jdbcType=TIMESTAMP}, #{loginStatus,jdbcType=TINYINT}, #{loginIp,jdbcType=VARCHAR}, #{loginTime,jdbcType=TIMESTAMP}, #{loginStatus,jdbcType=TINYINT},
#{createId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER}, #{createId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER},
#{modifyTime,jdbcType=TIMESTAMP}, #{deleteFlag,jdbcType=TINYINT}) #{modifyTime,jdbcType=TIMESTAMP}, #{deleteFlag,jdbcType=TINYINT},#{token},#{isLogin},#{userTokenTourist})
</insert> </insert>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.LogLoginOnekeyMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.LogLoginOnekey" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="log_login_id" property="logLoginId" jdbcType="INTEGER" />
<result column="device_type" property="deviceType" jdbcType="INTEGER" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="trade_no" property="tradeNo" jdbcType="VARCHAR" />
<result column="fanqizha" property="fanqizha" jdbcType="INTEGER" />
<result column="tag" property="tag" jdbcType="VARCHAR" />
<result column="info" property="info" jdbcType="VARCHAR" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="create_id" property="createId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="modify_id" property="modifyId" jdbcType="INTEGER" />
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, log_login_id, device_type, mobile, trade_no, fanqizha, tag, info, delete_flag,
create_id, create_time, modify_id, modify_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from log_login_onekey
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from log_login_onekey
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogLoginOnekey" >
insert into log_login_onekey (id, log_login_id, device_type,
mobile, trade_no, fanqizha,
tag, info, delete_flag,
create_id, create_time, modify_id,
modify_time)
values (#{id,jdbcType=INTEGER}, #{logLoginId,jdbcType=INTEGER}, #{deviceType,jdbcType=INTEGER},
#{mobile,jdbcType=VARCHAR}, #{tradeNo,jdbcType=VARCHAR}, #{fanqizha,jdbcType=INTEGER},
#{tag,jdbcType=VARCHAR}, #{info,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=INTEGER},
#{createId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER},
#{modifyTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.LogLoginOnekey" >
insert into log_login_onekey
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="logLoginId != null" >
log_login_id,
</if>
<if test="deviceType != null" >
device_type,
</if>
<if test="mobile != null" >
mobile,
</if>
<if test="tradeNo != null" >
trade_no,
</if>
<if test="fanqizha != null" >
fanqizha,
</if>
<if test="tag != null" >
tag,
</if>
<if test="info != null" >
info,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="createId != null" >
create_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="modifyId != null" >
modify_id,
</if>
<if test="modifyTime != null" >
modify_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="logLoginId != null" >
#{logLoginId,jdbcType=INTEGER},
</if>
<if test="deviceType != null" >
#{deviceType,jdbcType=INTEGER},
</if>
<if test="mobile != null" >
#{mobile,jdbcType=VARCHAR},
</if>
<if test="tradeNo != null" >
#{tradeNo,jdbcType=VARCHAR},
</if>
<if test="fanqizha != null" >
#{fanqizha,jdbcType=INTEGER},
</if>
<if test="tag != null" >
#{tag,jdbcType=VARCHAR},
</if>
<if test="info != null" >
#{info,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createId != null" >
#{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
#{modifyTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.LogLoginOnekey" >
update log_login_onekey
<set >
<if test="logLoginId != null" >
log_login_id = #{logLoginId,jdbcType=INTEGER},
</if>
<if test="deviceType != null" >
device_type = #{deviceType,jdbcType=INTEGER},
</if>
<if test="mobile != null" >
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="tradeNo != null" >
trade_no = #{tradeNo,jdbcType=VARCHAR},
</if>
<if test="fanqizha != null" >
fanqizha = #{fanqizha,jdbcType=INTEGER},
</if>
<if test="tag != null" >
tag = #{tag,jdbcType=VARCHAR},
</if>
<if test="info != null" >
info = #{info,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createId != null" >
create_id = #{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.LogLoginOnekey" >
update log_login_onekey
set log_login_id = #{logLoginId,jdbcType=INTEGER},
device_type = #{deviceType,jdbcType=INTEGER},
mobile = #{mobile,jdbcType=VARCHAR},
trade_no = #{tradeNo,jdbcType=VARCHAR},
fanqizha = #{fanqizha,jdbcType=INTEGER},
tag = #{tag,jdbcType=VARCHAR},
info = #{info,jdbcType=VARCHAR},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
create_id = #{createId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
modify_id = #{modifyId,jdbcType=INTEGER},
modify_time = #{modifyTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.LogMobileModifyMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.LogMobileModify" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="acct_id" property="acctId" jdbcType="INTEGER" />
<result column="mobile_phone_new" property="mobilePhoneNew" jdbcType="VARCHAR" />
<result column="mobile_phone_old" property="mobilePhoneOld" jdbcType="VARCHAR" />
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modifiedId" jdbcType="INTEGER" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="created_id" property="createdId" jdbcType="INTEGER" />
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, acct_id, mobile_phone_new, mobile_phone_old, modified_time, modified_id, delete_flag,
created_id, created_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from log_mobile_modify
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from log_mobile_modify
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogMobileModify" >
insert into log_mobile_modify (id, acct_id, mobile_phone_new,
mobile_phone_old, modified_time, modified_id,
delete_flag, created_id, created_time
)
values (#{id,jdbcType=INTEGER}, #{acctId,jdbcType=INTEGER}, #{mobilePhoneNew,jdbcType=VARCHAR},
#{mobilePhoneOld,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=INTEGER},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.LogMobileModify" >
insert into log_mobile_modify
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="acctId != null" >
acct_id,
</if>
<if test="mobilePhoneNew != null" >
mobile_phone_new,
</if>
<if test="mobilePhoneOld != null" >
mobile_phone_old,
</if>
<if test="modifiedTime != null" >
modified_time,
</if>
<if test="modifiedId != null" >
modified_id,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="createdId != null" >
created_id,
</if>
<if test="createdTime != null" >
created_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="acctId != null" >
#{acctId,jdbcType=INTEGER},
</if>
<if test="mobilePhoneNew != null" >
#{mobilePhoneNew,jdbcType=VARCHAR},
</if>
<if test="mobilePhoneOld != null" >
#{mobilePhoneOld,jdbcType=VARCHAR},
</if>
<if test="modifiedTime != null" >
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
#{modifiedId,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
#{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null" >
#{createdTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.LogMobileModify" >
update log_mobile_modify
<set >
<if test="acctId != null" >
acct_id = #{acctId,jdbcType=INTEGER},
</if>
<if test="mobilePhoneNew != null" >
mobile_phone_new = #{mobilePhoneNew,jdbcType=VARCHAR},
</if>
<if test="mobilePhoneOld != null" >
mobile_phone_old = #{mobilePhoneOld,jdbcType=VARCHAR},
</if>
<if test="modifiedTime != null" >
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
modified_id = #{modifiedId,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
created_id = #{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null" >
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.LogMobileModify" >
update log_mobile_modify
set acct_id = #{acctId,jdbcType=INTEGER},
mobile_phone_new = #{mobilePhoneNew,jdbcType=VARCHAR},
mobile_phone_old = #{mobilePhoneOld,jdbcType=VARCHAR},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=INTEGER},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=INTEGER},
created_time = #{createdTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.PUserRoleMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.PUserRole" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="system_id" property="systemId" jdbcType="INTEGER" />
<result column="user_role_id" property="userRoleId" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="user_type" property="userType" jdbcType="INTEGER" />
<result column="param_1" property="param1" jdbcType="VARCHAR" />
<result column="param_2" property="param2" jdbcType="VARCHAR" />
<result column="param_3" property="param3" jdbcType="VARCHAR" />
<result column="param_4" property="param4" jdbcType="VARCHAR" />
<result column="param_5" property="param5" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="creat_id" property="creatId" jdbcType="INTEGER" />
<result column="creat_time" property="creatTime" jdbcType="TIMESTAMP" />
<result column="modify_id" property="modifyId" jdbcType="INTEGER" />
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, system_id, user_role_id, user_id, user_type, param_1, param_2, param_3, param_4,
param_5, status, delete_flag, creat_id, creat_time, modify_id, modify_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from p_user_role_mapping
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_user_role_mapping
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.PUserRole" >
insert into p_user_role_mapping (id, system_id, user_role_id,
user_id, user_type, param_1,
param_2, param_3, param_4,
param_5, status, delete_flag,
creat_id, creat_time, modify_id,
modify_time)
values (#{id,jdbcType=INTEGER}, #{systemId,jdbcType=INTEGER}, #{userRoleId,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER}, #{userType,jdbcType=INTEGER}, #{param1,jdbcType=VARCHAR},
#{param2,jdbcType=VARCHAR}, #{param3,jdbcType=VARCHAR}, #{param4,jdbcType=VARCHAR},
#{param5,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{deleteFlag,jdbcType=INTEGER},
#{creatId,jdbcType=INTEGER}, #{creatTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER},
#{modifyTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.PUserRole" >
insert into p_user_role_mapping
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="systemId != null" >
system_id,
</if>
<if test="userRoleId != null" >
user_role_id,
</if>
<if test="userId != null" >
user_id,
</if>
<if test="userType != null" >
user_type,
</if>
<if test="param1 != null" >
param_1,
</if>
<if test="param2 != null" >
param_2,
</if>
<if test="param3 != null" >
param_3,
</if>
<if test="param4 != null" >
param_4,
</if>
<if test="param5 != null" >
param_5,
</if>
<if test="status != null" >
status,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="creatId != null" >
creat_id,
</if>
<if test="creatTime != null" >
creat_time,
</if>
<if test="modifyId != null" >
modify_id,
</if>
<if test="modifyTime != null" >
modify_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="systemId != null" >
#{systemId,jdbcType=INTEGER},
</if>
<if test="userRoleId != null" >
#{userRoleId,jdbcType=INTEGER},
</if>
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="userType != null" >
#{userType,jdbcType=INTEGER},
</if>
<if test="param1 != null" >
#{param1,jdbcType=VARCHAR},
</if>
<if test="param2 != null" >
#{param2,jdbcType=VARCHAR},
</if>
<if test="param3 != null" >
#{param3,jdbcType=VARCHAR},
</if>
<if test="param4 != null" >
#{param4,jdbcType=VARCHAR},
</if>
<if test="param5 != null" >
#{param5,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null" >
#{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null" >
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
#{modifyTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.PUserRole" >
update p_user_role_mapping
<set >
<if test="systemId != null" >
system_id = #{systemId,jdbcType=INTEGER},
</if>
<if test="userRoleId != null" >
user_role_id = #{userRoleId,jdbcType=INTEGER},
</if>
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="userType != null" >
user_type = #{userType,jdbcType=INTEGER},
</if>
<if test="param1 != null" >
param_1 = #{param1,jdbcType=VARCHAR},
</if>
<if test="param2 != null" >
param_2 = #{param2,jdbcType=VARCHAR},
</if>
<if test="param3 != null" >
param_3 = #{param3,jdbcType=VARCHAR},
</if>
<if test="param4 != null" >
param_4 = #{param4,jdbcType=VARCHAR},
</if>
<if test="param5 != null" >
param_5 = #{param5,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{status,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null" >
creat_id = #{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null" >
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.PUserRole" >
update p_user_role_mapping
set system_id = #{systemId,jdbcType=INTEGER},
user_role_id = #{userRoleId,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
user_type = #{userType,jdbcType=INTEGER},
param_1 = #{param1,jdbcType=VARCHAR},
param_2 = #{param2,jdbcType=VARCHAR},
param_3 = #{param3,jdbcType=VARCHAR},
param_4 = #{param4,jdbcType=VARCHAR},
param_5 = #{param5,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
creat_id = #{creatId,jdbcType=INTEGER},
creat_time = #{creatTime,jdbcType=TIMESTAMP},
modify_id = #{modifyId,jdbcType=INTEGER},
modify_time = #{modifyTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.PermissionDoctorRoleMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="doctor_id" property="doctorId" jdbcType="BIGINT"/>
<result column="hospital_id" property="hospitalId" jdbcType="BIGINT"/>
<result column="role_id" property="roleId" jdbcType="BIGINT"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
<result column="created_id" property="createdId" jdbcType="BIGINT"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="modified_id" property="modifiedId" jdbcType="BIGINT"/>
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, doctor_id, hospital_id, role_id, delete_flag, created_id, created_time, modified_id,
modified_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from permission_doctor_role
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from permission_doctor_role
where id = #{id,jdbcType=BIGINT}
</delete>
<!--用户权限记录表的变更-->
<insert id="updatePermissionModifyRecord">
insert into log_permission_doctor_role(`id`, `doctor_id`, `hospital_id`, `role_id`, `delete_flag`, `created_id`,
`created_time`, `modified_id`, `modified_time`)
SELECT * FROM permission_doctor_role where modified_time &gt; DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d
%H:00:00'),INTERVAL 1 hour) and modified_time &lt; DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00')
</insert>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
insert into permission_doctor_role (id, doctor_id, hospital_id,
role_id, delete_flag, created_id,
created_time, modified_id, modified_time
)
values (#{id,jdbcType=BIGINT}, #{doctorId,jdbcType=BIGINT}, #{hospitalId,jdbcType=BIGINT},
#{roleId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT},
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
insert into permission_doctor_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="doctorId != null">
doctor_id,
</if>
<if test="hospitalId != null">
hospital_id,
</if>
<if test="roleId != null">
role_id,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="createdId != null">
created_id,
</if>
<if test="createdTime != null">
created_time,
</if>
<if test="modifiedId != null">
modified_id,
</if>
<if test="modifiedTime != null">
modified_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="doctorId != null">
#{doctorId,jdbcType=BIGINT},
</if>
<if test="hospitalId != null">
#{hospitalId,jdbcType=BIGINT},
</if>
<if test="roleId != null">
#{roleId,jdbcType=BIGINT},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
#{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null">
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
#{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null">
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
update permission_doctor_role
<set>
<if test="doctorId != null">
doctor_id = #{doctorId,jdbcType=BIGINT},
</if>
<if test="hospitalId != null">
hospital_id = #{hospitalId,jdbcType=BIGINT},
</if>
<if test="roleId != null">
role_id = #{roleId,jdbcType=BIGINT},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
created_id = #{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null">
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
modified_id = #{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null">
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
update permission_doctor_role
set doctor_id = #{doctorId,jdbcType=BIGINT},
hospital_id = #{hospitalId,jdbcType=BIGINT},
role_id = #{roleId,jdbcType=BIGINT},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;// Copyright 2016-2101 Pica.
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.AccountWeChatInfoEntity;
import com.pica.cloud.foundation.redis.ICacheClient;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @ClassName com.pica.cloud.account.account.server.mapper.Test
* @Description junit test
* @Author Chongwen.jiang
* @Date 2020/2/25 14:51
* @ModifyDate 2020/2/25 14:51
* @Version 1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class AccountWeChatInfoMapperTest {
@Autowired
private AccountWeChatInfoMapper weChatInfoMapper;
@Autowired
private ICacheClient cacheClient;
@org.junit.Test
public void test1(){
/* AccountWeChatInfoEntity record = new AccountWeChatInfoEntity();
record.setNickname("Zz");
record.setSex(1);
record.setCountry("中国");
record.setCity("邵阳");
int count = weChatInfoMapper.insertSelective(record);
System.out.println(count);*/
//System.out.println(cacheClient.set(Constants.AUTHCODE_H5_SWITCH_KEY, Constants.AUTHCODE_H5_SWITCH_KEY+"-/account/H5/authCode"));
//System.out.println(cacheClient.del(Constants.AUTHCODE_H5_SWITCH_KEY));
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.mapper;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.server.controller.AutoCodeController;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.RSAUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* @ClassName AutoCodeControllerTest
* @Description
* @Author Chongwen.jiang
* @Date 2020/4/3 14:31
* @ModifyDate 2020/4/3 14:31
* @Version 1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class AutoCodeControllerTest {
/*@Autowired
private AutoCodeController autoCodeController;
@Test
public void getH5AuthCodeTest() throws Exception {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
String publicKey = "1234567890123456";
BaseRequest req= new BaseRequest();
req.setFlag(4);
req.setMobile("13517477655");
req.setCapCode(String.valueOf(System.currentTimeMillis()));
req.setxPos(126);
req.setDevice_token("000000");
req.setSourceType(4);
String content = AESUtil.aesEncrypt(JSON.toJSONString(req), publicKey);
String encryptKey = RSAUtil.encrypt(publicKey);
EncryptEntity entity = new EncryptEntity();
entity.setKey(encryptKey);
entity.setContent(content);
autoCodeController.getH5AuthCode(entity, request);
}*/
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册