Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev/3.1_release_merge
This commit is contained in:
@@ -220,9 +220,9 @@ public class ConvenientInquiryController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有企业或教育机构")
|
||||
@GetMapping("/queryOrganization")
|
||||
public Response<List<Organization>> queryOrganization(@ApiParam(value = "Enterprise || Education") @RequestParam String type){
|
||||
return Response.success(convenientInquiryService.queryOrganization(type));
|
||||
@PostMapping("/queryOrganization")
|
||||
public Response<IPage<Organization>> queryOrganization(@RequestBody QueryOrganizationPageDTO queryOrganizationPageDTO){
|
||||
return Response.success(convenientInquiryService.queryOrganization(queryOrganizationPageDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ public class Organization extends BaseEntity{
|
||||
private String level;
|
||||
// 父分类ID(自引用)
|
||||
private Long parentId;
|
||||
// 状态
|
||||
// 状态 0 inactive || 1 active
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel
|
||||
@NoArgsConstructor
|
||||
public class QueryOrganizationPageDTO extends QueryPageByTimeDTO{
|
||||
@ApiModelProperty("组织类型 Enterprise || Education")
|
||||
private String type;
|
||||
@ApiModelProperty("组织名字")
|
||||
private String name;
|
||||
|
||||
public QueryOrganizationPageDTO(String type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
public enum PrintboardLevel2TypeEnum implements IEnumDisplay {
|
||||
PATTERN("图案", "Pattern"),
|
||||
@@ -41,6 +42,9 @@ public enum PrintboardLevel2TypeEnum implements IEnumDisplay {
|
||||
|
||||
// 根据名称获取枚举值
|
||||
public static PrintboardLevel2TypeEnum fromName(String name) {
|
||||
if (StringUtil.isNullOrEmpty(name)){
|
||||
return PrintboardLevel2TypeEnum.PATTERN;
|
||||
}
|
||||
for (PrintboardLevel2TypeEnum designElement : PrintboardLevel2TypeEnum.values()) {
|
||||
if (designElement.english.equals(name)) {
|
||||
return designElement;
|
||||
|
||||
@@ -242,4 +242,6 @@ public interface AccountService extends IService<Account> {
|
||||
/*void send618PromotionEmailTemp();*/
|
||||
|
||||
void checkEduAdminExpireStatus();
|
||||
|
||||
void setEduAdminToExpire(Account adminAccount);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public interface ConvenientInquiryService extends IService<Questionnaire> {
|
||||
|
||||
Boolean addUser(AccountAddDTO accountAddDTO);
|
||||
|
||||
Organization checkOrganization(Integer systemUser, String organizationName);
|
||||
|
||||
Boolean modifyUser(Long accountId, Long validEndTime, Integer systemUser, Long credits);
|
||||
|
||||
IPage<Account> getUserInfo(QueryUserConditionsVO queryUserConditionsVO);
|
||||
@@ -60,7 +62,7 @@ public interface ConvenientInquiryService extends IService<Questionnaire> {
|
||||
|
||||
List<String> getAllGenerateFuncName();
|
||||
|
||||
void addOrganization(String name, String type);
|
||||
Organization addOrganization(String name, String type);
|
||||
|
||||
List<Organization> queryOrganization(String type);
|
||||
IPage<Organization> queryOrganization(QueryOrganizationPageDTO queryOrganizationPageDTOe);
|
||||
}
|
||||
|
||||
@@ -12,10 +12,7 @@ import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.ResultEnum;
|
||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.AccountExtendMapper;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.QuestionnaireMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.AutoApproved;
|
||||
@@ -97,12 +94,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
@Resource
|
||||
private AccountLoginLogService accountLoginLogService;
|
||||
|
||||
@Resource
|
||||
private ConvenientInquiryService convenientInquiryService;
|
||||
|
||||
@Resource
|
||||
private LibraryService libraryService;
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
|
||||
@Resource
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
@@ -278,6 +281,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
return accountList.get(0);
|
||||
}
|
||||
|
||||
// 定义常量(临时)
|
||||
private static final Integer SYSTEM_USER_TYPE_EDU_ADMIN = 7;
|
||||
|
||||
private void validateUserValidaExpire(Account account) {
|
||||
Long currentTime = new Date().getTime();
|
||||
if (account.getSystemUser().equals(0)) {
|
||||
@@ -289,13 +295,20 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(account.getValidEndTime())) {
|
||||
if (currentTime > account.getValidEndTime()) {
|
||||
boolean isExpired = currentTime > account.getValidEndTime();
|
||||
boolean isEduAdmin = SYSTEM_USER_TYPE_EDU_ADMIN.equals(account.getSystemUser());
|
||||
|
||||
if (isExpired) {
|
||||
if (isEduAdmin) {
|
||||
setEduAdminToExpire(account);
|
||||
} else {
|
||||
toVisitor(account);
|
||||
return;
|
||||
// throw new BusinessException("user.expired");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前用户应该从哪个入口登录
|
||||
private void validateEduOrComLogin(Account account) {
|
||||
@@ -1895,6 +1908,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
return "参与成功";
|
||||
|
||||
}
|
||||
|
||||
// 将指定unix时间置为当天的23:59:59
|
||||
public long toDayEnd(long unixTimestampMillis) {
|
||||
// 将UNIX时间戳转换为LocalDateTime对象
|
||||
@@ -1912,6 +1926,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
|
||||
/**
|
||||
* 获取指定身份过期用户
|
||||
*
|
||||
* @param systemUserNum
|
||||
* @return
|
||||
*/
|
||||
@@ -2474,7 +2489,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
if (Objects.nonNull(subAccount) && personAccRole.contains(subAccount.getSystemUser())) {
|
||||
log.info("将用户{} 加入组织{}", addSubAccountDTO.getUserEmail(), adminAcc.getOrganizationName());
|
||||
subAccount.setUserName(addSubAccountDTO.getUserName());
|
||||
if (!StringUtil.isNullOrEmpty(addSubAccountDTO.getUserPassword())) subAccount.setUserPassword(addSubAccountDTO.getUserPassword());
|
||||
if (!StringUtil.isNullOrEmpty(addSubAccountDTO.getUserPassword()))
|
||||
subAccount.setUserPassword(addSubAccountDTO.getUserPassword());
|
||||
subAccount.setSystemUser(subUserRole);
|
||||
subAccount.setOrganizationName(adminAcc.getOrganizationName());
|
||||
subAccount.setParentId(adminAcc.getId());
|
||||
@@ -2660,7 +2676,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
|
||||
if (Objects.nonNull(adminAcc.getCreditsUsageLimit()) && (Objects.isNull(subAcc.getCreditsUsageLimit()) || subAcc.getCreditsUsageLimit().compareTo(BigDecimal.ZERO) == 0)) {
|
||||
// 默认使用平均积分
|
||||
BigDecimal defaultCredits = adminAcc.getCreditsUsageLimit().divide(new BigDecimal(adminAcc.getSubAccountNum()), RoundingMode.FLOOR);;
|
||||
BigDecimal defaultCredits = adminAcc.getCreditsUsageLimit().divide(new BigDecimal(adminAcc.getSubAccountNum()), RoundingMode.FLOOR);
|
||||
;
|
||||
|
||||
if (remainingCredits.compareTo(defaultCredits) >= 0) {
|
||||
subAcc.setCreditsUsageLimit(defaultCredits);
|
||||
@@ -3017,6 +3034,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
|
||||
private static final String WECHAT_USER_INFO_URL = "https://api.weixin.qq.com/sns/userinfo";
|
||||
|
||||
private JSONObject getUserInfoFromWeChat(String accessToken, String openId) {
|
||||
// 构造微信用户信息接口的 URL
|
||||
String url = String.format(
|
||||
@@ -3603,23 +3621,49 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
}*/
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void checkEduAdminExpireStatus() {
|
||||
// 1、检查所有管理员账号到期状态
|
||||
List<Account> expiredEduAdmin = getExpiredUserBySystemUser(7);
|
||||
// 2、若有过期教育管理员,则将该管理员下的所有子账号删除(降为游客或者恢复其原本身份与积分)
|
||||
if (!expiredEduAdmin.isEmpty()) {
|
||||
for (Account adminAccount : expiredEduAdmin) {
|
||||
setEduAdminToExpire(adminAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void setEduAdminToExpire(Account adminAccount) {
|
||||
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());
|
||||
}
|
||||
setOrganizationStatus(adminAccount, false);
|
||||
// 将教育管理员置为游客
|
||||
toVisitor(adminAccount);
|
||||
}
|
||||
|
||||
// todo 机构管理员再次订阅时,需要同步机构的激活状态
|
||||
private void setOrganizationStatus(Account adminAcc, boolean isActive){
|
||||
Organization organization;
|
||||
if (Objects.nonNull(adminAcc.getOrganizationId())){
|
||||
organization = organizationMapper.selectById(adminAcc.getOrganizationId());
|
||||
} else if (!StringUtil.isNullOrEmpty(adminAcc.getOrganizationName())){
|
||||
organization = convenientInquiryService.checkOrganization(adminAcc.getSystemUser(), adminAcc.getOrganizationName());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (isActive){
|
||||
organization.setStatus(1);
|
||||
} else {
|
||||
organization.setStatus(0);
|
||||
}
|
||||
organization.setUpdateTime(LocalDateTime.now());
|
||||
organizationMapper.updateById(organization);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -330,6 +330,18 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD);
|
||||
List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> {
|
||||
if (StringUtil.isNullOrEmpty(o.getLevel2Type())){
|
||||
switch(d.getLevel1Type()){
|
||||
case "Sketchboard":
|
||||
d.setLevel2Type("Outwear");
|
||||
break;
|
||||
case "Printboard":
|
||||
d.setLevel2Type("Pattern");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
d.setLevel2Type(o.getLevel2Type());
|
||||
}
|
||||
d.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
||||
d.setName(name);
|
||||
d.setId(null);
|
||||
@@ -369,6 +381,18 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
// // TODO:暂不处理
|
||||
// }
|
||||
}
|
||||
if (StringUtil.isNullOrEmpty(o.getLevel2Type())){
|
||||
switch(d.getLevel1Type()){
|
||||
case "Sketchboard":
|
||||
d.setLevel2Type("Outwear");
|
||||
break;
|
||||
case "Printboard":
|
||||
d.setLevel2Type("Pattern");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
d.setLevel2Type(o.getLevel2Type());
|
||||
}
|
||||
d.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
||||
d.setName(name);
|
||||
d.setId(null);
|
||||
|
||||
@@ -636,7 +636,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
account.setSubAccountNum(accountAddDTO.getSubAccountNum());
|
||||
}
|
||||
if (!StringUtil.isNullOrEmpty(accountAddDTO.getOrganizationName())) {
|
||||
account.setOrganizationName(accountAddDTO.getOrganizationName());
|
||||
checkAndSetOrganization(accountAddDTO, account);
|
||||
}
|
||||
account.setValidStartTime(Long.parseLong(accountAddDTO.getValidStartTime()));
|
||||
account.setValidEndTime(Long.parseLong(accountAddDTO.getValidEndTime()));
|
||||
@@ -649,6 +649,36 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
return accountService.save(account);
|
||||
}
|
||||
|
||||
private void checkAndSetOrganization(AccountAddDTO accountAddDTO, Account account){
|
||||
Organization organization = checkOrganization(accountAddDTO.getSystemUser(), accountAddDTO.getOrganizationName());
|
||||
if (Objects.nonNull(organization)){
|
||||
account.setOrganizationId(organization.getId());
|
||||
} else {
|
||||
organization = addOrganization(accountAddDTO.getOrganizationName(), organization.getType());
|
||||
account.setOrganizationName(accountAddDTO.getOrganizationName());
|
||||
account.setOrganizationId(organization.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public Organization checkOrganization(Integer systemUser, String organizationName){
|
||||
String type ;
|
||||
switch (systemUser){
|
||||
case 5:
|
||||
type = "Enterprise";
|
||||
break;
|
||||
case 7:
|
||||
type = "Education";
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
QueryWrapper<Organization> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(Organization::getType, type).eq(Organization::getName, organizationName);
|
||||
|
||||
return organizationMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
// 修改用户信息
|
||||
public Boolean modifyUser(Long accountId, Long validEndTime, Integer systemUser, Long credits) {
|
||||
log.info("modifyUser ==> accountId:{}, validEndTime:{}, systemUser:{}, systemUser:{}", accountId, validEndTime, systemUser, credits);
|
||||
@@ -1030,6 +1060,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
|
||||
/**
|
||||
* 查询generate使用频次
|
||||
*
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
@@ -1091,7 +1122,8 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
public void addOrganization(String name, String type){
|
||||
|
||||
public Organization addOrganization(String name, String type) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Account account = accountService.getById(accountId);
|
||||
// 允许查看数据的用户id
|
||||
@@ -1102,19 +1134,37 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
organization.setName(name);
|
||||
organization.setType(type);
|
||||
organization.setCategoryType("root");
|
||||
organization.setStatus(1);
|
||||
organization.setCreateTime(LocalDateTime.now());
|
||||
organizationMapper.insert(organization);
|
||||
return organization;
|
||||
}
|
||||
|
||||
public List<Organization> queryOrganization(String type){
|
||||
// 查询所有的组织名及id
|
||||
switch (type){
|
||||
case "Enterprise":
|
||||
case "Education":
|
||||
return organizationMapper.selectList(new QueryWrapper<Organization>().eq("type", type).eq("category_type", "root"));
|
||||
default:
|
||||
public IPage<Organization> queryOrganization(QueryOrganizationPageDTO queryDTO) {
|
||||
QueryWrapper<Organization> queryWrapper = new QueryWrapper<>();
|
||||
// 按时间区间查
|
||||
if (!StringUtils.isNullOrEmpty(queryDTO.getStartTime())) {
|
||||
queryWrapper.lambda().gt(Organization::getCreateTime, queryDTO.getStartTime());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryDTO.getEndTime())) {
|
||||
queryWrapper.lambda().lt(Organization::getCreateTime, queryDTO.getEndTime());
|
||||
}
|
||||
if (Objects.nonNull(queryDTO.getId())){
|
||||
queryWrapper.lambda().eq(Organization::getId, queryDTO.getId());
|
||||
}
|
||||
// 按类型查
|
||||
if (!StringUtil.isNullOrEmpty(queryDTO.getType())){
|
||||
if (!queryDTO.getType().equals("Enterprise") && !queryDTO.getType().equals("Education")) {
|
||||
throw new BusinessException("Unknown type");
|
||||
}
|
||||
queryWrapper.lambda().eq(Organization::getType, queryDTO.getType());
|
||||
}
|
||||
// 按机构名查
|
||||
if (!StringUtil.isNullOrEmpty(queryDTO.getName())){
|
||||
queryWrapper.lambda().like(Organization::getName, queryDTO.getName());
|
||||
}
|
||||
|
||||
return organizationMapper.selectPage(new Page<>(queryDTO.getPage(), queryDTO.getSize()), queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1052,6 +1052,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
Library library = new Library();
|
||||
library.setAccountId(UserContext.getUserHolder().getId());
|
||||
library.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
library.setLevel2Type(print.getLevel2Type());
|
||||
library.setUrl(print.getMinIOPath());
|
||||
library.setName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
|
||||
library.setMd5(md5);
|
||||
|
||||
Reference in New Issue
Block a user