企业初始化
This commit is contained in:
@@ -6,6 +6,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
@@ -25,4 +27,18 @@ public class EnterpriseUserDAO {
|
||||
return enterpriseUserMapper.getUserInfoById(enterpriseId, userId);
|
||||
}
|
||||
|
||||
public void batchInsertOrUpdate(String eid, List<EnterpriseUserDO> users) {
|
||||
List<EnterpriseUserDO> result = new ArrayList<>();
|
||||
users.forEach(user -> {
|
||||
if (StringUtils.isBlank(user.getUnionid()) || StringUtils.isBlank(user.getUserId())) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isBlank(user.getName())) {
|
||||
user.setName(user.getUserId());
|
||||
}
|
||||
result.add(user);
|
||||
});
|
||||
enterpriseUserMapper.batchInsertOrUpdate(eid, result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserRole;
|
||||
import com.cool.store.mapper.EnterpriseUserMapper;
|
||||
import com.cool.store.mapper.EnterpriseUserRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
@@ -9,4 +15,11 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class EnterpriseUserRoleDAO {
|
||||
|
||||
@Resource
|
||||
private EnterpriseUserRoleMapper enterpriseUserRoleMapper;
|
||||
|
||||
public Boolean insertBatchUserRole(String eid, List<EnterpriseUserRole> userRole) {
|
||||
return enterpriseUserRoleMapper.insertBatchUserRole(eid, userRole);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.enums.RoleEnum;
|
||||
import com.cool.store.mapper.SysRoleMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -30,4 +31,13 @@ public class SysRoleDAO {
|
||||
return sysRoleMapper.getHighestPrioritySysRoleDoByUserId(enterpriseId, userId);
|
||||
}
|
||||
|
||||
public Long getRoleIdByRoleEnum(String eid, String roleEnum) {
|
||||
|
||||
SysRoleDO roleByRoleEnum = sysRoleMapper.getRoleByRoleEnum(eid, roleEnum);
|
||||
if(roleByRoleEnum==null){
|
||||
return Long.valueOf(RoleEnum.getByCode(roleEnum).getId());
|
||||
}
|
||||
return roleByRoleEnum.getId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.cool.store.mapper;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:58
|
||||
@@ -30,4 +32,12 @@ public interface EnterpriseUserMapper {
|
||||
* @return
|
||||
*/
|
||||
EnterpriseUserDO getUserInfoById(@Param("enterpriseId")String enterpriseId, @Param("userId")String userId);
|
||||
|
||||
/**
|
||||
* 批量插入或更新
|
||||
* @param enterpriseId
|
||||
* @param users
|
||||
*/
|
||||
void batchInsertOrUpdate(@Param("enterpriseId") String enterpriseId, @Param("list") List<EnterpriseUserDO> users);
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserRole;
|
||||
import com.cool.store.entity.EnterpriseUserRoleDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
@@ -22,4 +25,12 @@ public interface EnterpriseUserRoleMapper {
|
||||
* dateTime:2023-05-19 02:59
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") EnterpriseUserRoleDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
* 批量插入用户角色
|
||||
* @param enterpriseId
|
||||
* @param userRoles
|
||||
* @return
|
||||
*/
|
||||
Boolean insertBatchUserRole(@Param("eid") String enterpriseId, @Param("userRoles") List<EnterpriseUserRole> userRoles);
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserRole;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
@@ -25,4 +28,6 @@ public interface SysRoleMapper {
|
||||
|
||||
|
||||
SysRoleDO getHighestPrioritySysRoleDoByUserId(@Param("enterpriseId") String enterpriseId, @Param("userId") String userId);
|
||||
|
||||
SysRoleDO getRoleByRoleEnum(@Param("eid") String enterpriseId, @Param("roleEnum") String roleEnum);
|
||||
}
|
||||
@@ -398,4 +398,73 @@
|
||||
where
|
||||
user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="batchInsertOrUpdate" parameterType="java.util.List">
|
||||
insert into enterprise_user_${eid} (
|
||||
id,
|
||||
user_id,
|
||||
`name`,
|
||||
mobile,
|
||||
email,
|
||||
active,
|
||||
order_in_depts,
|
||||
main_admin,
|
||||
is_admin,
|
||||
is_boss,
|
||||
dingId,
|
||||
unionid,
|
||||
is_leader_in_depts,
|
||||
is_hide,
|
||||
departments,
|
||||
`position`,
|
||||
avatar,
|
||||
jobnumber,
|
||||
extattr,
|
||||
roles,
|
||||
is_leader,
|
||||
create_time
|
||||
) values
|
||||
|
||||
<foreach collection="list" item="it" separator=",">
|
||||
|
||||
(
|
||||
#{it.id, jdbcType=VARCHAR},
|
||||
#{it.userId, jdbcType=VARCHAR},
|
||||
#{it.name, jdbcType=VARCHAR},
|
||||
#{it.mobile, jdbcType=VARCHAR},
|
||||
#{it.email, jdbcType=VARCHAR},
|
||||
#{it.active, jdbcType=BOOLEAN},
|
||||
#{it.orderInDepts, jdbcType=VARCHAR},
|
||||
#{it.mainAdmin, jdbcType=BOOLEAN},
|
||||
#{it.isAdmin, jdbcType=BOOLEAN},
|
||||
#{it.isBoss, jdbcType=BOOLEAN},
|
||||
#{it.dingid, jdbcType=VARCHAR},
|
||||
#{it.unionid, jdbcType=VARCHAR},
|
||||
#{it.isLeaderInDepts, jdbcType=VARCHAR},
|
||||
#{it.isHide, jdbcType=BOOLEAN},
|
||||
#{it.departments, jdbcType=VARCHAR},
|
||||
#{it.position, jdbcType=VARCHAR},
|
||||
#{it.avatar, jdbcType=VARCHAR},
|
||||
#{it.jobnumber, jdbcType=VARCHAR},
|
||||
#{it.extattr, jdbcType=VARCHAR},
|
||||
#{it.roles, jdbcType=VARCHAR},
|
||||
#{it.isLeader, jdbcType=BOOLEAN},
|
||||
sysdate()
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
departments=values(departments),
|
||||
`name`=values(name),
|
||||
main_admin=values(main_admin),
|
||||
is_admin=values(is_admin),
|
||||
mobile = values(mobile),
|
||||
order_in_depts=values(order_in_depts),
|
||||
is_leader_in_depts=values(is_leader_in_depts),
|
||||
avatar=values(avatar),
|
||||
active=values(active),
|
||||
`position`=values(position),
|
||||
roles=values(roles),
|
||||
jobnumber=values(jobnumber)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -60,4 +60,13 @@
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
|
||||
<insert id="insertBatchUserRole">
|
||||
insert ignore into enterprise_user_role_${eid}
|
||||
(role_id, user_id ,create_time)
|
||||
values
|
||||
<foreach collection="userRoles" item="userRole" separator=",">
|
||||
(#{userRole.roleId}, #{userRole.userId} ,#{userRole.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -180,4 +180,21 @@
|
||||
c.priority is null, c.priority, position_type desc
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="getRoleByRoleEnum" resultMap="BaseResultMap">
|
||||
select
|
||||
id as id,
|
||||
role_name as roleName,
|
||||
role_auth as roleAuth,
|
||||
is_internal as isInternal,
|
||||
`source` as source,
|
||||
priority as priority,
|
||||
app_menu as appMenu,
|
||||
position_type as positionType,
|
||||
role_enum as roleEnum
|
||||
from
|
||||
sys_role_${eid}
|
||||
where
|
||||
role_enum = #{roleEnum}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user