package com.gkhy.exam.system.service.impl; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.gkhy.exam.common.api.CommonPage; import com.gkhy.exam.common.api.CommonResult; import com.gkhy.exam.common.constant.UserConstant; import com.gkhy.exam.common.utils.PageUtils; import com.gkhy.exam.common.utils.SecurityUtils; import com.gkhy.exam.system.domain.ExternalKnowledge; import com.gkhy.exam.system.mapper.ExternalKnowledgeMapper; import com.gkhy.exam.system.service.ExternalKnowledgeService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; /** *

* 外部知识 服务实现类 *

* * @author hh * @since 2025-08-25 15:01:44 */ @Service public class ExternalKnowledgeServiceImpl extends ServiceImpl implements ExternalKnowledgeService { @Autowired private ExternalKnowledgeMapper externalKnowledgeMapper; @Override public CommonPage selectExternalKnowledgeList(ExternalKnowledge externalKnowledge) { PageUtils.startPage(); List externalKnowledge1 = externalKnowledgeMapper.getExternalKnowledge(externalKnowledge); return CommonPage.restPage(externalKnowledge1); } @Override public CommonResult saveExternalKnowledge(ExternalKnowledge externalKnowledge) { int i = 0; if (externalKnowledge.getId() == null){ externalKnowledge.setCreateBy(SecurityUtils.getUsername()); externalKnowledge.setCreateTime(LocalDateTime.now()); i = externalKnowledgeMapper.insert(externalKnowledge); }else { externalKnowledge.setUpdateBy(SecurityUtils.getUsername()); externalKnowledge.setUpdateTime(LocalDateTime.now()); i = externalKnowledgeMapper.updateById(externalKnowledge); } return CommonResult.success(); } @Override public CommonResult deletedExternalKnowledge(Integer id) { externalKnowledgeMapper.update(new ExternalKnowledge(), new LambdaUpdateWrapper().eq(ExternalKnowledge::getId, id) .set(ExternalKnowledge::getDelFlag, UserConstant.DEPT_DISABLE) .set(ExternalKnowledge::getUpdateTime, LocalDateTime.now()) .set(ExternalKnowledge::getUpdateBy, SecurityUtils.getUsername())); return CommonResult.success(); } }