package com.mindskip.xzs.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.mindskip.xzs.domain.Department; import com.mindskip.xzs.repository.BaseMapper; import com.mindskip.xzs.repository.DepartmentMapper; import com.mindskip.xzs.service.DepartmentService; import com.mindskip.xzs.utility.ModelMapperSingle; import com.mindskip.xzs.viewmodel.department.DepartmentResponseVM; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Service; import java.util.List; @Service public class DepartmentServiceImpl extends BaseServiceImpl implements DepartmentService { protected final static ModelMapper modelMapper = ModelMapperSingle.Instance(); private final DepartmentMapper departmentMapper; public DepartmentServiceImpl(BaseMapper baseMapper, DepartmentMapper departmentMapper) { super(baseMapper); this.departmentMapper = departmentMapper; } @Override public Integer add(String name) { Department department = new Department(); department.setDeleted("0"); department.setName(name); return departmentMapper.add(department); } @Override public Integer remove(Integer id) { Department department = new Department(); department.setId(id); department.setDeleted("1"); return departmentMapper.update(department); } @Override public Integer update(Department department) { return departmentMapper.update(department); } @Override public PageInfo gets(DepartmentResponseVM departmentResponseVM) { return PageHelper.startPage(departmentResponseVM.getPageIndex(), departmentResponseVM.getPageSize(), "id desc").doSelectPageInfo(() -> departmentMapper.page(departmentResponseVM) ); } @Override public Department getById(Integer id) { return departmentMapper.getById(id); } @Override public List gets() { return departmentMapper.gets(); } }