|
|
@@ -1,14 +1,16 @@
|
|
|
package com.sckw.system.service;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.ApprovalEnum;
|
|
|
+import com.sckw.core.model.enums.DeptTypeEnum;
|
|
|
import com.sckw.core.model.enums.EntTypeEnum;
|
|
|
+import com.sckw.core.model.enums.UserSystemTypeEnum;
|
|
|
import com.sckw.core.model.page.PageHelperUtil;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
@@ -21,10 +23,7 @@ import com.sckw.system.dao.KwsEntCertificateDao;
|
|
|
import com.sckw.system.dao.KwsEntCheckTrackDao;
|
|
|
import com.sckw.system.dao.KwsEntTypeDao;
|
|
|
import com.sckw.system.dao.KwsEnterpriseDao;
|
|
|
-import com.sckw.system.model.KwsEntCertificate;
|
|
|
-import com.sckw.system.model.KwsEntCheckTrack;
|
|
|
-import com.sckw.system.model.KwsEntType;
|
|
|
-import com.sckw.system.model.KwsEnterprise;
|
|
|
+import com.sckw.system.model.*;
|
|
|
import com.sckw.system.model.vo.req.*;
|
|
|
import com.sckw.system.model.vo.res.CertificateResVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -52,6 +51,15 @@ public class KwsEnterpriseService {
|
|
|
@Autowired
|
|
|
private KwsEntCheckTrackDao kwsEntCheckTrackDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KwsDeptService kwsDeptService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KwsRoleService kwsRoleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KwsUserService kwsUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加新纪录
|
|
|
*
|
|
|
@@ -66,8 +74,6 @@ public class KwsEnterpriseService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- params.setCreateBy(0L);
|
|
|
- params.setUpdateBy(0L);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -230,10 +236,11 @@ public class KwsEnterpriseService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {})
|
|
|
public void register(EntRegisterReqVo reqVo) {
|
|
|
- /*存企业信息表*/
|
|
|
+ /*1、存企业信息表*/
|
|
|
KwsEnterprise kwsEnterprise = new KwsEnterprise();
|
|
|
long entId = new IdWorker(1).nextId();
|
|
|
kwsEnterprise.setId(entId);
|
|
|
+ Date date = new Date();
|
|
|
BeanUtils.copyProperties(reqVo, kwsEnterprise);
|
|
|
|
|
|
//一些待确认的字段
|
|
|
@@ -241,50 +248,75 @@ public class KwsEnterpriseService {
|
|
|
kwsEnterprise.setBalance(0L);
|
|
|
kwsEnterprise.setExperience(0);
|
|
|
kwsEnterprise.setMemberLevel(0);
|
|
|
- kwsEnterprise.setRegTime(new Date());
|
|
|
+ kwsEnterprise.setRegTime(date);
|
|
|
kwsEnterprise.setApproval(ApprovalEnum.NO.getCode());
|
|
|
if (kwsEnterpriseDao.insert(kwsEnterprise) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
|
|
|
|
- /*存企业类型,一个企业可以有多个类型*/
|
|
|
+ /*2、存企业类型,一个企业可以有多个类型*/
|
|
|
List<KwsEntType> kwsEntTypes = new ArrayList<>();
|
|
|
Arrays.stream(reqVo.getEntTypes().split(",")).toList().forEach(item -> {
|
|
|
KwsEntType kwsEntType = new KwsEntType();
|
|
|
kwsEntType.setEntId(entId);
|
|
|
kwsEntType.setType(Integer.parseInt(item));
|
|
|
kwsEntType.setId(new IdWorker(1).nextId());
|
|
|
- kwsEntType.setDelFlag(Global.NO);
|
|
|
- kwsEntType.setStatus(Global.NO);
|
|
|
- kwsEntType.setCreateBy(1L);
|
|
|
- kwsEntType.setUpdateBy(1L);
|
|
|
- kwsEntType.setCreateTime(new Date());
|
|
|
- kwsEntType.setUpdateTime(new Date());
|
|
|
kwsEntTypes.add(kwsEntType);
|
|
|
});
|
|
|
if (kwsEntTypeDao.saveBatch(kwsEntTypes) != kwsEntTypes.size()) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
|
|
|
|
- /*存企业证书*/
|
|
|
+ /*3、存企业证书*/
|
|
|
List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
|
|
|
reqVo.getBusinessLicense().forEach(item -> {
|
|
|
KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
|
|
|
//todo 上传证书正反面,将url放到两个入参里
|
|
|
kwsEntCertificate.setEntId(entId);
|
|
|
kwsEntCertificate.setId(new IdWorker(1).nextId());
|
|
|
- kwsEntCertificate.setDelFlag(Global.NO);
|
|
|
- kwsEntCertificate.setStatus(Global.NO);
|
|
|
- kwsEntCertificate.setCreateBy(1L);
|
|
|
- kwsEntCertificate.setUpdateBy(1L);
|
|
|
- kwsEntCertificate.setCreateTime(new Date());
|
|
|
- kwsEntCertificate.setUpdateTime(new Date());
|
|
|
BeanUtils.copyProperties(item, kwsEntCertificate);
|
|
|
kwsEntCertificates.add(kwsEntCertificate);
|
|
|
});
|
|
|
if (kwsEntCertificateDao.saveBatch(kwsEntCertificates) != kwsEntCertificates.size()) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
|
+
|
|
|
+ /*4、新增管理员机构*/
|
|
|
+ KwsDept kwsDept = new KwsDept();
|
|
|
+ long deptId = new IdWorker(1L).nextId();
|
|
|
+ kwsDept.setSystemType(DeptTypeEnum.MANAGE.getCode());
|
|
|
+ kwsDept.setEntId(entId);
|
|
|
+ kwsDept.setName(DeptTypeEnum.MANAGE.getName());
|
|
|
+ kwsDept.setCompany(Global.NO);
|
|
|
+ kwsDept.setParentId(0L);
|
|
|
+ kwsDept.setParentIds("0");
|
|
|
+ kwsDept.setLevel(1);
|
|
|
+ kwsDept.setSort(0);
|
|
|
+ kwsDept.setId(deptId);
|
|
|
+ kwsDeptService.add(kwsDept);
|
|
|
+
|
|
|
+ /*5、新增管理员角色*/
|
|
|
+ KwsRole kwsRole = new KwsRole();
|
|
|
+ long roleId = new IdWorker(1L).nextId();
|
|
|
+ kwsRole.setName(Global.MANAGE_NAME);
|
|
|
+ kwsRole.setDeptId(deptId);
|
|
|
+ kwsRole.setId(roleId);
|
|
|
+ kwsRoleService.add(kwsRole);
|
|
|
+
|
|
|
+ /*5、新增管理员用户*/
|
|
|
+ String contacts = reqVo.getContacts();
|
|
|
+ String telephone = reqVo.getTelephone();
|
|
|
+ UserAddReqVo userAddReqVo = new UserAddReqVo();
|
|
|
+ userAddReqVo.setSystemType(UserSystemTypeEnum.ENTERPRISE.getCode());
|
|
|
+ userAddReqVo.setAccount(telephone);
|
|
|
+ userAddReqVo.setName(contacts);
|
|
|
+ userAddReqVo.setTelephone(telephone);
|
|
|
+ userAddReqVo.setPhoto("");
|
|
|
+ userAddReqVo.setEmail("");
|
|
|
+ userAddReqVo.setClientId("");
|
|
|
+ userAddReqVo.setIsMain(Global.YES);
|
|
|
+ userAddReqVo.setRoleIds(String.valueOf(roleId));
|
|
|
+ kwsUserService.add(userAddReqVo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -349,4 +381,15 @@ public class KwsEnterpriseService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param userId 用户id
|
|
|
+ * @return KwsEnterprise
|
|
|
+ * @desc: 根据用户id查企业
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/6/13
|
|
|
+ */
|
|
|
+ public KwsEnterprise findByUserId(long userId) {
|
|
|
+ return kwsEnterpriseDao.findByUserId(userId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|