Browse Source

为客户初始化角色信息,增加已存在的判断

dev_shibei_match
wxz 5 years ago
parent
commit
9c17111caa
  1. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java
  2. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java
  3. 6
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

2
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java

@ -77,4 +77,6 @@ public interface GovStaffRoleDao extends BaseDao<GovStaffRoleEntity> {
int updateSortById(@Param("roleId") String roleId, @Param("sort") int sort);
List<GovStaffRoleResultDTO> listRolesByRoleKey(@Param("roleKey") String roleKey);
Integer countRolesByCustomerId(@Param("customerId") String customerId);
}

11
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java

@ -39,6 +39,8 @@ import com.epmet.feign.GovAccessFeignClient;
import com.epmet.redis.GovStaffRoleRedis;
import com.epmet.service.GovStaffRoleService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -57,6 +59,8 @@ import java.util.Map;
@Service
public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, GovStaffRoleEntity> implements GovStaffRoleService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private GovStaffRoleRedis govStaffRoleRedis;
@ -140,8 +144,13 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void initGovStaffRolesForCustomer(String customerId) {
Integer rolesCount = baseDao.countRolesByCustomerId(customerId);
if (rolesCount > 0) {
logger.info("为客户初始化角色列表-该客户【客户ID:%s】已存在角色信息,无需再次初始化。", customerId);
return;
}
// 增加角色列表
List<GovStaffRoleTemplateDTO> validRoles = govStaffRoleTemplateDao.listValidateRoles();

6
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

@ -111,4 +111,10 @@
where gsr.ROLE_KEY = #{roleKey}
and gsr.DEL_FLAG=0
</select>
<select id="countRolesByCustomerId" resultType="java.lang.Integer">
select count(0)
from gov_staff_role
where CUSTOMER_ID = #{customerId}
</select>
</mapper>
Loading…
Cancel
Save