release- 代表作处理

release-2024-08-08
pikaqiudeshujia 8 months ago
parent 1a9371cb49
commit 3dae08cdb9

@ -0,0 +1,133 @@
package dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author: yawei.huang
* @Package: dto
* @Project: luoo_parent
* @Date: 2024/5/15 14:07
* @Filename: PmsProduct
* @Describe:
*/
@Data
public class PmsProduct implements Serializable {
private Long id;
private Long brandId;
private Long productCategoryId;
private Long feightTemplateId;
private Long productAttributeCategoryId;
private String name;
private String pic;
@ApiModelProperty(value = "货号")
private String productSn;
@ApiModelProperty(value = "删除状态0->未删除1->已删除")
private Integer deleteStatus;
@ApiModelProperty(value = "上架状态0->下架1->上架")
private Integer publishStatus;
@ApiModelProperty(value = "新品状态:0->不是新品1->新品")
private Integer newStatus;
@ApiModelProperty(value = "推荐状态0->不推荐1->推荐")
private Integer recommandStatus;
@ApiModelProperty(value = "审核状态0->未审核1->审核通过")
private Integer verifyStatus;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "销量")
private Integer sale;
private BigDecimal price;
@ApiModelProperty(value = "促销价格")
private BigDecimal promotionPrice;
@ApiModelProperty(value = "赠送的成长值")
private Integer giftGrowth;
@ApiModelProperty(value = "赠送的积分")
private Integer giftPoint;
@ApiModelProperty(value = "限制使用的积分数")
private Integer usePointLimit;
@ApiModelProperty(value = "副标题")
private String subTitle;
@ApiModelProperty(value = "市场价")
private BigDecimal originalPrice;
@ApiModelProperty(value = "库存")
private Integer stock;
@ApiModelProperty(value = "库存预警值")
private Integer lowStock;
@ApiModelProperty(value = "单位")
private String unit;
@ApiModelProperty(value = "商品重量,默认为克")
private BigDecimal weight;
@ApiModelProperty(value = "是否为预告商品0->不是1->是")
private Integer previewStatus;
@ApiModelProperty(value = "以逗号分割的产品服务1->无忧退货2->快速退款3->免费包邮")
private String serviceIds;
private String keywords;
private String note;
@ApiModelProperty(value = "画册图片连产品图片限制为5张以逗号分割")
private String albumPics;
private String detailTitle;
@ApiModelProperty(value = "促销开始时间")
private Date promotionStartTime;
@ApiModelProperty(value = "促销结束时间")
private Date promotionEndTime;
@ApiModelProperty(value = "活动限购数量")
private Integer promotionPerLimit;
@ApiModelProperty(value = "促销类型0->没有促销使用原价;1->使用促销价2->使用会员价3->使用阶梯价格4->使用满减价格5->限时购")
private Integer promotionType;
@ApiModelProperty(value = "品牌名称")
private String brandName;
@ApiModelProperty(value = "商品分类名称")
private String productCategoryName;
@ApiModelProperty(value = "商品描述")
private String description;
private String detailDesc;
@ApiModelProperty(value = "产品详情网页内容")
private String detailHtml;
@ApiModelProperty(value = "移动端网页详情")
private String detailMobileHtml;
}

@ -0,0 +1,41 @@
package enums;
import lombok.Getter;
/**
* @Author: yawei.huang
* @Package: enums
* @Project: luoo_parent
* @Date: 2024/5/15 13:24
* @Filename: RepresentativeTypeEnum
* @Describe:
*/
@Getter
public enum RepresentativeTypeEnum {
ALBUM(1, "专辑"),
SONG(2, "歌曲"),
GOODS(3, "商品"),
SHOW(4, "演出");
private Integer code;
private String desc;
RepresentativeTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public static RepresentativeTypeEnum getByStatus(Integer code) {
for (RepresentativeTypeEnum al : RepresentativeTypeEnum.values()) {
if (al.code.equals(code)) {
return al;
}
}
return null;
}
}

@ -64,4 +64,10 @@ public class MallConfig {
* id
*/
private Long songId;
// 其他
/**
* url
*/
private String productUrl;
}

@ -0,0 +1,45 @@
package com.luoo.music.controller;
import api.Result;
import com.luoo.music.pojo.ArtistRepresentative;
import com.luoo.music.service.ArtistRepresentativeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @Author: yawei.huang
* @Package: com.luoo.music.controller
* @Project: luoo_parent
* @Date: 2024/5/15 13:29
* @Filename: ArtistRepresentativeController
* @Describe:
*/
@RestController
@CrossOrigin
@Api(tags = "代表作")
@RequestMapping("/respresentative")
public class ArtistRepresentativeController {
@Autowired
private ArtistRepresentativeService artistRepresentativeService;
@ApiOperation(value = "查询音乐人的代表作", notes = "查询音乐人的代表作")
@RequestMapping(value = "/artist/{id}", method = RequestMethod.GET)
public Result<ArtistRepresentative> getInfo(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "音乐人", required = true) @PathVariable String id) {
return Result.success(artistRepresentativeService.getInfo(id));
}
@ApiOperation(value = "设置音乐人的代表作", notes = "设置音乐人的代表作")
@RequestMapping(value = "/set", method = RequestMethod.POST)
public Result<Void> set(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "音乐人", required = true) @Validated @RequestBody ArtistRepresentative artistRepresentative) {
artistRepresentativeService.set(artistRepresentative);
return Result.success();
}
}

