新增公司

This commit is contained in:
sxu 2025-01-05 00:39:26 +08:00
parent 340a724dfc
commit 3796dd92ef
4 changed files with 27 additions and 7 deletions

View File

@ -110,6 +110,11 @@ public class SysDept extends BaseEntity {
*/ */
private String logo; private String logo;
/**
* 公司用户初始密码
*/
private String initPassword;
private SysUser sysUser; private SysUser sysUser;
/** /**
@ -188,6 +193,14 @@ public class SysDept extends BaseEntity {
this.logo = logo; this.logo = logo;
} }
public String getInitPassword() {
return initPassword;
}
public void setInitPassword(String initPassword) {
this.initPassword = initPassword;
}
public SysUser getSysUser() { public SysUser getSysUser() {
return sysUser; return sysUser;
} }

View File

@ -133,5 +133,5 @@ public interface SysDeptMapper
* @param deptId * @param deptId
* @return * @return
*/ */
public SysUser selectCompanyAdminByDept(Long deptId); public SysUser selectCompanyAdminByDept(@Param("deptId") Long deptId);
} }

View File

@ -4,6 +4,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.web.domain.BaseEntity; import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.config.SystemConfig; import com.bonus.config.SystemConfig;
import com.bonus.system.api.domain.*; import com.bonus.system.api.domain.*;
@ -198,9 +199,10 @@ public class SysDeptServiceImpl implements ISysDeptService
public SysDept selectDeptById(Long deptId) public SysDept selectDeptById(Long deptId)
{ {
SysDept sysDept = deptMapper.selectDeptById(deptId); SysDept sysDept = deptMapper.selectDeptById(deptId);
if (Objects.nonNull(sysDept.getParentId()) && sysDept.getParentId().equals(0L)) { if (systemConfig.isAddRootCompany() && Objects.nonNull(sysDept.getParentId()) && sysDept.getParentId().equals(0L)) {
SysUser sysUser = deptMapper.selectCompanyAdminByDept(deptId); SysUser sysUser = deptMapper.selectCompanyAdminByDept(deptId);
sysDept.setSysUser(sysUser); sysDept.setSysUser(sysUser);
sysDept.setInitPassword(Sm4Utils.encrypt(sysDept.getInitPassword()));
} }
return sysDept; return sysDept;
} }

View File

@ -28,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deptAbbreviation" column="dept_abbreviation" /> <result property="deptAbbreviation" column="dept_abbreviation" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="logo" column="logo" /> <result property="logo" column="logo" />
<result property="initPassword" column="init_password" />
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
@ -50,7 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.address, d.address,
d.dept_abbreviation, d.dept_abbreviation,
d.remark, d.remark,
d.logo d.logo,
d.init_password
from sys_dept d from sys_dept d
</sql> </sql>
@ -172,6 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation,</if> <if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="logo != null and logo != ''">logo,</if> <if test="logo != null and logo != ''">logo,</if>
<if test="initPassword != null and initPassword != ''">init_password,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="templateId != null">template_id,</if> <if test="templateId != null">template_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
@ -192,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptAbbreviation != null and deptAbbreviation != ''">#{deptAbbreviation},</if> <if test="deptAbbreviation != null and deptAbbreviation != ''">#{deptAbbreviation},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="logo != null and logo != ''">#{logo},</if> <if test="logo != null and logo != ''">#{logo},</if>
<if test="initPassword != null and initPassword != ''">#{initPassword},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="templateId != null">#{templateId},</if> <if test="templateId != null">#{templateId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
@ -216,6 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation = #{deptAbbreviation},</if> <if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation = #{deptAbbreviation},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if> <if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="logo != null and logo != ''">logo = #{logo},</if> <if test="logo != null and logo != ''">logo = #{logo},</if>
<if test="initPassword != null and initPassword != ''">init_password = #{initPassword},</if>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = sysdate()
@ -248,13 +253,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<select id="selectCompanyAdminByDept" resultType="com.bonus.system.api.domain.SysUser"> <select id="selectCompanyAdminByDept" resultType="com.bonus.system.api.domain.SysUser">
select su.nick_name as nickName,su.user_name as userName,su.password as password,su.phonenumber as phonenumber, select su.nick_name as nickName, su.user_name as userName, su.phonenumber as phonenumber,
sr.role_name as roleName,su.user_id as userId,sr.role_id as roleId, sd.dept_id as deptId su.user_id as userId, sr.role_id as roleId, sd.dept_id as deptId
from sys_dept sd from sys_dept sd
left join sys_role_dept srd on sd.dept_id = srd.dept_id left join sys_role_dept srd on sd.dept_id = srd.dept_id
left join sys_role sr on srd.role_id = sr.role_id and sr.role_key LIKE 'dept_%_admin' left join sys_role sr on srd.role_id = sr.role_id
left join sys_user_role sur on sur.role_id = sr.role_id left join sys_user_role sur on sur.role_id = sr.role_id
left join sys_user su on su.user_id = sur.user_id left join sys_user su on su.user_id = sur.user_id
where sd.dept_id = #{deptId} where sd.dept_id = #{deptId} and sr.role_key LIKE 'dept_%_admin'
</select> </select>
</mapper> </mapper>