|
|
@@ -17,7 +17,10 @@ import com.cyksj.model.entity.MidjourneyUser;
|
|
|
import com.cyksj.model.entity.MidjourneyUserConversation;
|
|
|
import com.cyksj.model.response.SubmitResult;
|
|
|
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;
|
|
|
@@ -30,7 +33,6 @@ 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;
|
|
|
@@ -387,44 +389,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);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -443,12 +414,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()
|