zhitong.yu
2024-03-21 6beef2ce75f15a8b3d4394b83da62071c686eb3d
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
package com.hxzk.controller;
 
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.*;
import com.hxzk.service.*;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@RestController
@RequestMapping("/")
public class ScreenSettingsController {
 
    @Autowired
    ScreenService screenService;
 
    @Autowired
    UserService userService;
 
    @Autowired
    ComapanyService comapanyService;
 
    @Autowired
    HomeIconService homeIconService;
 
    @Autowired
    MapShowService mapShowService;
 
    @GetMapping("findScreen")
    result<List<TbScreenSettings>> findScreen(Integer page, Integer limit){
        PageInfo<TbScreenSettings> cz= screenService.findAll(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping("upScreen")
    public void upScreen(TbScreenSettings screenSettings, HttpServletResponse response) throws IOException {
        if (screenSettings.getBgcolor() != null){
            homeIconService.upnameColor(screenSettings.getBgcolor());
            mapShowService.upColor(screenSettings.getBgcolor());
        }
        screenService.upScreen(screenSettings);
        response.sendRedirect("/hxzkuwb/HouTai/XiTong/SystemScreen.jsp");
    }
    @GetMapping("deScreen")
    public void deScreen(String username,HttpServletResponse response) throws IOException {
        screenService.deScreen(username);
        TbCompany company = new TbCompany();
        company.setCompanyname(username);
        comapanyService.deleteCompany(company);
        response.sendRedirect("/hxzkuwb/HouTai/XiTong/SystemScreen.jsp");
    }
 
 
    //表格搜索
    @PostMapping("findScreenSearch")
    result<List<TbScreenSettings>> findScreenSearch(Integer page, Integer limit, TbScreenSettings screenSettings){
        PageInfo<TbScreenSettings> cz= screenService.findSearch(page, limit,screenSettings);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
 
    //根据权限显示对应看板
    @GetMapping("findScreenRole")
    public TbScreenSettings findScreenRole(String username){
        //先根据用户名称查询公司,
        TbUser user = userService.findCompanyName(username);
        return screenService.findScreenRole(user.getCompany());
    }
    public String gettime(){
        Date now = new Date();
        // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm"
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        // 格式化日期对象,输出字符串结果
        String formattedDate = sdf.format(now);
        return formattedDate;
    }
}