|
@@ -1,14 +1,22 @@
|
|
|
package com.cyksj.web.controller.mirror;
|
|
package com.cyksj.web.controller.mirror;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
-import com.cyksj.model.dto.*;
|
|
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
|
|
+import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
|
|
+import com.cyksj.mapper.MidjourneyPaintingPlazaMapper;
|
|
|
import com.cyksj.mapper.MidjourneyUserMapper;
|
|
import com.cyksj.mapper.MidjourneyUserMapper;
|
|
|
|
|
+import com.cyksj.model.dto.*;
|
|
|
|
|
+import com.cyksj.model.entity.GroupsRelation;
|
|
|
|
|
+import com.cyksj.model.entity.MidjourneyPaintingPlaza;
|
|
|
import com.cyksj.model.entity.MidjourneyUser;
|
|
import com.cyksj.model.entity.MidjourneyUser;
|
|
|
import com.cyksj.model.entity.MidjourneyUserConversation;
|
|
import com.cyksj.model.entity.MidjourneyUserConversation;
|
|
|
|
|
+import com.cyksj.model.views.MidjourneyPaintingUserView;
|
|
|
|
|
+import com.cyksj.model.views.MidjourneyUserPaintingDayRecordView;
|
|
|
|
|
+import com.cyksj.model.views.MidjourneyUserPaintingRecordView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.midjourney.MidjourneyService;
|
|
import com.cyksj.service.midjourney.MidjourneyService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
@@ -23,7 +31,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
|
|
+/** server/镜像服务/mj绘画
|
|
|
* @author zwhui
|
|
* @author zwhui
|
|
|
* @date 2024/4/23 10:31
|
|
* @date 2024/4/23 10:31
|
|
|
*/
|
|
*/
|
|
@@ -43,6 +51,9 @@ public class MidjourneyController {
|
|
|
|
|
|
|
|
private final RedisService redisService;
|
|
private final RedisService redisService;
|
|
|
|
|
|
|
|
|
|
+ private final GroupsRelationMapper groupsRelationMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final MidjourneyPaintingPlazaMapper midjourneyPaintingPlazaMapper;
|
|
|
public MidjourneyUser getUser(){
|
|
public MidjourneyUser getUser(){
|
|
|
String userToken = request.getHeader("user-token");
|
|
String userToken = request.getHeader("user-token");
|
|
|
MidjourneyUser midjourneyUser = (MidjourneyUser) redisService.get(RedisService.key.MIDJOURNEY_USER.getName() + userToken);
|
|
MidjourneyUser midjourneyUser = (MidjourneyUser) redisService.get(RedisService.key.MIDJOURNEY_USER.getName() + userToken);
|
|
@@ -52,6 +63,9 @@ public class MidjourneyController {
|
|
|
if (midjourneyUser == null){
|
|
if (midjourneyUser == null){
|
|
|
throw new BusinessRuntimeException("账号不存在,请重新登录");
|
|
throw new BusinessRuntimeException("账号不存在,请重新登录");
|
|
|
}
|
|
}
|
|
|
|
|
+ Long relationId = midjourneyUser.getRelationId();
|
|
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
|
|
+ midjourneyUser.setAqType(relation.getAqType());
|
|
|
redisService.set(RedisService.key.MIDJOURNEY_USER.getName() + userToken, midjourneyUser, RedisService.key.MIDJOURNEY_USER.getTimeout());
|
|
redisService.set(RedisService.key.MIDJOURNEY_USER.getName() + userToken, midjourneyUser, RedisService.key.MIDJOURNEY_USER.getTimeout());
|
|
|
Object fastNum = redisService.get(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + midjourneyUser.getId());
|
|
Object fastNum = redisService.get(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + midjourneyUser.getId());
|
|
|
if (fastNum == null){
|
|
if (fastNum == null){
|
|
@@ -338,4 +352,58 @@ public class MidjourneyController {
|
|
|
redisService.del(RedisService.key.MIDJOURNEY_USER.getName() + midjourneyUser.getUserToken());
|
|
redisService.del(RedisService.key.MIDJOURNEY_USER.getName() + midjourneyUser.getUserToken());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * mj绘画广场
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/painting")
|
|
|
|
|
+ public Result<SearchResult<MidjourneyPaintingUserView>> getPaintingCollect() {
|
|
|
|
|
+ SearchResult<MidjourneyPaintingUserView> search = beanSearcher.search(MidjourneyPaintingUserView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 复制mj绘画广场 提示词
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/painting/copy/{id}")
|
|
|
|
|
+ public Result<String> resetPaintingCopyNum(@PathVariable Long id) {
|
|
|
|
|
+ MidjourneyPaintingPlaza midjourneyPaintingPlaza = midjourneyPaintingPlazaMapper.selectById(id);
|
|
|
|
|
+ if (midjourneyPaintingPlaza != null) {
|
|
|
|
|
+ midjourneyPaintingPlazaMapper.updatePaintingCopyNum(id);
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户绘画记录
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/painting/record")
|
|
|
|
|
+ public Result<SearchResult<MidjourneyUserPaintingDayRecordView>> getPaintingRecord(String prompt, Boolean bookmark) {
|
|
|
|
|
+ MidjourneyUser user = getUser();
|
|
|
|
|
+ String condition = String.format(" and mc.user_id = %s", user.getId());
|
|
|
|
|
+ if (StrUtil.isNotBlank(prompt)) {
|
|
|
|
|
+ condition += String.format(" and mc.prompt like '%%%s%%'", prompt);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (bookmark != null) {
|
|
|
|
|
+ condition += String.format(" and mc.bookmark is %s", bookmark);
|
|
|
|
|
+ }
|
|
|
|
|
+ SearchResult<MidjourneyUserPaintingDayRecordView> search = beanSearcher.search(MidjourneyUserPaintingDayRecordView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .put("condition", condition)
|
|
|
|
|
+ .orderBy(MidjourneyUserPaintingRecordView::getCreatedTime).desc()
|
|
|
|
|
+ .build());
|
|
|
|
|
+ String dateSql;
|
|
|
|
|
+ for (MidjourneyUserPaintingDayRecordView e : search.getDataList()) {
|
|
|
|
|
+ String date = e.getDate();
|
|
|
|
|
+ dateSql = String.format(" and DATE_FORMAT(mc.created_time,'%%Y-%%m-%%d') = '%s'", date);
|
|
|
|
|
+ List<MidjourneyUserPaintingRecordView> list = beanSearcher.searchAll(MidjourneyUserPaintingRecordView.class, MapUtils.builder()
|
|
|
|
|
+ .put("condition", condition)
|
|
|
|
|
+ .put("date", dateSql)
|
|
|
|
|
+ .orderBy(MidjourneyUserPaintingRecordView::getCreatedTime).desc()
|
|
|
|
|
+ .build());
|
|
|
|
|
+ e.setList(list);
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|