package com.jpsoft.shinestar.modules.base.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jpsoft.shinestar.modules.base.dao.ProblemFeedbackDAO;
import com.jpsoft.shinestar.modules.base.entity.ProblemFeedback;
import com.jpsoft.shinestar.modules.base.service.ProblemFeedbackService;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * @author 墨鱼_mo
 * @date 2020-10-12 10:44
 */
@Transactional
@Component(value="problemFeedbackService")
public class ProblemFeedbackServiceImpl implements ProblemFeedbackService {


    @Resource(name="problemFeedbackDAO")
    private ProblemFeedbackDAO problemFeedbackDAO;

    @Override
    public ProblemFeedback get(String id) {
        // TODO Auto-generated method stub
        return problemFeedbackDAO.get(id);
    }

    @Override
    public int insert(ProblemFeedback model) {
        // TODO Auto-generated method stub
        //model.setId(UUID.randomUUID().toString());

        return problemFeedbackDAO.insert(model);
    }

    @Override
    public int update(ProblemFeedback model) {
        // TODO Auto-generated method stub
        return problemFeedbackDAO.update(model);
    }

    @Override
    public int delete(String id) {
        // TODO Auto-generated method stub
        return problemFeedbackDAO.delete(id);
    }

    @Override
    public boolean exist(String id) {
        // TODO Auto-generated method stub
        int count = problemFeedbackDAO.exist(id);

        return count > 0 ? true : false;
    }

    @Override
    public List<ProblemFeedback> list() {
        // TODO Auto-generated method stub
        return problemFeedbackDAO.list();
    }

    @Override
    public Page<ProblemFeedback> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
        Page<ProblemFeedback> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            problemFeedbackDAO.search(searchParams,sortList);
        });

        return page;
    }
}
