企业信息账号创建

dev
masong 3 years ago
parent 82a7ca405b
commit f97bd82407
  1. 53
      cjy-project/src/main/java/com/cjy/enterprise/service/impl/EnterpriseInfoServiceImpl.java
  2. 4
      ruoyi-admin/src/main/resources/application.yml
  3. 11
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java
  4. 9
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  5. 6
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
  6. 43
      ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
  7. 3
      ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@ -1,8 +1,15 @@
package com.cjy.enterprise.service.impl;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysUserMapper;
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;
@ -20,6 +27,14 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService
@Autowired
private EnterpriseInfoMapper enterpriseInfoMapper;
@Autowired
private SysDeptMapper deptMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Value("${default.password}")
private String password;
/**
* 查询企业信息
*
@ -54,7 +69,9 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService
public int insertEnterpriseInfo(EnterpriseInfo enterpriseInfo)
{
//1. 创建单位
Long deptId = insertOrganDept(enterpriseInfo);
//2. 创建人员
insertOrganUser(enterpriseInfo,deptId);
return enterpriseInfoMapper.insertEnterpriseInfo(enterpriseInfo);
}
@ -94,4 +111,40 @@ public class EnterpriseInfoServiceImpl implements IEnterpriseInfoService
{
return enterpriseInfoMapper.deleteEnterpriseInfoById(id);
}
/**
* 新增部门返回部门id
* @param enterprise
* @return
*/
private Long insertOrganDept(EnterpriseInfo enterprise){
SysDept dept = new SysDept();
dept.setParentId(0l);
dept.setAncestors("0");
dept.setDeptName(enterprise.getOrganName());
dept.setOrderNum(1);
dept.setLeader(enterprise.getContactPerson());
dept.setPhone(enterprise.getContactNumber());
dept.setStatus("0");
dept.setDelFlag("0");
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){
SysUser user = new SysUser();
user.setDeptId(deptId);
user.setUserName(enterpriseInfo.getOrganCode());
user.setNickName(enterpriseInfo.getOrganName()+"-管理员");
user.setPhonenumber(enterpriseInfo.getContactNumber());
user.setStatus("0");
user.setDelFlag("0");
user.setCreateBy(enterpriseInfo.getCreaterUserId()+"");
user.setOrganCode(enterpriseInfo.getOrganCode());
user.setPassword(SecurityUtils.encryptPassword(password));
sysUserMapper.insertUser(user);
}
}

@ -130,4 +130,6 @@ xss:
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
website:
url: http://127.0.0.1
url: http://127.0.0.1
default:
password: Cjy@2023!

@ -54,7 +54,8 @@ public class SysDept extends BaseEntity
/** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>();
/** 企业标识号*/
private Long organCode;
public Long getDeptId()
{
return deptId;
@ -200,4 +201,12 @@ public class SysDept extends BaseEntity
.append("updateTime", getUpdateTime())
.toString();
}
public Long getOrganCode() {
return organCode;
}
public void setOrganCode(Long organCode) {
this.organCode = organCode;
}
}

@ -89,6 +89,7 @@ public class SysUser extends BaseEntity
/** 角色ID */
private Long roleId;
private Long organCode;
public SysUser()
{
@ -297,6 +298,14 @@ public class SysUser extends BaseEntity
this.roleId = roleId;
}
public Long getOrganCode() {
return organCode;
}
public void setOrganCode(Long organCode) {
this.organCode = organCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -85,6 +85,12 @@ public interface SysDeptMapper
*/
public int insertDept(SysDept dept);
/**
* 说明 :新增部门返回id
* @param dept
* @return
*/
int insertDeptResultId(SysDept dept);
/**
* 修改部门信息
*

@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="organCode" column="organ_code"/>
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time ,d.organ_code
from sys_dept d
</sql>
@ -42,6 +43,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="organCode !=null and organCode !=''">
AND organ_code =#{organCode}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by d.parent_id, d.order_num
@ -99,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="organCode !=null and organCode !=''">organ_code,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
@ -111,10 +116,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="organCode !=null and organCode !=''">#{organCode},</if>
sysdate()
)
</insert>
<insert id="insertDeptResultId" parameterType="SysDept">
<selectKey keyProperty="deptId" order="AFTER" resultType="Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="organCode !=null and organCode !=''">organ_code,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="organCode !=null and organCode !=''">#{organCode},</if>
sysdate()
)
</insert>
<update id="updateDept" parameterType="SysDept">
update sys_dept
<set>
@ -127,6 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="organCode !=null and organCode !=''">organ_code = #{organCode},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}

@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="organCode" column="organ_code"/>
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
@ -157,6 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="organCode !=null and organCode !=''"> organ_code,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
@ -171,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="organCode !=null and organCode !=''">#{organCode},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()

Loading…
Cancel
Save