com.wuyu.module.hunter.service.impl.DimSchoolServiceImpl Maven / Gradle / Ivy
package com.wuyu.module.hunter.service.impl;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.github.dennisit.vplus.data.enums.common.EnableEnum;
import com.github.dennisit.vplus.data.page.Pagination;
import com.github.dennisit.vplus.data.utils.NumberUtils;
import com.github.dennisit.vplus.data.utils.PaginationUtils;
import com.github.dennisit.vplus.data.utils.UniqueUtils;
import com.google.common.collect.Lists;
import com.wuyu.module.hunter.entity.DimPosition;
import com.wuyu.module.hunter.entity.DimSchool;
import com.wuyu.module.hunter.mapper.DimSchoolMapper;
import com.wuyu.module.hunter.service.IDimSchoolService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
@Service
public class DimSchoolServiceImpl extends ServiceImpl implements IDimSchoolService {
@Override
public List enable(Collection ids) {
List list = this.selectBatchIds(ids);
if(CollectionUtils.isNotEmpty(list)){
list.stream().forEach(x -> x.setEnabled(EnableEnum.ENABLED.getValue()));
this.updateBatchById(list);
}
return Lists.newArrayList(ids);
}
@Override
public List disable(Collection ids) {
List list = this.selectBatchIds(ids);
if(CollectionUtils.isNotEmpty(list)){
list.stream().forEach(x -> x.setEnabled(EnableEnum.DISABLE.getValue()));
this.updateBatchById(list);
}
return Lists.newArrayList(ids);
}
@Override
public boolean insertOrUpdate(DimSchool entity) {
Date now = new Date();
entity.setUpdateTime(now);
if (NumberUtils.valueOf(entity.getId()) <= 0L) {
entity.setUuid(UniqueUtils.getUUId());
entity.setCreateTime(now);
}
return super.insertOrUpdate(entity);
}
@Override
public Pagination selectPagination(Page page, Wrapper wrapper) {
return PaginationUtils.builder(selectPage(page, wrapper));
}
@Override
public List selectList(Page page, Wrapper wrapper) {
return PaginationUtils.items(selectPage(page, wrapper));
}
}