xiangpei
2025-05-14 47cd9ecc0eff38ffe6b3b794b2bf197e958f4403
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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));
    }
 
}