feat 是否置顶

master
ChenYan 2025-01-21 16:45:00 +08:00
parent f5f2693e8e
commit d8c964f98b
25 changed files with 246 additions and 121 deletions

View File

@ -5,17 +5,16 @@ import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.communityCenter.domain.dto.CommentDelRes; import com.mcwl.communityCenter.domain.dto.CommentDelRes;
import com.mcwl.communityCenter.domain.dto.CommentDetailRes; import com.mcwl.communityCenter.domain.dto.CommentDetailRes;
import com.mcwl.communityCenter.domain.dto.CommentRes; import com.mcwl.communityCenter.domain.dto.CommentRes;
import com.mcwl.communityCenter.domain.vo.CommentVo;
import com.mcwl.communityCenter.domain.PublishComment;
import com.mcwl.communityCenter.service.PublishCommentService; import com.mcwl.communityCenter.service.PublishCommentService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
/** /**
* *

View File

@ -18,9 +18,12 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* *
@ -152,6 +155,40 @@ public class MallProductController extends BaseController {
return modelService.selectModelById(id); return modelService.selectModelById(id);
} }
/**
*
* @param id
* @param isTop
* @return
*/
@PutMapping("/{id}/top")
public ResponseEntity<ModelProduct> setModelTop(@PathVariable Long id, @RequestParam boolean isTop) {
try {
modelService.setModelTop(id, isTop);
return ResponseEntity.ok().build();
} catch (Exception e) {
return ResponseEntity.badRequest().build();
}
}
/**
*
* @return
*/
@GetMapping
public ResponseEntity<List<ModelProduct>> fetchModelsSortedByTopStatus() {
List<ModelProduct> models = modelService.fetchModelsSortedByTopStatus();
return ResponseEntity.ok(models);
}
/** /**
* - * -
*/ */
@ -219,4 +256,6 @@ public class MallProductController extends BaseController {
} }
} }

View File

@ -8,6 +8,7 @@ import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.dto.ModelImageRes; import com.mcwl.resource.domain.dto.ModelImageRes;
import com.mcwl.resource.domain.vo.ModelImageVo; import com.mcwl.resource.domain.vo.ModelImageVo;
@ -17,9 +18,11 @@ import com.mcwl.system.service.ISysUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -102,5 +105,25 @@ public class ModelImageController {
} }
@PutMapping("/{id}/top")
public ResponseEntity<ModelImage> setModelImageTop(@PathVariable Long id, @RequestParam boolean isTop) {
try {
modelImageLikeService.setModelImageTop(id, isTop);
return ResponseEntity.ok().build();
} catch (Exception e) {
return ResponseEntity.badRequest().build();
}
}
/**
*
* @return
*/
@GetMapping
public ResponseEntity<List<ModelImage>> fetchModelImagesSortedByTopStatus() {
List<ModelImage> models = modelImageLikeService.fetchModelImageSortedByTopStatus();
return ResponseEntity.ok(models);
}
} }

View File

