Merge branch 'dev/dev_xp' into dev/3.1_release_merge
This commit is contained in:
@@ -5,6 +5,7 @@ import com.ai.da.common.response.ResultEnum;
|
||||
import com.ai.da.model.enums.Language;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -20,6 +21,7 @@ import java.util.ResourceBundle;
|
||||
* @create: 2020-01-01 17:24
|
||||
**/
|
||||
@Data
|
||||
@Slf4j
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
private Integer code;
|
||||
@@ -47,6 +49,7 @@ public class BusinessException extends RuntimeException {
|
||||
|
||||
private static Locale getUserLocale() {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
log.info("userinfo: {}", userInfo);
|
||||
if (Objects.isNull(userInfo)) {
|
||||
return new Locale("en");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
@@ -302,7 +303,7 @@ public class AccountController {
|
||||
@ApiOperation(value = "子账号删除")
|
||||
public Response<Boolean> deleteSubAccount(@Valid @RequestBody AddSubAccountDTO addSubAccountDTO) {
|
||||
// return Response.success(accountService.deleteSubAccount(addSubAccountDTO));
|
||||
accountService.removeSubAccount(addSubAccountDTO);
|
||||
accountService.removeSubAccount(addSubAccountDTO, UserContext.getUserHolder().getId());
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
@@ -390,6 +391,11 @@ public class AccountController {
|
||||
public void refreshCreditsMonthly() {
|
||||
accountService.refreshCreditsMonthly();
|
||||
}*/
|
||||
@GetMapping("/checkEduAdminExpireStatus")
|
||||
@ApiOperation(value = "检查教育管理员账号到期情况")
|
||||
public void checkEduAdminExpireStatus() {
|
||||
accountService.checkEduAdminExpireStatus();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public interface AccountService extends IService<Account> {
|
||||
|
||||
// Boolean deleteSubAccount(AddSubAccountDTO addSubAccountDTO);
|
||||
|
||||
void removeSubAccount(AddSubAccountDTO addSubAccountDTO);
|
||||
void removeSubAccount(AddSubAccountDTO addSubAccountDTO, Long adminAccId);
|
||||
|
||||
PageBaseResponse<Account> subAccountList(SubAccountPageDTO subAccountPageDTO);
|
||||
|
||||
@@ -240,4 +240,6 @@ public interface AccountService extends IService<Account> {
|
||||
Set<String> organizationNameSearch(String type, String name);
|
||||
|
||||
/*void send618PromotionEmailTemp();*/
|
||||
|
||||
void checkEduAdminExpireStatus();
|
||||
}
|
||||
|
||||
@@ -2605,7 +2605,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
// BigDecimal creditsUsage = exAccountInfo.getCreditsUsage();
|
||||
addSubAccountDTO.setCreditsUsage(exAccountInfo.getCreditsUsage());
|
||||
// 这里移除原账号,但是积分不回流,机构分配的积分会由下一个账号继续持有(包括积分上限和已使用的积分都保持不变)
|
||||
removeSubAccount(new AddSubAccountDTO(Collections.singletonList(addSubAccountDTO.getId())));
|
||||
removeSubAccount(new AddSubAccountDTO(Collections.singletonList(addSubAccountDTO.getId())), adminAcc.getId());
|
||||
// 移入新子账号(可能是移入,也可能是新增)
|
||||
createSubAccount(addSubAccountDTO, adminAcc, subUserRole);
|
||||
} else {
|
||||
@@ -2691,8 +2691,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
return Boolean.TRUE;
|
||||
}*/
|
||||
|
||||
public void removeSubAccount(AddSubAccountDTO addSubAccountDTO) {
|
||||
Long adminAccId = UserContext.getUserHolder().getId();
|
||||
public void removeSubAccount(AddSubAccountDTO addSubAccountDTO, Long adminAccId) {
|
||||
// Long adminAccId = UserContext.getUserHolder().getId();
|
||||
Account adminAcc = baseMapper.selectById(adminAccId);
|
||||
if (Objects.isNull(adminAcc) || (adminAcc.getSystemUser() != 5 && adminAcc.getSystemUser() != 7)) {
|
||||
throw new BusinessException("have.no.permission");
|
||||
@@ -3595,4 +3595,23 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
}*/
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void checkEduAdminExpireStatus(){
|
||||
// 1、检查所有管理员账号到期状态
|
||||
List<Account> expiredEduAdmin = getExpiredUserBySystemUser(7);
|
||||
// 2、若有过期教育管理员,则将该管理员下的所有子账号删除(降为游客或者恢复其原本身份与积分)
|
||||
if (!expiredEduAdmin.isEmpty()) {
|
||||
for (Account adminAccount : expiredEduAdmin){
|
||||
List<Account> subAccountsByAdmin = getSubAccountsByAdmin(adminAccount);
|
||||
if (!subAccountsByAdmin.isEmpty()){
|
||||
// 获取所有子账号的id,并删除
|
||||
List<Long> subAccIdList = subAccountsByAdmin.stream().map(Account::getId).collect(Collectors.toList());
|
||||
removeSubAccount(new AddSubAccountDTO(subAccIdList), adminAccount.getId());
|
||||
}
|
||||
// 将教育管理员置为游客
|
||||
toVisitor(adminAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
</select>
|
||||
<update id="toVisitor">
|
||||
update t_account
|
||||
set is_trial = 0, credits = 0, system_user = 0
|
||||
set is_trial = 0, credits = 0, system_user = 0,
|
||||
organization_name = null, credits_usage = null, credits_usage_limit = null, sub_account_num = null
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user