commit
57e5b55fa9
101 changed files with 3140 additions and 589 deletions
@ -0,0 +1,97 @@ |
||||
package com.daqing.financial.crms.controller; |
||||
|
||||
import com.daqing.financial.crms.model.request.CompanyAppletRequest; |
||||
import com.daqing.financial.crms.model.request.CompanyCustomerRequest; |
||||
import com.daqing.financial.crms.model.request.PersonalAppletRequest; |
||||
import com.daqing.financial.crms.service.CustomerAppletService; |
||||
import com.daqing.framework.domain.crms.ext.CustomerPersonalTOI; |
||||
import com.daqing.framework.model.response.ResponseResult; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
|
||||
/** |
||||
* 小程序客户模块数据录入(认证) |
||||
* |
||||
* @auther River |
||||
* @date 2021/1/28 14:08 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/customer/applet") |
||||
@Api(value = "客户数据录入(认证)", tags = "小程序客户数据录入(认证)") |
||||
public class CustomerAppletController { |
||||
|
||||
@Autowired |
||||
private CustomerAppletService customerAppletService; |
||||
|
||||
/** |
||||
* 个人类型客户数据录入(认证) |
||||
*/ |
||||
@PostMapping("/save/personal") |
||||
@ApiOperation(value = "个人类型客户数据录入(认证)") |
||||
public ResponseResult savePersonal(@RequestBody @Valid PersonalAppletRequest personalAppletRequest) { |
||||
|
||||
Boolean result = customerAppletService.savePersonal(personalAppletRequest); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
|
||||
/** |
||||
* 企业类型客户数据录入(认证) |
||||
*/ |
||||
@PostMapping("/save/company") |
||||
@ApiOperation(value = "企业类型客户数据录入(认证)") |
||||
public ResponseResult saveCompany(@RequestBody @Valid CompanyAppletRequest companyAppletRequest) { |
||||
|
||||
Boolean result = customerAppletService.saveCompany(companyAppletRequest); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
|
||||
/** |
||||
* 获取当前客户认证(录入)状态 |
||||
*/ |
||||
@GetMapping("/get/status") |
||||
@ApiOperation(value = "获取当前客户认证(录入)状态") |
||||
public ResponseResult getCustomerStatus() { |
||||
|
||||
return ResponseResult.SUCCESS(customerAppletService.getCustomerStatus()); |
||||
} |
||||
|
||||
/** |
||||
* 获取已认证(录入)的客户信息 |
||||
*/ |
||||
@GetMapping("/get/customer") |
||||
@ApiOperation(value = "获取已认证(录入)的客户信息") |
||||
public ResponseResult getCustomer(@RequestParam("type") Integer type) { |
||||
|
||||
return ResponseResult.SUCCESS(customerAppletService.getCustomer(type)); |
||||
} |
||||
|
||||
/** |
||||
* 更新个人类型客户信息 |
||||
*/ |
||||
@ApiOperation(value = "更新个人类型的客户信息") |
||||
@PostMapping("/update/personal") |
||||
public ResponseResult updatePersonal(@RequestBody @Valid PersonalAppletRequest personalAppletRequest) { |
||||
|
||||
Boolean result = customerAppletService.updatePersonal(personalAppletRequest); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
|
||||
/** |
||||
* 更新企业类型的客户信息 |
||||
*/ |
||||
@PostMapping("/update/company") |
||||
@ApiOperation(value = "更新企业类型的客户信息") |
||||
public ResponseResult updateCompany(@RequestBody @Valid CompanyAppletRequest companyAppletRequest) { |
||||
|
||||
Boolean result = customerAppletService.updateCompany(companyAppletRequest); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
} |
@ -0,0 +1,26 @@ |
||||
package com.daqing.financial.crms.dao; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.daqing.framework.domain.crms.CustomerEntity; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
/** |
||||
* 客户小程序认证(录入) |
||||
* |
||||
* @auther River |
||||
* @date 2021/1/27 15:54 |
||||
*/ |
||||
@Mapper |
||||
public interface CustomerAppletDao extends BaseMapper<CustomerEntity> { |
||||
|
||||
Boolean saveCustomerIdAndUserId(@Param("customerId") Integer customerId, @Param("userId") Integer userId, |
||||
@Param("type") Integer type); |
||||
|
||||
Integer getCustomerStatus(@Param("userId") Integer userId, @Param("type") Integer type); |
||||
|
||||
Integer getCustomerId(@Param("userId") Integer userId, @Param("type") Integer type); |
||||
|
||||
Boolean updateCustomer(@Param("customer") CustomerEntity customerEntity); |
||||
|
||||
} |
@ -0,0 +1,92 @@ |
||||
package com.daqing.financial.crms.model.request; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.ToString; |
||||
|
||||
import javax.validation.constraints.NotNull; |
||||
import javax.validation.constraints.Pattern; |
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 小程序客户模块企业类型数据录入(认证) |
||||
* |
||||
* @auther River |
||||
* @date 2021/1/29 11:16 |
||||
*/ |
||||
@Data |
||||
@ToString |
||||
public class CompanyAppletRequest implements Serializable { |
||||
|
||||
@NotNull(message = "客户名称不能为空") |
||||
@ApiModelProperty(value = "客户名称") |
||||
private String name; |
||||
|
||||
@NotNull(message = "社会统一代码不能为空") |
||||
@ApiModelProperty(value = "社会统一代码") |
||||
private String socialUnifiedCode; |
||||
|
||||
@NotNull(message = "联系电话不能为空") |
||||
@Pattern(regexp = "^[0-9]*$",message = "联系电话格式错误") |
||||
@ApiModelProperty(value = "联系电话") |
||||
private String phone; |
||||
|
||||
@ApiModelProperty(value = "注册时间") |
||||
private Date registerTime; |
||||
|
||||
@Pattern(regexp = "^[0-9]+\\.{0,1}[0-9]{0,2}$",message = "注册资金格式有误") |
||||
@NotNull(message = "注册资金不能为空") |
||||
@ApiModelProperty(value = "注册资金") |
||||
private String registeredCapital; |
||||
|
||||
@Pattern(regexp = "^[0-9]*$",message = "员工人数格式错误") |
||||
@NotNull(message = "员工人数不能为空") |
||||
@ApiModelProperty(value = "员工人数") |
||||
private String empNum; |
||||
|
||||
@ApiModelProperty(value = "注册地址") |
||||
private String registerAddr; |
||||
|
||||
@NotNull(message = "联系人不能为空") |
||||
@ApiModelProperty(value = "联系人") |
||||
private String linkman; |
||||
|
||||
@ApiModelProperty(value = "联系人电话") |
||||
private String linkPhone; |
||||
|
||||
@ApiModelProperty(value = "经营地址") |
||||
private String businessAddr; |
||||
|
||||
@NotNull(message = "业务来源不能为空") |
||||
@ApiModelProperty(value = "业务来源") |
||||
private String businessSource; |
||||
|
||||
@ApiModelProperty(value = "经营范围") |
||||
private String businessScope; |
||||
|
||||
@ApiModelProperty(value = "法人-姓名") |
||||
private String legalName; |
||||
|
||||
@ApiModelProperty(value = "法人-性别 1、男,0、女") |
||||
private Integer legalGender; |
||||
|
||||
@ApiModelProperty(value = "法人-身份证号") |
||||
private String legalIdNumber; |
||||
|
||||
@ApiModelProperty(value = "法人-户口所在地") |
||||
private String legalHukouAddr; |
||||
|
||||
@ApiModelProperty(value = "法人-联系电话") |
||||
private String legalPhone; |
||||
|
||||
@ApiModelProperty(value = "法人-家庭住址") |
||||
private String legalHomeAddr; |
||||
|
||||
@ApiModelProperty(value = "是否存在关联人 0->否;1->是") |
||||
private Integer isExistRelated; |
||||
|
||||
@ApiModelProperty(value = "关联人id") |
||||
private List<Integer> relatedId; |
||||
} |
@ -0,0 +1,102 @@ |
||||
package com.daqing.financial.crms.model.request; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.ToString; |
||||
|
||||
import javax.validation.constraints.Max; |
||||
import javax.validation.constraints.Min; |
||||
import javax.validation.constraints.NotNull; |
||||
import javax.validation.constraints.Pattern; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 小程序客户模块个人类型数据录入(认证) |
||||
* |
||||
* @auther River |
||||
* @date 2021/1/29 11:04 |
||||
*/ |
||||
@Data |
||||
@ToString |
||||
public class PersonalAppletRequest implements Serializable { |
||||
|
||||
@NotNull(message = "客户名称不能为空") |
||||
@ApiModelProperty(value = "客户名称") |
||||
private String name; |
||||
|
||||
@NotNull(message = "联系地址不能为空") |
||||
@ApiModelProperty(value = "联系地址") |
||||
private String addr; |
||||
|
||||
@Pattern(regexp = "^[0-9]*$",message = "联系电话格式错误") |
||||
@NotNull(message = "联系电话不能为空") |
||||
@ApiModelProperty(value = "联系电话") |
||||
private String phone; |
||||
|
||||
@NotNull(message = "身份证号不能为空") |
||||
@ApiModelProperty(value = "身份证号") |
||||
private String idCard; |
||||
|
||||
@NotNull(message = "年龄不能为空") |
||||
@ApiModelProperty(value = "年龄") |
||||
private Integer age; |
||||
|
||||
@Min(value = 0,message = "性别格式有误") |
||||
@Max(value = 1,message = "性别格式有误") |
||||
@NotNull(message = "性别不能为空") |
||||
@ApiModelProperty(value = "性别,1、男,0、女") |
||||
private Integer gender; |
||||
|
||||
@Min(value = 0,message = "婚姻状况格式有误") |
||||
@Max(value = 3,message = "婚姻状况格式有误") |
||||
@NotNull(message = "婚姻状况不能为空") |
||||
@ApiModelProperty(value = "婚姻状况,0:未婚,1:已婚,2:离异,3:再婚") |
||||
private Integer maritalStatus; |
||||
|
||||
@Min(value = 0,message = "学历格式有误") |
||||
@Max(value = 4,message = "学历格式有误") |
||||
@NotNull(message = "学历不能为空") |
||||
@ApiModelProperty(value = "学历,0:本科,1:大专,2:高职,3:中专,4:其他") |
||||
private Integer education; |
||||
|
||||
@NotNull(message = "工作单位不能为空") |
||||
@ApiModelProperty(value = "工作单位") |
||||
private String employer; |
||||
|
||||
@NotNull(message = "职务不能为空") |
||||
@ApiModelProperty(value = "职务") |
||||
private String position; |
||||
|
||||
@NotNull(message = "工作年限不能为空") |
||||
@ApiModelProperty(value = "工作年限") |
||||
private Integer workingYears; |
||||
|
||||
@NotNull(message = "社保账号不能为空") |
||||
@ApiModelProperty(value = "社保账号") |
||||
private String socialSecurityNum; |
||||
|
||||
@NotNull(message = "居住情况不能为空") |
||||
@ApiModelProperty(value = "居住情况") |
||||
private String livingSituation; |
||||
|
||||
@NotNull(message = "户籍地址不能为空") |
||||
@ApiModelProperty(value = "户籍地址") |
||||
private String residenceAddr; |
||||
|
||||
@NotNull(message = "业务来源不能为空") |
||||
@ApiModelProperty(value = "业务来源") |
||||
private String businessSource; |
||||
|
||||
@NotNull(message = "紧急联系人不能为空") |
||||
@ApiModelProperty(value = "紧急联系人") |
||||
private String emergencyLinkman; |
||||
|
||||
@NotNull(message = "紧急联系人关系不能为空") |
||||
@ApiModelProperty(value = "紧急联系人关系") |
||||
private String emergencyLinkmanRelationship; |
||||
|
||||
@Pattern(regexp = "^[0-9]*$",message = "紧急联系人电话格式错误") |
||||
@NotNull(message = "紧急联系人电话不能为空") |
||||
@ApiModelProperty(value = "紧急联系人电话") |
||||
private String emergencyLinkmanPhone; |
||||
} |
@ -0,0 +1,29 @@ |
||||
package com.daqing.financial.crms.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.daqing.financial.crms.model.request.CompanyAppletRequest; |
||||
import com.daqing.financial.crms.model.request.PersonalAppletRequest; |
||||
import com.daqing.framework.domain.crms.CustomerEntity; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 客户小程序认证(数据录入) |
||||
* |
||||
* @auther River |
||||
* @date 2021/1/27 15:51 |
||||
*/ |
||||
public interface CustomerAppletService extends IService<CustomerEntity> { |
||||
|
||||
Boolean savePersonal(PersonalAppletRequest personalAppletRequest); |
||||
|
||||
Boolean saveCompany(CompanyAppletRequest companyAppletRequest); |
||||
|
||||
Map getCustomerStatus(); |
||||
|
||||
Object getCustomer(Integer type); |
||||
|
||||
Boolean updatePersonal(PersonalAppletRequest personalAppletRequest); |
||||
|
||||
Boolean updateCompany(CompanyAppletRequest companyAppletRequest); |
||||
} |
@ -0,0 +1,320 @@ |
||||
package com.daqing.financial.crms.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.daqing.financial.crms.dao.CompanyCustomerDao; |
||||
import com.daqing.financial.crms.dao.CustomerAppletDao; |
||||
import com.daqing.financial.crms.dao.CustomerDao; |
||||
import com.daqing.financial.crms.dao.PersonalCustomerDao; |
||||
import com.daqing.financial.crms.mapper.CrmsCustomerRelatedMapper; |
||||
import com.daqing.financial.crms.model.request.CompanyAppletRequest; |
||||
import com.daqing.financial.crms.model.request.CompanyCustomerRequest; |
||||
import com.daqing.financial.crms.model.request.PersonalAppletRequest; |
||||
import com.daqing.financial.crms.service.CustomerAppletService; |
||||
import com.daqing.financial.crms.service.CustomerService; |
||||
import com.daqing.financial.crms.service.ICrmsCustomerRelatedService; |
||||
import com.daqing.framework.domain.crms.CompanyCustomerEntity; |
||||
import com.daqing.framework.domain.crms.CrmsCustomerRelated; |
||||
import com.daqing.framework.domain.crms.CustomerEntity; |
||||
import com.daqing.framework.domain.crms.PersonalCustomerEntity; |
||||
import com.daqing.framework.domain.crms.ext.CrmsConstant; |
||||
import com.daqing.framework.domain.crms.ext.CustomerPersonalTOU; |
||||
import com.daqing.framework.domain.crms.response.CrmsCode; |
||||
import com.daqing.framework.exception.ExceptionCast; |
||||
import com.daqing.framework.model.response.CommonCode; |
||||
import com.daqing.framework.model.response.PromptSuccess; |
||||
import com.daqing.framework.model.response.ResponseResult; |
||||
import com.daqing.framework.util.RedisUtil; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 客户小程序认证(录入) |
||||
* |
||||
* @auther River |
||||
* @date 2021/1/27 15:53 |
||||
*/ |
||||
@Service |
||||
public class CustomerAppletServiceImpl extends ServiceImpl<CustomerAppletDao, CustomerEntity> implements CustomerAppletService { |
||||
|
||||
|
||||
@Autowired |
||||
private CustomerDao customerDao; |
||||
|
||||
@Autowired |
||||
private PersonalCustomerDao personalCustomerDao; |
||||
|
||||
@Autowired |
||||
private CompanyCustomerDao companyCustomerDao; |
||||
|
||||
@Autowired |
||||
private ICrmsCustomerRelatedService crmsCustomerRelatedService; |
||||
|
||||
@Resource |
||||
private CrmsCustomerRelatedMapper crmsCustomerRelatedMapper; |
||||
|
||||
/** |
||||
* 录入(认证)个人类型客户数据 |
||||
*/ |
||||
@Transactional |
||||
@Override |
||||
public Boolean savePersonal(PersonalAppletRequest personalAppletRequest) { |
||||
if (this.getBaseMapper().getCustomerStatus(Integer.parseInt(this.getUserId()), 0) > 0) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_EXIST); |
||||
} |
||||
if (personalAppletRequest.getName() != null && personalAppletRequest.getName().length() != 0) { |
||||
// 客户姓名判重
|
||||
List<String> names = customerDao.listCustomerName(0); // 个人类型客户名称
|
||||
for (String name : names) { |
||||
if (personalAppletRequest.getName().equals(name)) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); |
||||
} |
||||
} |
||||
} |
||||
CustomerEntity customerEntity = new CustomerEntity(); |
||||
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); |
||||
BeanUtils.copyProperties(personalAppletRequest, customerEntity); |
||||
BeanUtils.copyProperties(personalAppletRequest, personalCustomerEntity); |
||||
// 设置客户编号
|
||||
String code = customerDao.getCodeByType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType()); |
||||
if (code == null || code.length() == 0) { |
||||
code = PromptSuccess.PERSONAL_START_CODE; |
||||
} |
||||
int codeNumber = Integer.parseInt(code.substring(code.length() - 4)); |
||||
customerEntity.setCode(PromptSuccess.PERSONAL_CODE + String.format("%04d", (codeNumber + 1))); |
||||
customerEntity.setCreateTime(new Date()); |
||||
customerEntity.setMotifyTime(new Date()); |
||||
customerEntity.setType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType()); |
||||
boolean customer = customerDao.saveCustomer(customerEntity); |
||||
// 将自增的客户id返回给工作台
|
||||
personalCustomerEntity.setCustomerId(customerEntity.getId()); |
||||
boolean personal = personalCustomerDao.savePersonalCustomer(personalCustomerEntity); |
||||
Boolean user = this.getBaseMapper().saveCustomerIdAndUserId(customerEntity.getId().intValue(), Integer.parseInt(this.getUserId()), 0); |
||||
return customer && personal && user; |
||||
} |
||||
|
||||
/** |
||||
* 录入(认证)企业类型的客户数据 |
||||
*/ |
||||
@Transactional |
||||
@Override |
||||
public Boolean saveCompany(CompanyAppletRequest companyAppletRequest) { |
||||
if (this.getBaseMapper().getCustomerStatus(Integer.parseInt(this.getUserId()), 1) > 0) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_EXIST); |
||||
} |
||||
// 客户名称判重
|
||||
if (companyAppletRequest.getName() != null && companyAppletRequest.getName().length() != 0) { |
||||
List<String> names = customerDao.listCustomerName(1); // 企业类型客户名称
|
||||
for (String name : names) { |
||||
if (companyAppletRequest.getName().equals(name)) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); |
||||
} |
||||
} |
||||
} |
||||
CustomerEntity customerEntity = new CustomerEntity(); |
||||
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
||||
BeanUtils.copyProperties(companyAppletRequest, customerEntity); |
||||
BeanUtils.copyProperties(companyAppletRequest, companyCustomerEntity); |
||||
// 设置客户编号
|
||||
String code = customerDao.getCodeByType(CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType()); |
||||
if (code == null || code.length() == 0) { |
||||
code = PromptSuccess.COMPANY_START_CODE; |
||||
} |
||||
int codeNumber = Integer.parseInt(code.substring(code.length() - 4)); |
||||
customerEntity.setCode(PromptSuccess.COMPANY_CODE + String.format("%04d", (codeNumber + 1))); |
||||
customerEntity.setMotifyTime(new Date()); |
||||
customerEntity.setCreateTime(new Date()); |
||||
customerEntity.setType(CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType()); |
||||
boolean customer = customerDao.saveCustomer(customerEntity); |
||||
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
||||
int company = companyCustomerDao.insert(companyCustomerEntity); |
||||
// 绑定客户信息和客户的用户信息
|
||||
Boolean user = this.getBaseMapper().saveCustomerIdAndUserId(customerEntity.getId().intValue(), Integer.parseInt(this.getUserId()), 1); |
||||
if (companyAppletRequest.getIsExistRelated() == 1) {//有关联人的情况下才绑定关联关系
|
||||
//绑定关联关系
|
||||
List<CrmsCustomerRelated> relatedList = new ArrayList<>(); |
||||
List<Integer> intList = companyAppletRequest.getRelatedId(); |
||||
|
||||
for (int i = 0; i < intList.size(); i++) { |
||||
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); |
||||
Integer integer = intList.get(i); |
||||
crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id
|
||||
crmsCustomerRelated.setRelatedId(integer);//关联人/企业id
|
||||
relatedList.add(crmsCustomerRelated); |
||||
} |
||||
crmsCustomerRelatedService.insertCustomerRelated(relatedList); |
||||
} |
||||
if (customer && company > 0 && user) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前客户的认证状态 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Transactional |
||||
@Override |
||||
public Map getCustomerStatus() { |
||||
Map<String, Boolean> map = new HashMap<>(); |
||||
Integer personalCount = this.getBaseMapper().getCustomerStatus(Integer.parseInt(this.getUserId()), 0); |
||||
Integer companyCount = this.getBaseMapper().getCustomerStatus(Integer.parseInt(this.getUserId()), 1); |
||||
if (personalCount > 0) { |
||||
map.put("personal", true); |
||||
} else { |
||||
map.put("personal", false); |
||||
} |
||||
if (companyCount > 0) { |
||||
map.put("company", true); |
||||
} else { |
||||
map.put("company", false); |
||||
} |
||||
return map; |
||||
} |
||||
|
||||
/** |
||||
* 查看认证的详情 |
||||
*/ |
||||
@Override |
||||
public Object getCustomer(Integer type) { |
||||
String userId = this.getUserId(); |
||||
Integer customerId = this.getBaseMapper().getCustomerId(Integer.parseInt(userId), type); |
||||
if (customerId == null) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_IS_NULL); |
||||
} |
||||
// 员工基本信息
|
||||
CustomerEntity customer = customerDao.queryCustomerById((long) customerId); |
||||
// 判断该客户的类型
|
||||
if (type == 0) { |
||||
PersonalAppletRequest personalAppletRequest = new PersonalAppletRequest(); |
||||
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById((long) customerId); |
||||
BeanUtils.copyProperties(customer, personalAppletRequest); |
||||
BeanUtils.copyProperties(personalCustomerEntity, personalAppletRequest); |
||||
return personalAppletRequest; |
||||
} |
||||
if (type == 1) { |
||||
CompanyAppletRequest companyAppletRequest = new CompanyAppletRequest(); |
||||
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.selectOne(new QueryWrapper<CompanyCustomerEntity>() |
||||
.eq("customer_id", (long) customerId)); |
||||
BeanUtils.copyProperties(customer, companyAppletRequest); |
||||
BeanUtils.copyProperties(companyCustomerEntity, companyAppletRequest); |
||||
return companyAppletRequest; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 修改个人类型的认证信息 |
||||
*/ |
||||
@Override |
||||
public Boolean updatePersonal(PersonalAppletRequest personalAppletRequest) { |
||||
Integer customerId = this.getBaseMapper().getCustomerId(Integer.parseInt(this.getUserId()), 0); |
||||
if (customerId == null) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_IS_NULL); |
||||
} |
||||
// 客户名称判重,注意判断是否与原来相同
|
||||
if (personalAppletRequest.getName() != null && personalAppletRequest.getName().length() != 0) { |
||||
String customerName = customerDao.getNameByCustomerId((long) customerId); |
||||
if (!personalAppletRequest.getName().equals(customerName)) { |
||||
List<String> names = customerDao.listCustomerName(0); |
||||
for (String name : names) { |
||||
if (personalAppletRequest.getName().equals(name)) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
CustomerEntity customerEntity = new CustomerEntity(); |
||||
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); |
||||
BeanUtils.copyProperties(personalAppletRequest, customerEntity); |
||||
BeanUtils.copyProperties(personalAppletRequest, personalCustomerEntity); |
||||
customerEntity.setId((long) customerId); |
||||
customerEntity.setMotifyTime(new Date()); |
||||
boolean customer = this.getBaseMapper().updateCustomer(customerEntity); |
||||
personalCustomerEntity.setCustomerId(customerEntity.getId()); |
||||
boolean personal = personalCustomerDao.updatePersonalCustomer(personalCustomerEntity); |
||||
return customer && personal; |
||||
} |
||||
|
||||
/** |
||||
* 修改企业类型的认证信息 |
||||
*/ |
||||
@Override |
||||
public Boolean updateCompany(CompanyAppletRequest companyAppletRequest) { |
||||
Integer customerId = this.getBaseMapper().getCustomerId(Integer.parseInt(this.getUserId()), 1); |
||||
if (customerId == null) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_IS_NULL); |
||||
} |
||||
// 客户名称判重,注意判断是否与原来相同
|
||||
if (companyAppletRequest.getName() != null && companyAppletRequest.getName().length() != 0) { |
||||
String customerName = customerDao.getNameByCustomerId((long) customerId); |
||||
if (!companyAppletRequest.getName().equals(customerName)) { |
||||
List<String> names = customerDao.listCustomerName(1); |
||||
for (String name : names) { |
||||
if (companyAppletRequest.getName().equals(name)) { |
||||
ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
CustomerEntity customerEntity = new CustomerEntity(); |
||||
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
||||
BeanUtils.copyProperties(companyAppletRequest, customerEntity); |
||||
BeanUtils.copyProperties(companyAppletRequest, companyCustomerEntity); |
||||
customerEntity.setId((long) customerId); |
||||
customerEntity.setMotifyTime(new Date()); |
||||
boolean customer = this.getBaseMapper().updateCustomer(customerEntity); |
||||
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
||||
int company = companyCustomerDao.update(companyCustomerEntity, new QueryWrapper<CompanyCustomerEntity>() |
||||
.eq("customer_id", companyCustomerEntity.getCustomerId())); |
||||
|
||||
//根据企业id删除关联关系
|
||||
crmsCustomerRelatedMapper.delete(new QueryWrapper<CrmsCustomerRelated>().eq("customer_id", companyCustomerEntity.getId())); |
||||
|
||||
//绑定关联关系
|
||||
List<CrmsCustomerRelated> relatedList = new ArrayList<>(); |
||||
List<Integer> intList = companyAppletRequest.getRelatedId(); |
||||
|
||||
for (int i = 0; i < intList.size(); i++) { |
||||
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); |
||||
Integer integer = intList.get(i); |
||||
crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id
|
||||
crmsCustomerRelated.setRelatedId(integer);//关联人/企业id
|
||||
relatedList.add(crmsCustomerRelated); |
||||
} |
||||
if (relatedList.size() > 0) { |
||||
crmsCustomerRelatedService.insertCustomerRelated(relatedList); |
||||
} |
||||
|
||||
if (customer && company > 0) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取当前登录用户信息 |
||||
*/ |
||||
private String getUserId() { |
||||
/*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
||||
String token = request.getHeader("token"); |
||||
String userId = RedisUtil.get("dq:token:" + token); |
||||
if (userId == null || userId.length() == 0) { |
||||
ExceptionCast.cast(CommonCode.GET_LOGIN_USER_FAIL); |
||||
}*/ |
||||
String userId = "63"; |
||||
return userId; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,25 @@ |
||||
<?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.daqing.financial.crms.dao.CustomerAppletDao"> |
||||
|
||||
<insert id="saveCustomerIdAndUserId"> |
||||
INSERT INTO crms_customer_user (customer_id, user_id, type) VALUES (#{customerId}, #{userId}, #{type}) |
||||
</insert> |
||||
|
||||
<select id="getCustomerStatus" resultType="integer"> |
||||
SELECT COUNT(id) FROM crms_customer_user WHERE user_id = #{userId} AND type = #{type} |
||||
</select> |
||||
|
||||
<select id="getCustomerId" resultType="integer"> |
||||
SELECT customer_id FROM crms_customer_user WHERE user_id = #{userId} AND type = #{type} |
||||
</select> |
||||
|
||||
<!-- 更新客户基本信息 --> |
||||
<update id="updateCustomer" parameterType="com.daqing.framework.domain.crms.CustomerEntity"> |
||||
UPDATE crms_customer |
||||
SET name=#{customer.name},addr=#{customer.addr},phone=#{customer.phone},motify_time=#{customer.motifyTime} |
||||
WHERE id = #{customer.id} |
||||
</update> |
||||
|
||||
</mapper> |
@ -1,21 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-24 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-apply-amount-list") |
||||
public class DgApplyAmountListController { |
||||
|
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 价值评估记录 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-assets-assessment-assets-log") |
||||
public class DgAssetsAssessmentAssetsLogController { |
||||
|
||||
} |
@ -1,21 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-26 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-assets-money") |
||||
public class DgAssetsMoneyController { |
||||
|
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 合规调查记录 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-compliance-assign-user") |
||||
public class DgComplianceAssignUserController { |
||||
|
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 附件 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-enclosure-info") |
||||
public class DgEnclosureInfoController { |
||||
|
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 企业法人信息 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-legal-info") |
||||
public class DgLegalInfoController { |
||||
|
||||
} |
@ -1,21 +0,0 @@ |
||||
package com.daqing.financial.guarantee.controller; |
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* <p> |
||||
* 流程管理可见表 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-01-15 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/dg-process-manage-visual") |
||||
public class DgProcessManageVisualController { |
||||
|
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.daqing.financial.guarantee.mapper; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.daqing.framework.domain.guarantee.DgBusinessCompany; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 业务关联企业表 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-01-27 |
||||
*/ |
||||
@Mapper |
||||
public interface DgBusinessCompanyMapper extends BaseMapper<DgBusinessCompany> { |
||||
|
||||
} |
@ -1,18 +0,0 @@ |
||||
package com.daqing.financial.guarantee.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.daqing.framework.domain.guarantee.DgComplianceAssignUser; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 合规调查记录 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@Mapper |
||||
public interface DgComplianceAssignUserMapper extends BaseMapper<DgComplianceAssignUser> { |
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.daqing.financial.guarantee.model.request; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
|
||||
/** |
||||
* @Author chen |
||||
* @DATE 2020/11/16 20:16 |
||||
* @Version 1.0 |
||||
* 业务申请列表导出 |
||||
*/ |
||||
@Data |
||||
public class ProcessManageRequest { |
||||
|
||||
@ApiModelProperty("流程管理模板id") |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty("图标") |
||||
private String iconImg; |
||||
|
||||
@ApiModelProperty("审批说明") |
||||
private String approvalInstructions; |
||||
|
||||
@ApiModelProperty("更新时间") |
||||
private Date updateTime; |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package com.daqing.financial.guarantee.model.request; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @Author chen |
||||
* @DATE 2020/11/16 20:16 |
||||
* @Version 1.0 |
||||
* 业务申请列表导出 |
||||
*/ |
||||
@Data |
||||
public class UpdateUserVisualReq { |
||||
|
||||
@ApiModelProperty("流程管理模板id") |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty("可见人id") |
||||
private List<Integer> ids; |
||||
} |
@ -1,34 +1,94 @@ |
||||
package com.daqing.financial.guarantee.model.response; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore; |
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.metadata.BaseRowModel; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.daqing.framework.utils.excel.ApprovalStatusConverter; |
||||
import com.daqing.framework.utils.excel.BusinessStatusConverter; |
||||
import com.daqing.framework.utils.excel.OperatingStatusConverter; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.ToString; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
@ToString |
||||
public class DgNoticeListResponse extends BaseRowModel implements Serializable { |
||||
|
||||
/** |
||||
* 业务编号 |
||||
*/ |
||||
@ExcelProperty(value = "业务编号",index = 0) |
||||
@ApiModelProperty(value = "业务编号") |
||||
private String businessCode; |
||||
|
||||
|
||||
/** |
||||
* 申请时间 |
||||
*/ |
||||
@ExcelProperty(value = "申请日期",index = 6) |
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
@ApiModelProperty(value = "申请时间") |
||||
private Date createTime; |
||||
|
||||
@ApiModelProperty(value = "id") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "企业id") |
||||
private Integer companyId; |
||||
|
||||
@ExcelIgnore |
||||
@ApiModelProperty(value = "业务id") |
||||
private Integer businessId; |
||||
|
||||
@ExcelIgnore |
||||
@ApiModelProperty(value = "角色id") |
||||
private Integer roleId; |
||||
|
||||
@ApiModelProperty(value = "提单人id") |
||||
private Integer presenterId; |
||||
|
||||
@ApiModelProperty(value = "客户名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "联系电话") |
||||
private String phone; |
||||
|
||||
@ApiModelProperty(value = "业务类型") |
||||
private String businessType; |
||||
|
||||
@ApiModelProperty(value = "申请额度") |
||||
private BigDecimal applyAmount; |
||||
|
||||
@ApiModelProperty(value = "申请期限") |
||||
private String applyTime; |
||||
|
||||
@ApiModelProperty("审核状态") |
||||
private Integer status; |
||||
|
||||
@ApiModelProperty("业务状态") |
||||
private Integer businessStatus; |
||||
|
||||
@ApiModelProperty("操作状态") |
||||
private Integer operatingStatus; |
||||
|
||||
//--------------工作会需要内容--------------------------
|
||||
|
||||
@ApiModelProperty("A角") |
||||
private Integer aUserId; |
||||
|
||||
@ApiModelProperty("B角") |
||||
private Integer bUserId; |
||||
|
||||
@ApiModelProperty("法规部领导") |
||||
private Integer iUserId; |
||||
|
||||
@ApiModelProperty("资产部领导") |
||||
private Integer assUserId; |
||||
|
||||
@ApiModelProperty("信息部领导") |
||||
private Integer mUserId; |
||||
//-------------------结束-----------------------------
|
||||
|
||||
@ApiModelProperty("业务管理模块id") |
||||
private Integer modelId; |
||||
|
||||
} |
||||
|
@ -0,0 +1,17 @@ |
||||
package com.daqing.financial.guarantee.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.daqing.framework.domain.guarantee.DgBusinessCompany; |
||||
|
||||
/** |
||||
* <p> |
||||
* 业务关联企业表 服务类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-01-27 |
||||
*/ |
||||
public interface IDgBusinessCompanyService extends IService<DgBusinessCompany> { |
||||
|
||||
} |
@ -1,16 +0,0 @@ |
||||
package com.daqing.financial.guarantee.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.daqing.framework.domain.guarantee.DgComplianceAssignUser; |
||||
|
||||
/** |
||||
* <p> |
||||
* 合规调查记录 服务类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
public interface IDgComplianceAssignUserService extends IService<DgComplianceAssignUser> { |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.daqing.financial.guarantee.service.impl; |
||||
|
||||
import com.daqing.financial.guarantee.mapper.DgBusinessCompanyMapper; |
||||
import com.daqing.financial.guarantee.service.IDgBusinessCompanyService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.daqing.framework.domain.guarantee.DgBusinessCompany; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 业务关联企业表 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-01-27 |
||||
*/ |
||||
@Service |
||||
public class DgBusinessCompanyServiceImpl extends ServiceImpl<DgBusinessCompanyMapper, DgBusinessCompany> implements IDgBusinessCompanyService { |
||||
|
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.daqing.financial.guarantee.service.impl; |
||||
|
||||
import com.daqing.financial.guarantee.mapper.DgComplianceAssignUserMapper; |
||||
import com.daqing.financial.guarantee.service.IDgComplianceAssignUserService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.daqing.framework.domain.guarantee.DgComplianceAssignUser; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 合规调查记录 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@Service |
||||
public class DgComplianceAssignUserServiceImpl extends ServiceImpl<DgComplianceAssignUserMapper, DgComplianceAssignUser> implements IDgComplianceAssignUserService { |
||||
|
||||
} |
@ -0,0 +1,34 @@ |
||||
<?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.daqing.financial.guarantee.mapper.DgBusinessCompanyMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="BaseResultMap" type="com.daqing.framework.domain.guarantee.DgBusinessCompany"> |
||||
<id column="id" property="id" /> |
||||
<result column="business_id" property="businessId" /> |
||||
<result column="registered_capital" property="registeredCapital" /> |
||||
<result column="social_unified_code" property="socialUnifiedCode" /> |
||||
<result column="emp_num" property="empNum" /> |
||||
<result column="linkman" property="linkman" /> |
||||
<result column="link_phone" property="linkPhone" /> |
||||
<result column="business_source" property="businessSource" /> |
||||
<result column="business_scope" property="businessScope" /> |
||||
<result column="business_addr" property="businessAddr" /> |
||||
<result column="register_time" property="registerTime" /> |
||||
<result column="register_addr" property="registerAddr" /> |
||||
<result column="legal_id_number" property="legalIdNumber" /> |
||||
<result column="legal_hukou_addr" property="legalHukouAddr" /> |
||||
<result column="legal_phone" property="legalPhone" /> |
||||
<result column="legal_home_addr" property="legalHomeAddr" /> |
||||
<result column="legal_gender" property="legalGender" /> |
||||
<result column="legal_name" property="legalName" /> |
||||
<result column="is_exist_related" property="isExistRelated" /> |
||||
<result column="code" property="code" /> |
||||
<result column="type" property="type" /> |
||||
<result column="name" property="name" /> |
||||
<result column="addr" property="addr" /> |
||||
<result column="phone" property="phone" /> |
||||
<result column="customer_id" property="customerId" /> |
||||
</resultMap> |
||||
|
||||
</mapper> |
@ -1,20 +0,0 @@ |
||||
<?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.daqing.financial.guarantee.mapper.DgComplianceAssignUserMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="BaseResultMap" type="com.daqing.framework.domain.guarantee.DgComplianceAssignUser"> |
||||
<id column="id" property="id" /> |
||||
<result column="company_id" property="companyId" /> |
||||
<result column="emp_id" property="empId" /> |
||||
<result column="type" property="type" /> |
||||
<result column="status" property="status" /> |
||||
<result column="amount" property="amount" /> |
||||
<result column="term" property="term" /> |
||||
<result column="remark" property="remark" /> |
||||
<result column="apply_content" property="applyContent" /> |
||||
<result column="create_time" property="createTime" /> |
||||
<result column="update_time" property="updateTime" /> |
||||
</resultMap> |
||||
|
||||
</mapper> |
@ -0,0 +1,66 @@ |
||||
package com.daqing.financial.hrauth.handle; |
||||
|
||||
import com.daqing.financial.hrauth.model.ApiResult; |
||||
import com.daqing.financial.hrauth.service.impl.UserDetailsServiceImpl; |
||||
import com.daqing.financial.hrauth.util.ResponseUtils; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.security.access.AccessDeniedException; |
||||
import org.springframework.security.web.access.AccessDeniedHandler; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.io.PrintWriter; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Security自定义异常处理类 |
||||
* @Author: jialing xu |
||||
* @Description: xvjialing@outlook.com |
||||
* @Date: 17:24 2018/8/7 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
public class CustomAccessDeniedHandler implements AccessDeniedHandler { |
||||
|
||||
@Autowired |
||||
private ObjectMapper objectMapper; |
||||
|
||||
private final UserDetailsServiceImpl userDetailsService; |
||||
|
||||
protected CustomAccessDeniedHandler(UserDetailsServiceImpl userDetailsService) { |
||||
this.userDetailsService = userDetailsService; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException { |
||||
/* log.error("Token异常处理来了~~~~"+accessDeniedException.getMessage()); |
||||
response.setContentType("application/json;charset=UTF-8"); |
||||
Map map = new HashMap(); |
||||
map.put("code", "403"); |
||||
map.put("msg", accessDeniedException.getMessage()); |
||||
map.put("data",""); |
||||
response.setContentType("application/json"); |
||||
response.setStatus(HttpServletResponse.SC_OK); |
||||
response.getWriter().write(objectMapper.writeValueAsString(map));*/ |
||||
|
||||
// ResponseUtils.out(response, ApiResult.fail(401, e.getMessage()));
|
||||
String token = request.getHeader("token"); |
||||
if (StringUtils.isNotBlank(token)) { |
||||
// 检查token
|
||||
SecurityUser securityUser = userDetailsService.getUserByToken(token); |
||||
if (securityUser == null || securityUser.getCurrentUserInfo() == null) { |
||||
//ExceptionCast.cast(HrmsCode.TOKEN_EXCEPTION);
|
||||
throw new AccessDeniedException("TOKEN已过期,请重新登录~~~"); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,25 @@ |
||||
package com.daqing.financial.hrauth.model; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p> |
||||
* 访问记录表 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-01-12 |
||||
*/ |
||||
@Data |
||||
public class XccLoginReq implements Serializable { |
||||
|
||||
private String encryptedData;//明文,加密数据
|
||||
private String iv;//加密算法的初始向量
|
||||
private String code;//用户允许登录后,回调内容会带上 code(有效期五分钟),开发者需要将 code 发送到开发者服务器后台
|
||||
// ,使用code 换取 session_key api,将 code 换成 openid 和 session_key
|
||||
|
||||
} |
@ -0,0 +1,73 @@ |
||||
package com.daqing.financial.hrauth.util; |
||||
|
||||
import java.security.AlgorithmParameters; |
||||
import java.security.InvalidAlgorithmParameterException; |
||||
import java.security.InvalidKeyException; |
||||
import java.security.Key; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.security.NoSuchProviderException; |
||||
import java.security.Security; |
||||
|
||||
import javax.crypto.BadPaddingException; |
||||
import javax.crypto.Cipher; |
||||
import javax.crypto.IllegalBlockSizeException; |
||||
import javax.crypto.NoSuchPaddingException; |
||||
import javax.crypto.spec.IvParameterSpec; |
||||
import javax.crypto.spec.SecretKeySpec; |
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider; |
||||
|
||||
public class AES { |
||||
public static boolean initialized = false; |
||||
|
||||
/** |
||||
* AES对称解密工具类 |
||||
* |
||||
* @param content |
||||
* 密文 |
||||
* @return |
||||
* @throws InvalidAlgorithmParameterException |
||||
* @throws NoSuchProviderException |
||||
*/ |
||||
public byte[] decrypt(byte[] content, byte[] keyByte, byte[] ivByte) throws InvalidAlgorithmParameterException { |
||||
initialize(); |
||||
try { |
||||
// java是没有
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); |
||||
Key sKeySpec = new SecretKeySpec(keyByte, "AES"); |
||||
|
||||
cipher.init(Cipher.DECRYPT_MODE, sKeySpec, generateIV(ivByte));// 初始化
|
||||
byte[] result = cipher.doFinal(content); |
||||
return result; |
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidKeyException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalBlockSizeException e) { |
||||
e.printStackTrace(); |
||||
} catch (BadPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchProviderException e) { |
||||
e.printStackTrace(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static void initialize() { |
||||
if (initialized) |
||||
return; |
||||
Security.addProvider(new BouncyCastleProvider()); |
||||
initialized = true; |
||||
} |
||||
|
||||
// 生成iv
|
||||
public static AlgorithmParameters generateIV(byte[] iv) throws Exception { |
||||
AlgorithmParameters params = AlgorithmParameters.getInstance("AES"); |
||||
params.init(new IvParameterSpec(iv)); |
||||
return params; |
||||
} |
||||
} |
@ -0,0 +1,171 @@ |
||||
package com.daqing.financial.hrauth.util; |
||||
|
||||
import org.apache.commons.codec.binary.Base64; |
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider; |
||||
|
||||
import javax.crypto.*; |
||||
import javax.crypto.spec.IvParameterSpec; |
||||
import javax.crypto.spec.SecretKeySpec; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.security.*; |
||||
import java.security.spec.InvalidParameterSpecException; |
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* Created by yfs on 2018/3/25. |
||||
* <p> |
||||
* AES-128-CBC 加密方式 |
||||
* 注: |
||||
* AES-128-CBC可以自己定义“密钥”和“偏移量“。 |
||||
* AES-128是jdk自动生成的“密钥”。 |
||||
*/ |
||||
public class AesCbcUtil { |
||||
|
||||
|
||||
static { |
||||
//BouncyCastle是一个开源的加解密解决方案,主页在http://www.bouncycastle.org/
|
||||
Security.addProvider(new BouncyCastleProvider()); |
||||
} |
||||
|
||||
/** |
||||
* AES解密 |
||||
* |
||||
* @param data //密文,被加密的数据
|
||||
* @param key //秘钥
|
||||
* @param iv //偏移量
|
||||
* @param encodingFormat //解密后的结果需要进行的编码
|
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String decrypt(String data, String key, String iv, String encodingFormat) throws Exception { |
||||
// initialize();
|
||||
|
||||
//被加密的数据
|
||||
byte[] dataByte = Base64.decodeBase64(data); |
||||
//加密秘钥
|
||||
byte[] keyByte = Base64.decodeBase64(key); |
||||
//偏移量
|
||||
byte[] ivByte = Base64.decodeBase64(iv); |
||||
|
||||
|
||||
try { |
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); |
||||
|
||||
SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); |
||||
|
||||
AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); |
||||
parameters.init(new IvParameterSpec(ivByte)); |
||||
|
||||
cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化
|
||||
|
||||
byte[] resultByte = cipher.doFinal(dataByte); |
||||
if (null != resultByte && resultByte.length > 0) { |
||||
String result = new String(resultByte, encodingFormat); |
||||
return result; |
||||
} |
||||
return null; |
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidParameterSpecException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidKeyException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidAlgorithmParameterException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalBlockSizeException e) { |
||||
e.printStackTrace(); |
||||
} catch (BadPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (UnsupportedEncodingException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* AES解密 |
||||
* |
||||
* @param encryptedData 消息密文 |
||||
* @param ivStr iv字符串 |
||||
*/ |
||||
public static byte[] decrypt2(String sessionKey, String encryptedData, String ivStr) { |
||||
try { |
||||
AlgorithmParameters params = AlgorithmParameters.getInstance("AES"); |
||||
params.init(new IvParameterSpec(Base64.decodeBase64(ivStr))); |
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); |
||||
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(Base64.decodeBase64(sessionKey), "AES"), params); |
||||
|
||||
String encodingFormat = "UTF-8"; |
||||
byte[] resultByte = cipher.doFinal(Base64.decodeBase64(encryptedData)); |
||||
return resultByte; |
||||
/* System.out.println("resultByte===="+resultByte); |
||||
if (null != resultByte && resultByte.length > 0) { |
||||
String result = new String(resultByte, encodingFormat); |
||||
return result; |
||||
} |
||||
return null;*/ |
||||
//return new String(PKCS7Encoder.decode(cipher.doFinal(Base64.decodeBase64(encryptedData))), StandardCharsets.UTF_8);
|
||||
} catch (Exception e) { |
||||
throw new RuntimeException("AES解密失败", e); |
||||
} |
||||
} |
||||
|
||||
|
||||
public static String decryptNew(String encryptedData, String sessionKey, String iv) throws Exception { |
||||
String result = ""; |
||||
// 被加密的数据
|
||||
byte[] dataByte = Base64.decodeBase64(encryptedData); |
||||
// 加密秘钥
|
||||
byte[] keyByte = Base64.decodeBase64(sessionKey); |
||||
// 偏移量
|
||||
byte[] ivByte = Base64.decodeBase64(iv); |
||||
try { |
||||
// 如果密钥不足16位,那么就补足. 这个if 中的内容很重要
|
||||
int base = 16; |
||||
if (keyByte.length % base != 0) { |
||||
int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0); |
||||
byte[] temp = new byte[groups * base]; |
||||
Arrays.fill(temp, (byte) 0); |
||||
System.arraycopy(keyByte, 0, temp, 0, keyByte.length); |
||||
keyByte = temp; |
||||
} |
||||
// 初始化
|
||||
Security.addProvider(new BouncyCastleProvider()); |
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC"); |
||||
SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); |
||||
AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); |
||||
parameters.init(new IvParameterSpec(ivByte)); |
||||
// 初始化
|
||||
cipher.init(Cipher.DECRYPT_MODE, spec, parameters); |
||||
byte[] resultByte = cipher.doFinal(dataByte); |
||||
if (null != resultByte && resultByte.length > 0) { |
||||
result = new String(resultByte, "UTF-8"); |
||||
} |
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidParameterSpecException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalBlockSizeException e) { |
||||
e.printStackTrace(); |
||||
} catch (BadPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (UnsupportedEncodingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidKeyException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidAlgorithmParameterException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchProviderException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,137 @@ |
||||
package com.daqing.financial.hrauth.util; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.IOException; |
||||
import java.io.InputStreamReader; |
||||
import java.io.PrintWriter; |
||||
import java.net.URL; |
||||
import java.net.URLConnection; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class HttpRequest { |
||||
|
||||
public static void main(String[] args) { |
||||
//发送 GET 请求
|
||||
String s=HttpRequest.sendGet("http://v.qq.com/x/cover/kvehb7okfxqstmc.html?vid=e01957zem6o", ""); |
||||
System.out.println(s); |
||||
|
||||
// //发送 POST 请求
|
||||
// String sr=HttpRequest.sendPost("http://www.toutiao.com/stream/widget/local_weather/data/?city=%E4%B8%8A%E6%B5%B7", "");
|
||||
// JSONObject json = JSONObject.fromObject(sr);
|
||||
// System.out.println(json.get("data"));
|
||||
} |
||||
|
||||
/** |
||||
* 向指定URL发送GET方法的请求 |
||||
* |
||||
* @param url |
||||
* 发送请求的URL |
||||
* @param param |
||||
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 |
||||
* @return URL 所代表远程资源的响应结果 |
||||
*/ |
||||
public static String sendGet(String url, String param) { |
||||
String result = ""; |
||||
BufferedReader in = null; |
||||
try { |
||||
String urlNameString = url + "?" + param; |
||||
URL realUrl = new URL(urlNameString); |
||||
// 打开和URL之间的连接
|
||||
URLConnection connection = realUrl.openConnection(); |
||||
// 设置通用的请求属性
|
||||
connection.setRequestProperty("accept", "*/*"); |
||||
connection.setRequestProperty("connection", "Keep-Alive"); |
||||
connection.setRequestProperty("user-agent", |
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
||||
// 建立实际的连接
|
||||
connection.connect(); |
||||
// 获取所有响应头字段
|
||||
Map<String, List<String>> map = connection.getHeaderFields(); |
||||
// 遍历所有的响应头字段
|
||||
for (String key : map.keySet()) { |
||||
System.out.println(key + "--->" + map.get(key)); |
||||
} |
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader( |
||||
connection.getInputStream())); |
||||
String line; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line; |
||||
} |
||||
} catch (Exception e) { |
||||
System.out.println("发送GET请求出现异常!" + e); |
||||
e.printStackTrace(); |
||||
} |
||||
// 使用finally块来关闭输入流
|
||||
finally { |
||||
try { |
||||
if (in != null) { |
||||
in.close(); |
||||
} |
||||
} catch (Exception e2) { |
||||
e2.printStackTrace(); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 向指定 URL 发送POST方法的请求 |
||||
* |
||||
* @param url |
||||
* 发送请求的 URL |
||||
* @param param |
||||
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 |
||||
* @return 所代表远程资源的响应结果 |
||||
*/ |
||||
public static String sendPost(String url, String param) { |
||||
PrintWriter out = null; |
||||
BufferedReader in = null; |
||||
String result = ""; |
||||
try { |
||||
URL realUrl = new URL(url); |
||||
// 打开和URL之间的连接
|
||||
URLConnection conn = realUrl.openConnection(); |
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestProperty("connection", "Keep-Alive"); |
||||
conn.setRequestProperty("user-agent", |
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream()); |
||||
// 发送请求参数
|
||||
out.print(param); |
||||
// flush输出流的缓冲
|
||||
out.flush(); |
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader( |
||||
new InputStreamReader(conn.getInputStream())); |
||||
String line; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line; |
||||
} |
||||
} catch (Exception e) { |
||||
System.out.println("发送 POST 请求出现异常!"+e); |
||||
e.printStackTrace(); |
||||
} |
||||
//使用finally块来关闭输出流、输入流
|
||||
finally{ |
||||
try{ |
||||
if(out!=null){ |
||||
out.close(); |
||||
} |
||||
if(in!=null){ |
||||
in.close(); |
||||
} |
||||
} |
||||
catch(IOException ex){ |
||||
ex.printStackTrace(); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
package com.daqing.financial.hrauth.util; |
||||
/** |
||||
* 对公众平台发送给公众账号的消息加解密示例代码. |
||||
* |
||||
* @copyright Copyright (c) 1998-2014 Tencent Inc. |
||||
*/ |
||||
|
||||
import java.nio.charset.Charset; |
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* 提供基于PKCS7算法的加解 |
||||
*/ |
||||
public class PKCS7Encoder { |
||||
|
||||
private static final Charset CHARSET = Charset.forName("utf-8"); |
||||
private static final int BLOCK_SIZE = 32; |
||||
|
||||
/** |
||||
* 获得对明文进行补位填充的字节. |
||||
* |
||||
* @param count 需要进行填充补位操作的明文字节个数 |
||||
* @return 补齐用的字节数组 |
||||
*/ |
||||
public static byte[] encode(int count) { |
||||
// 计算需要填充的位数
|
||||
int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); |
||||
if (amountToPad == 0) { |
||||
amountToPad = BLOCK_SIZE; |
||||
} |
||||
// 获得补位所用的字符
|
||||
char padChr = chr(amountToPad); |
||||
String tmp = new String(); |
||||
for (int index = 0; index < amountToPad; index++) { |
||||
tmp += padChr; |
||||
} |
||||
return tmp.getBytes(CHARSET); |
||||
} |
||||
|
||||
/** |
||||
* 删除解密后明文的补位字符 |
||||
* |
||||
* @param decrypted 解密后的明文 |
||||
* @return 删除补位字符后的明文 |
||||
*/ |
||||
public static byte[] decode(byte[] decrypted) { |
||||
int pad = decrypted[decrypted.length - 1]; |
||||
if (pad < 1 || pad > 32) { |
||||
pad = 0; |
||||
} |
||||
return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); |
||||
} |
||||
|
||||
/** |
||||
* 将数字转化成ASCII码对应的字符,用于对明文进行补码 |
||||
* |
||||
* @param a 需要转化的数字 |
||||
* @return 转化得到的字符 |
||||
*/ |
||||
public static char chr(int a) { |
||||
byte target = (byte) (a & 0xFF); |
||||
return (char) target; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,198 @@ |
||||
package com.daqing.financial.hrauth.util; |
||||
|
||||
import com.google.common.primitives.Bytes; |
||||
import org.apache.commons.codec.binary.Base64; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
import java.security.InvalidAlgorithmParameterException; |
||||
import java.security.InvalidKeyException; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.security.SecureRandom; |
||||
|
||||
import javax.crypto.BadPaddingException; |
||||
import javax.crypto.Cipher; |
||||
import javax.crypto.IllegalBlockSizeException; |
||||
import javax.crypto.KeyGenerator; |
||||
import javax.crypto.NoSuchPaddingException; |
||||
import javax.crypto.SecretKey; |
||||
import javax.crypto.spec.SecretKeySpec; |
||||
|
||||
public class TestUtil { |
||||
/** |
||||
* 加密 |
||||
* |
||||
* @param content |
||||
* 需要加密的内容 |
||||
* @param password |
||||
* 加密密码 |
||||
* @return |
||||
*/ |
||||
public static byte[] encrypt(String content, String password) { |
||||
try { |
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES"); |
||||
kgen.init(128, new SecureRandom(password.getBytes())); |
||||
SecretKey secretKey = kgen.generateKey(); |
||||
byte[] enCodeFormat = secretKey.getEncoded(); |
||||
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); |
||||
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
|
||||
byte[] byteContent = content.getBytes("utf-8"); |
||||
cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化
|
||||
byte[] result = cipher.doFinal(byteContent); |
||||
return result; // 加密
|
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidKeyException e) { |
||||
e.printStackTrace(); |
||||
} catch (UnsupportedEncodingException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalBlockSizeException e) { |
||||
e.printStackTrace(); |
||||
} catch (BadPaddingException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 解密 |
||||
* |
||||
* @param content |
||||
* 待解密内容 |
||||
* @param password |
||||
* 解密密钥 |
||||
* @return |
||||
*/ |
||||
public static byte[] decrypt(byte[] content, String password) { |
||||
try { |
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES"); |
||||
kgen.init(128, new SecureRandom(password.getBytes())); |
||||
SecretKey secretKey = kgen.generateKey(); |
||||
byte[] enCodeFormat = secretKey.getEncoded(); |
||||
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); |
||||
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);// 初始化
|
||||
byte[] result = cipher.doFinal(content); |
||||
return result; // 加密
|
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidKeyException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalBlockSizeException e) { |
||||
e.printStackTrace(); |
||||
} catch (BadPaddingException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 将二进制转换成16进制 |
||||
* |
||||
* @param buf |
||||
* @return |
||||
*/ |
||||
public static String parseByte2HexStr(byte buf[]) { |
||||
StringBuffer sb = new StringBuffer(); |
||||
for (int i = 0; i < buf.length; i++) { |
||||
String hex = Integer.toHexString(buf[i] & 0xFF); |
||||
if (hex.length() == 1) { |
||||
hex = '0' + hex; |
||||
} |
||||
sb.append(hex.toUpperCase()); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 将16进制转换为二进制 |
||||
* |
||||
* @param hexStr |
||||
* @return |
||||
*/ |
||||
public static byte[] parseHexStr2Byte(String hexStr) { |
||||
if (hexStr.length() < 1) |
||||
return null; |
||||
byte[] result = new byte[hexStr.length() / 2]; |
||||
for (int i = 0; i < hexStr.length() / 2; i++) { |
||||
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); |
||||
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16); |
||||
result[i] = (byte) (high * 16 + low); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 加密 |
||||
* |
||||
* @param content |
||||
* 需要加密的内容 |
||||
* @param password |
||||
* 加密密码 |
||||
* @return |
||||
*/ |
||||
public static byte[] encrypt2(String content, String password) { |
||||
try { |
||||
SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES"); |
||||
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding"); |
||||
byte[] byteContent = content.getBytes("utf-8"); |
||||
cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化
|
||||
byte[] result = cipher.doFinal(byteContent); |
||||
return result; // 加密
|
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (NoSuchPaddingException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvalidKeyException e) { |
||||
e.printStackTrace(); |
||||
} catch (UnsupportedEncodingException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalBlockSizeException e) { |
||||
e.printStackTrace(); |
||||
} catch (BadPaddingException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException, InvalidAlgorithmParameterException { |
||||
String encryptedData="+WQuaG5Tr9EU6f+Cx7OR7O8/HbVAUK77P9/BRqhdA4qYKLcw0sbS1R5DfoU+D4HEpoUCXtmRH/gP" + |
||||
"eJqYFJpauBysbadiYrZ6wYWjp5wP+HgxWnfCOk7jwR8WUdvFFDuQMhAVudnFhhNP3g4iHfCeiU5yfmN4iw" + |
||||
"gpL4txJpuZDHhyjqBqGGxntyxgxHFonbFi94e+IaPrFqigvqJXI9RGW9eXUVhZEQGeadv+eW72ucPq90KGH" + |
||||
"wPj0uUMWRWPJC8ZWp+uRUbrENiKfo9QJqiMljq/wcbz4c/u/Wd7PF4o4s02uutMjsrpYdnpw20E7DDpUIBU" + |
||||
"fIkeDmIFOIEQYPAGbTFtbHwPyyrx/r+fSihmO6PRwAlUrfhCOZ3KNkmtqZPDjqfHGrW+MeiquW5vryXL8FWy++z" + |
||||
"OVdGzymGvW6E/hSVDoTNL4+zeuxhJAXCnuPjLtYeL0EkGam8ks0KDqhZy3gUwRwrM0HFzQ1IryTMsqeLCcLMm" + |
||||
"0vWG4PEuPv5j5+V66MTGYvyyM2v67zK7Z2cn2A=="; |
||||
String iv="zI+P8RVxEwMFBXcJDCemHg=="; |
||||
String session_key="Piqc8iFe6pN0i5ofq4Y6PA=="; |
||||
|
||||
String content = encryptedData; |
||||
String password = ""; |
||||
// 加密
|
||||
System.out.println("加密前:" + content); |
||||
byte[] encode = encrypt(content, password); |
||||
|
||||
//传输过程,不转成16进制的字符串,就等着程序崩溃掉吧
|
||||
String code = parseByte2HexStr(encode); |
||||
System.out.println("密文字符串:" + code); |
||||
byte[] decode = parseHexStr2Byte(code); |
||||
// 解密
|
||||
byte[] decryptResult = decrypt(decode, password); |
||||
System.out.println("decryptResult==="+decryptResult); |
||||
System.out.println("解密后:" + new String(decryptResult, "UTF-8")); //不转码会乱码
|
||||
System.out.println("========================================================="); |
||||
|
||||
byte[] dataByte = Base64.decodeBase64(session_key); |
||||
//byte[] d = TestUtil.parseHexStr2Byte(encryptedData);
|
||||
byte[] dr = decrypt(dataByte, ""); |
||||
//String re = new String(dr, "UTF-8");
|
||||
//System.out.println("result====="+re);
|
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,115 @@ |
||||
package com.daqing.financial.hrauth.util; |
||||
import javax.crypto.Cipher; |
||||
import javax.crypto.spec.IvParameterSpec; |
||||
import javax.crypto.spec.SecretKeySpec; |
||||
|
||||
import sun.misc.BASE64Decoder; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
/** |
||||
* 对微信小程序用户加密数据的解密示例代码. |
||||
* |
||||
* @ClassName WXBizDataCrypt |
||||
* @Description TODO(这里用一句话描述这个类的作用) |
||||
* @author tf |
||||
* @Date 2016年11月19日 下午2:56:36 |
||||
* @version 1.0.0 |
||||
*/ |
||||
@SuppressWarnings("restriction") |
||||
public class WXBizDataCrypt { |
||||
/* |
||||
* 加密用的Key 可以用26个字母和数字组成 此处使用AES-128-CBC加密模式,key需要为16位。 |
||||
*/ |
||||
private static WXBizDataCrypt instance = null; |
||||
|
||||
private WXBizDataCrypt() { |
||||
|
||||
} |
||||
|
||||
public static WXBizDataCrypt getInstance() { |
||||
if (instance == null) |
||||
instance = new WXBizDataCrypt(); |
||||
return instance; |
||||
} |
||||
|
||||
/** |
||||
* 对于官方加密数据(encryptData)解密说明如下: 加密数据解密算法 接口如果涉及敏感数据(如wx.getUserInfo当中的 |
||||
* openId 和unionId ),接口的明文内容将不包含这些敏感数据。开发者如需要获取敏感数据,需要对接口返回的加密数据( |
||||
* encryptedData )进行对称解密。 解密算法如下: 对称解密使用的算法为 AES-128-CBC,数据采用PKCS#7填充。 |
||||
* 对称解密的目标密文为 Base64_Decode(encryptedData), 对称解密秘钥 aeskey = |
||||
* Base64_Decode(session_key), aeskey 是16字节 对称解密算法初始向量 iv 会在数据接口中返回。 |
||||
* |
||||
* @Description (TODO这里用一句话描述这个方法的作用) |
||||
* @param encryptedData |
||||
* 加密内容 |
||||
* @param sessionKey |
||||
* 小程序登录sessionKey |
||||
* @param iv |
||||
* 解密算法初始向量 iv 会在数据接口中返回。 |
||||
* @param encodingFormat |
||||
* 编码格式默认UTF-8 |
||||
* @return 返回解密后的字符串 |
||||
* @throws Exception |
||||
*/ |
||||
public String decrypt(String encryptedData, String sessionKey, String iv, String encodingFormat) throws Exception { |
||||
try { |
||||
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); |
||||
BASE64Decoder base64Decoder = new BASE64Decoder(); |
||||
byte[] _encryptedData = base64Decoder.decodeBuffer(encryptedData); |
||||
byte[] _sessionKey = base64Decoder.decodeBuffer(sessionKey); |
||||
byte[] _iv = base64Decoder.decodeBuffer(iv); |
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(_sessionKey, "AES"); |
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(_iv); |
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); |
||||
byte[] original = cipher.doFinal(_encryptedData); |
||||
byte[] bytes = PKCS7Encoder.decode(original); |
||||
String originalString = new String(bytes, "ISO-8859-1"); |
||||
return originalString; |
||||
} catch (Exception ex) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) throws Exception { |
||||
// 需要加密的字串
|
||||
// String appid = "wx4f4bc4dec97d474b";
|
||||
/* String sessionKey = "tiihtNczf5v6AKRyjwEUhQ=="; |
||||
|
||||
String encryptedData = "CiyLU1Aw2KjvrjMdj8YKliAjtP4gsMZM" + "QmRzooG2xrDcvSnxIMXFufNstNGTyaGS" |
||||
+ "9uT5geRa0W4oTOb1WT7fJlAC+oNPdbB+" + "3hVbJSRgv+4lGOETKUQz6OYStslQ142d" |
||||
+ "NCuabNPGBzlooOmB231qMM85d2/fV6Ch" + "evvXvQP8Hkue1poOFtnEtpyxVLW1zAo6" |
||||
+ "/1Xx1COxFvrc2d7UL/lmHInNlxuacJXw" + "u0fjpXfz/YqYzBIBzD6WUfTIF9GRHpOn" |
||||
+ "/Hz7saL8xz+W//FRAUid1OksQaQx4CMs" + "8LOddcQhULW4ucetDf96JcR3g0gfRK4P" |
||||
+ "C7E/r7Z6xNrXd2UIeorGj5Ef7b1pJAYB" + "6Y5anaHqZ9J6nKEBvB4DnNLIVWSgARns" |
||||
+ "/8wR2SiRS7MNACwTyrGvt9ts8p12PKFd" + "lqYTopNHR1Vf7XjfhQlVsAJdNiKdYmYV" |
||||
+ "oKlaRv85IfVunYzO0IKXsyl7JCUjCpoG" + "20f0a04COwfneQAGGwd5oa+T8yO5hzuy" + "Db/XcxxmK01EpqOyuxINew=="; |
||||
|
||||
String iv = "r7BXXKkLb8qrSNn05n0qiA==";*/ |
||||
|
||||
/* String encryptedData="+WQuaG5Tr9EU6f+Cx7OR7O8/HbVAUK77P9/BRqhdA4qYKLcw0sbS1R5DfoU+D4HEpoUCXtmRH/gP" + |
||||
"eJqYFJpauBysbadiYrZ6wYWjp5wP+HgxWnfCOk7jwR8WUdvFFDuQMhAVudnFhhNP3g4iHfCeiU5yfmN4iw" + |
||||
"gpL4txJpuZDHhyjqBqGGxntyxgxHFonbFi94e+IaPrFqigvqJXI9RGW9eXUVhZEQGeadv+eW72ucPq90KGH" + |
||||
"wPj0uUMWRWPJC8ZWp+uRUbrENiKfo9QJqiMljq/wcbz4c/u/Wd7PF4o4s02uutMjsrpYdnpw20E7DDpUIBU" + |
||||
"fIkeDmIFOIEQYPAGbTFtbHwPyyrx/r+fSihmO6PRwAlUrfhCOZ3KNkmtqZPDjqfHGrW+MeiquW5vryXL8FWy++z" + |
||||
"OVdGzymGvW6E/hSVDoTNL4+zeuxhJAXCnuPjLtYeL0EkGam8ks0KDqhZy3gUwRwrM0HFzQ1IryTMsqeLCcLMm" + |
||||
"0vWG4PEuPv5j5+V66MTGYvyyM2v67zK7Z2cn2A=="; |
||||
String iv="zI+P8RVxEwMFBXcJDCemHg=="; |
||||
String sessionKey="Piqc8iFe6pN0i5ofq4Y6PA==";*/ |
||||
|
||||
String iv="Y37DfoP3+4ysUBo8YOnfiQ=="; |
||||
String sessionKey="Piqc8iFe6pN0i5ofq4Y6PA=="; |
||||
String encryptedData="V6E2hVgfhatfPt/octP4c6881lJ1GCsYqtzY9MzqlWTpthAw5uWJLpRoXtmO5oM7XSHS6xKqh8YVzhKmrfzbb66574fbfE7n5ADSJYlsJwem1ifm3sypW9Ys3GSBwHaQ/x+Sn3rfs+HKMJgegGn+b3R5X7eXFhrA6lFnd+/xpYB4VWztFMsIyVT85Mlv5G3vp1FryctiGjWTFDDh1kAFXQ31Cso91SuAW2muSUaHh32pJ+WBrpZ7wrEZyyuqMqA0UpZve+gonUpZjnRWXewTTWm6jvc7lMQqFA1PD13pOGKYNKD/WxtaMXPWmvN+5WVwScH7ueEeppA1/aFwsMGnDBUU/+B04WxuQxo+M4b15vIq5GxI5Qvulv1taRdA5oiI10K+9UJAm+dz/2c2ZqEIiu+QTj9gvgbJsrIWMe0Wu5qmNTj/V97furJlcVaVvJvUy0N8zrqb7unAptjL0bQUvIB0ZXVgNbGEZLmAbpQhNgpIJ0ft6LiqvIzkrRYR+sIVr+mJrCoYxhyxB8cqsHJT2w=="; |
||||
|
||||
/* String iv="sAUv8qjwP8j/Ql9KLgA4iQ=="; |
||||
String sessionKey="H5lUk3IPIIENRdLxzLi2Hg=="; |
||||
String encryptedData="QygyXroVw0DNuwO4mlZDBX9wy8XYYE+AA0D738aAKe4icD9UPhtFywJ49UbmT7syv+fb4cn+3ao/w0aQCceh/dEsUhdSWsqAQZtaaXGeCHzi1iGdznIVD06ZYUdgZrJ7rY8Ie9w5/SYVSdSn5pyGovNCohUW4fp2CVowzwrRydsngDDWYjutkSfdvKgT19sCwuOOqZTzDM3gRqIUxwfrjKaDaoCPfa6z+otC0F/BtZYiiqd3MQIMJ0+JSll3ZVrpQKitBhc1EydxN3WSayxhYc4fiEa0YHoXaci0C/6bAfedgGQhejK6hSPLXr/TC++I0lfWnCS/2aidIsifLfyNg2/84yc5mWY5snoc9QeyAoXHczL62n1RwGBetE1Sq7q/sRn9XOFvM0kJ6UOS0n3FvMrH7716hBjUIP/lIf7hAH2IBbnPWyk5iKrMYt/T1Ky5e+RjBwnqJCyYTAxrvEczj2IQPwpGS3B3KWNTGGaK42Sf07w6ID37J3bWsPDAllZUSDhm67vmUjH8AyPTPsGPOg=="; |
||||
*/ |
||||
|
||||
/* String iv="amXf/b7Ollz6WV6e9ZCosg=="; |
||||
String sessionKey="H8d5dQnmec8Wtm1Ac1IaxQ=="; |
||||
String encryptedData="/xY631in/VQwauJfAsB9gGH8XpFAzZUprSYBoZzfbDbx60xsBpaikxnn1K+00MMzZ9hAVV4RRKRp+4qaoj+iSuJArgKlZByXaPQa4TxV7JGEuAA2qByTNHK/H2hrFdAxEDERwk7DjYqq1OhMO5n4pTRPxVUZ5ovKm81oOxVw77TjfkkQlgd2Uab/Oe7eM59HkoDQQDC9H2f4q7KmX7sHUuUWmMhEa8+rsJBMy2CWfTvfJpKE9BqNuNOHrXILMpvNm4vKcsc5DB6QzjbwJq8BLCLbmcE3Fa4ZQzcVW2Zi5lT0sOMX/kytgaceo/Rw3VpLkBwwRTsZDB7p+KRUbJYG7f3iSMWYveH09vL8dU+s9ZRO1FCgkyOj5jcpRAKEUAT2njdK4ozXYu+/qMUPeCp00G1NNlDq7gvBnhzYbQzg4+InTmENDYlckAIktBxa3ENWpDjiYWHBSHwbA/gJpAKoZz/oNUrBnPIH91UqRjGQXhdVnBQxeyMcnPuVrk3D51r5Ki3aAuwvB1l6+TWA//RcjTfSQtQnJ/yFctMmk3A7OGo="; |
||||
*/String deString = WXBizDataCrypt.getInstance().decrypt(encryptedData, sessionKey, iv, "utf-8"); |
||||
JSONObject jsonObject = JSONObject.parseObject(deString); |
||||
System.out.println(jsonObject); |
||||
} |
||||
} |
@ -1,13 +1,132 @@ |
||||
//package com.daqing.financial.hrauth;
|
||||
//
|
||||
//import org.junit.Test;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//
|
||||
//@SpringBootTest
|
||||
//class DqFinancialHrmsAuthApplicationTests {
|
||||
//
|
||||
// @Test
|
||||
// void contextLoads() {
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package com.daqing.financial.hrauth; |
||||
|
||||
import com.daqing.financial.hrauth.util.AesCbcUtil; |
||||
import io.swagger.models.auth.In; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.FileReader; |
||||
import java.util.*; |
||||
import java.util.regex.Pattern; |
||||
import java.util.stream.Stream; |
||||
|
||||
class DqFinancialHrmsAuthApplicationTests{ |
||||
public static void main(String[] args) throws Exception { |
||||
String encryptedData="+WQuaG5Tr9EU6f+Cx7OR7O8/HbVAUK77P9/BRqhdA4qYKLcw0sbS1R5DfoU+D4HEpoUCXtmRH/gPeJqYFJpauBysbadiYrZ6wYWjp5wP+HgxWnfCOk7jwR8WUdvFFDuQMhAVudnFhhNP3g4iHfCeiU5yfmN4iwgpL4txJpuZDHhyjqBqGGxntyxgxHFonbFi94e+IaPrFqigvqJXI9RGW9eXUVhZEQGeadv+eW72ucPq90KGHwPj0uUMWRWPJC8ZWp+uRUbrENiKfo9QJqiMljq/wcbz4c/u/Wd7PF4o4s02uutMjsrpYdnpw20E7DDpUIBUfIkeDmIFOIEQYPAGbTFtbHwPyyrx/r+fSihmO6PRwAlUrfhCOZ3KNkmtqZPDjqfHGrW+MeiquW5vryXL8FWy++zOVdGzymGvW6E/hSVDoTNL4+zeuxhJAXCnuPjLtYeL0EkGam8ks0KDqhZy3gUwRwrM0HFzQ1IryTMsqeLCcLMm0vWG4PEuPv5j5+V66MTGYvyyM2v67zK7Z2cn2A=="; |
||||
String iv="zI+P8RVxEwMFBXcJDCemHg=="; |
||||
String session_key="Piqc8iFe6pN0i5ofq4Y6PA=="; |
||||
|
||||
|
||||
/* String result = AesCbcUtil.decrypt2(session_key,encryptedData,iv); |
||||
String s2 = new String(result.getBytes("UTF-8"),"GBK"); |
||||
System.out.println(result); |
||||
System.out.println(s2);*/ |
||||
} |
||||
|
||||
/* public static void main(String[] args) { |
||||
//=================================流的常用创建方法=======================================
|
||||
//1,使用Collection下的stream()和parallelStream()操作
|
||||
List<String> list = new ArrayList(); |
||||
Stream<String> stream = list.stream();//获取一个顺序流
|
||||
Stream<String> parallelStream = list.parallelStream();//获取一个并行流
|
||||
|
||||
//2,使用Arrays中的stream()方法,将数组转成流
|
||||
Integer[]num = new Integer[10]; |
||||
Stream<Integer> stream1 = Arrays.stream(num); |
||||
//System.out.println("stream1==="+stream1);
|
||||
|
||||
//3,使用Stream中的静态方法:如of(),iterate(),generate()
|
||||
Stream<Integer>stream2 = Stream.of(1,2,3,4,5,6); |
||||
//stream2.forEach(System.out::println);
|
||||
//stream2.forEach((t)->System.out.println(t));每次创建的stream只能使用一次,否则报错stream has already been operated upon or closed
|
||||
|
||||
Stream<Integer>stream3 = Stream.iterate(0,(x)->x+2).limit(8); |
||||
//stream3.forEach(System.out::println);
|
||||
|
||||
Stream<Double>stream4 = Stream.generate(Math::random).limit(2); |
||||
// stream4.forEach((t)->System.out.println(t));
|
||||
|
||||
//4,使用BufferedReader.lines()方法,将每行内容转成流
|
||||
BufferedReader reader=null; |
||||
try { |
||||
reader = new BufferedReader(new FileReader("D:\\myfile\\工作文档.txt")); |
||||
} catch (FileNotFoundException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
Stream<String>lineStream = reader.lines(); |
||||
//lineStream.forEach(System.out::println);
|
||||
|
||||
//5,使用Pattern.splitAsStream()方法,将字符串分隔成流
|
||||
Pattern pattern = Pattern.compile(","); |
||||
Stream<String> stream5 = pattern.splitAsStream("漆柒,菜园子"); |
||||
// stream5.forEach(System.out::println);
|
||||
|
||||
//=================================流的中间操作========================================
|
||||
//1,筛选与切片
|
||||
Stream<Integer> stream6 = Stream.of(6, 4, 6, 7, 3, 9, 8, 10, 12, 14, 14, 20, 3); |
||||
Stream<Integer> newStream = stream6.filter(t -> t>5)//6, 6, 7, 9, 8, 10, 12, 14, 14, 20
|
||||
.distinct()//6, 7, 9, 8, 10, 12, 14, 20
|
||||
.skip(2)//9, 8, 10, 12, 14, 20
|
||||
.limit(5);//9, 8, 10, 12, 14
|
||||
//filter:过滤流中的某些元素,limit(n):获取n个元素,skip(n):跳过n元素,配合limit(n)可做分页,distinct:通过流中元素的hashCode()和equals()去重
|
||||
// newStream.forEach(System.out::println);
|
||||
|
||||
//2,映射
|
||||
List<String> list2 = Arrays.asList("a,b,c", "1,2,3"); |
||||
//将每个元素转成一个新的且不带括号的元素
|
||||
Stream<String> streamMap = list2.stream().map(s->s.replaceAll(",","")); |
||||
// streamMap.forEach(System.out::println);
|
||||
|
||||
Stream<String> streamFlatMap = list2.stream().flatMap(s->{ |
||||
//将每个元素转换成一个Stream流
|
||||
String[]split = s.split(","); |
||||
Stream<String>ss = Arrays.stream(split); |
||||
return ss; |
||||
}); |
||||
// streamFlatMap.forEach(System.out::println);
|
||||
|
||||
//3,排序
|
||||
List<String>list3=Arrays.asList("az","fb","de"); |
||||
Stream<String>stream7 = list3.stream().sorted(); |
||||
// stream7.forEach(System.out::println);
|
||||
|
||||
Student s1 = new Student("aa",10); |
||||
Student s2 = new Student("bb",20); |
||||
Student s3 = new Student("aa",30); |
||||
Student s4 = new Student("dd",40); |
||||
List<Student>pojoList = Arrays.asList(s1,s2,s3,s4); |
||||
|
||||
//自定义排序,先按姓名升序,姓名相同的按年龄升序
|
||||
//jdk8新操作
|
||||
pojoList.stream().sorted( |
||||
(o1,o2)->{ |
||||
if(o1.getName().equals(o2.getName())){ |
||||
return o1.getAge()-o2.getAge(); |
||||
}else{ |
||||
return o1.getName().compareTo(o2.getName()); |
||||
} |
||||
}); |
||||
|
||||
//jdk7骚操作
|
||||
Collections.sort(pojoList, new Comparator<Student>() { |
||||
@Override |
||||
public int compare(Student o1, Student o2) { |
||||
if(o1.getName().equals(o2.getName())){ |
||||
return o1.getAge()-o2.getAge(); |
||||
}else{ |
||||
return o1.getName().compareTo(o2.getName()); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
//4,消费 peek
|
||||
List<Student> studentList = Arrays.asList(s1,s2); |
||||
studentList.stream().peek(s->s.setAge(100)); |
||||
|
||||
//===================================流的终止操作=====================================
|
||||
//1,匹配,聚合操作
|
||||
|
||||
|
||||
|
||||
}*/ |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.daqing.financial.hrauth; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 记录部门信息 |
||||
* |
||||
* @author gongsj |
||||
* @email gongsj@gmail.com |
||||
* @date 2020-09-07 17:12:14 |
||||
*/ |
||||
@Data |
||||
public class Student implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public Student(String name, Integer age) { |
||||
this.name = name; |
||||
this.age = age; |
||||
} |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
/** |
||||
* 部门名称 |
||||
*/ |
||||
@ApiModelProperty(value = "部门名称") |
||||
private String name; |
||||
/** |
||||
* 上级部门id |
||||
*/ |
||||
private Integer age; |
||||
|
||||
} |
@ -0,0 +1,152 @@ |
||||
package com.daqing.framework.domain.guarantee; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* <p> |
||||
* 业务关联企业表 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-01-27 |
||||
*/ |
||||
@TableName("dg_business_company") |
||||
@Data |
||||
public class DgBusinessCompany implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 业务id |
||||
*/ |
||||
private Integer businessId; |
||||
|
||||
/** |
||||
* 注册资金(万元) |
||||
*/ |
||||
private String registeredCapital; |
||||
|
||||
/** |
||||
* 社会统一代码 |
||||
*/ |
||||
private String socialUnifiedCode; |
||||
|
||||
/** |
||||
* 员工人数 |
||||
*/ |
||||
private String empNum; |
||||
|
||||
/** |
||||
* 联系人 |
||||
*/ |
||||
private String linkman; |
||||
|
||||
/** |
||||
* 联系人的联系电话 |
||||
*/ |
||||
private String linkPhone; |
||||
|
||||
/** |
||||
* 业务来源 |
||||
*/ |
||||
private String businessSource; |
||||
|
||||
/** |
||||
* 经营范围 |
||||
*/ |
||||
private String businessScope; |
||||
|
||||
/** |
||||
* 经营地址 |
||||
*/ |
||||
private String businessAddr; |
||||
|
||||
/** |
||||
* 注册时间 |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date registerTime; |
||||
|
||||
/** |
||||
* 注册地址 |
||||
*/ |
||||
private String registerAddr; |
||||
|
||||
/** |
||||
* 法人-身份证号 |
||||
*/ |
||||
private String legalIdNumber; |
||||
|
||||
/** |
||||
* 法人-户口所在地 |
||||
*/ |
||||
private String legalHukouAddr; |
||||
|
||||
/** |
||||
* 法人-联系电话 |
||||
*/ |
||||
private String legalPhone; |
||||
|
||||
/** |
||||
* 法人-家庭住址 |
||||
*/ |
||||
private String legalHomeAddr; |
||||
|
||||
/** |
||||
* 法人-性别 1、男,0、女 |
||||
*/ |
||||
private Integer legalGender; |
||||
|
||||
/** |
||||
* 法人-姓名 |
||||
*/ |
||||
private String legalName; |
||||
|
||||
/** |
||||
* 是否存在关联人 0->否;1->是 |
||||
*/ |
||||
private Integer isExistRelated; |
||||
|
||||
/** |
||||
* 客户编号 |
||||
*/ |
||||
private String code; |
||||
|
||||
/** |
||||
* 客户类型:1、企业类型,0:个人类型 |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* 客户名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 联系地址(指个人的) |
||||
*/ |
||||
private String addr; |
||||
|
||||
/** |
||||
* 联系电话(指个人或企业的) |
||||
*/ |
||||
private String phone; |
||||
|
||||
/** |
||||
* 客户基本信息表id |
||||
*/ |
||||
private Long customerId; |
||||
} |
@ -1,79 +0,0 @@ |
||||
package com.daqing.framework.domain.guarantee; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* <p> |
||||
* 合规调查记录 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2020-11-05 |
||||
*/ |
||||
@Data |
||||
@TableName("dg_compliance_assign_user") |
||||
public class DgComplianceAssignUser implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
/** |
||||
* 企业id |
||||
*/ |
||||
private Integer companyId; |
||||
|
||||
/** |
||||
* 员工id |
||||
*/ |
||||
private Integer empId; |
||||
|
||||
/** |
||||
* 类型(1:第一审批人 2:指派人AB角 3:第一审批人审核 3:经理) |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* 状态(1:待指派 2:审核中 3:审核通过 4:审核不通过 5:驳回) |
||||
*/ |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 审核金额 |
||||
*/ |
||||
private BigDecimal amount; |
||||
|
||||
/** |
||||
* 期限 |
||||
*/ |
||||
private String term; |
||||
|
||||
/** |
||||
* 补充调查原因 |
||||
*/ |
||||
private String remark; |
||||
|
||||
/** |
||||
* 审核意见 |
||||
*/ |
||||
private String applyContent; |
||||
|
||||
@ApiModelProperty(value = "创建时间") |
||||
@TableField(fill = FieldFill.INSERT) |
||||
private Date createTime; |
||||
|
||||
@ApiModelProperty(value = "更新时间") |
||||
@TableField(fill = FieldFill.INSERT_UPDATE) |
||||
private Date updateTime; |
||||
|
||||
} |
@ -0,0 +1,33 @@ |
||||
package com.daqing.framework.domain.hrms; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 记录部门信息 |
||||
* |
||||
* @author gongsj |
||||
* @email gongsj@gmail.com |
||||
* @date 2020-09-07 17:12:14 |
||||
*/ |
||||
@Data |
||||
@TableName("hrms_dept") |
||||
public class Login implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private String openid; |
||||
|
||||
private String session_key; |
||||
|
||||
private String unionid; |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue