Merge branch 'develop' into dev/dev

This commit is contained in:
shahaibo
2024-01-15 15:25:08 +08:00
16 changed files with 226 additions and 18 deletions

View File

@@ -1,10 +1,10 @@
version: "3" version: "3"
services: services:
aida_back: aida_back:
container_name: develop-version-aida-back container_name: stable-version-aida-back
build: . build: .
volumes: volumes:
# 数据挂载 # 数据挂载
- /workspace/home/aida/file/:/workspace/home/aida/file/ - /workspace/home/aida/file/:/workspace/home/aida/file/
ports: ports:
- "10090:5567" - "10086:5567"

View File

@@ -76,6 +76,12 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>

View File

@@ -41,10 +41,11 @@ public class AuthenticationFilter extends OncePerRequestFilter {
private SecurityProperties properties; private SecurityProperties properties;
private static final List<String> FILTER_URL = private static final List<String> FILTER_URL =
Arrays.asList("/favicon.ico", "/doc.html", "api/account/login", "api/account/preLogin", "api/account/sendEmail", Arrays.asList("/favicon.ico", "/doc.html", "api/account/login", "api/account/preLogin", "api/account/sendEmail","api/account/noLoginRequired",
"/webjars/", "/swagger-resources", "/v2/api-docs", "api/account/resetPwd", "/webjars/", "/swagger-resources", "/v2/api-docs", "api/account/resetPwd",
"/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId", "/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId",
"/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile", "/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile",
"/api/third/party/addNoLoginRequired","/api/third/party/deleteNoLoginRequired",
"/api/python/chatStream", "/api/python/chatStream",
"/api/python/flush", "/api/python/flush",
"/api/account/healthy" "/api/account/healthy"
@@ -110,12 +111,12 @@ public class AuthenticationFilter extends OncePerRequestFilter {
//校验token //校验token
String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId())); String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId()));
// if(StringUtils.isEmpty(cacheToken)){ if(StringUtils.isEmpty(cacheToken)){
// throw new RuntimeException("TOKEN已过期请重新登录"); throw new RuntimeException("TOKEN已过期请重新登录");
// } }
// if(!cacheToken.equals(jwtToken) ){ if(!cacheToken.equals(jwtToken) ){
// throw new RuntimeException("TOKEN已过期请重新登录"); throw new RuntimeException("TOKEN已过期请重新登录");
// } }
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(null, null); // UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(null, null);
// SecurityContextHolder.getContext().setAuthentication(authentication); // SecurityContextHolder.getContext().setAuthentication(authentication);
} }

View File

@@ -143,4 +143,10 @@ public class AccountController {
public Response<Long> getExpiredTime(){ public Response<Long> getExpiredTime(){
return Response.success(accountService.getExpiredTime()); return Response.success(accountService.getExpiredTime());
} }
@ApiOperation(value = "查询账号到期时间")
@PostMapping("/noLoginRequired")
public Response<AccountLoginVO> noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO){
return Response.success(accountService.noLoginRequired(noLoginRequiredDTO));
}
} }

View File

@@ -42,4 +42,17 @@ public class ThirdPartyController {
return Response.success(accountService.addTrialUser(accountTrialDTO)); return Response.success(accountService.addTrialUser(accountTrialDTO));
} }
@CrossOrigin
@ApiOperation(value = "add No Login Required")
@PostMapping("/addNoLoginRequired")
public Response<Boolean> addNoLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO) {
return Response.success(accountService.addNoLoginRequired(noLoginRequiredDTO));
}
@CrossOrigin
@ApiOperation(value = "add No Login Required")
@PostMapping("/deleteNoLoginRequired")
public Response<Boolean> deleteNoLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO) {
return Response.success(accountService.deleteNoLoginRequired(noLoginRequiredDTO));
}
} }

View File

@@ -78,4 +78,6 @@ public class Account implements Serializable {
private Integer isTrial; private Integer isTrial;
private Integer isBeginner; private Integer isBeginner;
private String browserIdentifiers;
} }

View File

@@ -29,4 +29,15 @@ public class DesignSingleIncludeLayersDTO {
@NotBlank(message = "timeZone.cannot.be.empty") @NotBlank(message = "timeZone.cannot.be.empty")
@ApiModelProperty("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取") @ApiModelProperty("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
private String timeZone; private String timeZone;
@Override
public String toString() {
return "DesignSingleIncludeLayersDTO{" +
"designItemId=" + designItemId +
", designSingleItemDTOList=" + designSingleItemDTOList +
", isPreview=" + isPreview +
", processId='" + processId + '\'' +
", timeZone='" + timeZone + '\'' +
'}';
}
} }

View File

@@ -0,0 +1,8 @@
package com.ai.da.model.dto;
import lombok.Data;
@Data
public class NoLoginRequiredDTO {
private String browserIdentifiers;
}

View File

@@ -1208,20 +1208,22 @@ public class PythonService {
//如果包含Pin只传一个 //如果包含Pin只传一个
if (isPin) { if (isPin) {
List<CollectionElement> finalPinData = pinData; List<CollectionElement> finalPinData = pinData;
DesignPythonItem.OUTWEAR_DRESS_BLOUSE.forEach(type -> { for (String type : DesignPythonItem.OUTWEAR_DRESS_BLOUSE) {
//剩余的的PinData // 剩余的的 PinData
List<CollectionElement> residueInnerPinData = residuePinData(finalPinData, existPinDataIds, elementVO.getHasUseMd5List()); List<CollectionElement> residueInnerPinData = residuePinData(finalPinData, existPinDataIds, elementVO.getHasUseMd5List());
CollectionElement elementNew = residueInnerPinData.stream() CollectionElement elementNew = residueInnerPinData.stream()
.filter(element -> element.getLevel2Type().equals(type)).findFirst().orElse(null); .filter(element -> element.getLevel2Type().equals(type)).findFirst().orElse(null);
if (Objects.nonNull(elementNew)) { if (Objects.nonNull(elementNew)) {
items.add(coverToDesignPythonItem(elementNew.getId(), type, elementNew.getUrl(), elementVO)); items.add(coverToDesignPythonItem(elementNew.getId(), type, elementNew.getUrl(), elementVO));
//去重用 // 去重用
existPinDataIds.add(elementNew.getId()); existPinDataIds.add(elementNew.getId());
//添加md5 // 添加md5
elementVO.getHasUseMd5List().add(elementNew.getMd5()); elementVO.getHasUseMd5List().add(elementNew.getMd5());
// 提前结束循环
break;
}
} }
});
} }
} }

View File

@@ -115,4 +115,10 @@ public interface AccountService extends IService<Account> {
Boolean trialOrderRefuse(List<Long> ids); Boolean trialOrderRefuse(List<Long> ids);
Long getExpiredTime(); Long getExpiredTime();
Boolean addNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO);
Boolean deleteNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO);
AccountLoginVO noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO);
} }

View File

@@ -32,6 +32,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@@ -566,4 +567,59 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
AuthPrincipalVo userInfo = UserContext.getUserHolder(); AuthPrincipalVo userInfo = UserContext.getUserHolder();
return accountMapper.selectById(userInfo.getId()).getValidEndTime(); return accountMapper.selectById(userInfo.getId()).getValidEndTime();
} }
@Override
public Boolean addNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) {
QueryWrapper<Account> qw = new QueryWrapper<>();
qw.lambda().isNotNull(Account::getBrowserIdentifiers);
qw.lambda().like(Account::getUserName, "PolyU-SFT-");
List<Account> accountList = accountMapper.selectList(qw);
if (accountList.size() >= 100) {
throw new BusinessException("The number of registered accounts exceeds the limit");
}
qw.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers());
if (!accountMapper.selectList(qw).isEmpty()) {
throw new BusinessException("This browser has already been registered");
}
Account account = new Account();
account.setUserName("PolyU-SFT-" + String.format("%03d", accountList.size() + 1));
account.setUserPassword("Third-000000");
account.setValidStartTime(System.currentTimeMillis());
account.setValidEndTime(System.currentTimeMillis() + 365L * 24 * 60 * 60 * 1000);
account.setCreateDate(new Date());
account.setIsBeginner(1);
account.setIsTrial(0);
account.setBrowserIdentifiers(noLoginRequiredDTO.getBrowserIdentifiers());
accountMapper.insert(account);
return Boolean.TRUE;
}
@Override
public Boolean deleteNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) {
QueryWrapper<Account> qw = new QueryWrapper<>();
qw.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers());
accountMapper.delete(qw);
return Boolean.TRUE;
}
@Override
public AccountLoginVO noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) {
QueryWrapper<Account> qw = new QueryWrapper<>();
qw.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers());
List<Account> accountList = accountMapper.selectList(qw);
if (CollectionUtil.isEmpty(accountList)) {
throw new BusinessException("This browser is not registered as login free");
}
Account account = accountList.get(0);
AccountLoginVO response = CopyUtil.copyObject(account, AccountLoginVO.class);
String token = LocalCacheUtils.getTokenCache(String.valueOf(account.getId()));
if (StringUtils.isNotBlank(token)) {
//用户已登入
response.setToken(token);
} else {
response.setToken(createAccountToken(account));
}
response.setUserId(account.getId());
return response;
}
} }

View File

