合并分支 图片审核+模型审核待合并
parent
cb5af5202f
commit
2b791a875a
|
@ -1,8 +1,6 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -13,11 +11,7 @@ import com.mcwl.common.core.domain.entity.SysUser;
|
|||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.common.utils.baidu.BaiduCensor;
|
||||
import com.mcwl.resource.domain.ModelImage;
|
||||
import com.mcwl.resource.domain.ModelImageComment;
|
||||
import com.mcwl.resource.domain.ModelProduct;
|
||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||
import com.mcwl.resource.domain.dto.ModelImageRes;
|
||||
import com.mcwl.resource.domain.vo.ModelImageVo;
|
||||
|
@ -28,16 +22,12 @@ import com.mcwl.system.init.DictInit;
|
|||
import com.mcwl.system.service.ISysDictDataService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelImage> implements ModelImageService {
|
||||
|
@ -50,8 +40,6 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
|||
|
||||
private final ISysDictDataService sysDictDataService;
|
||||
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -73,42 +61,6 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
|||
modelImage.setStatus(3);
|
||||
modelImageMapper.insert(modelImage);
|
||||
|
||||
audit(modelImage);
|
||||
}
|
||||
|
||||
private void audit(ModelImage modelImage) {
|
||||
|
||||
// 执行审核操作
|
||||
threadPoolTaskExecutor.submit(() -> {
|
||||
if (modelImage != null) {
|
||||
|
||||
if (modelImage.getTitle() != null) {
|
||||
|
||||
//审核名称
|
||||
String s = BaiduCensor.TextCensor(modelImage.getTitle() + "," + modelImage.getTags() + ","
|
||||
+ modelImage.getDescription());
|
||||
// 解析 JSON 字符串
|
||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
// 获取 'conclusion' 字段的值
|
||||
String conclusion = jsonObject.getString("conclusion");
|
||||
|
||||
if (conclusion.equals("不合规")) {
|
||||
|
||||
//更改状态,添加原因 -> 结束任务
|
||||
// 获取 'data' 数组
|
||||
JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||
|
||||
// 存储所有的失败原因
|
||||
List<String> failureReasons = new ArrayList<>();
|
||||
// 遍历 'data' 数组中的每个元素
|
||||
for (Object itemObj : dataArray) {
|
||||
JSONObject item = (JSONObject) itemObj;
|
||||
String msg = item.getString("msg");
|
||||
failureReasons.add(msg);
|
||||
}
|
||||
// 使用逗号拼接所有的失败原因
|
||||
String concatenatedReasons = String.join(", ", failureReasons);
|
||||
modelImage.setAuditText(concatenatedReasons);
|
||||
|
||||
}
|
||||
|
||||
|
@ -196,5 +148,4 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,272 +0,0 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.constant.DictConstants;
|
||||
import com.mcwl.common.constant.HttpStatus;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.common.core.redis.RedisCache;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.common.utils.baidu.BaiduCensor;
|
||||
import com.mcwl.resource.domain.ModelProduct;
|
||||
import com.mcwl.resource.domain.ModelVersion;
|
||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||
import com.mcwl.resource.domain.request.RequestModel;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
import com.mcwl.resource.domain.vo.ModelVo;
|
||||
import com.mcwl.resource.mapper.ModelMapper;
|
||||
import com.mcwl.resource.mapper.ModelVersionMapper;
|
||||
import com.mcwl.resource.service.ModelService;
|
||||
import com.mcwl.resource.service.ToActivityService;
|
||||
import com.mcwl.system.init.DictInit;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**模型 业务实现层
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.resource.service.impl
|
||||
* @Filename:MallProductServiceImpl
|
||||
* @Description TODO
|
||||
* @Date:2024/12/30 18:22
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> implements ModelService {
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private ToActivityService toActivityService;
|
||||
@Autowired
|
||||
private ModelVersionMapper modelVersionMapper;
|
||||
@Autowired
|
||||
private ModelMapper postMapper;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
/**
|
||||
* 设置模型置顶状态
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @param isTop 是否置顶
|
||||
*/
|
||||
@Override
|
||||
public void setModelTop(Long id, boolean isTop) {
|
||||
postMapper.updateTopStatus(id, isTop ? 1 : 0);
|
||||
}
|
||||
/**
|
||||
* 获取模型列表
|
||||
*
|
||||
* @param
|
||||
* @return 模型列表
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<ModelProduct> fetchModelsSortedByTopStatus() {
|
||||
return postMapper.selectAllModelsSortedByTopStatus();
|
||||
}
|
||||
@Override
|
||||
public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) {
|
||||
|
||||
// 创建分页对象
|
||||
Page<ModelProduct> mallProductPage = new Page<>(mallProductVo.getPageNumber(), mallProductVo.getPageSize());
|
||||
|
||||
//获取当前登录人ID
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
LambdaQueryWrapper<ModelProduct> mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
mallProductLambdaQueryWrapper.eq(ModelProduct::getUserId,userId);
|
||||
mallProductLambdaQueryWrapper.eq(ModelProduct::getDelFlag,0);
|
||||
|
||||
// 开始时间和结束时间过滤
|
||||
if (mallProductVo.getStartTime() != null && mallProductVo.getEndTime() != null) {
|
||||
// 查询开始时间和结束时间之间的商品
|
||||
mallProductLambdaQueryWrapper.between(ModelProduct::getCreateTime, mallProductVo.getStartTime(), mallProductVo.getEndTime());
|
||||
} else if (mallProductVo.getStartTime() != null) {
|
||||
// 只有开始时间,查询大于等于开始时间的商品
|
||||
mallProductLambdaQueryWrapper.ge(ModelProduct::getCreateTime, mallProductVo.getStartTime());
|
||||
} else if (mallProductVo.getEndTime() != null) {
|
||||
// 只有结束时间,查询小于等于结束时间的商品
|
||||
mallProductLambdaQueryWrapper.le(ModelProduct::getCreateTime, mallProductVo.getEndTime());
|
||||
}
|
||||
|
||||
return postMapper.selectPage(mallProductPage, mallProductLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ModelProduct> pageLike(MallProductVo mallProductVo, List<Long> list) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param imagePageRes 分页参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo listByPage(ModelImagePageRes imagePageRes) {
|
||||
|
||||
Page<ModelProduct> page = new Page<>(imagePageRes.getPageNum(), imagePageRes.getPageSize());
|
||||
if (StringUtils.isEmpty(imagePageRes.getOrderByColumn())) {
|
||||
imagePageRes.setOrderByColumn("create_time");
|
||||
}
|
||||
// 设置排序
|
||||
boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc");
|
||||
OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc);
|
||||
page.addOrder(orderItem);
|
||||
|
||||
LambdaQueryWrapper<ModelProduct> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(imagePageRes.getStatus() != null, ModelProduct::getAuditStatus, imagePageRes.getStatus())
|
||||
.eq(imagePageRes.getUserId() != null, ModelProduct::getUserId, imagePageRes.getUserId())
|
||||
.ge(imagePageRes.getStartTime() != null, ModelProduct::getCreateTime, imagePageRes.getStartTime())
|
||||
.le(imagePageRes.getEndTime() != null, ModelProduct::getCreateTime, imagePageRes.getEndTime());
|
||||
|
||||
postMapper.selectPage(page, lqw);
|
||||
// 获取分页数据
|
||||
List<ModelProduct> modelImageList = page.getRecords();
|
||||
|
||||
// Model数据转为ModelPageVo
|
||||
List<ModelVo> modelVoList = new ArrayList<>();
|
||||
for (ModelProduct modelImage : modelImageList) {
|
||||
ModelVo modelVo = new ModelVo();
|
||||
BeanUtil.copyProperties(modelImage, modelVo);
|
||||
// 获取用户信息
|
||||
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
||||
modelVo.setUserId(sysUser.getUserId());
|
||||
modelVo.setUserName(sysUser.getUserName());
|
||||
modelVo.setUserAvatar(sysUser.getAvatar());
|
||||
modelVoList.add(modelVo);
|
||||
}
|
||||
|
||||
// 封装分页数据
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(modelVoList);
|
||||
rspData.setTotal(page.getTotal());
|
||||
|
||||
return rspData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult addModel(RequestModel requestModel) {
|
||||
//获取封面图
|
||||
String filePath = requestModel.getModelVersionList().get(0).getFilePath();
|
||||
String[] split = filePath.split(",");
|
||||
ModelProduct modelProduct = requestModel.getModelProduct();
|
||||
modelProduct.setSurfaceUrl(split[0]);
|
||||
modelProduct.setCreateTime(new Date());
|
||||
|
||||
|
||||
//添加模型表数据
|
||||
postMapper.insert(requestModel.getModelProduct());
|
||||
|
||||
log.info("获取到的入参:{}",requestModel.getModelProduct());
|
||||
|
||||
//批量添加版本
|
||||
modelVersionMapper.addModelVersion(requestModel.getModelProduct(),requestModel.getModelVersionList());
|
||||
|
||||
//执行审核方法
|
||||
audit(requestModel);
|
||||
|
||||
return AjaxResult.success("添加成功,等待审核");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updaModel(RequestModel requestModel) {
|
||||
//修改模版的信息
|
||||
ModelProduct modelProduct = requestModel.getModelProduct();
|
||||
if (ObjectUtils.isNotEmpty(modelProduct)){
|
||||
|
||||
if (StringUtils.isNotNull(modelProduct.getId())){
|
||||
modelProduct.setAuditStatus(3);
|
||||
modelProduct.setUpdateTime(new Date());
|
||||
postMapper.updateById(requestModel.getModelProduct());
|
||||
}
|
||||
}
|
||||
|
||||
//修改工作流版本的信息
|
||||
if (requestModel.getModelVersionList().size() != 0){
|
||||
|
||||
//批量修改
|
||||
for (ModelVersion modelVersion : requestModel.getModelVersionList()) {
|
||||
modelVersion.setAuditStatus(3);
|
||||
modelVersionMapper.updateById(modelVersion);
|
||||
}
|
||||
|
||||
ModelProduct model = ModelProduct.builder().
|
||||
id(requestModel.getModelVersionList().get(0).
|
||||
getModelId()).build();
|
||||
model.setUpdateTime(new Date());
|
||||
postMapper.updateById(model);
|
||||
}
|
||||
|
||||
//审核
|
||||
audit(requestModel);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult selectModelById(Long id) {
|
||||
//查询详情
|
||||
ModelProduct modelProduct = postMapper.selectById(id);
|
||||
|
||||
//翻译属性 垂类
|
||||
if (StringUtils.isNotEmpty(modelProduct.getCategory())){
|
||||
modelProduct.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY,modelProduct.getCategory()));
|
||||
}
|
||||
|
||||
|
||||
//标签
|
||||
if (StringUtils.isNotEmpty(modelProduct.getTags())){
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
String[] split = modelProduct.getTags().split(",");
|
||||
for (String s : split) {
|
||||
if (s != ""){
|
||||
strings.add(s);
|
||||
}
|
||||
}
|
||||
modelProduct.setStyleList(strings);
|
||||
}
|
||||
|
||||
//功能
|
||||
if (StringUtils.isNotEmpty(modelProduct.getFunctions())){
|
||||
modelProduct.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS,modelProduct.getFunctions()));
|
||||
}
|
||||
|
||||
//活动
|
||||
if (StringUtils.isNotEmpty(modelProduct.getActivityId())){
|
||||
modelProduct.setActivityId(toActivityService.getById(modelProduct.getActivityId()).getActivityName());
|
||||
}
|
||||
|
||||
return AjaxResult.success(modelProduct);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue