package com.qianwen.smartman.modules.tool.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.qianwen.core.log.exception.ServiceException; import com.qianwen.core.mp.base.BaseServiceImpl; import com.qianwen.core.mp.support.Condition; import com.qianwen.core.mp.support.Query; import com.qianwen.core.tool.utils.Func; import com.qianwen.smartman.common.utils.MessageUtils; import com.qianwen.smartman.modules.tool.convert.ToolModelConvert; import com.qianwen.smartman.modules.tool.entity.Tool; import com.qianwen.smartman.modules.tool.entity.ToolCategory; import com.qianwen.smartman.modules.tool.entity.ToolModel; import com.qianwen.smartman.modules.tool.mapper.ToolModelMapper; import com.qianwen.smartman.modules.tool.service.IToolCategoryService; import com.qianwen.smartman.modules.tool.service.IToolManageService; import com.qianwen.smartman.modules.tool.service.IToolModelService; import com.qianwen.smartman.modules.tool.vo.ToolModelVO; @Service /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/tool/service/impl/ToolModelServiceImpl.class */ public class ToolModelServiceImpl extends BaseServiceImpl implements IToolModelService { @Autowired @Lazy private IToolCategoryService toolCategoryService; @Autowired @Lazy private IToolManageService toolManageService; @Override // org.springblade.modules.tool.service.IToolModelService public IPage page(String keyWord, Long categoryId, Boolean isShowChild, Query query) { if (Func.isEmpty(isShowChild)) { isShowChild = true; } List categoryIdList = this.toolCategoryService.getChildrenIds(Lists.newArrayList(new Long[]{categoryId}), Lists.newArrayList(new Long[]{categoryId})); if (!isShowChild.booleanValue()) { categoryIdList = Lists.newArrayList(new Long[]{categoryId}); } return ((ToolModelMapper) this.baseMapper).listByIds(Condition.getPage(query), categoryId, categoryIdList, keyWord); } @Override // org.springblade.modules.tool.service.IToolModelService public ToolModelVO save(ToolModelVO toolModelVO) { checkName(toolModelVO); if (Func.isNotEmpty(toolModelVO.getId())) { ToolCategory toolCategory = (ToolCategory) this.toolCategoryService.getById(toolModelVO.getToolCategoryId()); toolModelVO.setToolPrefixCode(toolCategory.getToolPrefixCode()); } ToolModel toolModel = ToolModelConvert.INSTANCE.convert(toolModelVO); saveOrUpdate(toolModel); return ToolModelConvert.INSTANCE.convert(toolModel); } private void checkName(ToolModelVO toolModelVO) { long count = count(Wrappers.lambdaQuery() .ne(Func.isNotEmpty(toolModelVO.getId()), ToolModel::getId, toolModelVO.getId()) .eq(ToolModel::getToolCategoryId, toolModelVO.getToolCategoryId()) .eq(ToolModel::getModel, toolModelVO.getModel())); /* long count = count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().ne(Func.isNotEmpty(toolModelVO.getId()), (v0) -> { return v0.getId(); }, toolModelVO.getId()).eq((v0) -> { return v0.getToolCategoryId(); }, toolModelVO.getToolCategoryId())).eq((v0) -> { return v0.getModel(); }, toolModelVO.getModel()));*/ if (count > 0) { throw new ServiceException(MessageUtils.message("tool.model.name.already.exists", new Object[0])); } } @Override // org.springblade.modules.tool.service.IToolModelService public boolean remove(List ids) { long count = this.toolManageService.count(Wrappers.lambdaQuery().in(Tool::getToolModelId, ids)); /* long count = this.toolManageService.count((Wrapper) Wrappers.lambdaQuery().in((v0) -> { return v0.getToolModelId(); }, ids));*/ if (count > 0) { throw new ServiceException(MessageUtils.message("tool.model.have.tool.can.not.delete", new Object[0])); } return removeBatchByIds(ids); } @Override // org.springblade.modules.tool.service.IToolModelService public ToolModelVO detail(String id) { return ((ToolModelMapper) this.baseMapper).detail(id); } }