@ -0,0 +1,22 @@
package com.luoo.music.dao;
import com.luoo.music.pojo.ArtistRepresentative;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @Author: yawei.huang
* @Package: com.luoo.music.dao
* @Project: luoo_parent
* @Date: 2024/5/15 13:29
* @Filename: ArtistRepresentativeDao
* @Describe:
*/
public interface ArtistRepresentativeDao extends JpaRepository<ArtistRepresentative,String>, JpaSpecificationExecutor<ArtistRepresentative> {
public List<ArtistRepresentative> getAllByArtistId(String artistId);
public void deleteAllByArtistIdAndType(String artistId, Integer type);
}

@ -0,0 +1,55 @@
package com.luoo.music.pojo;
import dto.PmsProduct;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Author: yawei.huang
* @Package: com.luoo.music.pojo
* @Project: luoo_parent
* @Date: 2024/5/15 13:22
* @Filename: ArtistRepresentative
* @Describe:
*/
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Builder
@Table(name = "tb_artist_representative")
public class ArtistRepresentative {
@Id
@ApiModelProperty("id")
private String id;
@NotBlank
@ApiModelProperty("音乐人id")
private String artistId;
@NotBlank
@ApiModelProperty("所代表事物id")
private String representativeId;
@NotNull
@ApiModelProperty("类型 1-代表专辑 2-代表歌曲 3-代表商品 4-代表演出(暂无)")
private Integer type;
@Transient
private ArtistAlbum artistAlbum;
@Transient
private SongInfo songInfo;
@Transient
private PmsProduct pmsProduct;
}

@ -0,0 +1,98 @@
package com.luoo.music.service;
import com.luoo.music.config.MallConfig;
import com.luoo.music.dao.ArtistAlbumDao;
import com.luoo.music.dao.ArtistRepresentativeDao;
import com.luoo.music.dao.SongInfoDao;
import com.luoo.music.pojo.ArtistAlbum;
import com.luoo.music.pojo.ArtistRepresentative;
import com.luoo.music.pojo.SongInfo;
import dto.PmsProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import util.IdWorker;
import java.util.List;
/**
* @Author: yawei.huang
* @Package: com.luoo.music.service
* @Project: luoo_parent
* @Date: 2024/5/15 13:30
* @Filename: ArtistRepresentativeService
* @Describe:
*/
@Service
public class ArtistRepresentativeService {
@Autowired
private ArtistRepresentativeDao artistRepresentativeDao;
@Autowired
private SongInfoDao songInfoDao;
@Autowired
private ArtistAlbumDao artistAlbumDao;
@Autowired
private RestTemplate restTemplate;
@Autowired
private MallConfig mallConfig;
@Autowired
private IdWorker idWorker;
/**
* id
*
* @param artistId id
* @return
*/
public ArtistRepresentative getInfo(String artistId) {
ArtistRepresentative artistRepresentative = new ArtistRepresentative();
List<ArtistRepresentative> representativeList = artistRepresentativeDao.getAllByArtistId(artistId);
if (!representativeList.isEmpty()) {
for (ArtistRepresentative representative : representativeList) {
Integer type = representative.getType();
switch (type) {
case 1:
// 专辑
ArtistAlbum artistAlbum = artistAlbumDao.findById(representative.getRepresentativeId()).get();
representative.setArtistAlbum(artistAlbum);
case 2:
// 歌曲
SongInfo songInfo = songInfoDao.findById(representative.getRepresentativeId()).get();
representative.setSongInfo(songInfo);
case 3:
// 商品
PmsProduct pmsProduct = restTemplate.getForObject(mallConfig.getProductUrl(), PmsProduct.class);
representative.setPmsProduct(pmsProduct);
break;
default:
break;
}
}
}
return artistRepresentative;
}
/**
*
*
* @param artistRepresentative
*/
@Transactional(rollbackFor = Exception.class)
public void set(ArtistRepresentative artistRepresentative) {
// 同一音乐人同一类型只能有一条记录
artistRepresentativeDao.deleteAllByArtistIdAndType(artistRepresentative.getArtistId(), artistRepresentative.getType());
artistRepresentative.setId(String.valueOf(idWorker.nextId()));
artistRepresentativeDao.save(artistRepresentative);
}
}

@ -68,3 +68,4 @@ mall:
albumId: 76
albumName: 77
songId: 78
productUrl: http://43.248.137.154:8085/product/detail/{id}

@ -0,0 +1,10 @@
create table tb_artist_representative
(
id varchar(20) not null comment 'id'
primary key,
artist_id varchar(20) null comment '音乐人id',
representative_id varchar(20) null comment '所代表事物的id',
type int null comment '类型 1-代表专辑 2-代表歌曲 3-代表商品 4-代表演出(暂无)'
)
comment 'tb_artist_representative';
Loading…
Cancel
Save