package io.renren.modules.sys.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 io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.SysJobDao;
import io.renren.modules.sys.entity.SysDepartmentEntity;
import io.renren.modules.sys.entity.SysJobEntity;
import io.renren.modules.sys.service.SysJobService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author yinhao
 * @date 2021/6/9 15:39
 */
@Service
public class SysJobServiceImpl extends ServiceImpl<SysJobDao, SysJobEntity> implements SysJobService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String keyword = (String)params.get("keyword");

        QueryWrapper<SysJobEntity> queryWrapper = new QueryWrapper<>();

        if (StringUtils.isNotEmpty(keyword)) {
            queryWrapper.and(q -> q.like("job_name",keyword)
                    .or().like("job_code",keyword));
        }

        IPage<SysJobEntity> page = this.page(new Query<SysJobEntity>().getPage(params), queryWrapper);

        return new PageUtils(page);
    }
}
