7 changed files with 218 additions and 1 deletions
@ -0,0 +1,26 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
|
<parent> |
||||
|
<groupId>com.dimensionalnode</groupId> |
||||
|
<artifactId>bnyer-api</artifactId> |
||||
|
<version>1.0.0</version> |
||||
|
</parent> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
|
||||
|
<artifactId>bnyer-api-img</artifactId> |
||||
|
|
||||
|
<description> |
||||
|
bnyer-api-img图文服务接口模块 |
||||
|
</description> |
||||
|
|
||||
|
<dependencies> |
||||
|
<!-- bnyer Common Core--> |
||||
|
<dependency> |
||||
|
<groupId>com.dimensionalnode</groupId> |
||||
|
<artifactId>bnyer-common-core</artifactId> |
||||
|
</dependency> |
||||
|
</dependencies> |
||||
|
|
||||
|
</project> |
||||
@ -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<Integer> insertTiktokImg(@Validated @RequestBody @ApiParam("TiktokImg对象") TiktokImgMiniDto dto); |
||||
|
} |
||||
@ -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; |
||||
|
} |
||||
@ -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; |
||||
|
} |
||||
|
} |
||||
@ -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<RemoteImgService> |
||||
|
{ |
||||
|
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<Integer> insertTiktokImg(TiktokImgMiniDto dto) { |
||||
|
return R.fail("图片保存失败:" + throwable.getMessage()); |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue