package com.tiesheng.core.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 基础Service
 *
 * @author hao
 */
public class TsServiceBase<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {


    /**
     * 通过属性获取一个对象
     *
     * @param column
     * @param val
     * @return
     */
    public T getOneByColumn(String column, Object val) {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_deleted", 0);
        queryWrapper.eq(column, val);
        queryWrapper.last("limit 1");
        return getOne(queryWrapper);
    }

}
