111
fei.wang
2025-04-18 a6686570ac48648e2bf2ec93d27272a4473cac08
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.hxzkappboot.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hxzkappboot.mapper.TbDepartmentMapper;
import com.hxzkappboot.pojo.TbDepartment;
import com.hxzkappboot.service.TbDepartmentService;
import com.hxzkappboot.util.R;
import com.hxzkappboot.util.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangfei
 * @since 2024-03-08
 */
@RestController
//@RequestMapping("/tb-department")
public class TbDepartmentController {
 
    @Autowired
    TbDepartmentService tbDepartmentService;
 
    @Autowired
    TbDepartmentMapper tbDepartmentMapper;
 
 
 
    @GetMapping({"/api/wx/findbumen"})
    public R findbumen(String juese,String company) throws ParseException {
        R response ;
        List<TbDepartment> fenceList = new ArrayList();
        fenceList = tbDepartmentService.findbumen(juese,company);
        response = new R(StatusCode.Success);
        response.setData(fenceList);
        return response;
    }
 
//    @GetMapping({"/api/wx/findbumen"})
//    public R findbumen() throws ParseException {
//        R response ;
//        List<TbDepartment> fenceList = new ArrayList();
//        fenceList = tbDepartmentService.findbumen();
//        response = new R(StatusCode.Success);
//        response.setData(fenceList);
//        return response;
//    }
 
    @GetMapping("/api/wx/findbumenpage")
    public R findbumen(Page page, String objectid, String company,String juese) {
        R response;
        List<TbDepartment> ipage = tbDepartmentService.findAll(page,objectid,company,juese);
        response = new R(StatusCode.Success);
        response.setData(ipage);
        return response;
    }
 
    @PostMapping("/api/wx/saveBumen")
    public R saveBumen(@Valid @RequestBody TbDepartment tbDepartment) {
        R response;
 
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name",tbDepartment.getName());
//        tbDepartmentMapper.selectList(queryWrapper);
        if (tbDepartmentMapper.selectList(queryWrapper).size()>0){
            response = new R(StatusCode.Fail);
            response.setData("部门名称重复,保存失败");
        }else{
            response = new R(StatusCode.Success);
            response.setData(tbDepartmentService.updateBumen(tbDepartment));
        }
 
        return response;
    }
 
    @GetMapping("/api/wx/deleteBumen")
    public void deleteBumen(String id) throws IOException {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
//        List<TbDepartment> tbZypHandel = tbZypHandelMapper.selectList(queryWrapper);
//        for (int i = 0; i < tbZypHandel.size(); i++) {
//            QueryWrapper queryWrapper1 = new QueryWrapper<>();
//            queryWrapper1.eq("id",tbZypHandel.get(i).getId());
//            tbZypHandelMapper.delete(queryWrapper1);
//        }
        tbDepartmentMapper.delete(queryWrapper);
//        response.sendRedirect("/hxzkuwb/HouTai/JobTicket/DongHuo.jsp");
    }
 
}