package com.mindskip.xzs.controller.admin;
|
|
|
import com.github.pagehelper.PageInfo;
|
import com.mindskip.xzs.base.BaseApiController;
|
import com.mindskip.xzs.base.RestResponse;
|
import com.mindskip.xzs.domain.DepartmentExamine;
|
import com.mindskip.xzs.domain.Notify;
|
import com.mindskip.xzs.domain.enums.NotifyRefType;
|
import com.mindskip.xzs.domain.vo.DepartmentExamineVO;
|
import com.mindskip.xzs.service.DepartmentExamineService;
|
import com.mindskip.xzs.service.NotifyService;
|
import lombok.RequiredArgsConstructor;
|
import org.apache.commons.lang3.ObjectUtils;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.time.LocalDateTime;
|
import java.util.Date;
|
|
/**
|
* <p>
|
* 部门审核表 前端控制器
|
* </p>
|
*
|
* @author gonghl
|
* @since 2024-05-13
|
*/
|
@RestController
|
@RequestMapping("/api/admin/department/examine")
|
@RequiredArgsConstructor
|
public class DepartmentExamineController extends BaseApiController {
|
|
private final DepartmentExamineService departmentExamineService;
|
private final NotifyService notifyService;
|
|
@RequestMapping(value = "list", method = RequestMethod.POST)
|
public RestResponse<PageInfo<DepartmentExamineVO>> list(@RequestBody DepartmentExamineVO departmentExamineVO) {
|
departmentExamineVO.setDeptIds(ObjectUtils.isNotEmpty(departmentExamineVO.getDeptIds()) ? departmentExamineVO.getDeptIds() : getAdminDeptIds());
|
return RestResponse.ok(departmentExamineService.pageInfo(departmentExamineVO));
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@RequestMapping(value = "save", method = RequestMethod.POST)
|
public RestResponse<Boolean> save(@RequestBody DepartmentExamine departmentExamine) {
|
departmentExamine.setCreateTime(LocalDateTime.now());
|
departmentExamine.setCreateUser(getCurrentUser().getId());
|
|
departmentExamineService.save(departmentExamine);
|
|
// 添加通知
|
Notify notify = new Notify();
|
notify.setCreateTime(new Date());
|
notify.setReadStatus(2);
|
notify.setRefId(departmentExamine.getId());
|
notify.setRefType(NotifyRefType.MOBILIZE.getValue());
|
notify.setCreateUserId(webContext.getCurrentUser().getId());
|
notifyService.add(notify);
|
return RestResponse.ok();
|
}
|
|
@RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
|
public RestResponse<Boolean> delete(@PathVariable Integer id) {
|
return RestResponse.ok(departmentExamineService.removeById(id));
|
}
|
|
@RequestMapping(value = "audit", method = RequestMethod.POST)
|
public RestResponse<Boolean> audit(@RequestBody DepartmentExamineVO departmentExamine) {
|
return RestResponse.ok(departmentExamineService.audit(departmentExamine));
|
}
|
|
}
|