|
@@ -1,13 +1,27 @@
|
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.HelpCategoryDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.HelpCategoryModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.HelpCategoryPagingParam;
|
|
|
+import com.chelvc.cloud.vehicle.server.copier.HelpCategoryCopier;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.HelpCategoryMapper;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.HelpCategory;
|
|
|
import com.chelvc.cloud.vehicle.server.service.IHelpCategoryService;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.IHelpService;
|
|
|
+import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
+import com.chelvc.framework.base.util.ResourceUtils;
|
|
|
+import com.chelvc.framework.common.model.Pagination;
|
|
|
+import com.chelvc.framework.common.util.StringUtils;
|
|
|
+import com.chelvc.framework.database.util.PagingUtils;
|
|
|
+import lombok.NonNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -16,12 +30,13 @@ import java.util.List;
|
|
|
* @author liude
|
|
|
* @date 2023-11-08
|
|
|
*/
|
|
|
-@Service
|
|
|
+@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.IHelpCategoryService.class)
|
|
|
@RequiredArgsConstructor(onConstructor = @__({@Autowired, @Lazy}))
|
|
|
-public class HelpCategoryServiceImpl implements IHelpCategoryService
|
|
|
-{
|
|
|
- private final HelpCategoryMapper helpCategoryMapper;
|
|
|
+public class HelpCategoryServiceImpl extends ServiceImpl<HelpCategoryMapper,HelpCategory> implements
|
|
|
+ IHelpCategoryService,com.chelvc.cloud.vehicle.api.service.IHelpCategoryService
|
|
|
|
|
|
+{
|
|
|
+ private final IHelpService helpService;
|
|
|
/**
|
|
|
* 查询帮助分类
|
|
|
*
|
|
@@ -29,58 +44,68 @@ public class HelpCategoryServiceImpl implements IHelpCategoryService
|
|
|
* @return 帮助分类
|
|
|
*/
|
|
|
@Override
|
|
|
- public HelpCategory selectHelpCategoryById(Long id)
|
|
|
+ public HelpCategoryDTO selectHelpCategoryById(@NonNull Long id)
|
|
|
{
|
|
|
- return helpCategoryMapper.selectHelpCategoryById(id);
|
|
|
+ return HelpCategoryCopier.INSTANCE.copying(this.getById(id));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询帮助分类列表
|
|
|
*
|
|
|
- * @param helpCategory 帮助分类
|
|
|
+ * @param param 帮助分类
|
|
|
* @return 帮助分类
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<HelpCategory> selectHelpCategoryList(HelpCategory helpCategory)
|
|
|
+ public List<HelpCategoryDTO> selectHelpCategoryList(@NonNull HelpCategoryModifyParam param)
|
|
|
{
|
|
|
- return helpCategoryMapper.selectHelpCategoryList(helpCategory);
|
|
|
+ List<HelpCategory> helpCategories = this.lambdaQuery()
|
|
|
+ .like(StringUtils.nonEmpty(param.getName()),HelpCategory::getName,param.getName())
|
|
|
+ .eq(StringUtils.nonEmpty(param.getShowStatus()),HelpCategory::getShowStatus,param.getShowStatus())
|
|
|
+ .orderByDesc(HelpCategory::getSort)
|
|
|
+ .list();
|
|
|
+ List<HelpCategoryDTO> helpCategoryList = HelpCategoryCopier.INSTANCE.copying(helpCategories);
|
|
|
+ helpCategoryList.forEach(item ->{
|
|
|
+ item.setHelpList(this.helpService.helpList(item.getId()));
|
|
|
+ });
|
|
|
+ return helpCategoryList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增帮助分类
|
|
|
*
|
|
|
- * @param helpCategory 帮助分类
|
|
|
+ * @param param 帮助分类
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertHelpCategory(HelpCategory helpCategory)
|
|
|
+ public void insertHelpCategory(@NonNull HelpCategoryModifyParam param)
|
|
|
{
|
|
|
- return helpCategoryMapper.insertHelpCategory(helpCategory);
|
|
|
+ HelpCategory helpCategory = HelpCategoryCopier.INSTANCE.copying(param);
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
+ helpCategory.setCreateTime(new Date());
|
|
|
+ helpCategory.setUpdater(userId);
|
|
|
+ helpCategory.setUpdateTime(new Date());
|
|
|
+ helpCategory.setCreator(userId);
|
|
|
+ this.save(helpCategory);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改帮助分类
|
|
|
*
|
|
|
- * @param helpCategory 帮助分类
|
|
|
+ * @param param 帮助分类
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateHelpCategory(HelpCategory helpCategory)
|
|
|
+ public void updateHelpCategory(@NonNull Long id, @NonNull HelpCategoryModifyParam param)
|
|
|
{
|
|
|
- return helpCategoryMapper.updateHelpCategory(helpCategory);
|
|
|
+ HelpCategory helpCategory = ResourceUtils.required(this.getById(id), "该分类不存在");
|
|
|
+ HelpCategoryCopier.INSTANCE.copying(param,helpCategory);
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
+ helpCategory.setUpdater(userId);
|
|
|
+ helpCategory.setUpdateTime(new Date());
|
|
|
+ this.updateById(helpCategory);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 批量删除帮助分类
|
|
|
- *
|
|
|
- * @param ids 需要删除的帮助分类主键
|
|
|
- * @return 结果
|
|
|
- */
|
|
|
- @Override
|
|
|
- public int deleteHelpCategoryByIds(Long[] ids)
|
|
|
- {
|
|
|
- return helpCategoryMapper.deleteHelpCategoryByIds(ids);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 删除帮助分类信息
|
|
@@ -89,8 +114,20 @@ public class HelpCategoryServiceImpl implements IHelpCategoryService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteHelpCategoryById(Long id)
|
|
|
+ public void deleteHelpCategoryById(@NonNull Long id)
|
|
|
{
|
|
|
- return helpCategoryMapper.deleteHelpCategoryById(id);
|
|
|
+ HelpCategory helpCategory = ResourceUtils.required(this.getById(id), "该分类不存在");
|
|
|
+ this.deleteHelpCategoryById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Pagination<HelpCategoryDTO> getHelpCategoryPaging(HelpCategoryPagingParam param){
|
|
|
+ Page<HelpCategory> page = this.lambdaQuery()
|
|
|
+ .like(StringUtils.nonEmpty(param.getTitle()),HelpCategory::getName,param.getTitle())
|
|
|
+ .orderByDesc(HelpCategory::getShowStatus)
|
|
|
+ .orderByDesc(HelpCategory::getSort)
|
|
|
+ .page(PagingUtils.convert(param.getPaging()));
|
|
|
+ return PagingUtils.convert(page, HelpCategoryCopier.INSTANCE::copying);
|
|
|
}
|
|
|
}
|