Commit e15a7269 authored by hezhuozhi's avatar hezhuozhi

27301 经销商管理员不能对经销商账号进行删除操作

parent cbec0fa5
......@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.PersonnelBusiness;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
......@@ -43,4 +44,8 @@ public interface PersonnelBusinessMapper extends BaseMapper<PersonnelBusiness> {
void deleteSueByUserId(String userId);
void deleteAliByUserId(String userId);
List<String> selectHygfTableName();
int countByUserId(@Param("tableName") String tableName, @Param("userId")String userId);
}
......@@ -148,4 +148,14 @@ select ORG_CODE orgCode from privilege_company where privilege_company.SEQUEN
DELETE FROM auth_login_info WHERE USER_ID=#{userId}
</select>
<select id="selectHygfTableName" resultType="java.lang.String">
SELECT table_name
FROM information_schema.tables
WHERE table_schema=DATABASE() and table_name LIKE 'hygf_%';
</select>
<select id="countByUserId" resultType="int">
select count(1) from ${tableName} where rec_user_id =#{userId}
</select>
</mapper>
......@@ -498,10 +498,21 @@ public class PersonnelBusinessServiceImpl extends BaseService<PersonnelBusinessD
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteAllBySequenceNbr(Long sequenceNbr) {
// 根据sequenceNbr查询用户userId
String userId = personnelBusinessMapper.selectUserInfo(sequenceNbr);
//添加校验,如果业务表里面有相关的用户id不能删除
List<String> tableName = personnelBusinessMapper.selectHygfTableName();
if (CollectionUtil.isNotEmpty(tableName)) {
for (String table : tableName) {
int count = personnelBusinessMapper.countByUserId(table, userId);
if (count > 0) {
throw new BadRequest("该用户有操作记录无法删除!");
}
}
}
try {
// 根据sequenceNbr查询用户userId
String userId = personnelBusinessMapper.selectUserInfo(sequenceNbr);
// 删除privilege_agency_user表中数据
personnelBusinessMapper.deletePauByUserId(userId);
// 删除privilege_group_user表中数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment