All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.service_impl.vm Maven / Gradle / Ivy

package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import ${package.QueryBo}.${table.queryName};
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List;

/**
 * 

* ${table.comment} 服务实现类 *

* * @author ${author} * @since ${date} */ @Service public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} { /** * 按照条件分页查询 * @param query */ @Override public IPage<${entity}> page(${table.queryName} query,int pageNo,int pageSize){ if(query==null){ return new Page<>(); } IPage<${entity}> page = new Page<>(); page.setCurrent(pageNo); page.setSize(pageSize); QueryWrapper<${entity}> queryWrapper = query.buildQuery(); return this.page(page, queryWrapper); } @Override public ${entity} getOne(${table.queryName} query) { QueryWrapper<${entity}> queryWrapper = query.buildQuery(); return this.getOne(queryWrapper); } @Override public IPage<${entity}> page(QueryWrapper<${entity}> queryWrapper, int pageNo, int pageSize) { return getPage(queryWrapper,pageNo,pageSize,true); } @Override public IPage<${entity}> pageNoCount(QueryWrapper<${entity}> queryWrapper, int pageNo, int pageSize) { return getPage(queryWrapper,pageNo,pageSize,false); } private IPage<${entity}> getPage(QueryWrapper<${entity}> queryWrapper, int pageNo, int pageSize,boolean isSearchCount) { if(queryWrapper ==null){ return new Page<>(); } Page<${entity}> page = new Page<>(); page.setCurrent(pageNo); page.setSize(pageSize); page.setSearchCount(isSearchCount); return this.page(page, queryWrapper); } @Override public boolean update(${entity} entity,${table.queryName} query) { if(entity==null || query==null){ return false; } return this.update(entity,query.buildQuery()); } @Override public boolean updateByColumn(${entity} entity, String column, Object value) { QueryWrapper<${entity}> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(column,value); return this.update(entity, queryWrapper); } @Override public List<${entity}> list(${table.queryName} query) { if(query==null){ return new ArrayList<>(2); } return this.list(query.buildQuery()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy