From ea3e40330575519d9a4c7dbe4f6d63e4a22ea861 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期二, 02 四月 2024 09:41:52 +0800 Subject: [PATCH] Revert "Revert "新考核"" --- ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java | 178 +++++++++++++++++++---------------------------------------- 1 files changed, 57 insertions(+), 121 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java index 8374785..518e882 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java @@ -1,161 +1,97 @@ package com.ycl.platform.service.impl; -import com.ycl.platform.base.BaseSelect; import com.ycl.platform.domain.entity.CheckRule; -import com.ycl.platform.domain.entity.YwUnit; import com.ycl.platform.mapper.CheckRuleMapper; -import com.ycl.platform.service.CheckRuleService; -import com.ycl.system.Result; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ycl.platform.domain.form.CheckRuleForm; -import com.ycl.platform.domain.vo.CheckRuleVO; -import com.ycl.platform.domain.query.CheckRuleQuery; +import com.ycl.platform.service.ICheckRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import utils.DateUtils; + import java.util.List; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.ycl.system.page.PageUtil; -import com.ycl.utils.DateUtils; -import org.springframework.stereotype.Service; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.beans.BeanUtils; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; -import java.util.ArrayList; -import java.util.Objects; -import java.util.stream.Collectors; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; -import lombok.RequiredArgsConstructor; -import org.springframework.util.StringUtils; - /** - * 鑰冩牳瑙勫垯 鏈嶅姟瀹炵幇绫� - * - * @author xp - * @since 2024-03-06 + * 鑰冩牳瑙勫垯Service涓氬姟灞傚鐞� + * + * @author ruoyi + * @date 2024-04-01 */ @Service -@RequiredArgsConstructor -public class CheckRuleServiceImpl extends ServiceImpl<CheckRuleMapper, CheckRule> implements CheckRuleService { - - private final CheckRuleMapper checkRuleMapper; +public class CheckRuleServiceImpl implements ICheckRuleService +{ + @Autowired + private CheckRuleMapper checkRuleMapper; /** - * 娣诲姞 - * @param form - * @return + * 鏌ヨ鑰冩牳瑙勫垯 + * + * @param id 鑰冩牳瑙勫垯涓婚敭 + * @return 鑰冩牳瑙勫垯 */ @Override - public Result add(CheckRuleForm form) { - CheckRule entity = CheckRuleForm.getEntityByForm(form, null); - if(baseMapper.insert(entity) > 0) { - return Result.ok("娣诲姞鎴愬姛"); - } - return Result.error("娣诲姞澶辫触"); + public CheckRule selectCheckRuleById(Long id) + { + return checkRuleMapper.selectCheckRuleById(id); } /** - * 淇敼 - * @param form - * @return + * 鏌ヨ鑰冩牳瑙勫垯鍒楄〃 + * + * @param checkRule 鑰冩牳瑙勫垯 + * @return 鑰冩牳瑙勫垯 */ @Override - public Result update(CheckRuleForm form) { - - CheckRule entity = baseMapper.selectById(form.getId()); - - // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊 - Assert.notNull(entity, "璁板綍涓嶅瓨鍦�"); - BeanUtils.copyProperties(form, entity); - if (baseMapper.updateById(entity) > 0) { - return Result.ok("淇敼鎴愬姛"); - } - return Result.error("淇敼澶辫触"); + public List<CheckRule> selectCheckRuleList(CheckRule checkRule) + { + return checkRuleMapper.selectCheckRuleList(checkRule); } /** - * 鎵归噺鍒犻櫎 - * @param ids - * @return + * 鏂板鑰冩牳瑙勫垯 + * + * @param checkRule 鑰冩牳瑙勫垯 + * @return 缁撴灉 */ @Override - public Result remove(List<String> ids) { - if(baseMapper.deleteBatchIds(ids) > 0) { - return Result.ok("鍒犻櫎鎴愬姛"); - } - return Result.error("鍒犻櫎澶辫触"); + public int insertCheckRule(CheckRule checkRule) + { + checkRule.setCreateTime(DateUtils.getNowDate()); + return checkRuleMapper.insertCheckRule(checkRule); } /** - * id鍒犻櫎 - * @param id - * @return + * 淇敼鑰冩牳瑙勫垯 + * + * @param checkRule 鑰冩牳瑙勫垯 + * @return 缁撴灉 */ @Override - public Result removeById(String id) { - if(baseMapper.deleteById(id) > 0) { - return Result.ok("鍒犻櫎鎴愬姛"); - } - return Result.error("鍒犻櫎澶辫触"); + public int updateCheckRule(CheckRule checkRule) + { + checkRule.setUpdateTime(DateUtils.getNowDate()); + return checkRuleMapper.updateCheckRule(checkRule); } /** - * 鍒嗛〉鏌ヨ - * @param query - * @return + * 鎵归噺鍒犻櫎鑰冩牳瑙勫垯 + * + * @param ids 闇�瑕佸垹闄ょ殑鑰冩牳瑙勫垯涓婚敭 + * @return 缁撴灉 */ @Override - public Result page(CheckRuleQuery query) { - - IPage<CheckRule> page = new LambdaQueryChainWrapper<>(baseMapper) - .like(StringUtils.hasText(query.getRuleName()), CheckRule::getRuleName, query.getRuleName()) - .between(Objects.nonNull(query.getStart()) && Objects.nonNull(query.getEnd()), - CheckRule::getCreateTime, - DateUtils.getDayStart(query.getStart()), - DateUtils.getDayEnd(query.getEnd())) - .eq(Objects.nonNull(query.getAuditState()),CheckRule::getAuditState, query.getAuditState()) - .orderByDesc(CheckRule::getCreateTime) - .page(PageUtil.getPage(query, CheckRule.class)); - - List<CheckRuleVO> vos = page.getRecords().stream() - .map( - entity -> CheckRuleVO.getVoByEntity(entity, null) - ) - .collect(Collectors.toList()); - return Result.ok().data(vos).total(page.getTotal()); + public int deleteCheckRuleByIds(Long[] ids) + { + return checkRuleMapper.deleteCheckRuleByIds(ids); } /** - * 鏍规嵁id鏌ユ壘 - * @param id - * @return + * 鍒犻櫎鑰冩牳瑙勫垯淇℃伅 + * + * @param id 鑰冩牳瑙勫垯涓婚敭 + * @return 缁撴灉 */ @Override - public Result detail(String id) { - - CheckRule entity = baseMapper.selectById(id); - Assert.notNull(entity, "璁板綍涓嶅瓨鍦�"); - CheckRuleVO vo = CheckRuleVO.getVoByEntity(entity, null); - return Result.ok().data(vo); - } - - /** - * 鍒楄〃 - * @return - */ - @Override - public Result all() { - List<CheckRule> entities = baseMapper.selectList(null); - List<BaseSelect> vos = entities.stream() - .map( - entity -> { - BaseSelect vo = new BaseSelect(); - vo.setId(entity.getId()); - vo.setValue(entity.getRuleName()); - return vo; - } - ) - .collect(Collectors.toList()); - return Result.ok().data(vos); + public int deleteCheckRuleById(Long id) + { + return checkRuleMapper.deleteCheckRuleById(id); } } -- Gitblit v1.8.0