提交 c03680a8 编写于 作者: dong.an's avatar dong.an

协议优化

上级 27de7f8f
流水线 #17304 已失败 于阶段
in 0 second
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;
}
}
......@@ -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.PProtocolLog;
public interface AgreementLogEntityMapper {
int deleteByPrimaryKey(Long id);
......@@ -15,4 +16,10 @@ public interface AgreementLogEntityMapper {
int updateByPrimaryKeySelective(AgreementLogEntity record);
int updateByPrimaryKey(AgreementLogEntity record);
Integer getLatestProtocolId(int type);
int insertProtocolLog(PProtocolLog record);
int updateSignNum(Integer id);
}
\ No newline at end of file
......@@ -274,31 +274,50 @@ public class RegisterServiceImpl implements RegisterService {
private void processAgreement(Long userId) {
ExecutorService executor = ExecutorServiceUtils.getExecutor();
executor.submit(() -> {
//用户协议
Date currentTime = new Date();
Integer userVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.USER_AGREEMENT.getCode());
AgreementLogEntity userAgreementLogEntity = new AgreementLogEntity();
userAgreementLogEntity.setAgreement_type(AccountAgreementEnum.USER_AGREEMENT.getCode());
userAgreementLogEntity.setDoctor_id(userId);
userAgreementLogEntity.setVersion(userVersion.toString());
userAgreementLogEntity.setCreated_id(userId);
userAgreementLogEntity.setCreated_time(currentTime);
userAgreementLogEntity.setModified_id(userId);
userAgreementLogEntity.setModified_time(currentTime);
userAgreementLogEntity.setDelete_flag(1);
agreementLogEntityMapper.insert(userAgreementLogEntity);
//隐私协议
Integer privateVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode());
AgreementLogEntity privateAgreementLogEntity = new AgreementLogEntity();
privateAgreementLogEntity.setAgreement_type(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode());
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);
// //用户协议
// Date currentTime = new Date();
// Integer userVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.USER_AGREEMENT.getCode());
// AgreementLogEntity userAgreementLogEntity = new AgreementLogEntity();
// userAgreementLogEntity.setAgreement_type(AccountAgreementEnum.USER_AGREEMENT.getCode());
// userAgreementLogEntity.setDoctor_id(userId);
// userAgreementLogEntity.setVersion(userVersion.toString());
// userAgreementLogEntity.setCreated_id(userId);
// userAgreementLogEntity.setCreated_time(currentTime);
// userAgreementLogEntity.setModified_id(userId);
// userAgreementLogEntity.setModified_time(currentTime);
// userAgreementLogEntity.setDelete_flag(1);
// agreementLogEntityMapper.insert(userAgreementLogEntity);
// //隐私协议
// Integer privateVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode());
// AgreementLogEntity privateAgreementLogEntity = new AgreementLogEntity();
// privateAgreementLogEntity.setAgreement_type(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode());
// 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);
Integer protocolId = agreementLogEntityMapper.getLatestProtocolId(2); //获取最新用户协议ID
PProtocolLog log = new PProtocolLog();
log.setUserId(userId.toString());
log.setProtocolId(protocolId);
log.setUserType(2);
log.setType(2);
log.setStatus((short) 1);
log.setCreatedId(userId.intValue());
log.setModifiedId(userId.intValue());
agreementLogEntityMapper.insertProtocolLog(log);
agreementLogEntityMapper.updateSignNum(protocolId); //更新用户协议签署数量
protocolId = agreementLogEntityMapper.getLatestProtocolId(3); //获取最新隐私协议ID
log.setProtocolId(protocolId);
log.setType(3);
agreementLogEntityMapper.insertProtocolLog(log);
agreementLogEntityMapper.updateSignNum(protocolId); //更新隐私协议签署数量
});
}
}
......@@ -140,4 +140,72 @@
modified_time = #{modified_time,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</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>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册