提交 9ac3167f 作者: zhenjie

后台账号绑定单位相关bug修复

上级 bb8611b4
......@@ -57,6 +57,7 @@ public enum ResultEnum implements BaseErrorInfoInterface {
ONLY_ONE_ADMIN_ERROR("8010", "禁止该账号获取超级管理员角色"),
DELETE_ADMIN_ERROR("8011", "禁止删除超级管理员角色账号"),
DELETE_YOURSELF_ERROR("8011", "禁止删除自己的账号"),
FRANCHISEE_ACCOUNT_MORE_THAN_ONE_ERROR("8012", "绑定企业为加盟公司,禁止使用该单位"),
ID_INFO_AND_ID_card_MISMATCH("3904", "身份信息与身份证不匹配"),
INTERFACE_ACCESS_EXCEPTION("36894", "接口访问异常/次数用尽"),
......
......@@ -193,4 +193,8 @@ public interface CompanyDao {
List<UserAccountDO> listCompanyMembersPage(Integer id, Integer pageNo, Integer pageSize);
int countBingingCompanyInfoByUID(Integer userAccountId);
void unbindingAllAppUsers(Integer id);
void unbindingAllPcUsers(Integer id);
}
......@@ -45,7 +45,7 @@ public interface CompanyService {
* @param id
* @return
*/
ResultBody getCompanyInfoById(Integer id);
ResultBody<CompanyInfoVO> getCompanyInfoById(Integer id);
/**
* 单位列表
......@@ -147,4 +147,19 @@ public interface CompanyService {
ResultBody listCompanyMembers(Integer companyInfoId, LoginSuccessDTO userLoginInfoFromRedis, Integer pageNo, Integer pageSize);
ResultBody<CompanyInfoVO> getCompanyInfoByBUId(Integer backUserAccountId);
/**
* 查看绑定的后台账号个数
*
* @param id
* @return
*/
Integer countCompanyBackUser(Integer id);
/**
* 解绑当前单位全部成员
*
* @param id
*/
void unbindingAllUsers(Integer id);
}
......@@ -11,6 +11,7 @@ import com.mmc.iuav.user.entity.BackUserAccountDO;
import com.mmc.iuav.user.entity.CompanyBackUserDO;
import com.mmc.iuav.user.entity.CompanyInfoDO;
import com.mmc.iuav.user.entity.RoleInfoDO;
import com.mmc.iuav.user.enums.CompanyTypeEnums;
import com.mmc.iuav.user.enums.RoleEnums;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.qo.BUserAccountQO;
......@@ -65,6 +66,15 @@ public class BackUserAccountServiceImpl implements BackUserAccountService {
} catch (NoSuchAlgorithmException e) {
return ResultBody.error(ResultEnum.PWD_CREATE_ERROR);
}
ResultBody<CompanyInfoVO> companyInfoVOResultBody = companyService.getCompanyInfoById(bUserAccountVO.getCompanyId());
CompanyInfoVO companyInfoVO = companyInfoVOResultBody.getResult();
if (companyInfoVO != null && companyInfoVO.getCompanyType().equals(CompanyTypeEnums.FRANCHISEE.getType())) {
// 绑定企业为加盟公司,不能生成多个账号
int bindingCount = companyService.countCompanyBackUser(companyInfoVO.getId());
if (bindingCount > 0) {
return ResultBody.error(ResultEnum.FRANCHISEE_ACCOUNT_MORE_THAN_ONE_ERROR);
}
}
backUserAccountDao.insertBackUserAccount(backUserAccountDO);
// 添加角色
roleDao.insertUserRoleRel(backUserAccountDO.getId(), bUserAccountVO.getRoleId());
......@@ -103,6 +113,15 @@ public class BackUserAccountServiceImpl implements BackUserAccountService {
if (bUserAccountVO.getId().equals(1) && !bUserAccountVO.getRoleId().equals(RoleEnums.ADMIN.getId())) {
return ResultBody.error(ResultEnum.UPDATE_ADMIN_ROLE_ERROR);
}
ResultBody<CompanyInfoVO> companyInfoVOResultBody = companyService.getCompanyInfoById(bUserAccountVO.getCompanyId());
CompanyInfoVO companyInfoVO = companyInfoVOResultBody.getResult();
if (companyInfoVO != null && companyInfoVO.getCompanyType().equals(CompanyTypeEnums.FRANCHISEE.getType())) {
// 绑定企业为加盟公司,不能生成多个账号
int bindingCount = companyService.countCompanyBackUser(companyInfoVO.getId());
if (bindingCount > 0) {
return ResultBody.error(ResultEnum.FRANCHISEE_ACCOUNT_MORE_THAN_ONE_ERROR);
}
}
BackUserAccountDO userAccountDO = new BackUserAccountDO(bUserAccountVO);
backUserAccountDao.updateBackUserAccount(userAccountDO);
// 修改单位信息
......@@ -125,6 +144,11 @@ public class BackUserAccountServiceImpl implements BackUserAccountService {
if (accountId.toString().equals(backUserAccountId.toString())) {
return ResultBody.error(ResultEnum.DELETE_YOURSELF_ERROR);
}
CompanyInfoVO companyInfoVO = companyService.getCompanyInfoByBackUserAccountId(backUserAccountId);
if (companyInfoVO != null && companyInfoVO.getCompanyType().equals(CompanyTypeEnums.FRANCHISEE.getType())) {
// 加盟企业的账号,需要把对应的成员和后台账号解绑
companyService.unbindingAllUsers(companyInfoVO.getId());
}
backUserAccountDao.disableBackUserAccountDO(accountId);
return ResultBody.success();
}
......
......@@ -16,6 +16,7 @@ import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
......@@ -78,7 +79,7 @@ public class CompanyServiceImpl implements CompanyService {
}
@Override
public ResultBody getCompanyInfoById(Integer id) {
public ResultBody<CompanyInfoVO> getCompanyInfoById(Integer id) {
CompanyInfoDO companyInfoDO = companyDao.getCompanyInfoById(id);
if (companyInfoDO != null) {
return ResultBody.success(companyInfoDO.buildCompanyInfoVO());
......@@ -214,4 +215,19 @@ public class CompanyServiceImpl implements CompanyService {
}
return ResultBody.success();
}
@Override
public Integer countCompanyBackUser(Integer id) {
int countCompanyBackUser = companyDao.countCompanyBackUser(id);
return countCompanyBackUser;
}
@Transactional
@Override
public void unbindingAllUsers(Integer id) {
// 解绑小程序成员
companyDao.unbindingAllAppUsers(id);
// 解绑后台账号
companyDao.unbindingAllPcUsers(id);
}
}
......@@ -99,6 +99,14 @@
delete from company_member where user_account_id = #{userAccountId} and company_info_id = #{companyInfoId}
</delete>
<delete id="unbindingAllAppUsers">
delete from company_member where company_info_id = #{companyInfoId}
</delete>
<delete id="unbindingAllPcUsers">
delete from company_back_user where company_info_id = #{companyInfoId}
</delete>
<select id="getCompanyInfoById" resultType="com.mmc.iuav.user.entity.CompanyInfoDO">
select id, company_type, company_name, full_name, province, city, district, address, company_user_name,
phone_num, remark, create_time, lon, lat, credit_code, license_img, brand_name, brand_logo,content, score
......
......@@ -106,13 +106,7 @@
apply_status = #{applyStatus},
</if>
<if test="remark != null and remark != '' ">
remark = #{remark},
</if>
<if test="content != null and content != ''">
content = #{content},
</if>
<if test="score != null">
score = #{score}
remark = #{remark}
</if>
</set>
WHERE id = #{id}
......@@ -305,8 +299,8 @@
ci.lon,
ci.lat,
ct.id AS type,
uat.content,
uat.score,
ci.content,
ci.score,
st_distance_sphere(point(ci.lon,ci.lat), point(${lon}, ${lat})) AS distance
FROM
user_apply_tag uat
......@@ -376,8 +370,8 @@
ua.apply_status,
ua.remark,
ua.create_time,
ua.content,
ua.score,
ci.content,
ci.score,
ct.tag_name,
ci.company_name,
ci.brand_name,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论