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> findScreen(Integer page, Integer limit){ PageInfo 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> findScreenSearch(Integer page, Integer limit, TbScreenSettings screenSettings){ PageInfo 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; } }