@@ -79,6 +79,10 @@ public class ChatRobotServiceImpl implements ChatRobotService {
private final ExecutorService executorService = Executors.newSingleThreadExecutor(); private final ExecutorService executorService = Executors.newSingleThreadExecutor();
Integer timeout = 99999999; Integer timeout = 99999999;
@Value("${access.python.ip:''}")
private String accessPythonIp;
@Value("${access.python.port:''}")
private String accessPythonPort;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ChatRobotVO sendMessageToChatRobot(ChatSendDTO chatSendDTO) { public ChatRobotVO sendMessageToChatRobot(ChatSendDTO chatSendDTO) {
@@ -142,7 +146,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
RequestBody body = RequestBody.create(mediaType, param); RequestBody body = RequestBody.create(mediaType, param);
Request request = new Request.Builder() Request request = new Request.Builder()
// .url("http://127.0.0.1:5000/api/chat_stream_test") // .url("http://127.0.0.1:5000/api/chat_stream_test")
.url("http://18.167.251.121:9991/api/chat_stream_test") .url(accessPythonIp + ":" + accessPythonPort + "/api/chat_stream_test")
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate") // .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
.method("POST", body) .method("POST", body)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")

View File

@@ -413,6 +413,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) { public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
log.info("designSingle request入参 ==> " + designSingleIncludeLayersDTO.toString());
AuthPrincipalVo userInfo = UserContext.getUserHolder(); AuthPrincipalVo userInfo = UserContext.getUserHolder();
DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId()); DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId());
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {

View File

@@ -77,6 +77,11 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
@Value("${minio.bucketName.sysImage}") @Value("${minio.bucketName.sysImage}")
private String sysImage; private String sysImage;
@Value("${access.python.ip:''}")
private String accessPythonIp;
@Value("${access.python.port:''}")
private String accessPythonPort;
@Resource @Resource
private PythonTAllInfoService pythonTAllInfoService; private PythonTAllInfoService pythonTAllInfoService;
@@ -292,7 +297,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
log.info("processMannequins请求python 参数:####{}", param); log.info("processMannequins请求python 参数:####{}", param);
RequestBody body = RequestBody.create(mediaType, param); RequestBody body = RequestBody.create(mediaType, param);
Request request = new Request.Builder() Request request = new Request.Builder()
.url("http://18.167.251.121:9991/api/model_process") .url(accessPythonIp + ":" + accessPythonPort + "/api/model_process")
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate") // .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
.method("POST", body) .method("POST", body)
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==") // .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
@@ -349,7 +354,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
log.info("processSketchBoards请求python 参数:####{}", param); log.info("processSketchBoards请求python 参数:####{}", param);
RequestBody body = RequestBody.create(mediaType, param); RequestBody body = RequestBody.create(mediaType, param);
Request request = new Request.Builder() Request request = new Request.Builder()
.url("http://18.167.251.121:9991/api/sketches_bounding_box") .url(accessPythonIp + ":" + accessPythonPort + "/api/sketches_bounding_box")
.method("POST", body) .method("POST", body)
// .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==") // .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")

View File

@@ -50,7 +50,8 @@ spring.servlet.multipart.max-request-size= 5MB
#access.python.ip=http://43.198.80.117 #access.python.ip=http://43.198.80.117
access.python.ip=http://18.167.251.121 access.python.ip=http://18.167.251.121
#access.python.ip=http://18.167.251.121:9991/ #access.python.ip=http://18.167.251.121:9991/
access.python.port=9992 #access.python.port=9992
access.python.port=9990
# minIO服务配置之信息 # minIO服务配置之信息
minio.endpoint=https://www.minio.aida.com.hk:9000 minio.endpoint=https://www.minio.aida.com.hk:9000

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!-- 日志存放路径 -->
<property name="log.path" value="./log" />
<!-- 日志输出格式 -->
<!--value为输出格式设置用正则表达式格式化 d:时间 -->
<!--<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %-5level %logger{36} - [%method,%line] - %msg%n" />-->
<property name="log.pattern.console" value="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
<property name="log.pattern.file" value="${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%15t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern.console}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<!--动态的创建一个文件,将日志写入到新的文件中-->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/aida-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/aida-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<!--encoder 将事件转换为格式化后的日志记录,在文件中输出-->
<encoder>
<pattern>${log.pattern.file}</pattern>
</encoder>
<!--LevelFilter过滤器对指定level的日志进行记录或不记录
对不等于指定level的日志不记录或记录-->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 只会打印debug不会有info日志-->
<!-- <level>DEBUG</level>-->
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/aida-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/aida-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern.file}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ai.da" level="debug" />
<logger name="com.ai.da.mapper" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>