@ -2,6 +2,8 @@ package com.mcwl.web.controller.resource;
import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.request.RequestWorkFlow;
import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.service.impl.WorkFlowServiceImpl; import com.mcwl.resource.service.impl.WorkFlowServiceImpl;
@ -9,9 +11,12 @@ import com.mcwl.web.controller.common.OssUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* *
@ -31,6 +36,36 @@ public class WorkFlowController extends BaseController {
@Autowired @Autowired
private WorkFlowServiceImpl workFlowService; private WorkFlowServiceImpl workFlowService;
/**
*
* @param id
* @param isTop
* @return
*/
@PutMapping("/{id}/top")
public ResponseEntity<WorkFlow> setworkFlowTop(@PathVariable Long id, @RequestParam boolean isTop) {
try {
workFlowService.setworkFlowTop(id, isTop);
return ResponseEntity.ok().build();
} catch (Exception e) {
return ResponseEntity.badRequest().build();
}
}
/**
*
* @return
*/
@GetMapping
public ResponseEntity<List<WorkFlow>> fetchWorkFlowSortedByTopStatus() {
List<WorkFlow> models = workFlowService.fetchWorkFlowSortedByTopStatus();
return ResponseEntity.ok(models);
}
/*** /***
* *
* @param file * @param file

View File

@ -1,53 +0,0 @@
///*
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
// *
// * https://www.mall4j.com/
// *
// * 未经允许,不可做商业用途!
// *
// * 版权所有,侵权必究!
// */
//package com.mcwl.common.i18n;
//
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.i18n.LocaleContextHolder;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Locale;
//import java.util.Objects;
//
///**
// * RequestContextFilter 会传入默认的Locale优先级(-105) 要比RequestContextFilter优先级高
// * @author LGH
// */
//@Slf4j
//@Component
//@Order(-104)
//public class YamiLocaleChangeFilter implements Filter {
//
// public static String ZH_CN = "zh_CN";
// public static String ZH_CN_L = "zh_cn";
//
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
// HttpServletRequest request = (HttpServletRequest) servletRequest;
// HttpServletResponse response = (HttpServletResponse) servletResponse;
//
// String newLocale = request.getHeader("locale");
// if(Objects.equals(newLocale,ZH_CN)||Objects.equals(newLocale,ZH_CN_L)){
// newLocale = "zh";
// }
// if (newLocale != null) {
// String lowerLocale = newLocale.toLowerCase();
// LocaleContextHolder.setLocale(new Locale(lowerLocale));
// }
// filterChain.doFilter(request, response);
// }
//}

View File

@ -1,58 +0,0 @@
///*
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
// *
// * https://www.mall4j.com/
// *
// * 未经允许,不可做商业用途!
// *
// * 版权所有,侵权必究!
// */
//package com.mcwl.common.i18n;
//
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.LocaleResolver;
//import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
//import org.springframework.web.servlet.support.RequestContextUtils;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * @author LGH
// */
//@Component("localeChangeInterceptor")
//@Slf4j
//public class YamiLocaleChangeInterceptor extends LocaleChangeInterceptor {
//
// @Override
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//
// String newLocale = request.getHeader(getParamName());
// if (newLocale != null) {
// LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
// if (localeResolver == null) {
// throw new IllegalStateException(
// "No LocaleResolver found: not in a DispatcherServlet request?");
// }
// try {
// localeResolver.setLocale(request, response, parseLocaleValue(newLocale));
// }
// catch (IllegalArgumentException ex) {
// if (isIgnoreInvalidLocale()) {
// if (logger.isDebugEnabled()) {
// logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage());
// }
// }
// else {
// throw ex;
// }
// }
// }
// // Proceed in any case.
// return true;
// }
//
//}

View File

@ -109,4 +109,11 @@ public class ModelImage extends BaseEntity {
*/ */
@ApiModelProperty(value = "是否置顶") @ApiModelProperty(value = "是否置顶")
private Integer isTop; private Integer isTop;
/**
* 1 2
*/
@ApiModelProperty(value = "审核1公开 2自见")
private Integer jurisdiction;
} }

View File

