/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.base.entity.Annex;
import com.tofly.base.mapper.AnnexMapper;
import com.tofly.base.service.AnnexService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author wangjian
 * @date Mon Jun 22 00:00:00 CST 2020
 */
@Service("annexService")
public class AnnexServiceImpl extends ServiceImpl<AnnexMapper, Annex> implements AnnexService {

    @Override
    public List<Annex> page(Annex annex) {
        LambdaQueryWrapper<Annex> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotEmpty(annex.getTitle()), Annex::getTitle, annex.getTitle());
        return this.list(wrapper);
    }

    @Override
    public boolean reviewed(Annex annex) {
        LambdaUpdateWrapper<Annex> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(Annex::getReviewedContent, annex.getReviewedContent())
                .set(Annex::getReviewedUser, annex.getReviewedUser())
                .set(Annex::getReviewedDate, annex.getReviewedDate())
                .set(Annex::getReviewedStatus, annex.getReviewedStatus())
                .eq(Annex::getId, annex.getId());
        return this.update(wrapper);
    }
}
