|
|
|
@ -1,19 +1,25 @@ |
|
|
|
|
package com.cjy.enterprise.service.impl; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import com.cjy.enterprise.domain.EnterpriseInfo; |
|
|
|
|
import com.cjy.enterprise.mapper.EnterpriseInfoMapper; |
|
|
|
|
import com.cjy.enterprise.service.IEnterpriseInfoService; |
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept; |
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole; |
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser; |
|
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils; |
|
|
|
|
import com.ruoyi.system.domain.SysUserRole; |
|
|
|
|
import com.ruoyi.system.mapper.SysDeptMapper; |
|
|
|
|
import com.ruoyi.system.mapper.SysRoleMapper; |
|
|
|
|
import com.ruoyi.system.mapper.SysUserMapper; |
|
|
|
|
import com.ruoyi.system.mapper.SysUserRoleMapper; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import com.cjy.enterprise.mapper.EnterpriseInfoMapper; |
|
|
|
|
import com.cjy.enterprise.domain.EnterpriseInfo; |
|
|
|
|
import com.cjy.enterprise.service.IEnterpriseInfoService; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 企业信息Service业务层处理 |
|
|
|
@ -22,8 +28,7 @@ import com.cjy.enterprise.service.IEnterpriseInfoService; |
|
|
|
|
* @date 2023-02-19 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
{ |
|
|
|
|
public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService { |
|
|
|
|
@Autowired |
|
|
|
|
private EnterpriseInfoMapper enterpriseInfoMapper; |
|
|
|
|
|
|
|
|
@ -33,8 +38,13 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
@Autowired |
|
|
|
|
private SysUserMapper sysUserMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private SysRoleMapper sysRoleMapper; |
|
|
|
|
@Autowired |
|
|
|
|
private SysUserRoleMapper sysUserRoleMapper; |
|
|
|
|
@Value("${default.password}") |
|
|
|
|
private String password; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询企业信息 |
|
|
|
|
* |
|
|
|
@ -42,8 +52,7 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
* @return 企业信息 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public EnterpriseInfo selectEnterpriseInfoById(Long id) |
|
|
|
|
{ |
|
|
|
|
public EnterpriseInfo selectEnterpriseInfoById(Long id) { |
|
|
|
|
return enterpriseInfoMapper.selectEnterpriseInfoById(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -54,8 +63,7 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
* @return 企业信息 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<EnterpriseInfo> selectEnterpriseInfoList(EnterpriseInfo enterpriseInfo) |
|
|
|
|
{ |
|
|
|
|
public List<EnterpriseInfo> selectEnterpriseInfoList(EnterpriseInfo enterpriseInfo) { |
|
|
|
|
return enterpriseInfoMapper.selectEnterpriseInfoList(enterpriseInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -66,12 +74,13 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int insertEnterpriseInfo(EnterpriseInfo enterpriseInfo) |
|
|
|
|
{ |
|
|
|
|
public int insertEnterpriseInfo(EnterpriseInfo enterpriseInfo) { |
|
|
|
|
//1. 创建单位
|
|
|
|
|
Long deptId = insertOrganDept(enterpriseInfo); |
|
|
|
|
Long deptId = insertOrganDept(enterpriseInfo); |
|
|
|
|
//2. 创建人员
|
|
|
|
|
insertOrganUser(enterpriseInfo,deptId); |
|
|
|
|
Long userId = insertOrganUser(enterpriseInfo, deptId); |
|
|
|
|
//3. 创建空角色
|
|
|
|
|
isnertOrganRole(userId,Long.parseLong(enterpriseInfo.getOrganCode())); |
|
|
|
|
return enterpriseInfoMapper.insertEnterpriseInfo(enterpriseInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -82,8 +91,7 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int updateEnterpriseInfo(EnterpriseInfo enterpriseInfo) |
|
|
|
|
{ |
|
|
|
|
public int updateEnterpriseInfo(EnterpriseInfo enterpriseInfo) { |
|
|
|
|
enterpriseInfo.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
return enterpriseInfoMapper.updateEnterpriseInfo(enterpriseInfo); |
|
|
|
|
} |
|
|
|
@ -95,8 +103,7 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int deleteEnterpriseInfoByIds(Long[] ids) |
|
|
|
|
{ |
|
|
|
|
public int deleteEnterpriseInfoByIds(Long[] ids) { |
|
|
|
|
return enterpriseInfoMapper.deleteEnterpriseInfoByIds(ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -107,18 +114,18 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int deleteEnterpriseInfoById(Long id) |
|
|
|
|
{ |
|
|
|
|
public int deleteEnterpriseInfoById(Long id) { |
|
|
|
|
return enterpriseInfoMapper.deleteEnterpriseInfoById(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增部门返回部门id |
|
|
|
|
* 新增部门返回部门id |
|
|
|
|
* |
|
|
|
|
* @param enterprise |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private Long insertOrganDept(EnterpriseInfo enterprise){ |
|
|
|
|
SysDept dept = new SysDept(); |
|
|
|
|
private Long insertOrganDept(EnterpriseInfo enterprise) { |
|
|
|
|
SysDept dept = new SysDept(); |
|
|
|
|
dept.setParentId(0l); |
|
|
|
|
dept.setAncestors("0"); |
|
|
|
|
dept.setDeptName(enterprise.getOrganName()); |
|
|
|
@ -127,24 +134,60 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService |
|
|
|
|
dept.setPhone(enterprise.getContactNumber()); |
|
|
|
|
dept.setStatus("0"); |
|
|
|
|
dept.setDelFlag("0"); |
|
|
|
|
dept.setCreateBy(enterprise.getCreaterUserId()+""); |
|
|
|
|
dept.setCreateBy(enterprise.getCreaterUserId() + ""); |
|
|
|
|
dept.setOrganCode(Long.parseLong(enterprise.getOrganCode())); |
|
|
|
|
deptMapper.insertDeptResultId(dept); |
|
|
|
|
System.out.println(dept.getDeptId()); |
|
|
|
|
return dept.getDeptId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void insertOrganUser(EnterpriseInfo enterpriseInfo,Long deptId){ |
|
|
|
|
/** |
|
|
|
|
* 新增人员 |
|
|
|
|
* |
|
|
|
|
* @param enterpriseInfo |
|
|
|
|
* @param deptId |
|
|
|
|
*/ |
|
|
|
|
private Long insertOrganUser(EnterpriseInfo enterpriseInfo, Long deptId) { |
|
|
|
|
SysUser user = new SysUser(); |
|
|
|
|
user.setDeptId(deptId); |
|
|
|
|
user.setUserName(enterpriseInfo.getOrganCode()); |
|
|
|
|
user.setNickName(enterpriseInfo.getOrganName()+"-管理员"); |
|
|
|
|
user.setNickName(enterpriseInfo.getOrganName() + "-管理员"); |
|
|
|
|
user.setPhonenumber(enterpriseInfo.getContactNumber()); |
|
|
|
|
user.setStatus("0"); |
|
|
|
|
user.setDelFlag("0"); |
|
|
|
|
user.setCreateBy(enterpriseInfo.getCreaterUserId()+""); |
|
|
|
|
user.setCreateBy(enterpriseInfo.getCreaterUserId() + ""); |
|
|
|
|
user.setOrganCode(Long.parseLong(enterpriseInfo.getOrganCode())); |
|
|
|
|
user.setPassword(SecurityUtils.encryptPassword(password)); |
|
|
|
|
|
|
|
|
|
sysUserMapper.insertUser(user); |
|
|
|
|
System.out.println(user.getUserId()); |
|
|
|
|
return user.getUserId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 说明: 新增 角色信息及用户角色关联 |
|
|
|
|
* @param userId |
|
|
|
|
* @param enterpriseId |
|
|
|
|
*/ |
|
|
|
|
public void isnertOrganRole(Long userId,Long enterpriseId){ |
|
|
|
|
SysRole role = new SysRole(); |
|
|
|
|
role.setRoleName(enterpriseId+""); |
|
|
|
|
role.setRoleKey(enterpriseId+""); |
|
|
|
|
role.setRoleSort(1); |
|
|
|
|
role.setDataScope("4"); |
|
|
|
|
role.setMenuCheckStrictly(true); |
|
|
|
|
role.setDeptCheckStrictly(true); |
|
|
|
|
role.setStatus("0"); |
|
|
|
|
role.setDelFlag("0"); |
|
|
|
|
role.setOrganCode(enterpriseId); |
|
|
|
|
role.setCreateBy(userId+""); |
|
|
|
|
role.setRemark(enterpriseId+"系统管理员角色"); |
|
|
|
|
sysRoleMapper.insertRole(role); |
|
|
|
|
SysUserRole userRole = new SysUserRole(); |
|
|
|
|
userRole.setRoleId(role.getRoleId()); |
|
|
|
|
userRole.setUserId(userId); |
|
|
|
|
List<SysUserRole> userRoleList = new ArrayList<>(); |
|
|
|
|
userRoleList.add(userRole); |
|
|
|
|
sysUserRoleMapper.batchUserRole(userRoleList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|