package ink.wgink.service.department.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.dao.IDepartmentUserAdjustmentDao;
import ink.wgink.service.department.pojo.dtos.DepartmentUserAdjustmentDTO;
import ink.wgink.service.department.service.IDepartmentUserAdjustmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: DepartmentUserAdjustmentServiceImpl
 * @Description: 部门用户调整
 * @Author: wanggeng
 * @Date: 2021/1/29 11:36 上午
 * @Version: 1.0
 */
@Service
public class DepartmentUserAdjustmentServiceImpl extends DefaultBaseService implements IDepartmentUserAdjustmentService {

    @Autowired
    private IDepartmentUserAdjustmentDao departmentUserAdjustmentDao;

    @Override
    public void save(Map<String, Object> params) {
        departmentUserAdjustmentDao.save(params);
    }

    @Override
    public SuccessResultList<List<DepartmentUserAdjustmentDTO>> listPage(ListPage page) {
        PageHelper.startPage(page.getPage(), page.getRows());
        List<DepartmentUserAdjustmentDTO> userDepartmentLogDTOs = departmentUserAdjustmentDao.list(page.getParams());
        PageInfo<DepartmentUserAdjustmentDTO> pageInfo = new PageInfo<>(userDepartmentLogDTOs);
        return new SuccessResultList<>(userDepartmentLogDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
    }

}
