package com.mindskip.xzs.service.impl;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.domain.DepartmentExamine;
import com.mindskip.xzs.domain.vo.DepartmentExamineVO;
import com.mindskip.xzs.repository.DepartmentExamineMapper;
import com.mindskip.xzs.service.DepartmentExamineService;
import com.mindskip.xzs.service.UserDepartMentService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
*
* 部门审核表 服务实现类
*
*
* @author gonghl
* @since 2024-05-13
*/
@Service
@RequiredArgsConstructor
public class DepartmentExamineServiceImpl extends ServiceImpl implements DepartmentExamineService {
private final UserDepartMentService userDepartMentService;
@Override
public PageInfo pageInfo(DepartmentExamineVO departmentExamineVO) {
return PageHelper.startPage(departmentExamineVO.getPageIndex(), departmentExamineVO.getPageSize(), "id desc").doSelectPageInfo(() ->
baseMapper.pageInfo(departmentExamineVO)
);
}
@Override
@Transactional
public Boolean audit(DepartmentExamineVO departmentExamine) {
// 审核通过重新绑定
if ("1".equals(departmentExamine.getResult().getCode())) {
userDepartMentService.removeByUserId(departmentExamine.getUserId());
userDepartMentService.insertBatchByDepartmentExamine(departmentExamine);
}
return new LambdaUpdateChainWrapper<>(baseMapper)
.eq(DepartmentExamine::getId, departmentExamine.getId())
.set(DepartmentExamine::getResult, departmentExamine.getResult())
.set(DepartmentExamine::getRemark, departmentExamine.getRemark())
.update();
}
}