Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ai.da.service;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Organization;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.*;
|
||||
@@ -58,4 +59,8 @@ public interface ConvenientInquiryService extends IService<Questionnaire> {
|
||||
PageBaseResponse<AccountCreditsUsageDTO> getGenerateFrequency(AccountCreditsUsageQueryDTO queryDTO);
|
||||
|
||||
List<String> getAllGenerateFuncName();
|
||||
|
||||
void addOrganization(String name, String type);
|
||||
|
||||
List<Organization> queryOrganization(String type);
|
||||
}
|
||||
|
||||
@@ -90,4 +90,12 @@ public interface LibraryService extends IService<Library> {
|
||||
void moveLibraryDate() throws ParseException;
|
||||
|
||||
Map<String, String> addSysModelToLib(long sysModelId);
|
||||
|
||||
boolean saveToOrganizationLibrary(Long libraryId);
|
||||
|
||||
void deleteFromPublicLib(Long libraryId);
|
||||
|
||||
PageBaseResponse<Library> getPublicLib(String order, long page, long size);
|
||||
|
||||
PageBaseResponse<Library> getAllSubAccLib(String order, long page, long size);
|
||||
}
|
||||
|
||||
@@ -62,4 +62,6 @@ public interface PortfolioService extends IService<Portfolio> {
|
||||
List<Long> getFolloweeList(Long accountId);
|
||||
|
||||
// List<PortfolioVO> queryPortfolioByTag(String tagName, Long tagId);
|
||||
|
||||
void setPortfolioToPublic(Long portfolioId);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Organization;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.*;
|
||||
@@ -160,11 +161,11 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
role = "prsn";
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("Sorry, you don't have permission", ResultEnum.PROMPT.getCode());
|
||||
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
return designMapper.getDesignStatistic(startTime, endTime, ids, email, role);
|
||||
} else {
|
||||
throw new BusinessException("Sorry, you don't have permission", ResultEnum.PROMPT.getCode());
|
||||
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +877,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
role = "prsn";
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("Sorry, you don't have permission");
|
||||
throw new BusinessException("have.no.permission");
|
||||
}
|
||||
Integer size = queryDTO.getSize();
|
||||
int offset = (queryDTO.getPage() - 1) * size;
|
||||
@@ -901,7 +902,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
return new PageBaseResponse<>();
|
||||
}
|
||||
}else {
|
||||
throw new BusinessException("Sorry, you don't have permission");
|
||||
throw new BusinessException("have.no.permission");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,4 +910,26 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
return CreditsEventsEnum.generateFunctionNames();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
public void addOrganization(String name, String type){
|
||||
Organization organization = new Organization();
|
||||
organization.setName(name);
|
||||
organization.setType(type);
|
||||
organization.setCategoryType("root");
|
||||
organization.setCreateTime(LocalDateTime.now());
|
||||
organizationMapper.insert(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:
|
||||
throw new BusinessException("Unknown type");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import java.nio.file.Files;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -80,6 +81,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
private GenerateService generateService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
@Resource
|
||||
private EductionLibraryMapper eductionLibraryMapper;
|
||||
@Resource
|
||||
private EnterpriseLibraryMapper enterpriseLibraryMapper;
|
||||
|
||||
@Value("${minio.bucketName.users}")
|
||||
private String users;
|
||||
@@ -879,4 +886,109 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
resp.put("url", minioUtil.getPreSignedUrl(library.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
return resp;
|
||||
}
|
||||
|
||||
public boolean saveToOrganizationLibrary(Long libraryId){
|
||||
// 1、判断该用户是否属于某个组织
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Account account = accountMapper.selectById(accountId);
|
||||
if (Objects.nonNull(account.getOrganizationId())){
|
||||
// 2、添加元素信息到对应的住址表里
|
||||
switch(account.getSystemUser()){
|
||||
case 5:
|
||||
case 6:
|
||||
EnterpriseLibrary enterpriseLibrary = enterpriseLibraryMapper.selectOne(new QueryWrapper<EnterpriseLibrary>().eq("library_id", libraryId));
|
||||
if (Objects.nonNull(enterpriseLibrary)){
|
||||
throw new BusinessException("element.already.exists");
|
||||
}
|
||||
// 存储到企业表
|
||||
enterpriseLibrary = new EnterpriseLibrary();
|
||||
enterpriseLibrary.setEnterpriseId(account.getOrganizationId());
|
||||
enterpriseLibrary.setLibraryId(libraryId);
|
||||
enterpriseLibrary.setCreateTime(LocalDateTime.now());
|
||||
enterpriseLibraryMapper.insert(enterpriseLibrary);
|
||||
log.info("企业用户添加元素到公共库");
|
||||
return true;
|
||||
case 7:
|
||||
case 8:
|
||||
EducationLibrary educationLibrary = eductionLibraryMapper.selectOne(new QueryWrapper<EducationLibrary>().eq("library_id", libraryId));
|
||||
if (Objects.nonNull(educationLibrary)){
|
||||
throw new BusinessException("element.already.exists");
|
||||
}
|
||||
// 存储到教育表
|
||||
educationLibrary = new EducationLibrary();
|
||||
educationLibrary.setEducationId(account.getOrganizationId());
|
||||
educationLibrary.setLibraryId(libraryId);
|
||||
educationLibrary.setCreateTime(LocalDateTime.now());
|
||||
eductionLibraryMapper.insert(educationLibrary);
|
||||
log.info("教育版用户添加元素到公共库");
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 删除公共库中的元素
|
||||
public void deleteFromPublicLib(Long libraryId){
|
||||
// 谁有权限删除公共库里的东西?1、元素所有者 2、管理员
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Account account = accountMapper.selectById(accountId);
|
||||
Library library = libraryMapper.selectById(libraryId);
|
||||
|
||||
if (account.getSystemUser().equals(5)
|
||||
|| account.getSystemUser().equals(7)
|
||||
|| library.getAccountId().equals(accountId)){
|
||||
switch (account.getSystemUser()){
|
||||
case 5:
|
||||
case 6:
|
||||
enterpriseLibraryMapper.delete(new QueryWrapper<EnterpriseLibrary>().eq("library_id", libraryId));
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
eductionLibraryMapper.delete(new QueryWrapper<EducationLibrary>().eq("library_id", libraryId));
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 查询企业或教育的公共库
|
||||
public PageBaseResponse<Library> getPublicLib(String order, long page, long size){
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Account account = accountMapper.selectById(accountId);
|
||||
if (Objects.isNull(account.getOrganizationId())){
|
||||
throw new BusinessException("未查询到您的组织信息,无法获取公共库的元素", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
Long organizationId = account.getOrganizationId();
|
||||
long offset = (page - 1) * size;
|
||||
List<Library> libraries = libraryMapper.selectCommonLib(organizationId, order, size, offset);
|
||||
Long count = libraryMapper.selectCommonLibCount(organizationId);
|
||||
long pages = (long) Math.ceil(count / size);
|
||||
return new PageBaseResponse<>(libraries, page, size, count, pages == 0 ? 1 : pages);
|
||||
}
|
||||
|
||||
// 管理员查所有子账号的library
|
||||
public PageBaseResponse<Library> getAllSubAccLib(String order, long page, long size){
|
||||
// 1、判断当前账号是不是管理员
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Account account = accountMapper.selectById(accountId);
|
||||
long offset = (page - 1) * size;
|
||||
switch(account.getSystemUser()){
|
||||
case 5:
|
||||
case 7:
|
||||
if (Objects.isNull(account.getOrganizationId())){
|
||||
throw new BusinessException("未查询到您的组织信息,无法获取元素", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
List<Library> libraries = libraryMapper.selectAllSubAccLib(account.getOrganizationId(), order, size, offset);
|
||||
Long count = libraryMapper.selectAllSubAccLibCount(account.getOrganizationId());
|
||||
long pages = (long) Math.ceil(count / size);
|
||||
return new PageBaseResponse<>(libraries, page, size, count, pages == 0 ? 1 : pages);
|
||||
default:
|
||||
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -184,6 +184,12 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
portfolio.setIsDeleted(0);
|
||||
portfolio.setCanvasId(canvas.getId());
|
||||
portfolio.setPortfolioDes(portfolioDTO.getPortfolioDes());
|
||||
if (Objects.isNull(portfolioDTO.getIsPublic())){
|
||||
portfolio.setIsPublic(0);
|
||||
}else {
|
||||
portfolio.setIsPublic(portfolioDTO.getIsPublic());
|
||||
}
|
||||
portfolio.setOrganizationId(accountMapper.selectById(authPrincipalVo.getId()).getOrganizationId());
|
||||
|
||||
if (portfolioDTO.getOpenSource() == 1) {
|
||||
// 副本存储对象
|
||||
@@ -430,6 +436,12 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
return queryPortfolioByTag(null, query.getTagId(), query.getPage(), query.getSize());
|
||||
}
|
||||
|
||||
if (Objects.nonNull(query.getOrganizationId())){
|
||||
qw.eq("organization_id", query.getOrganizationId());
|
||||
}else {
|
||||
qw.isNull("is_public").or().eq("is_public", 1);
|
||||
}
|
||||
|
||||
/*List<Portfolio> topThree = new ArrayList<>();
|
||||
List<Long> excludeIds = new ArrayList<>(); // 存放需要排除的 ID 列表
|
||||
// 获取前三点赞和前三浏览的作品集,并将其排除在分页查询之外
|
||||
@@ -1184,4 +1196,24 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
return userFollows.stream().map(UserFollow::getFolloweeId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void setPortfolioToPublic(Long portfolioId){
|
||||
// 判断当前用户与作品用户是不是一家公司的
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Account currentAccount = accountMapper.selectById(accountId);
|
||||
Portfolio portfolio = baseMapper.selectById(portfolioId);
|
||||
|
||||
if (Objects.isNull(portfolio)){
|
||||
throw new BusinessException("unknown portfolio");
|
||||
}
|
||||
if (Objects.nonNull(portfolio.getOrganizationId())
|
||||
&& Objects.nonNull(currentAccount.getOrganizationId())
|
||||
&& portfolio.getOrganizationId().equals(currentAccount.getOrganizationId())){
|
||||
portfolio.setIsPublic(1);
|
||||
portfolio.setUpdateDate(LocalDateTime.now());
|
||||
baseMapper.updateById(portfolio);
|
||||
}else {
|
||||
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user