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.IndexDataClockDao; import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; import com.iailab.module.data.indexdata.service.IndexDataClockService; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; /** * @author PanZhibao * @Description * @createTime 2022年09月08日 21:49:00 */ @Service public class IndexDataClockServiceImpl extends ServiceImpl implements IndexDataClockService { @Override public PageUtils queryPage(Map params) { String clockCode = (String)params.get("clockCode"); String clockName = (String)params.get("clockName"); IPage page = this.page( new Query().getPage(params), new QueryWrapper() .like(StringUtils.isNotBlank(clockCode),"clock_code", clockCode) .like(StringUtils.isNotBlank(clockName),"clock_name", clockName) .orderByDesc("create_time") ); return new PageUtils(page); } @Override public List queryList(Map params) { return getBaseMapper().selectList( new QueryWrapper().eq("status", CommonConstant.IS_ENABLE) .orderByDesc("create_time") ); } @Override public void add(IndexDataClockEntity indexDataClockEntity) { this.save(indexDataClockEntity); } @Override public void update(IndexDataClockEntity indexDataClockEntity) { this.updateById(indexDataClockEntity); } @Override public void deleteById(String id) { this.removeById(id); } @Override public IndexDataClockEntity getInfoById(String id) { return this.getById(id); } @Override public IndexDataClockEntity getInfoByCode(String clockCode) { return getBaseMapper().selectOne(new QueryWrapper() .eq("clock_code", clockCode) .eq("status", CommonConstant.IS_ENABLE)); } @Override public int cheack(IndexDataClockEntity indexDataClockEntity) { String id = indexDataClockEntity.getId(); String clockCode = indexDataClockEntity.getClockCode(); String clockName = indexDataClockEntity.getClockName(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); queryWrapper.and(wrapper -> wrapper.eq("clock_code", clockCode).or(). eq(StringUtils.isNotBlank(clockName),"clock_name", clockName)); return (int)this.count(queryWrapper); } }