| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import com.ycl.platform.base.BaseSelect; |
| | | import com.ycl.platform.domain.entity.YwUnit; |
| | | import com.ycl.platform.domain.form.YwUnitForm; |
| | | import com.ycl.platform.domain.query.YwUnitQuery; |
| | |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.platform.service.YwUnitService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.utils.DateUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | /** |
| | | * 运维单位 服务实现类 |
| | |
| | | */ |
| | | @Override |
| | | public Result add(YwUnitForm form) { |
| | | // todo 增加对应账号 |
| | | YwUnit entity = YwUnitForm.getEntityByForm(form, null); |
| | | if(baseMapper.insert(entity) > 0) { |
| | | return Result.ok("添加成功"); |
| | |
| | | */ |
| | | @Override |
| | | public Result update(YwUnitForm form) { |
| | | |
| | | // todo 修改对应账号 |
| | | YwUnit entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | |
| | | */ |
| | | @Override |
| | | public Result page(YwUnitQuery query) { |
| | | |
| | | // 分页条件查询你 |
| | | IPage<YwUnit> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .eq(StringUtils.hasText(query.getUnitCode()), YwUnit::getUnitCode, query.getUnitCode()) |
| | | .like(StringUtils.hasText(query.getUnitName()), YwUnit::getUnitName, query.getUnitName()) |
| | | .between(Objects.nonNull(query.getStart()) && Objects.nonNull(query.getEnd()), |
| | | YwUnit::getCreateTime, |
| | | DateUtils.getDayStart(query.getStart()), |
| | | DateUtils.getDayEnd(query.getEnd())) |
| | | .orderByDesc(YwUnit::getCreateTime) |
| | | .page(PageUtil.getPage(query, YwUnit.class)); |
| | | |
| | |
| | | @Override |
| | | public Result all() { |
| | | List<YwUnit> entities = baseMapper.selectList(null); |
| | | List<YwUnitVO> vos = entities.stream() |
| | | |
| | | List<BaseSelect> vos = entities.stream() |
| | | .map( |
| | | entity -> YwUnitVO.getVoByEntity(entity, null) |
| | | entity -> { |
| | | BaseSelect baseSelect = new BaseSelect(); |
| | | baseSelect.setId(entity.getId()); |
| | | baseSelect.setValue(entity.getUnitName()); |
| | | return baseSelect; |
| | | } |
| | | ) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |