package com.chaozhanggui.admin.system.service;

import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.TbPlussAppGuideMapper;
import com.chaozhanggui.dao.system.entity.TbPlussAppGuide;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author lyf
 */
@Service
@Slf4j
public class PromotionImageService {
    @Resource
    private TbPlussAppGuideMapper appGuideMapper;
    public RespBody getPromotionImage(Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<TbPlussAppGuide> appGuides = appGuideMapper.selectGuideList();
        PageInfo pageInfo=new PageInfo(appGuides);
        return new RespBody("000000",pageInfo);
    }

    public RespBody updateByPrimaryKey(TbPlussAppGuide appGuide){
        appGuide.setUpdateTime(new Date());
        int i = appGuideMapper.updateByPrimaryKeySelective(appGuide);
        if (i>0) {
            return new RespBody("000000");
        }
        log.error("修改错误");
        return new RespBody("000051");
    }

    public RespBody insert(TbPlussAppGuide appGuide){
        appGuide.setType("1");
        appGuide.setCreatetime(new Date());
        appGuide.setUpdateTime(new Date());
        appGuide.setAndroid("0");
        appGuide.setIos("0");
        int i = appGuideMapper.insert(appGuide);
        if (i>0) {
            return new RespBody("000000");
        }
        log.error("增加错误");
        return new RespBody("000052");
    }
}
