package com.iailab.module.data.indexdata.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iailab.module.data.common.enums.CommonConstant; import com.iailab.module.data.common.utils.PageUtils; import com.iailab.module.data.common.utils.Query; import com.iailab.module.data.indexdata.dao.IndexDataItemDao; import com.iailab.module.data.indexdata.service.IndexDataItemService; import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.List; import java.util.Map; /** * @author PanZhibao * @Description * @createTime 2022年09月08日 21:49:00 */ @Service public class IndexDataItemServiceImpl extends ServiceImpl implements IndexDataItemService { @Override public PageUtils queryPage(Map params) { String itemCode = (String)params.get("itemCode"); String itemName = (String)params.get("itemName"); IPage page = this.page( new Query().getPage(params), new QueryWrapper() .like(StringUtils.isNotBlank(itemCode),"item_code", itemCode) .like(StringUtils.isNotBlank(itemName),"item_name", itemName) .orderByDesc("create_time") ); return new PageUtils(page); } @Override public List getListByClockConfig(String clockConfig) { return getBaseMapper().selectList(new QueryWrapper() .eq("clock_config", clockConfig) .eq("status", CommonConstant.IS_ENABLE)); } @Override public void add(IndexDataItemEntity enity) { this.save(enity); } @Override public void update(IndexDataItemEntity enity) { this.updateById(enity); } @Override public void deleteById(String id) { this.removeById(id); } @Override public void deleteBatch(String[] ids) { this.removeByIds(Arrays.asList(ids)); } @Override public IndexDataItemEntity getInfoById(String id) { return this.getById(id); } @Override public int cheack(IndexDataItemEntity enity) { String id = enity.getId(); String itemCode = enity.getItemCode(); String itemName = enity.getItemName(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); queryWrapper.and(wrapper -> wrapper.eq("item_code", itemCode).or(). eq(StringUtils.isNotBlank(itemName),"item_name", itemName)); return (int)this.count(queryWrapper); } }