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

io.github.wujun728.online.common.impl.BaseServiceImpl Maven / Gradle / Ivy

The newest version!
package io.github.wujun728.online.common.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.wujun728.online.common.BaseService;
import io.github.wujun728.online.common.Query;


/**
 * 基础服务类,所有Service都要继承
 *
 */
public class BaseServiceImpl, T> extends ServiceImpl implements BaseService {

    /**
     * 获取分页对象
     *
     * @param query 分页参数
     */
    protected IPage getPage(Query query) {
        Page page = new Page<>(query.getPage(), query.getLimit());
        page.addOrder(OrderItem.desc("id"));
        return page;
    }

    protected QueryWrapper getWrapper(Query query) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.like(StrUtil.isNotBlank(query.getCode()), "code", query.getCode());
        wrapper.like(StrUtil.isNotBlank(query.getTableName()), "table_name", query.getTableName());
        wrapper.like(StrUtil.isNotBlank(query.getAttrType()), "attr_type", query.getAttrType());
        wrapper.like(StrUtil.isNotBlank(query.getColumnType()), "column_type", query.getColumnType());
        wrapper.like(StrUtil.isNotBlank(query.getConnName()), "conn_name", query.getConnName());
        wrapper.eq(StrUtil.isNotBlank(query.getDbType()), "db_type", query.getDbType());
        wrapper.like(StrUtil.isNotBlank(query.getProjectName()), "project_name", query.getProjectName());
        return wrapper;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy