Commit 1ca59fdd authored by 王俊权's avatar 王俊权

Merge remote-tracking branch 'origin/v1' into v1

parents fa11dbeb 7380332b
...@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; ...@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
...@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableFeignClients @EnableFeignClients
@EnableAsync
public class Bootstrap { public class Bootstrap {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -4,6 +4,7 @@ import cn.quantgroup.cashloanflowboss.api.role.entity.Role; ...@@ -4,6 +4,7 @@ import cn.quantgroup.cashloanflowboss.api.role.entity.Role;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank; import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank;
import lombok.Data; import lombok.Data;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -31,7 +32,7 @@ public class Principal { ...@@ -31,7 +32,7 @@ public class Principal {
/** /**
* 角色列表 * 角色列表
*/ */
private Set<Role> roles; private List<Role> roles;
/** /**
* 是否是超级管理员 * 是否是超级管理员
......
...@@ -3,7 +3,7 @@ package cn.quantgroup.cashloanflowboss.api.login.service; ...@@ -3,7 +3,7 @@ package cn.quantgroup.cashloanflowboss.api.login.service;
import cn.quantgroup.cashloanflowboss.api.login.model.Principal; import cn.quantgroup.cashloanflowboss.api.login.model.Principal;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus; import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.api.user.entity.User; import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.api.user.service.UserService; import cn.quantgroup.cashloanflowboss.api.user.service.UserServiceImpl;
import cn.quantgroup.cashloanflowboss.core.asserts.Assert; import cn.quantgroup.cashloanflowboss.core.asserts.Assert;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationDictionary; import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationDictionary;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus; import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
...@@ -11,7 +11,6 @@ import cn.quantgroup.cashloanflowboss.utils.JSONTools; ...@@ -11,7 +11,6 @@ import cn.quantgroup.cashloanflowboss.utils.JSONTools;
import cn.quantgroup.cashloanflowboss.utils.MD5Tools; import cn.quantgroup.cashloanflowboss.utils.MD5Tools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -25,7 +24,7 @@ import javax.servlet.http.HttpSession; ...@@ -25,7 +24,7 @@ import javax.servlet.http.HttpSession;
public class LogService { public class LogService {
@Autowired @Autowired
private UserService userService; private UserServiceImpl userService;
@Autowired @Autowired
private HttpServletRequest request; private HttpServletRequest request;
......
...@@ -107,6 +107,7 @@ public class OrderController { ...@@ -107,6 +107,7 @@ public class OrderController {
} }
} }
/** /**
* 贷前关单 * 贷前关单
* *
......
...@@ -38,6 +38,7 @@ public class OrderVo { ...@@ -38,6 +38,7 @@ public class OrderVo {
audit("审批"), audit("审批"),
cancel("贷前关单"), cancel("贷前关单"),
second_audit("二次风控审批"), second_audit("二次风控审批"),
reload_second_audit_job("刷新待放款任务"),
pay_succ("放款成功"), pay_succ("放款成功"),
pay_fail("放款失败"), pay_fail("放款失败"),
withdraw_second("存管提现"), withdraw_second("存管提现"),
......
...@@ -39,4 +39,6 @@ public interface OrderService { ...@@ -39,4 +39,6 @@ public interface OrderService {
List<CallbackRecordVoModel> getOrderCallbackRecordList(String channelOrderNumber); List<CallbackRecordVoModel> getOrderCallbackRecordList(String channelOrderNumber);
Object findRepaymentPlan(String channelOrderNumber, Long loanId); Object findRepaymentPlan(String channelOrderNumber, Long loanId);
void loadSecondAuditJob();
} }
...@@ -19,9 +19,8 @@ import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping; ...@@ -19,9 +19,8 @@ import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping;
import cn.quantgroup.cashloanflowboss.spi.clf.model.CallbackRecordVoModel; import cn.quantgroup.cashloanflowboss.spi.clf.model.CallbackRecordVoModel;
import cn.quantgroup.cashloanflowboss.spi.clf.repository.ClfOrderMappingRepository; import cn.quantgroup.cashloanflowboss.spi.clf.repository.ClfOrderMappingRepository;
import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterService; import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterService;
import cn.quantgroup.cashloanflowboss.spi.clotho.client.ClothoCenter;
import cn.quantgroup.cashloanflowboss.spi.clotho.service.ClothoCenterService; import cn.quantgroup.cashloanflowboss.spi.clotho.service.ClothoCenterService;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneCenter; import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneService;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneUtil; import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneUtil;
import cn.quantgroup.cashloanflowboss.spi.opapi.OPCenter; import cn.quantgroup.cashloanflowboss.spi.opapi.OPCenter;
import cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService; import cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService;
...@@ -52,7 +51,6 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -52,7 +51,6 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -88,7 +86,7 @@ public class OrderServiceImpl implements OrderService{ ...@@ -88,7 +86,7 @@ public class OrderServiceImpl implements OrderService{
@Autowired @Autowired
private CLFCenterService clfCenterService; private CLFCenterService clfCenterService;
@Autowired @Autowired
private JolyneCenter jolyneCenter; private JolyneService jolyneService;
...@@ -341,15 +339,16 @@ public class OrderServiceImpl implements OrderService{ ...@@ -341,15 +339,16 @@ public class OrderServiceImpl implements OrderService{
Contract conscont= xyqbCenterService.findContractByUserId(orderMapping.getQgUserId()); Contract conscont= xyqbCenterService.findContractByUserId(orderMapping.getQgUserId());
if (conscont != null) { if (conscont != null) {
if (conscont.getGenerateStatus() != 2) { if (conscont.getGenerateStatus() != 2) {
log.info("secondAudit,合同为空,channelOrderNumber=".concat(channelOrderNumber)); log.info("secondAudit,合同状态不对,channelOrderNumber=".concat(channelOrderNumber));
optHistoryLog.setOptName("二次审批操作"); optHistoryLog.setOptName("二次审批操作");
optHistoryLog.setOptLogDetail("合同未生成,请更换新的身份证尝试"); optHistoryLog.setOptLogDetail("合同状态不对,手动修改,可能会导致合同签章获取失败,请更换新的身份证尝试");
optHistoryLog.setOptResult(false); optHistoryLog.setOptResult(false);
optHistoryLog.setCreateTime(new Date()); optHistoryLog.setCreateTime(new Date());
optHistoryLogService.save(optHistoryLog); optHistoryLogService.save(optHistoryLog);
// 修改合同状态
// conscont.setGenerateStatus(2); ArrayList<String> updateContract = Lists.newArrayList();
// xyqbCenterService.saveContract(conscont); updateContract.add("update contract set generate_status = 2 where user_id = " + orderMapping.getQgUserId() + ";");
jolyneService.executeXYQBSQL(JolyneUtil.getJolneSql(updateContract));
} }
} else { } else {
// 合同为空 log表记录问题,UI用户查询 // 合同为空 log表记录问题,UI用户查询
...@@ -400,11 +399,7 @@ public class OrderServiceImpl implements OrderService{ ...@@ -400,11 +399,7 @@ public class OrderServiceImpl implements OrderService{
result = true; result = true;
} }
jolyneService.delayUpdateWaitingXyqbSql(orderMapping.getLoanId(), 200L);
// 更新待放款时间(5分钟之前)
ArrayList<String> updateWaitingFundingCorpOperatePeople = Lists.newArrayList();
updateWaitingFundingCorpOperatePeople.add("update waiting_funding_corp_operate_people set created_at = DATE_SUB(created_at, interval 5 minute) where loan_application_history_id = " + orderMapping.getLoanId() + ";");
jolyneCenter.sqlXyqb(JolyneUtil.getJolneSql(updateWaitingFundingCorpOperatePeople));
optHistoryLog.setOptLogDetail("二次风控操作成功"); optHistoryLog.setOptLogDetail("二次风控操作成功");
optHistoryLog.setOptResult(true); optHistoryLog.setOptResult(true);
...@@ -487,13 +482,13 @@ public class OrderServiceImpl implements OrderService{ ...@@ -487,13 +482,13 @@ public class OrderServiceImpl implements OrderService{
public boolean cancel(OrderVo orderVo) { public boolean cancel(OrderVo orderVo) {
ClfOrderMapping orderMapping = clfOrderMappingRepository.findByChannelOrderNoLastOne(orderVo.getChannelOrderNumber()); ClfOrderMapping orderMapping = clfOrderMappingRepository.findByChannelOrderNoLastOne(orderVo.getChannelOrderNumber());
if (orderMapping == null) { if (orderMapping == null) {
log.info("sqlXyqb,关单失败,无订单 channelOrderNumber={}", orderVo.getChannelOrderNumber()); log.info("executeXYQBSQL,关单失败,无订单 channelOrderNumber={}", orderVo.getChannelOrderNumber());
return false; return false;
} }
XUser xUser = xyqbUserService.findXUserById(orderMapping.getQgUserId()); XUser xUser = xyqbUserService.findXUserById(orderMapping.getQgUserId());
if (xUser == null) { if (xUser == null) {
log.info("sqlXyqb,关单失败,未找到用户 channelOrderNumber={}", orderVo.getChannelOrderNumber()); log.info("executeXYQBSQL,关单失败,未找到用户 channelOrderNumber={}", orderVo.getChannelOrderNumber());
return false; return false;
} }
Long userId = xUser.getId(); Long userId = xUser.getId();
...@@ -506,7 +501,7 @@ public class OrderServiceImpl implements OrderService{ ...@@ -506,7 +501,7 @@ public class OrderServiceImpl implements OrderService{
cancel_list.add("delete from apply_quota_record where user_id=" + userId); cancel_list.add("delete from apply_quota_record where user_id=" + userId);
cancel_list.add("delete from user_operation_history where user_id=" + userId); cancel_list.add("delete from user_operation_history where user_id=" + userId);
data.put("sql", cancel_list); data.put("sql", cancel_list);
String cancel_result = jolyneCenter.sqlXyqb(JSONTools.serialize(data)); String cancel_result = jolyneService.executeXYQBSQL(JSONTools.serialize(data));
return "success".equals(cancel_result); return "success".equals(cancel_result);
} }
...@@ -694,6 +689,12 @@ public class OrderServiceImpl implements OrderService{ ...@@ -694,6 +689,12 @@ public class OrderServiceImpl implements OrderService{
return null; return null;
} }
@Override
public void loadSecondAuditJob() {
jolyneService.fetchDataLoanJob();
jolyneService.loanDataJob();
}
/** /**
* 查询订单状态 * 查询订单状态
......
...@@ -4,7 +4,9 @@ import cn.quantgroup.cashloanflowboss.api.user.entity.User; ...@@ -4,7 +4,9 @@ import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.api.user.model.Pagination; import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.api.user.model.RegisterUserFormModel; import cn.quantgroup.cashloanflowboss.api.user.model.RegisterUserFormModel;
import cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo; import cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo;
import cn.quantgroup.cashloanflowboss.api.user.service.UserService; import cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel;
import cn.quantgroup.cashloanflowboss.api.user.service.UserServiceImpl;
import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security;
import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty; import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty;
import cn.quantgroup.cashloanflowboss.core.base.Result; import cn.quantgroup.cashloanflowboss.core.base.Result;
import cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService; import cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService;
...@@ -28,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -28,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
public class UserController { public class UserController {
@Autowired @Autowired
private UserService userService; private UserServiceImpl userService;
@Autowired @Autowired
private XyqbUserService xyqbUserService; private XyqbUserService xyqbUserService;
...@@ -43,6 +45,19 @@ public class UserController { ...@@ -43,6 +45,19 @@ public class UserController {
return this.userService.createUser(registerUserFormModel.getUsername(), registerUserFormModel.getPassword()); return this.userService.createUser(registerUserFormModel.getUsername(), registerUserFormModel.getPassword());
} }
/**
* 添加用户
*
* @param userInfoModel
* @return
*/
@Security(authorityId = "User.addUser")
@PostMapping("saveUserInfo")
public Result<User> saveUserInfo(@RequestBody UserInfoModel userInfoModel) {
User info = this.userService.saveUserInfo(userInfoModel);
return Result.buildSuccess(info);
}
/** /**
* 获取用户列表(分页) * 获取用户列表(分页)
* *
......
...@@ -8,6 +8,7 @@ import lombok.Data; ...@@ -8,6 +8,7 @@ import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -24,6 +25,12 @@ public class User extends Primary { ...@@ -24,6 +25,12 @@ public class User extends Primary {
@Column(name = "username") @Column(name = "username")
private String username; private String username;
/**
* 昵称
*/
@Column(name = "nickname")
private String nickname;
/** /**
* 密码 * 密码
*/ */
...@@ -48,7 +55,7 @@ public class User extends Primary { ...@@ -48,7 +55,7 @@ public class User extends Primary {
*/ */
@OneToMany(fetch = FetchType.EAGER) @OneToMany(fetch = FetchType.EAGER)
@JoinTable(name = "user_role_mapping", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) @JoinTable(name = "user_role_mapping", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<Role> roles; private List<Role> roles;
/** /**
* 用户状态 * 用户状态
......
...@@ -2,6 +2,7 @@ package cn.quantgroup.cashloanflowboss.api.user.model; ...@@ -2,6 +2,7 @@ package cn.quantgroup.cashloanflowboss.api.user.model;
import cn.quantgroup.cashloanflowboss.api.login.model.Principal; import cn.quantgroup.cashloanflowboss.api.login.model.Principal;
import cn.quantgroup.cashloanflowboss.api.role.entity.Role; import cn.quantgroup.cashloanflowboss.api.role.entity.Role;
import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.core.asserts.Assert; import cn.quantgroup.cashloanflowboss.core.asserts.Assert;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus; import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -33,15 +34,16 @@ public class UserDetailInfo { ...@@ -33,15 +34,16 @@ public class UserDetailInfo {
public static class UserInfo { public static class UserInfo {
private Long userId; private Long userId;
private String userName; private String userName;
private String nickname;
} }
public static UserDetailInfo valueOf(Principal principal) { public static UserDetailInfo valueOf(Principal principal, User user) {
Assert.isNull(principal, ApplicationStatus.INVALID_USER); Assert.isNull(principal, ApplicationStatus.INVALID_USER);
UserDetailInfo userDetailInfo = new UserDetailInfo(); UserDetailInfo userDetailInfo = new UserDetailInfo();
Long userId = principal.getUserId(); Long userId = principal.getUserId();
userDetailInfo.setRank(principal.getRank().name()); userDetailInfo.setRank(principal.getRank().name());
userDetailInfo.setChannelId(principal.getChannelId()); userDetailInfo.setChannelId(principal.getChannelId());
Set<Role> roles = principal.getRoles(); List<Role> roles = principal.getRoles();
if (null != roles && roles.size() > 0) { if (null != roles && roles.size() > 0) {
RoleInfo roleInfo = new RoleInfo(); RoleInfo roleInfo = new RoleInfo();
...@@ -58,6 +60,8 @@ public class UserDetailInfo { ...@@ -58,6 +60,8 @@ public class UserDetailInfo {
UserInfo userInfo = new UserInfo(); UserInfo userInfo = new UserInfo();
userInfo.setUserId(userId); userInfo.setUserId(userId);
userInfo.setNickname(user.getNickname());
userInfo.setUserName(user.getUsername());
userDetailInfo.setUserInfo(userInfo); userDetailInfo.setUserInfo(userInfo);
return userDetailInfo; return userDetailInfo;
......
package cn.quantgroup.cashloanflowboss.api.user.model;
import cn.quantgroup.cashloanflowboss.api.role.entity.Role;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserRank;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty;
import cn.quantgroup.cashloanflowboss.core.persistence.Primary;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* Created by WeiWei on 2019/7/22.
*/
@Data
public class UserInfoModel {
private Long id;
/**
* 用户名
*/
@NotEmpty(message = "用户名不能为空")
private String username;
/**
* 昵称
*/
@NotEmpty(message = "用户昵称不能为空")
private String nickname;
/**
* 密码
*/
private String password;
/**
* 渠道ID
*/
private Long channelId;
/**
* 用户级别
*/
@NotNull(message = "用户级别不能为空")
private UserRank rank;
/**
* 用户角色列表
*/
private List<Role> roles;
/**
* 用户状态
*/
@NotNull(message = "用户活跃状态不能为空")
private UserStatus status;
}
...@@ -22,6 +22,14 @@ public interface UserRepository extends PagingAndSortingRepository<User, String> ...@@ -22,6 +22,14 @@ public interface UserRepository extends PagingAndSortingRepository<User, String>
*/ */
User getUserByUsername(String username); User getUserByUsername(String username);
/**
* 获取用户
*
* @param id
* @return
*/
User findById(Long id);
/** /**
* 获取用户列表(分页) * 获取用户列表(分页)
* *
......
package cn.quantgroup.cashloanflowboss.api.user.service; package cn.quantgroup.cashloanflowboss.api.user.service;
import cn.quantgroup.cashloanflowboss.api.login.model.Principal;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.api.user.entity.User; import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo; import cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo;
import cn.quantgroup.cashloanflowboss.api.user.repository.UserRepository; import cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel;
import cn.quantgroup.cashloanflowboss.core.Application;
import cn.quantgroup.cashloanflowboss.core.asserts.Assert;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
import cn.quantgroup.cashloanflowboss.utils.MD5Tools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.Objects;
/** /**
* Created by WeiWei on 2019/7/22. * function:
* date: 2019/9/19
*
* @author: suntao
*/ */
@Slf4j public interface UserService {
@Service boolean createUser(String username, String password);
public class UserService {
@Autowired
private UserRepository userRepository;
/**
* 创建用户
*
* @param username 用户名
* @param password 登录密码(明文)
* @return
*/
public boolean createUser(String username, String password) {
User user = new User();
user.setUsername(username);
user.setPassword(MD5Tools.md5(password));
user.setStatus(UserStatus.ENABLED);
return Objects.nonNull(this.userRepository.save(user));
}
/**
* 获取用户
*
* @param username 用户名
* @return
*/
public User getUser(String username) {
return this.userRepository.getUserByUsername(username);
}
/**
* 获取用户列表(分页)
*
* @param pageNumber
* @param pageSize
* @return
*/
public Page<User> getUsers(Integer pageNumber, Integer pageSize) {
return this.userRepository.findAllBy(new PageRequest(pageNumber, pageSize));
}
/**
* 启用用户
*
* @param id 用户ID
* @return
*/
public boolean enableUser(String id) {
User user = this.userRepository.findOne(id);
// 检查用户是否存在
Assert.isNull(user, ApplicationStatus.INVALID_USER);
user.setStatus(UserStatus.ENABLED);
return Objects.nonNull(this.userRepository.save(user));
}
/**
* 禁用用户
*
* @param id 用户ID
* @return
*/
public boolean disableUser(String id) {
User user = this.userRepository.findOne(id);
// 检查用户是否存在
Assert.isNull(user, ApplicationStatus.INVALID_USER);
user.setStatus(UserStatus.DISABLED);
return Objects.nonNull(this.userRepository.save(user));
}
/** User getUser(String username);
* 更新用户
*
* @param user
* @return
*/
public User updateUser(User user) {
return this.userRepository.save(user);
}
/** Page<User> getUsers(Integer pageNumber, Integer pageSize);
* 移除用户
*
* @param id 用户ID
* @return
*/
public Boolean removeUser(String id) {
try { boolean enableUser(String id);
this.userRepository.delete(id);
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return false; boolean disableUser(String id);
} User updateUser(User user);
public UserDetailInfo getUserDetailInfo() { Boolean removeUser(String id);
Principal principal = Application.getPrincipal();
Assert.isNull(principal, ApplicationStatus.INVALID_USER);
return UserDetailInfo.valueOf(principal); UserDetailInfo getUserDetailInfo();
}
User saveUserInfo(UserInfoModel user);
} }
package cn.quantgroup.cashloanflowboss.api.user.service;
import cn.quantgroup.cashloanflowboss.api.login.model.Principal;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.api.user.entity.User;
import cn.quantgroup.cashloanflowboss.api.user.model.UserDetailInfo;
import cn.quantgroup.cashloanflowboss.api.user.model.UserInfoModel;
import cn.quantgroup.cashloanflowboss.api.user.repository.UserRepository;
import cn.quantgroup.cashloanflowboss.core.Application;
import cn.quantgroup.cashloanflowboss.core.asserts.Assert;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
import cn.quantgroup.cashloanflowboss.utils.MD5Tools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.HashSet;
import java.util.Objects;
/**
* Created by WeiWei on 2019/7/22.
*/
@Slf4j
@Service
public class UserServiceImpl implements UserService{
@Autowired
private UserRepository userRepository;
/**
* 创建用户
*
* @param username 用户名
* @param password 登录密码(明文)
* @return
*/
@Override
public boolean createUser(String username, String password) {
User user = new User();
user.setUsername(username);
user.setPassword(MD5Tools.md5(password));
user.setStatus(UserStatus.ENABLED);
return Objects.nonNull(this.userRepository.save(user));
}
/**
* 获取用户
*
* @param username 用户名
* @return
*/
@Override
public User getUser(String username) {
return this.userRepository.getUserByUsername(username);
}
/**
* 获取用户列表(分页)
*
* @param pageNumber
* @param pageSize
* @return
*/
@Override
public Page<User> getUsers(Integer pageNumber, Integer pageSize) {
return this.userRepository.findAllBy(new PageRequest(pageNumber, pageSize));
}
/**
* 启用用户
*
* @param id 用户ID
* @return
*/
@Override
public boolean enableUser(String id) {
User user = this.userRepository.findOne(id);
// 检查用户是否存在
Assert.isNull(user, ApplicationStatus.INVALID_USER);
user.setStatus(UserStatus.ENABLED);
return Objects.nonNull(this.userRepository.save(user));
}
/**
* 禁用用户
*
* @param id 用户ID
* @return
*/
@Override
public boolean disableUser(String id) {
User user = this.userRepository.findOne(id);
// 检查用户是否存在
Assert.isNull(user, ApplicationStatus.INVALID_USER);
user.setStatus(UserStatus.DISABLED);
return Objects.nonNull(this.userRepository.save(user));
}
/**
* 更新用户
*
* @param user
* @return
*/
@Override
public User updateUser(User user) {
return this.userRepository.save(user);
}
/**
* 移除用户
*
* @param id 用户ID
* @return
*/
@Override
public Boolean removeUser(String id) {
try {
this.userRepository.delete(id);
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return false;
}
@Override
public UserDetailInfo getUserDetailInfo() {
Principal principal = Application.getPrincipal();
Assert.isNull(principal, ApplicationStatus.INVALID_USER);
User user = userRepository.findById(principal.getUserId());
return UserDetailInfo.valueOf(principal, user);
}
@Override
public User saveUserInfo(UserInfoModel userInfoModel) {
User user1 = new User();
BeanUtils.copyProperties(userInfoModel, user1);
user1.setPassword(MD5Tools.md5(userInfoModel.getUsername()));
user1.setRoles(userInfoModel.getRoles());
return userRepository.save(user1);
}
}
...@@ -2,23 +2,39 @@ package cn.quantgroup.cashloanflowboss.spi.jolyne; ...@@ -2,23 +2,39 @@ package cn.quantgroup.cashloanflowboss.spi.jolyne;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@Component @Component
@FeignClient(name = "JolyneServiceCenter", url = "http://192.168.4.156:9001/executeSQL/"+"${NAMESPACE}", fallback = JolyneCenter.Fallback.class) @FeignClient(name = "JolyneServiceCenter", url = "http://192.168.4.156:9001", fallback = JolyneCenter.Fallback.class)
public interface JolyneCenter { public interface JolyneCenter {
@PostMapping(value = "/executeSQL/"+"${NAMESPACE}" + "/xyqb", consumes = "application/json")
String executeXYQBSQL(String jsonData);
@PostMapping(value = "/xyqb", consumes = "application/json") @GetMapping(value = "/job/clotho-elastic-job/cn.qg.clotho.job.FetchDataLoanJob")
String sqlXyqb(String jsonData); void fetchDataLoanJob(@RequestParam("namespace") String namespace);
@GetMapping(value = "/job/clotho-elastic-job/cn.qg.clotho.job.LoanDataJob")
void loanDataJob(@RequestParam("namespace") String namespace);
@Component @Component
class Fallback implements JolyneCenter { class Fallback implements JolyneCenter {
@Override @Override
public String sqlXyqb(String jsonData) { public String executeXYQBSQL(String jsonData) {
return null; return null;
} }
@Override
public void fetchDataLoanJob(String namespace) {
}
@Override
public void loanDataJob(String namespace) {
}
} }
} }
package cn.quantgroup.cashloanflowboss.spi.jolyne;
/**
* function:
* date: 2019/9/20
*
* @author: suntao
*/
public interface JolyneService {
String executeXYQBSQL(String jsonData);
void fetchDataLoanJob();
void loanDataJob();
String delayUpdateWaitingXyqbSql(Long sqlContent, Long delayTime);
}
package cn.quantgroup.cashloanflowboss.spi.jolyne;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.WaitingFundingCorpOperatePeople;
import cn.quantgroup.cashloanflowboss.spi.xyqb.service.XYQBCenterService;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
/**
* function:
* date: 2019/9/20
*
* @author: suntao
*/
@Slf4j
@Service
public class JolyneServiceImpl implements JolyneService {
@Autowired
private XYQBCenterService xyqbCenterService;
@Autowired
private JolyneCenter jolyneCenter;
@Value("${NAMESPACE}")
private String namespace;
@Override
public String executeXYQBSQL(String jsonData) {
return jolyneCenter.executeXYQBSQL(jsonData);
}
@Override
public void fetchDataLoanJob() {
jolyneCenter.fetchDataLoanJob(namespace);
}
@Override
public void loanDataJob() {
jolyneCenter.loanDataJob(namespace);
}
@Async
@Override
public String delayUpdateWaitingXyqbSql(Long loanId, Long delayTime) {
WaitingFundingCorpOperatePeople waitingFundingCorpOperatePeople = xyqbCenterService.findWaitingFundingCorpOperatePeopleByLoanId(loanId);
int i = 0;
while (waitingFundingCorpOperatePeople == null) {
try {
Thread.sleep(delayTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
waitingFundingCorpOperatePeople = xyqbCenterService.findWaitingFundingCorpOperatePeopleByLoanId(loanId);
if (++ i > 10000) {
return "fail";
}
}
if (waitingFundingCorpOperatePeople.getCreatedAt().getTime() > (System.currentTimeMillis() - 5 * 60 * 1000)) {
// 更新待放款时间(5分钟之前)
ArrayList<String> updateWaitingFundingCorpOperatePeople = Lists.newArrayList();
updateWaitingFundingCorpOperatePeople.add("update waiting_funding_corp_operate_people set created_at = DATE_SUB(created_at, interval 5 minute) where loan_application_history_id = " + loanId + ";");
return jolyneCenter.executeXYQBSQL(JolyneUtil.getJolneSql(updateWaitingFundingCorpOperatePeople));
}
fetchDataLoanJob();
loanDataJob();
return "success";
}
}
...@@ -179,7 +179,7 @@ public class XyqbUserServiceImpl implements XyqbUserService { ...@@ -179,7 +179,7 @@ public class XyqbUserServiceImpl implements XyqbUserService {
cancel_list.add("delete from apply_quota_record where user_id="+userId); cancel_list.add("delete from apply_quota_record where user_id="+userId);
cancel_list.add("delete from user_operation_history where user_id="+userId); cancel_list.add("delete from user_operation_history where user_id="+userId);
data.put("sql",cancel_list); data.put("sql",cancel_list);
String cancel_result = jolyneCenter.sqlXyqb(JSONTools.serialize(data)); String cancel_result = jolyneCenter.executeXYQBSQL(JSONTools.serialize(data));
return "success".equals(cancel_result); return "success".equals(cancel_result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment