fei.wang
2024-04-15 61747a14819075bf6da2c1597b6c22e22e026686
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
package com.flow.controller;
 
import com.flow.pojo.Duanxinlog;
import com.flow.pojo.Manager;
import com.flow.pojo.TbFuwuqi;
import com.flow.service.ManagerService;
import com.flow.util.result;
import com.flow.util.resultutil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@RestController
@RequestMapping({"/hxzk"})
public class ManagerController {
 
    @Autowired
    ManagerService managerService;
 
    @GetMapping({"findManager"})
    result<List<Manager>> findManager(Integer page, Integer limit) {
        PageInfo<Manager> cz = this.managerService.FindManager(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping({"addManager"})
    public ModelAndView addManager(Manager manager) throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        manager.setId(null);
        this.managerService.addManager(manager);
//        modelAndView.addObject("suoshu", this.managerService.findSuoShu());
        modelAndView.setViewName("/page/manager.jsp");
        return modelAndView;
    }
 
    @PostMapping({"UpdateManager"})
    public ModelAndView UpdateManager(Manager manager) {
        this.managerService.UpdateManager(manager);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/page/manager.jsp");
        return modelAndView;
    }
 
    @PostMapping({"DeleteManager"})
    public ModelAndView DeleteManager(String num,String caozuoname) {
        this.managerService.DeleteManager(num,caozuoname);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/page/manager.jsp");
        return modelAndView;
 
    }
 
    @PostMapping({"ManagerSearch"})
    public result<List<Manager>> tableSearch(Manager manager, int page, int limit) throws Exception {
        PageInfo<Manager> cz = this.managerService.tableSearch(manager, page, limit);
//        for(int i = 0; i < cz.getSize(); ++i) {
//            if (((Manager)cz.getList().get(i)).getCompany() != null) {
//                SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
//                Date date = new Date();
//                Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
//                Long starTime = date.getTime();
//                Long endTime = endDay.getTime();
//                Long num11 = endTime - starTime;//时间戳
//
////                if ((num11/24/60/60/1000)<0){
////                    ((Manager)cz.getList().get(i)).setRemainingdays("0天");
////                }else{
////                    ((Manager)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
////                }
////                this.cardService.UpdateCard((Card)cz.getList().get(i));
////                this.cardService.UpdateCard((Card)cz.getList().get(i));
//            }
//        }
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping({"ifManager"})
    public List<Manager> ifManager(Manager manager) {
        return this.managerService.ifManager(manager);
    }
 
}