From 5e814f6fb886255134c4b513eba698ad931ad14e Mon Sep 17 00:00:00 2001 From: Penny <2500338766@qq.com> Date: Sun, 9 Apr 2023 02:17:59 +0800 Subject: [PATCH] =?UTF-8?q?feature-img-1.0:=E6=96=B0=E5=A2=9EAI=E7=BB=98?= =?UTF-8?q?=E5=9B=BE=E7=9B=B8=E5=85=B3=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnyer/common/core/domain/PaintStyle.java | 58 +++++++++++++ .../com/bnyer/common/core/domain/Prompt.java | 44 ++++++++++ .../bnyer/common/core/dto/PaintStyleDto.java | 41 +++++++++ .../common/core/dto/PaintStylePageDto.java | 22 +++++ .../com/bnyer/common/core/dto/PromptDto.java | 32 +++++++ .../bnyer/common/core/dto/PromptPageDto.java | 22 +++++ .../img/config/RestTemplateConfiguration.java | 2 +- .../img/controller/FhMiniController.java | 18 ++++ .../img/controller/TiktokMiniController.java | 27 ++++++ .../img/controller/WxMiniController.java | 18 ++++ .../bnyer/img/mapper/PaintStyleMapper.java | 18 ++++ .../com/bnyer/img/mapper/PromptMapper.java | 18 ++++ .../bnyer/img/service/PaintStyleService.java | 14 +++ .../com/bnyer/img/service/PromptService.java | 14 +++ .../service/impl/PaintStyleServiceImpl.java | 23 +++++ .../img/service/impl/PromptServiceimpl.java | 40 +++++++++ .../java/com/bnyer/img/vo/PaintStyleVo.java | 31 +++++++ .../main/java/com/bnyer/img/vo/PromptVo.java | 26 ++++++ .../com/bnyer/img/mapper/PaintStyleMapper.xml | 28 ++++++ .../com/bnyer/img/mapper/PromptMapper.xml | 27 ++++++ .../controller/PaintStyleController.java | 87 +++++++++++++++++++ .../system/controller/PromptController.java | 79 +++++++++++++++++ .../bnyer/system/mapper/PaintStyleMapper.java | 11 +++ .../com/bnyer/system/mapper/PromptMapper.java | 11 +++ .../system/service/IPaintStyleService.java | 60 +++++++++++++ .../bnyer/system/service/IPromptService.java | 52 +++++++++++ .../service/impl/PaintStyleServiceImpl.java | 85 ++++++++++++++++++ .../service/impl/PromptServiceImpl.java | 76 ++++++++++++++++ 28 files changed, 983 insertions(+), 1 deletion(-) create mode 100644 bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/PaintStyle.java create mode 100644 bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/Prompt.java create mode 100644 bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStyleDto.java create mode 100644 bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStylePageDto.java create mode 100644 bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptDto.java create mode 100644 bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptPageDto.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PaintStyleMapper.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PromptMapper.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PaintStyleService.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PromptService.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PaintStyleServiceImpl.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PromptServiceimpl.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PaintStyleVo.java create mode 100644 bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PromptVo.java create mode 100644 bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PaintStyleMapper.xml create mode 100644 bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PromptMapper.xml create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PaintStyleController.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PromptController.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PaintStyleMapper.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PromptMapper.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPaintStyleService.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPromptService.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PaintStyleServiceImpl.java create mode 100644 bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PromptServiceImpl.java diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/PaintStyle.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/PaintStyle.java new file mode 100644 index 0000000..e6b9e1c --- /dev/null +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/PaintStyle.java @@ -0,0 +1,58 @@ +package com.bnyer.common.core.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +/** + * 绘画-模型风格表 + */ +@ApiModel(value="com-bnyer-common-core-domain-PaintStyle") +@Getter +@Setter +@ToString +@AllArgsConstructor +@NoArgsConstructor +@TableName(value = "img_paint_style") +public class PaintStyle extends BaseDomain { + /** + * 主键id + */ + @TableId(value = "id", type = IdType.AUTO) + @ApiModelProperty(value="主键id") + private Long id; + + /** + * 模型风格名称 + */ + @TableField(value = "`name`") + @ApiModelProperty(value="模型风格名称") + private String name; + + /** + * 模型名称 + */ + @TableField(value = "model_name") + @ApiModelProperty(value="模型名称") + private String modelName; + + /** + * 模型风格图片 + */ + @TableField(value = "img_url") + @ApiModelProperty(value="模型风格图片") + private String imgUrl; + + /** + * 是否热门(0->正常;1->热门) + */ + @TableField(value = "is_hot") + @ApiModelProperty(value="是否热门(0->正常;1->热门)") + private String isHot; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/Prompt.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/Prompt.java new file mode 100644 index 0000000..88a9bd9 --- /dev/null +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/domain/Prompt.java @@ -0,0 +1,44 @@ +package com.bnyer.common.core.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +/** + * 绘画-提示词表 + */ +@ApiModel(value="com-bnyer-common-core-domain-Prompt") +@Getter +@Setter +@ToString +@AllArgsConstructor +@NoArgsConstructor +@TableName(value = "img_prompt") +public class Prompt extends BaseDomain { + /** + * 主键id + */ + @TableId(value = "id", type = IdType.AUTO) + @ApiModelProperty(value="主键id") + private Long id; + + /** + * 提示词 + */ + @TableField(value = "`text`") + @ApiModelProperty(value="提示词") + private String text; + + /** + * 类型(0->绘画;1->gpt) + */ + @TableField(value = "`type`") + @ApiModelProperty(value="类型(0->绘画;1->gpt)") + private String type; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStyleDto.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStyleDto.java new file mode 100644 index 0000000..4cce2ae --- /dev/null +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStyleDto.java @@ -0,0 +1,41 @@ +package com.bnyer.common.core.dto; + +import com.bnyer.common.core.domain.PaintStyle; +import com.bnyer.common.core.utils.bean.BeanUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + + +@Getter +@Setter +@ApiModel("绘画风格入参接收类") +public class PaintStyleDto implements Serializable { + + @ApiModelProperty(value="主键id") + private Long id; + + @ApiModelProperty(value="模型风格名称") + private String name; + + @ApiModelProperty(value="模型名称") + private String modelName; + + @ApiModelProperty(value="模型风格图片") + private String imgUrl; + + @ApiModelProperty(value="是否热门(0->正常;1->热门)") + private String isHot; + + @ApiModelProperty(value="排序") + private Integer sort; + + public PaintStyle extractParam(){ + PaintStyle paintStyle = new PaintStyle(); + BeanUtils.copyProperties(this,paintStyle); + return paintStyle; + } +} diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStylePageDto.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStylePageDto.java new file mode 100644 index 0000000..66bd127 --- /dev/null +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PaintStylePageDto.java @@ -0,0 +1,22 @@ +package com.bnyer.common.core.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter +@ApiModel("绘画风格分页接收类") +public class PaintStylePageDto extends BasePageDto { + + @ApiModelProperty(value="模型风格名称") + private String name; + + @ApiModelProperty(value="是否热门(0->正常;1->热门)") + private String isHot; + + @ApiModelProperty(value="是否显示 (0->隐藏;1->显示)") + private String isShow; +} diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptDto.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptDto.java new file mode 100644 index 0000000..5f98f8d --- /dev/null +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptDto.java @@ -0,0 +1,32 @@ +package com.bnyer.common.core.dto; + +import com.bnyer.common.core.domain.Prompt; +import com.bnyer.common.core.utils.bean.BeanUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + + +@Getter +@Setter +@ApiModel("提示词入参接收类") +public class PromptDto implements Serializable { + + @ApiModelProperty(value="主键id") + private Long id; + + @ApiModelProperty(value="提示词") + private String text; + + @ApiModelProperty(value="类型(0->绘画;1->gpt)") + private String type; + + public Prompt extractParam(){ + Prompt prompt = new Prompt(); + BeanUtils.copyProperties(this,prompt); + return prompt; + } +} diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptPageDto.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptPageDto.java new file mode 100644 index 0000000..9f300a1 --- /dev/null +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/PromptPageDto.java @@ -0,0 +1,22 @@ +package com.bnyer.common.core.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter +@ApiModel("提示词分页接收类") +public class PromptPageDto extends BasePageDto { + + @ApiModelProperty(value="提示词") + private String text; + + @ApiModelProperty(value="类型(0->绘画;1->gpt)") + private String type; + + @ApiModelProperty(value="是否显示 (0->隐藏;1->显示)") + private String isShow; +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/config/RestTemplateConfiguration.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/config/RestTemplateConfiguration.java index 67e3d53..d6205ab 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/config/RestTemplateConfiguration.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/config/RestTemplateConfiguration.java @@ -21,7 +21,7 @@ public class RestTemplateConfiguration { public ClientHttpRequestFactory simpleClientHttpRequestFactory(){ SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); factory.setConnectTimeout(15000); - factory.setReadTimeout(5000); + factory.setReadTimeout(10000); return factory; } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java index 7d4d0a0..1a0aa9e 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java @@ -82,6 +82,12 @@ public class FhMiniController extends BaseController { @Autowired private HotSearchKeywordService hotSearchKeywordService; + @Autowired + private PaintStyleService paintStyleService; + + @Autowired + private PromptService promptService; + @ApiOperation(value="查询banner列表") @GetMapping(value = "/listBanner") public AjaxResult listBanner(){ @@ -374,4 +380,16 @@ public class FhMiniController extends BaseController { hotSearchKeywordService.insertHotKeyword(keyword); return AjaxResult.success(); } + + @ApiOperation(value="获取绘画风格列表") + @GetMapping(value = "/getPaintStyle") + public AjaxResult getPaintStyle(){ + return AjaxResult.success(paintStyleService.queryPaintStyleList()); + } + + @ApiOperation(value="获取提示词列表") + @GetMapping(value = "/getPrompt") + public AjaxResult getPrompt(){ + return AjaxResult.success(promptService.queryPromptList()); + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java index 83e573f..95f0b4e 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java @@ -80,6 +80,15 @@ public class TiktokMiniController extends BaseController { @Autowired private HotSearchKeywordService hotSearchKeywordService; + @Autowired + private PaintStyleService paintStyleService; + + @Autowired + private PromptService promptService; + + @Autowired + private StableDiffusionService stableDiffusionService; + @ApiOperation(value="查询banner列表") @GetMapping(value = "/listBanner") public AjaxResult listBanner(){ @@ -396,4 +405,22 @@ public class TiktokMiniController extends BaseController { hotSearchKeywordService.insertHotKeyword(keyword); return AjaxResult.success(); } + + @ApiOperation(value="获取绘画风格列表") + @GetMapping(value = "/getPaintStyle") + public AjaxResult getPaintStyle(){ + return AjaxResult.success(paintStyleService.queryPaintStyleList()); + } + + @ApiOperation(value="获取提示词列表") + @GetMapping(value = "/getPrompt") + public AjaxResult getPrompt(){ + return AjaxResult.success(promptService.queryPromptList()); + } + + @ApiOperation(value="文生图") + @PostMapping(value = "/textToImg") + public AjaxResult textToImg(@Validated @RequestBody @ApiParam("文生图对象") TextToImgDto param){ + return AjaxResult.success(stableDiffusionService.textToImg(param)); + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java index 309b967..3352d36 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java @@ -82,6 +82,12 @@ public class WxMiniController extends BaseController { @Autowired private HotSearchKeywordService hotSearchKeywordService; + @Autowired + private PaintStyleService paintStyleService; + + @Autowired + private PromptService promptService; + @ApiOperation(value="查询banner列表") @GetMapping(value = "/listBanner") @@ -404,4 +410,16 @@ public class WxMiniController extends BaseController { hotSearchKeywordService.insertHotKeyword(keyword); return AjaxResult.success(); } + + @ApiOperation(value="获取绘画风格列表") + @GetMapping(value = "/getPaintStyle") + public AjaxResult getPaintStyle(){ + return AjaxResult.success(paintStyleService.queryPaintStyleList()); + } + + @ApiOperation(value="获取提示词列表") + @GetMapping(value = "/getPrompt") + public AjaxResult getPrompt(){ + return AjaxResult.success(promptService.queryPromptList()); + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PaintStyleMapper.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PaintStyleMapper.java new file mode 100644 index 0000000..56d52cc --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PaintStyleMapper.java @@ -0,0 +1,18 @@ +package com.bnyer.img.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bnyer.common.core.domain.PaintStyle; +import com.bnyer.img.vo.PaintStyleVo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface PaintStyleMapper extends BaseMapper { + + /** + * 获取绘画风格列表 + * @return - + */ + List queryList(); +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PromptMapper.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PromptMapper.java new file mode 100644 index 0000000..76f4110 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/PromptMapper.java @@ -0,0 +1,18 @@ +package com.bnyer.img.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bnyer.common.core.domain.Prompt; +import com.bnyer.img.vo.PromptVo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface PromptMapper extends BaseMapper { + /** + * 获取提示词列表 + * @param type 类型 + * @return - + */ + List queryList(String type); +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PaintStyleService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PaintStyleService.java new file mode 100644 index 0000000..983af26 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PaintStyleService.java @@ -0,0 +1,14 @@ +package com.bnyer.img.service; + +import com.bnyer.img.vo.PaintStyleVo; + +import java.util.List; + +public interface PaintStyleService { + + /** + * 获取绘画风格列表 + * @return - + */ + List queryPaintStyleList(); +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PromptService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PromptService.java new file mode 100644 index 0000000..22086d8 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/PromptService.java @@ -0,0 +1,14 @@ +package com.bnyer.img.service; + +import com.bnyer.img.vo.PromptVo; + +import java.util.List; + +public interface PromptService { + + /** + * 随机获取8条提示词列表 + * @return - + */ + List queryPromptList(); +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PaintStyleServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PaintStyleServiceImpl.java new file mode 100644 index 0000000..a227f91 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PaintStyleServiceImpl.java @@ -0,0 +1,23 @@ +package com.bnyer.img.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.bnyer.common.core.domain.PaintStyle; +import com.bnyer.img.mapper.PaintStyleMapper; +import com.bnyer.img.service.PaintStyleService; +import com.bnyer.img.vo.PaintStyleVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class PaintStyleServiceImpl implements PaintStyleService { + + @Autowired + private PaintStyleMapper paintStyleMapper; + + @Override + public List queryPaintStyleList() { + return paintStyleMapper.queryList(); + } +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PromptServiceimpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PromptServiceimpl.java new file mode 100644 index 0000000..814a07f --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/PromptServiceimpl.java @@ -0,0 +1,40 @@ +package com.bnyer.img.service.impl; + +import com.bnyer.img.mapper.PromptMapper; +import com.bnyer.img.service.PromptService; +import com.bnyer.img.vo.PromptVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class PromptServiceimpl implements PromptService { + + @Autowired + private PromptMapper promptMapper; + + @Override + public List queryPromptList() { + //type:0->绘画;1->gpt + List promptVos = promptMapper.queryList("0"); + List news = new ArrayList<>(); + Map map = new HashMap<>(); + //随机抽10条数据展示在页面上 + if (promptVos.size() <= 30) { + return promptVos; + }else{ + while (map.size() < 30) { + int random = (int)(Math.random() * promptVos.size()); + if (!map.containsKey(random)) { + map.put(random, ""); + news.add(promptVos.get(random)); + } + } + } + return news; + } +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PaintStyleVo.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PaintStyleVo.java new file mode 100644 index 0000000..2a6612e --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PaintStyleVo.java @@ -0,0 +1,31 @@ +package com.bnyer.img.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + + +@Getter +@Setter +@ApiModel("绘画风格响应体") +public class PaintStyleVo implements Serializable { + @ApiModelProperty(value="主键id") + private Long id; + + @ApiModelProperty(value="模型风格名称") + private String name; + + @ApiModelProperty(value="模型名称") + private String modelName; + + @ApiModelProperty(value="模型风格图片") + private String imgUrl; + + @ApiModelProperty(value="是否热门(0->正常;1->热门)") + private String isHot; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PromptVo.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PromptVo.java new file mode 100644 index 0000000..b738fd8 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/PromptVo.java @@ -0,0 +1,26 @@ +package com.bnyer.img.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + + +@Getter +@Setter +@ApiModel("提示词响应体") +public class PromptVo implements Serializable { + + @ApiModelProperty(value="主键id") + private Long id; + + @ApiModelProperty(value="提示词") + private String text; + + @ApiModelProperty(value="类型(0->绘画;1->gpt)") + private String type; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PaintStyleMapper.xml b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PaintStyleMapper.xml new file mode 100644 index 0000000..67d2765 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PaintStyleMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + id, `name`, model_name, img_url, is_show, is_hot, create_time, update_time, sort + + + + \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PromptMapper.xml b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PromptMapper.xml new file mode 100644 index 0000000..0c036e3 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/PromptMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + id, `text`, `type`, is_show, create_time, update_time, sort + + + + \ No newline at end of file diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PaintStyleController.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PaintStyleController.java new file mode 100644 index 0000000..e540d7b --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PaintStyleController.java @@ -0,0 +1,87 @@ +package com.bnyer.system.controller; + +import com.alibaba.fastjson.JSON; +import com.bnyer.common.core.domain.PaintStyle; +import com.bnyer.common.core.dto.PaintStyleDto; +import com.bnyer.common.core.dto.PaintStylePageDto; +import com.bnyer.common.core.dto.StatusDto; +import com.bnyer.common.core.web.controller.BaseController; +import com.bnyer.common.core.web.domain.AjaxResult; +import com.bnyer.common.core.web.page.TableDataInfo; +import com.bnyer.common.security.annotation.RequiresPermissions; +import com.bnyer.system.service.IPaintStyleService; +import com.github.pagehelper.PageHelper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Api(value = "【图文平台】绘画风格接口",tags = "【图文平台】绘画风格接口") +@RestController +@RequestMapping("/img/paintStyle") +@Slf4j +public class PaintStyleController extends BaseController { + + @Autowired + private IPaintStyleService paintStyleService; + + @ApiOperation(value="查询绘画风格分页") + @PostMapping("/page") + public TableDataInfo pagePaintStyle(@RequestBody @ApiParam("分页对象") PaintStylePageDto dto){ + PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); + List paintStyles = paintStyleService.queryPage(dto); + return getDataTable(paintStyles); + } + + @RequiresPermissions("img:paintStyle:add") + @ApiOperation(value="新增绘画风格") + @PostMapping(value = "/insert") + public AjaxResult insertPaintStyle(@Validated @RequestBody @ApiParam("绘画风格对象") PaintStyleDto dto){ + log.debug("【图文平台后台】新增绘画风格参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(paintStyleService.insert(dto.extractParam())); + } + + @RequiresPermissions("img:paintStyle:edit") + @ApiOperation(value="修改绘画风格") + @PostMapping(value = "/update") + public AjaxResult updatePaintStyle(@Validated @RequestBody @ApiParam("绘画风格对象") PaintStyleDto dto){ + log.debug("【图文平台后台】修改绘画风格参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(paintStyleService.update(dto.extractParam())); + } + + @RequiresPermissions("img:paintStyle:delete") + @ApiOperation(value="删除绘画风格") + @DeleteMapping(value = "/delete/{ids}") + public AjaxResult deletePaintStyle(@PathVariable @ApiParam("主键ids") List ids){ + log.debug("【图文平台后台】删除绘画风格参数为:{}", JSON.toJSONString(ids)); + return AjaxResult.success(paintStyleService.delete(ids)); + } + + @ApiOperation(value="查询绘画风格详情") + @GetMapping(value = "/details/{id}") + public AjaxResult detailsPaintStyle(@PathVariable @ApiParam("主键id") Long id){ + log.debug("【图文平台后台】查询绘画风格详情参数为:{}", id); + return AjaxResult.success(paintStyleService.queryDetails(id)); + } + + @RequiresPermissions("img:paintStyle:edit") + @ApiOperation(value="变更显示状态") + @PostMapping(value = "/changeStatus") + public AjaxResult changeStatus(@Validated @RequestBody @ApiParam("显示状态对象") StatusDto dto){ + log.debug("【图文平台后台】变更显示状态参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(paintStyleService.changeStatus(dto.getId(),dto.getStatus())); + } + + @RequiresPermissions("img:paintStyle:edit") + @ApiOperation(value="变更是否热门状态") + @PostMapping(value = "/changeHot") + public AjaxResult changeHot(@Validated @RequestBody @ApiParam("热门状态对象") StatusDto dto){ + log.debug("【图文平台后台】变更是否热门参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(paintStyleService.changeHot(dto.getId(),dto.getStatus())); + } +} diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PromptController.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PromptController.java new file mode 100644 index 0000000..8b72fef --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/controller/PromptController.java @@ -0,0 +1,79 @@ +package com.bnyer.system.controller; + +import com.alibaba.fastjson.JSON; +import com.bnyer.common.core.domain.Prompt; +import com.bnyer.common.core.dto.PromptDto; +import com.bnyer.common.core.dto.PromptPageDto; +import com.bnyer.common.core.dto.StatusDto; +import com.bnyer.common.core.web.controller.BaseController; +import com.bnyer.common.core.web.domain.AjaxResult; +import com.bnyer.common.core.web.page.TableDataInfo; +import com.bnyer.common.security.annotation.RequiresPermissions; +import com.bnyer.system.service.IPromptService; +import com.github.pagehelper.PageHelper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Api(value = "【图文平台】提示词接口",tags = "【图文平台】提示词接口") +@RestController +@RequestMapping("/img/prompt") +@Slf4j +public class PromptController extends BaseController { + + @Autowired + private IPromptService promptService; + + @ApiOperation(value="查询提示词分页") + @PostMapping("/page") + public TableDataInfo pagePrompt(@RequestBody @ApiParam("分页对象") PromptPageDto dto){ + PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); + List prompts = promptService.queryPage(dto); + return getDataTable(prompts); + } + + @RequiresPermissions("img:prompt:add") + @ApiOperation(value="新增提示词") + @PostMapping(value = "/insert") + public AjaxResult insertPrompt(@Validated @RequestBody @ApiParam("提示词对象") PromptDto dto){ + log.debug("【图文平台后台】新增提示词参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(promptService.insert(dto.extractParam())); + } + + @RequiresPermissions("img:prompt:edit") + @ApiOperation(value="修改提示词") + @PostMapping(value = "/update") + public AjaxResult updatePrompt(@Validated @RequestBody @ApiParam("提示词对象") PromptDto dto){ + log.debug("【图文平台后台】修改prompt参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(promptService.update(dto.extractParam())); + } + + @RequiresPermissions("img:prompt:delete") + @ApiOperation(value="删除提示词") + @DeleteMapping(value = "/delete/{ids}") + public AjaxResult deletePrompt(@PathVariable @ApiParam("主键ids") List ids){ + log.debug("【图文平台后台】删除提示词参数为:{}", JSON.toJSONString(ids)); + return AjaxResult.success(promptService.delete(ids)); + } + + @ApiOperation(value="查询提示词详情") + @GetMapping(value = "/details/{id}") + public AjaxResult detailsPrompt(@PathVariable @ApiParam("主键id") Long id){ + log.debug("【图文平台后台】查询提示词详情参数为:{}", id); + return AjaxResult.success(promptService.queryDetails(id)); + } + + @RequiresPermissions("img:prompt:edit") + @ApiOperation(value="变更type显示状态") + @PostMapping(value = "/changeStatus") + public AjaxResult changeStatus(@Validated @RequestBody @ApiParam("type状态对象") StatusDto dto){ + log.debug("【图文平台后台】变更type参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(promptService.changeStatus(dto.getId(),dto.getStatus())); + } +} diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PaintStyleMapper.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PaintStyleMapper.java new file mode 100644 index 0000000..a22f09a --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PaintStyleMapper.java @@ -0,0 +1,11 @@ +package com.bnyer.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bnyer.common.core.domain.PaintStyle; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PaintStyleMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PromptMapper.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PromptMapper.java new file mode 100644 index 0000000..e200ace --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/mapper/PromptMapper.java @@ -0,0 +1,11 @@ +package com.bnyer.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bnyer.common.core.domain.Prompt; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PromptMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPaintStyleService.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPaintStyleService.java new file mode 100644 index 0000000..b2a583f --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPaintStyleService.java @@ -0,0 +1,60 @@ +package com.bnyer.system.service; + +import com.bnyer.common.core.domain.PaintStyle; +import com.bnyer.common.core.dto.PaintStylePageDto; + +import java.util.List; + +public interface IPaintStyleService { + + /** + * 新增绘画风格 + * @param paintStyle 绘画风格 + * @return - + */ + int insert(PaintStyle paintStyle); + + /** + * 修改绘画风格 + * @param paintStyle 绘画风格 + * @return - + */ + int update(PaintStyle paintStyle); + + /** + * 删除绘画风格 + * @param ids 主键ids + * @return - + */ + int delete(List ids); + + /** + * 查询绘画风格分页 + * @param params 分页参数 + * @return - + */ + List queryPage(PaintStylePageDto params); + + /** + * 获取绘画风格详情 + * @param id 主键id + * @return - + */ + PaintStyle queryDetails(Long id); + + /** + * 变更显示状态 + * @param id 主键id + * @param status 状态 + * @return - + */ + int changeStatus(Long id, String status); + + /** + * 变更热门状态 + * @param id 主键id + * @param status 状态 + * @return - + */ + int changeHot(Long id, String status); +} diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPromptService.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPromptService.java new file mode 100644 index 0000000..8b0b59a --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/IPromptService.java @@ -0,0 +1,52 @@ +package com.bnyer.system.service; + +import com.bnyer.common.core.domain.Prompt; +import com.bnyer.common.core.dto.PromptPageDto; + +import java.util.List; + +public interface IPromptService { + + /** + * 新增提示词 + * @param prompt 提示词 + * @return - + */ + int insert(Prompt prompt); + + /** + * 更新提示词 + * @param prompt 提示词 + * @return - + */ + int update(Prompt prompt); + + /** + * 删除提示词 + * @param ids id列表 + * @return - + */ + int delete(List ids); + + /** + * 变更显示状态 + * @param id 主键id + * @param status 状态 + * @return - + */ + int changeStatus(Long id, String status); + + /** + * 查询提示词分页 + * @param params 分页参数 + * @return - + */ + List queryPage(PromptPageDto params); + + /** + * 获取提示词详情 + * @param id 主键id + * @return - + */ + Prompt queryDetails(Long id); +} diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PaintStyleServiceImpl.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PaintStyleServiceImpl.java new file mode 100644 index 0000000..16122ab --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PaintStyleServiceImpl.java @@ -0,0 +1,85 @@ +package com.bnyer.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.bnyer.common.core.domain.PaintStyle; +import com.bnyer.common.core.dto.PaintStylePageDto; +import com.bnyer.common.core.utils.StringUtils; +import com.bnyer.system.mapper.PaintStyleMapper; +import com.bnyer.system.service.IPaintStyleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +@Service +public class PaintStyleServiceImpl implements IPaintStyleService { + + @Autowired + private PaintStyleMapper paintStyleMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public int insert(PaintStyle paintStyle) { + paintStyle.setCreateTime(new Date()); + paintStyle.setUpdateTime(new Date()); + paintStyle.setIsShow("1"); + return paintStyleMapper.insert(paintStyle); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int update(PaintStyle paintStyle) { + paintStyle.setUpdateTime(new Date()); + return paintStyleMapper.updateById(paintStyle); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int delete(List ids) { + return paintStyleMapper.deleteBatchIds(ids); + } + + @Override + public List queryPage(PaintStylePageDto params) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if(StringUtils.isNotEmpty(params.getName())){ + wrapper.like(PaintStyle::getName, params.getName()); + } + if(StringUtils.isNotEmpty(params.getIsShow())){ + wrapper.eq(PaintStyle::getIsShow, params.getIsShow()); + } + if(StringUtils.isNotEmpty(params.getIsHot())){ + wrapper.eq(PaintStyle::getIsHot, params.getIsHot()); + } + wrapper.orderByDesc(PaintStyle::getSort); + return paintStyleMapper.selectList(wrapper); + } + + @Override + public PaintStyle queryDetails(Long id) { + return paintStyleMapper.selectById(id); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int changeStatus(Long id, String status) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(PaintStyle::getId, id); + PaintStyle paintStyle = new PaintStyle(); + paintStyle.setIsShow(status); + return paintStyleMapper.update(paintStyle,wrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int changeHot(Long id, String status) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(PaintStyle::getId, id); + PaintStyle paintStyle = new PaintStyle(); + paintStyle.setIsHot(status); + return paintStyleMapper.update(paintStyle,wrapper); + } +} diff --git a/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PromptServiceImpl.java b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PromptServiceImpl.java new file mode 100644 index 0000000..c09ab57 --- /dev/null +++ b/bnyer-services/bnyer-system/src/main/java/com/bnyer/system/service/impl/PromptServiceImpl.java @@ -0,0 +1,76 @@ +package com.bnyer.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.bnyer.common.core.domain.Prompt; +import com.bnyer.common.core.dto.PromptPageDto; +import com.bnyer.common.core.utils.StringUtils; +import com.bnyer.system.mapper.PromptMapper; +import com.bnyer.system.service.IPromptService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +@Service +public class PromptServiceImpl implements IPromptService { + + @Autowired + private PromptMapper promptMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public int insert(Prompt prompt) { + prompt.setCreateTime(new Date()); + prompt.setUpdateTime(new Date()); + prompt.setIsShow("1"); + prompt.setSort(0); + return promptMapper.insert(prompt); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int update(Prompt prompt) { + prompt.setUpdateTime(new Date()); + return promptMapper.updateById(prompt); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int delete(List ids) { + return promptMapper.deleteBatchIds(ids); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int changeStatus(Long id, String status) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(Prompt::getId, id); + Prompt prompt = new Prompt(); + prompt.setIsShow(status); + return promptMapper.update(prompt,wrapper); + } + + @Override + public List queryPage(PromptPageDto params) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if(StringUtils.isNotEmpty(params.getType())){ + wrapper.eq(Prompt::getType, params.getType()); + } + if(StringUtils.isNotEmpty(params.getIsShow())){ + wrapper.eq(Prompt::getIsShow, params.getIsShow()); + } + if(StringUtils.isNotEmpty(params.getText())){ + wrapper.like(Prompt::getText, params.getText()); + } + wrapper.orderByDesc(Prompt::getSort); + return promptMapper.selectList(wrapper); + } + + @Override + public Prompt queryDetails(Long id) { + return promptMapper.selectById(id); + } +}