diff --git a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java index 90f1bdaf..d09a0285 100644 --- a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java +++ b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/AppUserController.java @@ -35,10 +35,7 @@ import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.time.Duration; import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Base64; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -121,7 +118,7 @@ public class AppUserController extends ControllerBase { */ @GetMapping("getAreasByCompany") @ApiMark(moduleName = "代理商管理", apiName = "根据公司id获取区域列表",isPublic = true) - public ApiResult> getAreasByCompany(@Valid @RequestParam @NotNull List companyIds){ + public ApiResult> getAreasByCompany(@Valid @RequestParam @NotNull List companyIds){ return ApiResult.success(customerService.getAreas(companyIds)); } @@ -207,7 +204,18 @@ public class AppUserController extends ControllerBase { appUserService.updateById(user); } - public void updatePrimaryAppUser(AppUser user,AppUserUpdateRequest request) throws MessagingException { + public void updatePrimaryAppUser(AppUser user,AppUserUpdateRequest request) { + Collection currentCompanyIds=StrUtil.split(user.getCompanyId(),",").stream().map(Integer::parseInt).collect(Collectors.toSet()); + currentCompanyIds.removeAll(request.getCompanyIds()); + if (CollectionUtil.isNotEmpty(currentCompanyIds)){ + //删除了一些公司,需要判断被删除的公司是否被其他代理商子账号关联,如果被删除的公司下有子账号,则不允许删除 + VUtils.trueThrowBusinessError(appUserService.lambdaQuery() + .eq(AppUser::getIsDel,false) + .eq(AppUser::getIsPrimary,false) + .in(AppUser::getCompanyId, currentCompanyIds) + .exists()) + .throwMessage("被移除的公司存在子账号,移除失败"); + } List companyIds = appUserService.lambdaQuery() .select(AppUser::getCompanyId) .eq(AppUser::getIsPrimary, true) diff --git a/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/TestController.java b/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/TestController.java index b4e6b789..68aa2517 100644 --- a/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/TestController.java +++ b/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/TestController.java @@ -2,6 +2,7 @@ package com.nflg.mobilebroken.auth.controller; import cn.dev33.satoken.stp.SaLoginConfig; import cn.dev33.satoken.stp.SaTokenInfo; +import cn.hutool.core.util.StrUtil; import com.nflg.mobilebroken.common.pojo.ApiResult; import com.nflg.mobilebroken.common.util.SaTokenAppUtil; import com.nflg.mobilebroken.common.util.VUtils; @@ -13,8 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.Arrays; import java.util.Objects; +import java.util.stream.Collectors; /** * 测试相关 @@ -27,18 +28,20 @@ public class TestController extends ControllerBase { private IAppUserService appUserService; /** - * 获取token + * 获取用户端token * @param userId 用户端用户id * @return token */ - @GetMapping("getToken") - public ApiResult getToken(@RequestParam Integer userId){ + @GetMapping("app/getToken") + public ApiResult getAppToken(@RequestParam Integer userId){ AppUser user=appUserService.getById(userId); VUtils.trueThrowBusinessError(Objects.isNull(user)).throwMessage("没有找到用户"); - SaTokenAppUtil.login(userId, SaLoginConfig + SaTokenAppUtil.login(user.getId(), SaLoginConfig + .setExtra("from", "app") .setExtra("name", user.getName()) - .setExtra("companys", Arrays.asList(1,2)) - .setExtra("isPrimary",user.getIsPrimary())); + .setExtra("email", user.getEmail()) + .setExtra("companyIds", StrUtil.split(user.getCompanyId(), ",").stream().map(Integer::valueOf).collect(Collectors.toList())) + .setExtra("isPrimary", user.getIsPrimary())); return ApiResult.success(SaTokenAppUtil.getTokenInfo()); } } diff --git a/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java b/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java index e0e14338..2f839ca2 100644 --- a/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java +++ b/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/UserController.java @@ -157,7 +157,7 @@ public class UserController extends ControllerBase { List list = datas.stream().map(d -> { List lvos = JSONUtil.toList(d.getPositionLanguage(), PositionLanguageVO.class); PositionLanguageVO lvo = lvos.stream().filter(l -> StrUtil.equals(l.getCode(), language)).findFirst().orElse(null); - return new TitleVO().setId(d.getId()).setName(d.getName()).setValue(Objects.isNull(lvo) ? d.getName() : lvo.getLanguageValue()); + return new TitleVO().setId(d.getId()).setName(d.getName()).setValue(Objects.isNull(lvo) || StrUtil.isBlank(lvo.getLanguageValue()) ? d.getName() : lvo.getLanguageValue()); }).collect(Collectors.toList()); return ApiResult.success(list); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/ITBaseCustomerService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/ITBaseCustomerService.java index 7ba0fcd1..93c1a831 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/ITBaseCustomerService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/ITBaseCustomerService.java @@ -7,6 +7,7 @@ import com.nflg.mobilebroken.common.pojo.vo.CompanySimpleVO; import com.nflg.mobilebroken.repository.entity.TBaseCustomer; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -30,5 +31,5 @@ public interface ITBaseCustomerService extends IService { List getSimpleCompanysFromAdmin(Integer userId); - List getAreas(List companyIds); + Collection getAreas(List companyIds); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserApplyforServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserApplyforServiceImpl.java index aae54b29..41bfdbc5 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserApplyforServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserApplyforServiceImpl.java @@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -172,7 +173,7 @@ public class AppUserApplyforServiceImpl extends ServiceImpl areas=customerService.getAreas(Arrays.stream(appUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList())); + Collection areas=customerService.getAreas(Arrays.stream(appUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList())); vo.setUser(new AppUserVO() .setAreaName(StrUtil.join(",",areas)) .setSalesUserName(appUser.getSalesUserName()) diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TBaseCustomerServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TBaseCustomerServiceImpl.java index cf16fea2..bf2a8bd0 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TBaseCustomerServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TBaseCustomerServiceImpl.java @@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -105,7 +106,7 @@ public class TBaseCustomerServiceImpl extends ServiceImpl getAreas(List companyIds) { + public Collection getAreas(List companyIds) { return lambdaQuery() .eq(TBaseCustomer::getDelIs, 0) .eq(TBaseCustomer::getEnableState, 1) @@ -114,6 +115,6 @@ public class TBaseCustomerServiceImpl extends ServiceImpl StrUtil.split(name, ",").stream()) - .collect(Collectors.toList()); + .collect(Collectors.toSet()); } }