From f49af28c4b4933d7c7f8d00dd15e2739d251b3b3 Mon Sep 17 00:00:00 2001 From: chengkun <2500338766@qq.com> Date: Fri, 8 Jul 2022 13:42:31 +0800 Subject: [PATCH] =?UTF-8?q?feature1.0.0-img:=E6=B7=BB=E5=8A=A0bnyer-api-im?= =?UTF-8?q?g=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bnyer-api/bnyer-api-img/pom.xml | 26 ++++++ .../com/bnyer/img/api/RemoteImgService.java | 30 +++++++ .../com/bnyer/img/api/domain/TiktokImg.java | 87 +++++++++++++++++++ .../bnyer/img/api/dto/TiktokImgMiniDto.java | 35 ++++++++ .../api/factory/RemoteImgFallbackFactory.java | 33 +++++++ bnyer-api/pom.xml | 1 + .../core/constant/ServiceNameConstants.java | 7 +- 7 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 bnyer-api/bnyer-api-img/pom.xml create mode 100644 bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/RemoteImgService.java create mode 100644 bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/domain/TiktokImg.java create mode 100644 bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/dto/TiktokImgMiniDto.java create mode 100644 bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/factory/RemoteImgFallbackFactory.java diff --git a/bnyer-api/bnyer-api-img/pom.xml b/bnyer-api/bnyer-api-img/pom.xml new file mode 100644 index 0000000..8266a8f --- /dev/null +++ b/bnyer-api/bnyer-api-img/pom.xml @@ -0,0 +1,26 @@ + + + + com.dimensionalnode + bnyer-api + 1.0.0 + + 4.0.0 + + bnyer-api-img + + + bnyer-api-img图文服务接口模块 + + + + + + com.dimensionalnode + bnyer-common-core + + + + diff --git a/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/RemoteImgService.java b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/RemoteImgService.java new file mode 100644 index 0000000..6e97e57 --- /dev/null +++ b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/RemoteImgService.java @@ -0,0 +1,30 @@ +package com.bnyer.img.api; + +import com.bnyer.common.core.constant.ServiceNameConstants; +import com.bnyer.common.core.domain.R; +import com.bnyer.common.core.web.domain.AjaxResult; +import com.bnyer.img.api.dto.TiktokImgMiniDto; +import com.bnyer.img.api.factory.RemoteImgFallbackFactory; +import io.swagger.annotations.ApiParam; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * 图文服务 + * + * @author chengkun + * @date 2022/7/8 11:03 + */ +@FeignClient(contextId = "remoteImgService", value = ServiceNameConstants.IMG_SERVICE, fallbackFactory = RemoteImgFallbackFactory.class) +public interface RemoteImgService { + + /** + * 保存图片 + * @param dto 图片接收类 + * @return - + */ + @PostMapping(value = "/insertTiktokImg") + public R insertTiktokImg(@Validated @RequestBody @ApiParam("TiktokImg对象") TiktokImgMiniDto dto); +} diff --git a/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/domain/TiktokImg.java b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/domain/TiktokImg.java new file mode 100644 index 0000000..11e8365 --- /dev/null +++ b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/domain/TiktokImg.java @@ -0,0 +1,87 @@ +package com.bnyer.img.api.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +import java.io.Serializable; +import java.util.Date; + +@ApiModel("抖音图片小程序api端实体类") +@Getter +@Setter +@ToString +@AllArgsConstructor +@NoArgsConstructor +public class TiktokImg implements Serializable { + /** + * id + */ + @ApiModelProperty(value="id") + private Long id; + + /** + * 图片地址 + */ + @ApiModelProperty(value="图片地址") + private String imgUrl; + + /** + * 艺术家id + */ + @ApiModelProperty(value="艺术家id") + private Long creatorId; + + /** + * 分类id + */ + @ApiModelProperty(value="分类id") + private Long typeId; + + /** + * 下载量 + */ + @ApiModelProperty(value="下载量") + private Integer downloadNum; + + /** + * 点赞量 + */ + @ApiModelProperty(value="点赞量") + private Integer greatNum; + + /** + * 收藏量 + */ + @ApiModelProperty(value="收藏量") + private Integer collectionNum; + + /** + * 状态(0->待审核;1->审核通过) + */ + @ApiModelProperty(value="状态(0->待审核;1->审核通过;2->审核拒绝)") + private String status; + + /** + * 是否热门(0->冷门;1->热门) + */ + @ApiModelProperty(value="是否热门(0->冷门;1->热门)") + private String isHot; + + @ApiModelProperty(value="是否显示 (0->隐藏;1->显示)") + private String isShow; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value="创建时间") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value="更新时间") + private Date updateTime; + + @ApiModelProperty(value="排序") + private Integer sort; + + private static final long serialVersionUID = 1L; +} diff --git a/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/dto/TiktokImgMiniDto.java b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/dto/TiktokImgMiniDto.java new file mode 100644 index 0000000..848255a --- /dev/null +++ b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/dto/TiktokImgMiniDto.java @@ -0,0 +1,35 @@ +package com.bnyer.img.api.dto; + +import com.bnyer.common.core.utils.bean.BeanUtils; +import com.bnyer.img.api.domain.TiktokImg; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + + +@Getter +@Setter +@ApiModel("抖音图片小程序api端接收类") +public class TiktokImgMiniDto implements Serializable { + + @ApiModelProperty(value="id") + private Long id; + + @ApiModelProperty(value="图片地址") + private String imgUrl; + + @ApiModelProperty(value="艺术家id") + private Long creatorId; + + @ApiModelProperty(value="分类id") + private Long typeId; + + public TiktokImg extractParam(){ + TiktokImg tiktokImg = new TiktokImg(); + BeanUtils.copyProperties(this,tiktokImg); + return tiktokImg; + } +} diff --git a/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/factory/RemoteImgFallbackFactory.java b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/factory/RemoteImgFallbackFactory.java new file mode 100644 index 0000000..d03a044 --- /dev/null +++ b/bnyer-api/bnyer-api-img/src/main/java/com/bnyer/img/api/factory/RemoteImgFallbackFactory.java @@ -0,0 +1,33 @@ +package com.bnyer.img.api.factory; + +import com.bnyer.common.core.domain.R; +import com.bnyer.img.api.RemoteImgService; +import com.bnyer.img.api.dto.TiktokImgMiniDto; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 图文服务降级处理 + * + * @author penny + */ +@Component +public class RemoteImgFallbackFactory implements FallbackFactory +{ + private static final Logger log = LoggerFactory.getLogger(RemoteImgFallbackFactory.class); + + + @Override + public RemoteImgService create(Throwable throwable) { + log.error("api图文服务调用失败:{}", throwable.getMessage()); + return new RemoteImgService() + { + @Override + public R insertTiktokImg(TiktokImgMiniDto dto) { + return R.fail("图片保存失败:" + throwable.getMessage()); + } + }; + } +} diff --git a/bnyer-api/pom.xml b/bnyer-api/pom.xml index a7e4f62..78c3b28 100644 --- a/bnyer-api/pom.xml +++ b/bnyer-api/pom.xml @@ -10,6 +10,7 @@ bnyer-api-system + bnyer-api-img bnyer-api diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/ServiceNameConstants.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/ServiceNameConstants.java index cd85ab4..dd160bb 100644 --- a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/ServiceNameConstants.java +++ b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/ServiceNameConstants.java @@ -2,7 +2,7 @@ package com.bnyer.common.core.constant; /** * 服务名称 - * + * * @author ruoyi */ public class ServiceNameConstants @@ -21,4 +21,9 @@ public class ServiceNameConstants * 文件服务的serviceid */ public static final String FILE_SERVICE = "bnyer-file"; + + /** + * 图文服务的serviceid + */ + public static final String IMG_SERVICE = "bnyer-img"; }