01 | package controller; |
02 |
03 | import java.util.List; |
04 |
05 | import javax.servlet.http.HttpSession; |
06 |
07 | import org.springframework.beans.factory.annotation.Autowired; |
08 | import org.springframework.stereotype.Controller; |
09 | import org.springframework.ui.Model; |
10 | import org.springframework.web.bind.annotation.RequestMapping; |
11 | import org.springframework.web.bind.annotation.RequestParam; |
12 |
13 | import com.github.pagehelper.PageHelper; |
14 | import com.github.pagehelper.PageInfo; |
15 |
16 | import Pojo.Apply; |
17 | import Pojo.Applyout; |
18 | import Pojo.Houselist; |
19 | import Pojo.User; |
20 | import Pojo.Userlist; |
21 | import Pojo.Zulist; |
22 | import service.ApplyService; |
23 | import service.ApplyoutService; |
24 | import service.UserlistService; |
25 | import service.ZulistService; |
26 |
27 | @Controller |
28 | @RequestMapping ( "/applyout" ) |
29 | public class ApplyoutController { |
30 | @Autowired |
31 | private ZulistService zulistService; |
32 | @Autowired |
33 | private ApplyoutService applyoutService; |
34 | @Autowired |
35 | private ApplyService applyService; |
36 | @Autowired |
37 | private UserlistService userlistService; |
38 | //插入退租信息 |
39 | @RequestMapping ( "/insertapplyout" ) |
40 | public String insertapplyout(String house_id,Model model){ |
41 | Zulist zulist=zulistService.findzulist(house_id); |
42 | applyoutService.insertapplyout(zulist); |
43 | model.addAttribute( "error" , "applysuccess" ); |
44 | return "redirect:/zulist/myzulist.action" ; |
45 | } |
46 | //查看退租申请 |
47 | @RequestMapping ( "/findallapplyout" ) |
48 | public String findallapplyout(Model model , @RequestParam (required= false ,defaultValue= "1" ) Integer page, |
49 | @RequestParam (required= false ,defaultValue= "6" ) Integer pageSize){ |
50 | PageHelper.startPage(page, pageSize); |
51 | List<Apply> applyout=applyService.findallapplyout(); |
52 | for (Apply apply : applyout) { |
53 | System.out.println(apply.toString()); |
54 | } |
55 | PageInfo<Apply> p= new PageInfo<Apply>(applyout); |
56 | model.addAttribute( "applyout" , applyout); |
57 | model.addAttribute( "p" , p); |
58 | model.addAttribute( "mainPage" , "applyout.jsp" ); |
59 | return "admin/main1" ; |
60 | } |
61 | //管理员拒绝退租申请 |
62 | @RequestMapping ( "/refuseapplyout" ) |
63 | public String refuseapplyout(Model model,Integer id){ |
64 | Applyout applyout= new Applyout(); |
65 | applyout.setId(id); |
66 | applyout.setStatus( "已拒绝" ); |
67 | applyoutService.updateapplyout(applyout); |
68 | model.addAttribute( "mainPage" , "applyout.jsp" ); |
69 | return "redirect:findallapplyout.action" ; |
70 | } |
71 | //管理员同意退租申请 |
72 | @RequestMapping ( "/agreeapplyout" ) |
73 | public String agreeapplyout(Model model,Integer id){ |
74 | applyoutService.agreeapplyout(id); |
75 | model.addAttribute( "error" , "applyoutsucess" ); |
76 | return "redirect:findallapplyout.action" ; |
77 | } |
78 | //删除申请退租列表 |
79 | @RequestMapping ( "/deleteapplyout" ) |
80 | public String deleteapplyout(Model model,Integer id){ |
81 | applyoutService.deleteapplyout(id); |
82 | model.addAttribute( "error" , "deletesucess" ); |
83 | return "redirect:findallapplyout.action" ; |
84 | } |
85 | //租客查看自己的 退房申请 |
86 | @RequestMapping ( "/getmyapplyout" ) |
87 | public String getmyapplyout(Model model,HttpSession httpSession, @RequestParam (required= false ,defaultValue= "1" ) Integer page, |
88 | @RequestParam (required= false ,defaultValue= "6" ) Integer pageSize){ |
89 | User user1= (User) httpSession.getAttribute( "user" ); |
90 | Userlist userlist=userlistService.findhasuserlist(user1.getId()); |
91 | PageHelper.startPage(page, pageSize); |
92 | List<Userlist> list=userlistService.getmyapplyout(userlist.getId()); |
93 | PageInfo<Userlist> p= new PageInfo<Userlist>(list); |
94 | model.addAttribute( "userlist" , list); |
95 | model.addAttribute( "p" , p); |
96 | model.addAttribute( "mainPage" , "myapplyout.jsp" ); |
97 | return "zuke/main" ; |
98 | } |
99 | } |
