|
|
@@ -3,7 +3,6 @@ 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.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
@@ -12,7 +11,10 @@ import com.cyksj.mapper.MidjourneyPaintingCollectRecordMapper;
|
|
|
import com.cyksj.mapper.MidjourneyPaintingPlazaMapper;
|
|
|
import com.cyksj.mapper.MidjourneyUserMapper;
|
|
|
import com.cyksj.model.dto.*;
|
|
|
-import com.cyksj.model.entity.*;
|
|
|
+import com.cyksj.model.entity.GroupsRelation;
|
|
|
+import com.cyksj.model.entity.MidjourneyPaintingPlaza;
|
|
|
+import com.cyksj.model.entity.MidjourneyUser;
|
|
|
+import com.cyksj.model.entity.MidjourneyUserConversation;
|
|
|
import com.cyksj.model.views.MidjourneyPaintingUserView;
|
|
|
import com.cyksj.model.views.MidjourneyUserPaintingDayRecordView;
|
|
|
import com.cyksj.model.views.MidjourneyUserPaintingRecordView;
|
|
|
@@ -25,13 +27,11 @@ import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
/** server/镜像服务/mj绘画
|
|
|
* @author zwhui
|
|
|
@@ -362,44 +362,13 @@ public class MidjourneyController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * mj绘画广场 我的收藏
|
|
|
+ * mj绘画广场
|
|
|
*/
|
|
|
@GetMapping("/get/painting")
|
|
|
- public Result<Page<MidjourneyPaintingUserView>> getPaintingCollect(@RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "10") Integer limit, Boolean collect) {
|
|
|
- if (limit > 20) {
|
|
|
- limit = 20;
|
|
|
- }
|
|
|
- MidjourneyUser user = getUser();
|
|
|
- Page<MidjourneyPaintingUserView> page = midjourneyPaintingPlazaMapper.getPaintingList(new Page<>(start, limit), collect, user.getId());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(page);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改 mj绘画广场 收藏状态
|
|
|
- */
|
|
|
- @PutMapping("/collect/painting/{id}")
|
|
|
- public Result<SearchResult<MidjourneyPaintingUserView>> collectPainting(@PathVariable Long id) {
|
|
|
- MidjourneyUser user = getUser();
|
|
|
- MidjourneyPaintingPlaza midjourneyPaintingPlaza = midjourneyPaintingPlazaMapper.selectById(id);
|
|
|
- if (midjourneyPaintingPlaza == null || !midjourneyPaintingPlaza.getDeleted()) {
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
- MidjourneyPaintingCollectRecord record = Optional.ofNullable(midjourneyPaintingCollectRecordMapper.selectOne(Wrappers.lambdaQuery(MidjourneyPaintingCollectRecord.class)
|
|
|
- .eq(MidjourneyPaintingCollectRecord::getPlazaId, id)
|
|
|
- .eq(MidjourneyPaintingCollectRecord::getUserId, user.getId()).last("limit 1"))).orElse(new MidjourneyPaintingCollectRecord());
|
|
|
- if (record.getId() == null) {
|
|
|
- try {
|
|
|
- record.setStatus(true);
|
|
|
- record.setUserId(user.getId());
|
|
|
- record.setPlazaId(id);
|
|
|
- midjourneyPaintingCollectRecordMapper.insert(record);
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
- }
|
|
|
- } else {
|
|
|
- record.setStatus(!record.getStatus());
|
|
|
- midjourneyPaintingCollectRecordMapper.updateById(record);
|
|
|
- }
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ public Result<SearchResult<MidjourneyPaintingUserView>> getPaintingCollect() {
|
|
|
+ SearchResult<MidjourneyPaintingUserView> search = beanSearcher.search(MidjourneyPaintingUserView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -418,12 +387,15 @@ public class MidjourneyController {
|
|
|
* 用户绘画记录
|
|
|
*/
|
|
|
@GetMapping("/get/painting/record")
|
|
|
- public Result<SearchResult<MidjourneyUserPaintingDayRecordView>> getPaintingRecord(String prompt) {
|
|
|
+ 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 = '%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()
|