记得上下班打卡 | git大法好,push需谨慎

Commit 488e9f3b authored by 姜秀龙's avatar 姜秀龙

艺人合并需求-第二部分

parent 303c3969
......@@ -6,6 +6,10 @@ public class KylinRedisConst {
public static final String PERFORMANCES_INVOICE_REMINDER = "kylin:performances:invoice_reminder:id:";
public static final String PERFORMANCES_NOTICE_REMIND_STATUS = "kylin:performances:noticeRemindStatus:id:";
public static final String PERFORMANCES_ARTISTS = "kylin:performances:artists:id:";
public static final String ARTIST_DETAIL = "kylin:artist:detail:id:";
public static final String ARTIST_ALBUM = "kylin:artist:album:id:";
public static final String ARTIST_PERFORMANCES = "kylin:artist:performances:id:";
public static final String ARTIST_PRODUCTS = "kylin:artist:products:id:";
public static final String PERFORMANCES_TRUE_NAME = "kylin:performances_true_name:id:";
public static final String PERFORMANCES_LIST_CITY = "kylin:performances:city:";
public static final String PERFORMANCES_LIST_SYSTEM_RECOMMEND = "kylin:performances:systemRecommend";
......
......@@ -40,9 +40,6 @@ public class ArtistVo {
@ApiModelProperty(value = "关联演出")
private List<PerformanceVo> performanceVoList;
@ApiModelProperty(value = "关联商品")
private List<ProductVo> productVoList;
@ApiModelProperty(value = "排序权重")
private Integer sort;
......@@ -79,7 +76,27 @@ public class ArtistVo {
@Data
@ApiModel("商品VO")
private static class ProductVo {
public static class ProductVo {
@ApiModelProperty("商品SPU ID")
private String spuId;
@ApiModelProperty("商品编码")
private String productCode;
@ApiModelProperty("商品名称")
private String productName;
@ApiModelProperty("商品头图")
private String imageUrl;
@ApiModelProperty("商品分类")
private String category;
@ApiModelProperty("商品售价")
private String price;
@ApiModelProperty("上架状态 1已上架 0未上架")
private Integer status;
}
}
......@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo;
import com.liquidnet.service.kylin.dao.KylinArtistDao;
import com.liquidnet.service.kylin.dto.param.ArtistParam;
import com.liquidnet.service.kylin.dto.param.ArtistSearchParam;
import com.liquidnet.service.kylin.dto.vo.ArtistGoodsOptionVo;
import com.liquidnet.service.kylin.dto.vo.ArtistVo;
import com.liquidnet.service.kylin.entity.KylinArtist;
......@@ -32,4 +33,12 @@ public interface IKylinArtistService extends IService<KylinArtist> {
Boolean checkArtistNameExists(String artistName, String artistId);
List<ArtistGoodsOptionVo> searchGoods(String keyword);
String validateProductSpuIds(List<String> spuIds);
List<ArtistVo.ProductVo> listArtistProducts(String artistId);
Boolean saveArtistProducts(String artistId, List<String> spuIds);
}
......@@ -11,7 +11,9 @@ import com.liquidnet.service.kylin.dao.KylinArtistDao;
import com.liquidnet.service.kylin.dao.KylinArtistOperationLogDao;
import com.liquidnet.service.kylin.dao.KylinArtistPerformanceDao;
import com.liquidnet.service.kylin.dto.param.ArtistParam;
import com.liquidnet.service.kylin.dto.param.ArtistProductSaveParam;
import com.liquidnet.service.kylin.dto.param.ArtistSearchParam;
import com.liquidnet.service.kylin.dto.vo.ArtistGoodsOptionVo;
import com.liquidnet.service.kylin.dto.vo.ArtistVo;
import com.liquidnet.service.kylin.service.admin.IKylinArtistOperationLogService;
import com.liquidnet.service.kylin.service.admin.IKylinArtistPerformanceService;
......@@ -305,4 +307,55 @@ public class KylinArtistController extends BaseController {
}
}
/**
* 关联商品页面
*/
@RequiresPermissions("kylin:artist:update")
@GetMapping("/products/{artistId}")
public String productsPage(@PathVariable("artistId") String artistId, ModelMap mmap) {
ArtistVo artistVo = kylinArtistService.detail(artistId);
mmap.put("artistId", artistId);
mmap.put("artistName", artistVo != null ? artistVo.getArtistName() : "");
return prefix + "/products";
}
/**
* 查询艺人已关联商品
*/
@RequiresPermissions("kylin:artist:update")
@GetMapping("/products/list")
@ResponseBody
public AjaxResult productsList(@RequestParam String artistId) {
return AjaxResult.success(kylinArtistService.listArtistProducts(artistId));
}
/**
* 保存艺人关联商品
*/
@Log(title = "保存艺人关联商品", businessType = BusinessType.UPDATE)
@RequiresPermissions("kylin:artist:update")
@PostMapping("/products/save")
@ResponseBody
public AjaxResult productsSave(@RequestBody ArtistProductSaveParam param) {
try {
Boolean result = kylinArtistService.saveArtistProducts(param.getArtistId(), param.getSpuIds());
if (result) {
return success("保存成功");
}
return error("艺人不存在");
} catch (IllegalArgumentException e) {
return error(e.getMessage());
}
}
/**
* 搜索可选商品(按名称)
*/
@GetMapping("/searchGoods")
@ResponseBody
public AjaxResult searchGoods(@RequestParam(value = "keyword", required = false) String keyword) {
List<ArtistGoodsOptionVo> list = kylinArtistService.searchGoods(keyword);
return AjaxResult.success(list);
}
}
......@@ -127,6 +127,7 @@
var actions = [];
actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.artistId + '\')"><i class="fa fa-eye"></i>详情</a> ');
actions.push('<a class="btn btn-success btn-xs ' + updateFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.artistId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-primary btn-xs ' + updateFlag + '" href="javascript:void(0)" onclick="openProductModal(\'' + row.artistId + '\')"><i class="fa fa-shopping-bag"></i>关联商品</a> ');
actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="showOperationLog(\'' + row.artistId + '\')"><i class="fa fa-history"></i>操作日志</a> ');
return actions.join('');
}
......@@ -171,6 +172,11 @@
var url = prefix + '/operationLog/' + artistId;
$.modal.openTab("艺人操作记录", url);
}
function openProductModal(artistId) {
var url = prefix + '/products/' + artistId;
$.modal.open("关联商品", url, '900', '600');
}
</script>
</body>
</html>
......@@ -282,54 +282,6 @@
暂无演出信息
</div>
</div>
<!-- 关联商品信息 -->
<div>
<div class="section-title">
艺人关联商品信息
<span th:if="*{productVoList != null}" style="font-size: 14px; color: #666; margin-left: 10px;">
(共<span th:text="*{productVoList.size()}">2</span>条)
</span>
</div>
<div class="table-container" th:if="*{productVoList != null and !productVoList.isEmpty()}">
<table class="custom-table">
<thead>
<tr>
<th width="15%">商品编码</th>
<th width="20%">商品名称</th>
<th width="15%">商品头图</th>
<th width="15%">商品分类</th>
<th width="15%">商品售价</th>
<th width="15%">上架状态</th>
</tr>
</thead>
<tbody>
<tr th:each="product : ${ArtistVo.productVoList}">
<td th:text="${product.productCode} ?: '--'">goods001</td>
<td th:text="${product.productName} ?: '--'">摩登天空T恤</td>
<td>
<div class="product-image" th:if="${product.imageUrl}">
<img th:src="${product.imageUrl}" alt="商品图片">
</div>
<span th:unless="${product.imageUrl}">--</span>
</td>
<td th:text="${product.category} ?: '--'">服饰</td>
<td th:text="${product.price} ?: '--'">99.00元</td>
<td>
<span th:if="${product.status == 1}" class="status-badge status-on">已上架</span>
<span th:if="${product.status == 0}" class="status-badge status-off">未上架</span>
<span th:if="${product.status != 1 and product.status != 0}" th:text="${product.status}">--</span>
</td>
</tr>
</tbody>
</table>
</div>
<div th:if="*{productVoList == null or productVoList.isEmpty()}" class="empty-data">
暂无关联商品信息
</div>
</div>
</div>
</div>
</div>
......
......@@ -699,8 +699,10 @@
$('#selected-artists-container').html('');
// 打开弹窗
$('#associateArtistModal').modal('show');
// 加载初始艺人列表(含已关联状态)
loadAllArtistsForModal(timesId, true);
// 已绑定艺人从 getSessionArtists 初始化(含逻辑删除但仍关联的);可选列表走 getAllArtists
initSelectedArtistsFromSession(timesId, function () {
loadAllArtistsForModal(timesId);
});
}
// 防抖
......@@ -715,15 +717,45 @@
const debouncedSearch = debounce(function () {
const timesId = $('#associateArtistModal').data('timesId');
loadAllArtistsForModal(timesId, false);
loadAllArtistsForModal(timesId);
}, 300);
/** 从本场次已绑定阵容初始化已选艺人(不按 status 过滤) */
function initSelectedArtistsFromSession(timesId, callback) {
$.ajax({
url: ctx + "kylin/artist/getSessionArtists",
type: "GET",
data: {
performancesId: performancesId,
timesId: timesId
},
success: function (response) {
if (response.code === 0) {
selectedArtists = (response.data || [])
.map(function (a) {
return {
artistId: a.artistId,
artistName: a.artistName,
avatarUrl: a.avatarUrl,
sort: a.sort || 0
};
})
.sort(function (a, b) { return b.sort - a.sort; });
updateSelectedArtistsView();
}
if (callback) callback();
},
error: function () {
if (callback) callback();
}
});
}
/**
* 从后端加载艺人列表
* 从后端加载可选艺人列表(仅 status=1)
* @param {string} timesId
* @param {boolean} isInitialLoad 是否首次加载(用于初始化已选艺人)
*/
function loadAllArtistsForModal(timesId, isInitialLoad) {
function loadAllArtistsForModal(timesId) {
const keyword = $('#artist-search-input').val().trim();
// 显示加载中
......@@ -742,7 +774,7 @@
success: function (response) {
if (response.code === 0) {
currentModalArtists = response.data || [];
renderArtistsInModal(currentModalArtists, isInitialLoad);
renderArtistsInModal(currentModalArtists);
} else {
$('#modal-artist-list').html(
'<div class="modal-empty">加载艺人列表失败,请重试</div>'
......@@ -760,9 +792,8 @@
/**
* 渲染搜索结果列表
* @param {Array} artists
* @param {boolean} isInitialLoad
*/
function renderArtistsInModal(artists, isInitialLoad) {
function renderArtistsInModal(artists) {
const listContainer = $('#modal-artist-list');
if (!artists || artists.length === 0) {
......@@ -771,14 +802,6 @@
return;
}
// 首次加载时,从后端的 associated 字段初始化已选列表,并按 sort 降序排列(sort 越大越靠前)
if (isInitialLoad) {
selectedArtists = artists
.filter(a => a.associated)
.map(a => ({ artistId: a.artistId, artistName: a.artistName, avatarUrl: a.avatarUrl, sort: a.sort || 0 }))
.sort((a, b) => b.sort - a.sort);
}
let html = '';
artists.forEach(function (artist) {
const isSelected = selectedArtists.some(a => a.artistId === artist.artistId);
......
......@@ -14,10 +14,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.HashMap;
import java.util.stream.Collectors;
import com.liquidnet.service.kylin.service.admin.IKylinArtistOperationLogService;
......@@ -79,6 +79,7 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
// 删除缓存演出阵容
dataUtils.delPerformanceArtists(performanceId);
dataUtils.delArtistPerformancesCache(artistId);
int result = artistPerformanceMapper.deleteById(mid);
// 记录删除后的关联数量
......@@ -95,8 +96,9 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
@Override
public List<KylinArtistAssociationStatusDto> getAllArtists(String performancesId, String timesId, String keyword) {
// 1. 获取所有艺人
// 1. 可选艺人:仅启用中(已逻辑删除的不出现在选艺人列表;已绑定展示走 getSessionArtists)
List<KylinArtist> allArtists = artistMapper.selectList(new QueryWrapper<KylinArtist>()
.eq("status", 1)
.like(keyword != null && !keyword.isEmpty(), "artist_name", keyword)
.orderByDesc("created_at"));
......@@ -108,7 +110,7 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
.collect(Collectors.toMap(
KylinArtistPerformanceDao::getArtistId,
KylinArtistPerformanceDao::getSort,
(existing, replacement) -> existing // 重复 key 保留已有值
(existing, replacement) -> existing
));
// 3. 组装返回结果
......@@ -190,6 +192,9 @@ public class KylinArtistPerformanceServiceImpl extends ServiceImpl<KylinArtistPe
// 删除缓存演出阵容
dataUtils.delPerformanceArtists(performancesId);
for (String artistId : affectedArtistIds) {
dataUtils.delArtistPerformancesCache(artistId);
}
return true;
}
}
package com.liquidnet.client.admin.zhengzai.kylin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liquidnet.client.admin.zhengzai.goblin.utils.GoblinRedisUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.SweetArtistCacheUtils;
import com.liquidnet.commons.lang.util.BeanUtil;
......@@ -13,9 +16,15 @@ import com.liquidnet.service.kylin.dao.KylinArtistDao;
import com.liquidnet.service.kylin.dao.KylinArtistPerformanceDao;
import com.liquidnet.service.kylin.dto.param.ArtistParam;
import com.liquidnet.service.kylin.dto.param.ArtistSearchParam;
import com.liquidnet.service.kylin.dto.vo.ArtistGoodsOptionVo;
import com.liquidnet.service.kylin.dto.vo.ArtistVo;
import com.liquidnet.service.kylin.entity.KylinArtist;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.mapper.GoblinGoodsMapper;
import com.liquidnet.service.kylin.entity.KylinArtistAlbum;
import com.liquidnet.service.kylin.entity.KylinArtistProduct;
import com.liquidnet.service.kylin.mapper.KylinArtistProductMapper;
import com.liquidnet.service.kylin.mapper.KylinArtistAlbumMapper;
import com.liquidnet.service.kylin.mapper.KylinArtistMapper;
import com.liquidnet.service.kylin.mapper.KylinArtistPerformanceMapper;
......@@ -28,7 +37,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -51,6 +62,9 @@ public class KylinArtistServiceImpl extends ServiceImpl<KylinArtistMapper, Kylin
@Autowired
private KylinArtistAlbumMapper artistAlbumMapper;
@Autowired
private KylinArtistProductMapper artistProductMapper;
@Autowired
private KylinArtistPerformanceMapper artistPerformanceMapper;
......@@ -63,6 +77,12 @@ public class KylinArtistServiceImpl extends ServiceImpl<KylinArtistMapper, Kylin
@Autowired
private SweetArtistCacheUtils sweetArtistCacheUtils;
@Autowired
private GoblinRedisUtils goblinRedisUtils;
@Autowired
private GoblinGoodsMapper goblinGoodsMapper;
/**
* 创建艺人
*/
......@@ -152,6 +172,7 @@ public class KylinArtistServiceImpl extends ServiceImpl<KylinArtistMapper, Kylin
}
}
sweetArtistCacheUtils.invalidateByArtistId(artistId);
dataUtils.delArtistDetailAndAlbumCache(artistId);
return true;
} catch (Exception e) {
log.error("修改艺人失败", e);
......@@ -277,31 +298,16 @@ public class KylinArtistServiceImpl extends ServiceImpl<KylinArtistMapper, Kylin
new UpdateWrapper<KylinArtist>().in("artist_id", artistIds)
);
// 删除相册图片并记录日志
// 逻辑删除艺人,保留相册/商品/演出关联等历史数据;关联与展示内容未变,缓存自然过期即可
for (String artistId : artistIds) {
// 获取艺人信息用于日志
KylinArtist artist = artistMapper.selectOne(
new UpdateWrapper<KylinArtist>().eq("artist_id", artistId)
);
artistAlbumMapper.deleteByArtistId(artistId);
// 记录删除日志
String logContent = "删除艺人:" + (artist != null ? artist.getArtistName() + "(ID:" + artistId + ")" : artistId);
operationLogService.recordLog(artistId, 3, logContent);
}
// 根据艺人ID查询所有关联的演出
List<String> performanceIdList = artistPerformanceMapper.selectPerformanceIdsByArtistIds(artistIds);
if (!performanceIdList.isEmpty()) {
for (String p : performanceIdList) {
dataUtils.delPerformanceArtists(p);
}
}
for (String artistId : artistIds) {
sweetArtistCacheUtils.invalidateByArtistId(artistId);
}
return true;
} catch (Exception e) {
log.error("删除艺人失败", e);
......@@ -309,6 +315,142 @@ public class KylinArtistServiceImpl extends ServiceImpl<KylinArtistMapper, Kylin
}
}
@Override
public List<ArtistVo.ProductVo> listArtistProducts(String artistId) {
KylinArtist artist = artistMapper.selectOne(
new UpdateWrapper<KylinArtist>().eq("artist_id", artistId).eq("status", 1)
);
if (artist == null) {
return Collections.emptyList();
}
List<KylinArtistProduct> productRelations = artistProductMapper.selectByArtistId(artistId);
if (productRelations == null || productRelations.isEmpty()) {
return Collections.emptyList();
}
List<ArtistVo.ProductVo> productVoList = new ArrayList<>();
for (KylinArtistProduct relation : productRelations) {
ArtistVo.ProductVo productVo = buildProductVo(relation.getSpuId());
if (productVo != null) {
productVoList.add(productVo);
}
}
return productVoList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveArtistProducts(String artistId, List<String> spuIds) {
KylinArtist artist = artistMapper.selectOne(
new UpdateWrapper<KylinArtist>().eq("artist_id", artistId).eq("status", 1)
);
if (artist == null) {
return false;
}
List<String> normalizedSpuIds = spuIds == null ? Collections.emptyList() : spuIds;
String productError = validateProductSpuIds(normalizedSpuIds);
if (productError != null) {
throw new IllegalArgumentException(productError);
}
artistProductMapper.deleteByArtistId(artistId);
if (!normalizedSpuIds.isEmpty()) {
saveProductRelations(artistId, normalizedSpuIds);
}
operationLogService.recordLog(artistId, 2, "更新了艺人关联商品");
dataUtils.delArtistProductsCache(artistId);
return true;
}
@Override
public List<ArtistGoodsOptionVo> searchGoods(String keyword) {
LambdaQueryWrapper<GoblinGoods> query = Wrappers.lambdaQuery(GoblinGoods.class)
.ne(GoblinGoods::getDelFlg, "1")
.orderByDesc(GoblinGoods::getMid)
.last("LIMIT 50");
if (keyword != null && !keyword.trim().isEmpty()) {
query.like(GoblinGoods::getName, keyword.trim());
}
List<GoblinGoods> goodsList = goblinGoodsMapper.selectList(query);
List<ArtistGoodsOptionVo> result = new ArrayList<>();
for (GoblinGoods goods : goodsList) {
result.add(buildGoodsOption(goods));
}
return result;
}
@Override
public String validateProductSpuIds(List<String> spuIds) {
if (spuIds == null || spuIds.isEmpty()) {
return null;
}
LinkedHashSet<String> uniqueIds = new LinkedHashSet<>();
for (String spuId : spuIds) {
if (spuId != null && !spuId.trim().isEmpty()) {
uniqueIds.add(spuId.trim());
}
}
List<String> invalidIds = new ArrayList<>();
for (String spuId : uniqueIds) {
if (!isProductExists(spuId)) {
invalidIds.add(spuId);
}
}
if (invalidIds.isEmpty()) {
return null;
}
return "以下商品不存在或已删除:" + String.join("、", invalidIds);
}
private boolean isProductExists(String spuId) {
GoblinGoodsInfoVo goods = goblinRedisUtils.getGoodsInfoVo(spuId);
if (goods != null && "0".equals(goods.getDelFlg())) {
return true;
}
Integer count = goblinGoodsMapper.selectCount(
Wrappers.lambdaQuery(GoblinGoods.class)
.eq(GoblinGoods::getSpuId, spuId)
.ne(GoblinGoods::getDelFlg, "1")
);
return count != null && count > 0;
}
private ArtistGoodsOptionVo buildGoodsOption(GoblinGoods goods) {
ArtistGoodsOptionVo vo = new ArtistGoodsOptionVo();
vo.setSpuId(goods.getSpuId());
vo.setSpuNo(goods.getSpuNo());
vo.setName(goods.getName());
vo.setCoverPic(goods.getCoverPic());
GoblinGoodsInfoVo cache = goblinRedisUtils.getGoodsInfoVo(goods.getSpuId());
if (cache != null) {
vo.setSellPrice(cache.getSellPrice());
vo.setShelfStatusLabel(resolveShelfStatusLabel(cache.getShelvesStatus(), cache.getDelFlg()));
vo.setSelectable("0".equals(cache.getDelFlg()));
} else {
vo.setSellPrice(goods.getSellPrice());
vo.setShelfStatusLabel(resolveShelfStatusLabel(goods.getShelvesStatus(), goods.getDelFlg()));
vo.setSelectable(!"1".equals(goods.getDelFlg()));
}
if (vo.getSelectable() == null) {
vo.setSelectable(true);
}
return vo;
}
private String resolveShelfStatusLabel(String shelvesStatus, String delFlg) {
if (!"0".equals(delFlg)) {
return "已删除";
}
if ("3".equals(shelvesStatus)) {
return "已上架";
}
if ("0".equals(shelvesStatus)) {
return "待上架";
}
if ("1".equals(shelvesStatus)) {
return "未上架";
}
return "不可售";
}
/**
* 检查艺人名称是否存在
*/
......@@ -345,6 +487,50 @@ public class KylinArtistServiceImpl extends ServiceImpl<KylinArtistMapper, Kylin
}
}
private void saveProductRelations(String artistId, List<String> spuIds) {
LocalDateTime now = LocalDateTime.now();
int sort = spuIds.size();
for (String spuId : spuIds) {
if (spuId == null || spuId.trim().isEmpty()) {
continue;
}
KylinArtistProduct product = KylinArtistProduct.getNew();
product.setRelationId(IDGenerator.nextSnowId());
product.setArtistId(artistId);
product.setSpuId(spuId.trim());
product.setSort(sort--);
product.setStatus(1);
product.setCreatedAt(now);
product.setUpdatedAt(now);
artistProductMapper.insert(product);
}
}
private ArtistVo.ProductVo buildProductVo(String spuId) {
GoblinGoodsInfoVo goods = goblinRedisUtils.getGoodsInfoVo(spuId);
if (goods == null) {
ArtistVo.ProductVo vo = new ArtistVo.ProductVo();
vo.setSpuId(spuId);
vo.setProductCode(spuId);
vo.setProductName("商品不存在或缓存未命中");
vo.setStatus(0);
return vo;
}
ArtistVo.ProductVo vo = new ArtistVo.ProductVo();
vo.setSpuId(goods.getSpuId());
vo.setProductCode(goods.getSpuNo() != null ? goods.getSpuNo() : goods.getSpuId());
vo.setProductName(goods.getName());
vo.setImageUrl(goods.getCoverPic());
vo.setCategory(goods.getStoreName() != null ? goods.getStoreName() : "--");
if (goods.getSellPrice() != null) {
vo.setPrice(goods.getSellPrice().toPlainString() + "元");
} else {
vo.setPrice("--");
}
vo.setStatus("3".equals(goods.getShelvesStatus()) ? 1 : 0);
return vo;
}
/**
* 构建新增操作的日志内容
*/
......
......@@ -631,4 +631,39 @@ public class DataUtils {
final String redisKey = KylinRedisConst.PERFORMANCES_ARTISTS + performancesId;
redisDataSourceUtil.getRedisKylinUtil().del(redisKey);
}
/**
* 删除艺人 C 端缓存(详情/相册/演出/商品)
*/
public void delArtistCache(String artistId) {
if (artistId == null || artistId.isEmpty()) {
return;
}
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_DETAIL + artistId);
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_ALBUM + artistId);
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_PERFORMANCES + artistId);
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_PRODUCTS + artistId);
}
public void delArtistDetailAndAlbumCache(String artistId) {
if (artistId == null || artistId.isEmpty()) {
return;
}
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_DETAIL + artistId);
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_ALBUM + artistId);
}
public void delArtistPerformancesCache(String artistId) {
if (artistId == null || artistId.isEmpty()) {
return;
}
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_PERFORMANCES + artistId);
}
public void delArtistProductsCache(String artistId) {
if (artistId == null || artistId.isEmpty()) {
return;
}
redisDataSourceUtil.getRedisKylinUtil().del(KylinRedisConst.ARTIST_PRODUCTS + artistId);
}
}
......@@ -57,6 +57,9 @@ public class RedisKeyExpireConst {
// 演出关联阵容缓存过期时间
public static final long PERFORMANCES_ARTISTS_EXPIRE = 30 * 24 * 60 * 60;
// C端艺人详情相关缓存过期时间
public static final long ARTIST_FRONT_CACHE_EXPIRE = 30 * 24 * 60 * 60;
/**
* 演出关联收钱吧商品缓存过期时间 (30天)
*/
......
......@@ -19,7 +19,7 @@
a.introduction,
a.created_at,
(SELECT COUNT(1) FROM kylin_artist_performance ap WHERE ap.artist_id = a.artist_id) as performance_count,
0 as product_count
(SELECT COUNT(1) FROM kylin_artist_product ap2 WHERE ap2.artist_id = a.artist_id AND ap2.status = 1) as product_count
FROM kylin_artist a
<where>
a.status = 1
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.kylin.mapper.KylinArtistProductMapper">
<select id="selectByArtistId" parameterType="java.lang.String"
resultType="com.liquidnet.service.kylin.entity.KylinArtistProduct">
SELECT mid, relation_id, artist_id, spu_id, sort, status, created_at, updated_at
FROM kylin_artist_product
WHERE artist_id = #{artistId} AND status = 1
ORDER BY sort DESC, mid DESC
</select>
<update id="deleteByArtistId" parameterType="java.lang.String">
UPDATE kylin_artist_product
SET status = 0, updated_at = NOW()
WHERE artist_id = #{artistId}
</update>
</mapper>
......@@ -1782,4 +1782,23 @@ public class DataUtils {
final String redisKey = KylinRedisConst.PERFORMANCES_ARTISTS + performancesId;
redisUtil.set(redisKey, artistLineupVos, RedisKeyExpireConst.PERFORMANCES_ARTISTS_EXPIRE);
}
public void delArtistCache(String artistId) {
if (artistId == null || artistId.isEmpty()) {
return;
}
redisUtil.del(KylinRedisConst.ARTIST_DETAIL + artistId);
redisUtil.del(KylinRedisConst.ARTIST_ALBUM + artistId);
redisUtil.del(KylinRedisConst.ARTIST_PERFORMANCES + artistId);
redisUtil.del(KylinRedisConst.ARTIST_PRODUCTS + artistId);
}
@SuppressWarnings("unchecked")
public <T> T getArtistFrontCache(String redisKey) {
return (T) redisUtil.get(redisKey);
}
public void setArtistFrontCache(String redisKey, Object value) {
redisUtil.set(redisKey, value, RedisKeyExpireConst.ARTIST_FRONT_CACHE_EXPIRE);
}
}
......@@ -76,7 +76,6 @@ public class SweetArtistsServiceImpl extends ServiceImpl<SweetArtistsMapper, Swe
KylinArtist kylinArtist = kylinArtistMapper.selectOne(
Wrappers.lambdaQuery(KylinArtist.class)
.eq(KylinArtist::getArtistId, artistsId)
.eq(KylinArtist::getStatus, 1)
);
if (kylinArtist == null) {
return ResponseDto.failure();
......
......@@ -408,7 +408,7 @@ public class RedisDataUtils {
public SweetArtists setArtistsDetails(String artistsId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_ARTISTS_DETAILS.concat(artistsId);
KylinArtist kylinArtist = kylinArtistMapper.selectOne(
Wrappers.lambdaQuery(KylinArtist.class).eq(KylinArtist::getArtistId, artistsId).eq(KylinArtist::getStatus, 1)
Wrappers.lambdaQuery(KylinArtist.class).eq(KylinArtist::getArtistId, artistsId)
);
SweetArtists sweetArtists = null;
if (kylinArtist != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment