package cn.com.countrygarden.bi.main.service.review.impl;
import cn.com.countrygarden.bi.main.model.PageData;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.model.AccessToken;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.countrygarden.bi.main.model.review.ReviewJudge;
import cn.com.countrygarden.bi.main.dao.review.ReviewJudgeMapper;
import cn.com.countrygarden.bi.main.service.review.ReviewJudgeService;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example.Criteria;

/**
 * 评选人-业务逻辑层实现
 *
 * @author 汤婷
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2018-06-25
 */
@Service
@Transactional
public class ReviewJudgeServiceImpl implements ReviewJudgeService{
    @Autowired
    private ReviewJudgeMapper reviewJudgeMapper;

    @Override
    public Result queryPageList(ReviewJudge reviewJudge, int page, int size) {
        Page<Object> pageList = PageHelper.startPage(page, size);
        Condition condition=new Condition(ReviewJudge.class);
        Criteria criteria = condition.createCriteria();
//		TODO 添加条件
		reviewJudgeMapper.selectByCondition(condition);
        PageData data=new PageData(pageList);
        data.setData(pageList.getResult());
        return Response.response(data);
    }

    @Override
    public Result queryById(Integer id) {
        return Response.response(reviewJudgeMapper.selectByPrimaryKey(id));
    }

    @Override
    public Result add(ReviewJudge reviewJudge, AccessToken accessToken) {
    	reviewJudge.setCreateBy(accessToken.getUserCode());
        reviewJudgeMapper.insert(reviewJudge);
        return Response.response();
    }

    @Override
    public Result edit(ReviewJudge reviewJudge, AccessToken accessToken) {
        reviewJudgeMapper.updateByPrimaryKey(reviewJudge);
        return Response.response();
    }

    @Override
    public Result del(Integer id) {
        int count = reviewJudgeMapper.deleteByPrimaryKey(id);
        return Response.response(count);
    }

//	@Override
//	public Result selectJudge(Integer investigatedId) {
//	List<ReviewJudge> judgeList=reviewJudgeMapper.selectJudge(investigatedId);
//		return null;
//	}

}