Compare commits
No commits in common. "382f32de5f560cac8dbdf566acc55e8cf3ac9065" and "2b791a875a10e8314ba77ff07673ce60dfeaf1bc" have entirely different histories.
382f32de5f
...
2b791a875a
|
@ -162,7 +162,6 @@ public class MallProductController extends BaseController {
|
|||
* @param isTop
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "设置模型置顶状态")
|
||||
@PutMapping("/{id}/top")
|
||||
public ResponseEntity<ModelProduct> setModelTop(@PathVariable Long id, @RequestParam boolean isTop) {
|
||||
try {
|
||||
|
@ -178,7 +177,6 @@ public class MallProductController extends BaseController {
|
|||
* 获取置顶的模型列表
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取置顶的模型列表")
|
||||
@GetMapping
|
||||
public ResponseEntity<List<ModelProduct>> fetchModelsSortedByTopStatus() {
|
||||
List<ModelProduct> models = modelService.fetchModelsSortedByTopStatus();
|
||||
|
|
|
@ -105,13 +105,6 @@ public class ModelImageController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置图片置顶
|
||||
* @param id
|
||||
* @param isTop
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "设置图片置顶状态")
|
||||
@PutMapping("/{id}/top")
|
||||
public ResponseEntity<ModelImage> setModelImageTop(@PathVariable Long id, @RequestParam boolean isTop) {
|
||||
try {
|
||||
|
@ -124,10 +117,9 @@ public class ModelImageController {
|
|||
|
||||
|
||||
/**
|
||||
* 获取置顶的图片列表
|
||||
* 获取置顶的模型列表
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取置顶的图片列表")
|
||||
@GetMapping
|
||||
public ResponseEntity<List<ModelImage>> fetchModelImagesSortedByTopStatus() {
|
||||
List<ModelImage> models = modelImageLikeService.fetchModelImageSortedByTopStatus();
|
||||
|
|
|
@ -43,7 +43,6 @@ public class WorkFlowController extends BaseController {
|
|||
* @param isTop
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "设置工作流的置顶状态")
|
||||
@PutMapping("/{id}/top")
|
||||
public ResponseEntity<WorkFlow> setworkFlowTop(@PathVariable Long id, @RequestParam boolean isTop) {
|
||||
try {
|
||||
|
@ -59,7 +58,6 @@ public class WorkFlowController extends BaseController {
|
|||
* 获取所有工作流,按照置顶状态排序
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取置顶的模型列表")
|
||||
@GetMapping
|
||||
public ResponseEntity<List<WorkFlow>> fetchWorkFlowSortedByTopStatus() {
|
||||
List<WorkFlow> models = workFlowService.fetchWorkFlowSortedByTopStatus();
|
||||
|
|
|
@ -130,6 +130,11 @@ public class ModelProduct extends BaseEntity {
|
|||
@ApiModelProperty(value = "是否置顶")
|
||||
private Integer isTop;
|
||||
|
||||
/**
|
||||
* 审核(1公开 2自见)
|
||||
*/
|
||||
@ApiModelProperty(value = "审核(1公开 2自见)")
|
||||
private Integer jurisdiction;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
|
|
|
@ -21,6 +21,4 @@ public interface WorkFlowMapper extends BaseMapper<WorkFlow> {
|
|||
List<WorkFlow> fetchWorkFlowSortedByTopStatus();
|
||||
|
||||
|
||||
void setworkFlowTop(Long id, int i);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,409 +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 id 模型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);
|
||||
|
||||
}
|
||||
private void audit(RequestModel requestModel) {
|
||||
|
||||
// 执行审核操作
|
||||
threadPoolTaskExecutor.submit(() -> {
|
||||
ModelProduct modelProduct = requestModel.getModelProduct();
|
||||
|
||||
if (modelProduct != null){
|
||||
|
||||
if (modelProduct.getModelName() != null){
|
||||
|
||||
//审核名称
|
||||
String s = BaiduCensor.TextCensor(modelProduct.getModelName()+","+modelProduct.getTags());
|
||||
// 解析 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);
|
||||
modelProduct.setAuditText(concatenatedReasons);
|
||||
|
||||
//修改状态以及失败原因
|
||||
modelProduct.setAuditStatus(4);
|
||||
baseMapper.updateById(modelProduct);
|
||||
log.info("模型审核未通过");
|
||||
//结束任务
|
||||
return;
|
||||
}
|
||||
|
||||
//修改为合格
|
||||
modelProduct.setAuditText("");
|
||||
modelProduct.setAuditStatus(modelProduct.getJurisdiction());
|
||||
baseMapper.updateById(modelProduct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<ModelVersion> modelVersionList = requestModel.getModelVersionList();
|
||||
|
||||
if (modelVersionList != null){
|
||||
//审核版本
|
||||
for (ModelVersion modelVersion : modelVersionList) {
|
||||
modelVersion.setModelId(modelProduct.getId());
|
||||
//版本名称
|
||||
String s1 = BaiduCensor.TextCensor(modelVersion.getVersionName() + "," +
|
||||
modelVersion.getVersionDescription()+","+modelVersion.getTriggerWords());
|
||||
// 解析 JSON 字符串
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(s1);
|
||||
// 获取 'conclusion' 字段的值
|
||||
String conclusion1 = jsonObject1.getString("conclusion");
|
||||
if (conclusion1.equals("不合规")) {
|
||||
|
||||
//更改版本状态->跳出循环 审核下一个版本
|
||||
// 获取 'data' 数组
|
||||
JSONArray dataArray1 = jsonObject1.getJSONArray("data");
|
||||
// 存储所有的失败原因
|
||||
List<String> failureReasons = new ArrayList<>();
|
||||
// 遍历 'data' 数组中的每个元素
|
||||
for (Object itemObj : dataArray1) {
|
||||
JSONObject item = (JSONObject) itemObj;
|
||||
String msg = item.getString("msg");
|
||||
failureReasons.add(msg);
|
||||
}
|
||||
// 使用逗号拼接所有的失败原因
|
||||
String concatenatedReasons = String.join(", ", failureReasons);
|
||||
modelVersion.setAuditText(concatenatedReasons);
|
||||
modelVersion.setAuditStatus(4);
|
||||
//校验id是否存在 区别修改审核或者新增审核
|
||||
if (modelVersion.getId() != null){
|
||||
modelVersionMapper.updateById(modelVersion);
|
||||
}else {
|
||||
modelVersionMapper.updateByName(modelVersion);
|
||||
}
|
||||
log.info("版本审核未通过");
|
||||
continue;
|
||||
}
|
||||
|
||||
//审核版本图片
|
||||
String[] split = modelVersion.getFilePath().split(",");
|
||||
for (String path : split) {
|
||||
String s2 = BaiduCensor.ImageCnesor(path);
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(s2);
|
||||
if (jsonObject2.getString("conclusion").equals("不合规")) {
|
||||
|
||||
//修改状态->跳出循环 判断下一个版本
|
||||
// 获取 'data' 数组
|
||||
JSONArray dataArray2 = jsonObject2.getJSONArray("data");
|
||||
// 存储所有的失败原因
|
||||
List<String> failureReasons = new ArrayList<>();
|
||||
// 遍历 'data' 数组中的每个元素
|
||||
for (Object itemObj : dataArray2) {
|
||||
JSONObject item = (JSONObject) itemObj;
|
||||
String msg = item.getString("msg");
|
||||
failureReasons.add(msg);
|
||||
}
|
||||
// 使用逗号拼接所有的失败原因
|
||||
String concatenatedReasons = String.join(", ", failureReasons);
|
||||
modelVersion.setAuditText(concatenatedReasons);
|
||||
modelVersion.setAuditStatus(4);
|
||||
//校验id是否存在 区别修改审核或者新增审核
|
||||
if (modelVersion.getId() != null){
|
||||
modelVersionMapper.updateById(modelVersion);
|
||||
}else {
|
||||
modelVersionMapper.updateByName(modelVersion);
|
||||
}
|
||||
modelVersionMapper.updateByName(modelVersion);
|
||||
log.info("图片审核未通过");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//修改版本成功审核状态
|
||||
modelProduct.setAuditText("");
|
||||
modelVersion.setAuditStatus(1);
|
||||
modelVersionMapper.updateByName(modelVersion);
|
||||
log.info("全部通过审核");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -31,10 +31,6 @@
|
|||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
<update id="setworkFlowTop">
|
||||
UPDATE work_flow SET is_top = #{isTop} WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="fetchWorkFlowSortedByTopStatus" resultType="com.mcwl.resource.domain.WorkFlow">
|
||||
SELECT is_top FROM work_flow ORDER BY is_top DESC;
|
||||
</select>
|
||||
|
|
Loading…
Reference in New Issue