@ -124,6 +124,19 @@ public class ModelProduct extends BaseEntity {
*/ */
@ApiModelProperty(value = "是否推荐模型") @ApiModelProperty(value = "是否推荐模型")
private Integer isRecommend; private Integer isRecommend;
/**
*
*/
@ApiModelProperty(value = "是否置顶")
private Integer isTop;
/**
* 1 2
*/
@ApiModelProperty(value = "审核1公开 2自见")
private Integer jurisdiction;
/** /**
* 0 2 * 0 2
*/ */

View File

@ -147,6 +147,12 @@ public class WorkFlow {
@ApiModelProperty(value = "审核权限") @ApiModelProperty(value = "审核权限")
private Integer jurisdiction; private Integer jurisdiction;
/**
*
*/
@ApiModelProperty(value = "是否置顶")
private Integer isTop;
/** /**
* *
*/ */

View File

@ -5,7 +5,15 @@ import com.mcwl.resource.domain.ModelImage;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface ModelImageMapper extends BaseMapper<ModelImage> { public interface ModelImageMapper extends BaseMapper<ModelImage> {
Long sumLikeNumber(@Param("userId") Long userId); Long sumLikeNumber(@Param("userId") Long userId);
List<ModelImage> fetchModelImageSortedByTopStatus();
void setModelImageTop(@Param("id") Long id, @Param("isTop") int i);
} }

View File

@ -6,6 +6,8 @@ import com.mcwl.resource.domain.ModelProduct;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @AuthorChenYan * @AuthorChenYan
* @ProjectMcWl * @ProjectMcWl
@ -27,4 +29,11 @@ public interface ModelMapper extends BaseMapper<ModelProduct> {
Long sumLikeNumber(@Param("userId") Long userId); Long sumLikeNumber(@Param("userId") Long userId);
Long sumRunNumber(Long userId); Long sumRunNumber(Long userId);
void updateTopStatus(@Param("id") Long id, @Param("isTop") int i);
List<ModelProduct> selectAllModelsSortedByTopStatus();
} }

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlow;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* *
* @author DaiZibo * @author DaiZibo
@ -16,4 +18,7 @@ public interface WorkFlowMapper extends BaseMapper<WorkFlow> {
void updateWorkFlow(WorkFlow workFlow); void updateWorkFlow(WorkFlow workFlow);
List<WorkFlow> fetchWorkFlowSortedByTopStatus();
} }

View File

@ -4,8 +4,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageLike; import com.mcwl.resource.domain.ModelImageLike;
import java.util.List;
public interface ModelImageLikeService extends IService<ModelImageLike> { public interface ModelImageLikeService extends IService<ModelImageLike> {
void like(Long imageId); void like(Long imageId);
void setModelImageTop(Long id, boolean isTop);
List<ModelImage> fetchModelImageSortedByTopStatus();
} }

View File

@ -39,4 +39,8 @@ public interface ModelImageService extends IService<ModelImage> {
TableDataInfo listByPage(ModelImagePageRes imagePageRes); TableDataInfo listByPage(ModelImagePageRes imagePageRes);
ModelImageVo getDetail(@NotNull(message = "图片id不能为空") Long imageId); ModelImageVo getDetail(@NotNull(message = "图片id不能为空") Long imageId);
} }

View File

@ -36,4 +36,10 @@ public interface ModelService extends IService<ModelProduct> {
AjaxResult selectModelById(Long id); AjaxResult selectModelById(Long id);
void setModelTop(Long id, boolean isTop);
List<ModelProduct> fetchModelsSortedByTopStatus();
} }

View File

@ -8,6 +8,8 @@ import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.request.RequestWorkFlow;
import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.domain.vo.PageVo;
import java.util.List;
/** /**
* *
* @author DaiZibo * @author DaiZibo
@ -29,4 +31,9 @@ public interface WorkFlowService extends IService<WorkFlow> {
TableDataInfo listByPage(ModelImagePageRes imagePageRes); TableDataInfo listByPage(ModelImagePageRes imagePageRes);
void setworkFlowTop(Long id, boolean isTop);
List<WorkFlow> fetchWorkFlowSortedByTopStatus();
} }

View File

@ -46,19 +46,27 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
@Override @Override
public void comment(ModelComment modelComment) { public void comment(ModelComment modelComment) {
Long parentId = modelComment.getParentId(); Long parentId = modelComment.getParentId();
ModelComment mic = modelCommentMapper.selectById(parentId);
if (Objects.nonNull(parentId) && Objects.isNull(mic)) { if (Objects.nonNull(parentId)) {
return; ModelComment mic = modelCommentMapper.selectById(parentId);
if (Objects.isNull(mic)) {
return;
}
} }
modelComment.setUserId(SecurityUtils.getUserId()); modelComment.setUserId(SecurityUtils.getUserId());
modelComment.setCreateBy(SecurityUtils.getUsername()); modelComment.setCreateBy(SecurityUtils.getUsername());
modelComment.setCreateTime(new Date());
modelComment.setUpdateBy(SecurityUtils.getUsername()); modelComment.setUpdateBy(SecurityUtils.getUsername());
modelComment.setUpdateTime(new Date()); modelComment.setUpdateTime(new Date());
modelCommentMapper.insert(modelComment); modelCommentMapper.insert(modelComment);
} }
/**
*
*
* @param imageId id
* @return
*/
@Override @Override
public List<ModelCommentVo> getComment(Long imageId) { public List<ModelCommentVo> getComment(Long imageId) {
List<ModelCommentVo> modelCommentVoList = new ArrayList<>(); List<ModelCommentVo> modelCommentVoList = new ArrayList<>();

View File

@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects; import java.util.Objects;
@Service @Service
@ -58,4 +59,14 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
modelImage.setLikeNum(modelImage.getLikeNum() + 1); modelImage.setLikeNum(modelImage.getLikeNum() + 1);
modelImageMapper.updateById(modelImage); modelImageMapper.updateById(modelImage);
} }
@Override
public void setModelImageTop(Long id, boolean isTop) {
modelImageMapper.setModelImageTop(id,isTop?0:1);
}
@Override
public List<ModelImage> fetchModelImageSortedByTopStatus() {
return modelImageMapper.fetchModelImageSortedByTopStatus();
}
} }

View File

@ -15,6 +15,7 @@ import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageComment; 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.ModelImageCommentRes;
import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.dto.ModelImageRes; import com.mcwl.resource.domain.dto.ModelImageRes;
@ -155,5 +156,4 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
} }
} }

View File

@ -59,7 +59,27 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
@Autowired @Autowired
private ISysUserService sysUserService; private ISysUserService sysUserService;
/**
*
*
* @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 @Override
public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) { public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) {
@ -236,4 +256,6 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
} }
} }

View File

@ -386,5 +386,15 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
} }
@Override
public void setworkFlowTop(Long id, boolean isTop) {
flowMapper.setworkFlowTop(id,isTop?0:1);
}
@Override
public List<WorkFlow> fetchWorkFlowSortedByTopStatus() {
return flowMapper.fetchWorkFlowSortedByTopStatus();
}
} }

View File

@ -3,6 +3,12 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mcwl.resource.mapper.ModelImageMapper"> <mapper namespace="com.mcwl.resource.mapper.ModelImageMapper">
<update id="setModelImageTop">
UPDATE model_image SET is_top = #{isTop} WHERE image_id = #{imageId}
</update>
<update id="fetchModelImageSortedByTopStatus">
SELECT is_top FROM model_image ORDER BY is_top DESC;
</update>
<select id="sumLikeNumber" resultType="java.lang.Long"> <select id="sumLikeNumber" resultType="java.lang.Long">
SELECT sum(like_num)sum FROM model_image where user_id = #{userId} ORDER BY(user_id); SELECT sum(like_num)sum FROM model_image where user_id = #{userId} ORDER BY(user_id);

View File

@ -69,6 +69,9 @@
</set> </set>
where id = #{id} where id = #{id}
</update> </update>
<update id="updateTopStatus">
update model set is_top = #{isTop} where id = #{id}
</update>
<select id="sumNumber" resultType="java.lang.Long"> <select id="sumNumber" resultType="java.lang.Long">
@ -81,5 +84,8 @@
<select id="sumRunNumber" resultType="java.lang.Long"> <select id="sumRunNumber" resultType="java.lang.Long">
SELECT sum(reals)sum FROM model where user_id = #{userId} ORDER BY(user_id); SELECT sum(reals)sum FROM model where user_id = #{userId} ORDER BY(user_id);
</select> </select>
<select id="selectAllModelsSortedByTopStatus" resultType="com.mcwl.resource.domain.ModelProduct">
SELECT is_top FROM model ORDER BY is_top DESC;
</select>
</mapper> </mapper>

View File

@ -31,4 +31,7 @@
</set> </set>
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<select id="fetchWorkFlowSortedByTopStatus" resultType="com.mcwl.resource.domain.WorkFlow">
SELECT is_top FROM work_flow ORDER BY is_top DESC;
</select>
</mapper> </mapper>