Skip to content

Commit ddd15f9

Browse files
Add files via upload
1 parent fc2b0d1 commit ddd15f9

File tree

4 files changed

+213
-0
lines changed

4 files changed

+213
-0
lines changed

AdController.java

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package org.imooc.controller.content;
2+
3+
import javax.servlet.http.HttpServletRequest;
4+
5+
import org.imooc.constant.PageCodeEnum;
6+
import org.imooc.dto.AdDto;
7+
import org.imooc.service.AdService;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.stereotype.Controller;
10+
import org.springframework.ui.Model;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RequestParam;
13+
14+
@Controller
15+
@RequestMapping("/ad")
16+
public class AdController {
17+
18+
@Autowired
19+
private AdService adService;
20+
21+
/**
22+
* 广告管理页初始化(点广告管理菜单进入的第一个页面)
23+
*/
24+
@RequestMapping
25+
public String init(Model model, HttpServletRequest request) {
26+
AdDto adDto = new AdDto();
27+
model.addAttribute("list", adService.searchByPage(adDto));
28+
model.addAttribute("searchParam", adDto);
29+
return "/content/adList";
30+
}
31+
32+
/**
33+
* 查询
34+
*/
35+
@RequestMapping("/search")
36+
public String search(Model model, AdDto adDto) {
37+
model.addAttribute("list", adService.searchByPage(adDto));
38+
model.addAttribute("searchParam", adDto);
39+
return "/content/adList";
40+
}
41+
42+
/**
43+
* 删除
44+
*/
45+
@RequestMapping("/remove")
46+
public String remove(@RequestParam("id") Long id,Model model) {
47+
if(adService.remove(id)) {
48+
model.addAttribute(PageCodeEnum.KEY, PageCodeEnum.REMOVE_SUCCESS);
49+
} else {
50+
model.addAttribute(PageCodeEnum.KEY, PageCodeEnum.REMOVE_FAIL);
51+
}
52+
return "forward:/ad";
53+
}
54+
55+
/**
56+
* 新增页初始化
57+
*/
58+
@RequestMapping("/addInit")
59+
public String addInit() {
60+
return "/content/adAdd";
61+
}
62+
63+
/**
64+
* 新增
65+
*/
66+
@RequestMapping("/add")
67+
public String add(AdDto adDto, Model model) {
68+
if (adService.add(adDto)) {
69+
model.addAttribute(PageCodeEnum.KEY, PageCodeEnum.ADD_SUCCESS);
70+
} else {
71+
model.addAttribute(PageCodeEnum.KEY, PageCodeEnum.ADD_FAIL);
72+
}
73+
return "/content/adAdd";
74+
}
75+
76+
/**
77+
* 修改页初始化
78+
*/
79+
@RequestMapping("/modifyInit")
80+
public String modifyInit(Model model, @RequestParam("id") Long id) {
81+
model.addAttribute("modifyObj", adService.getById(id));
82+
return "/content/adModify";
83+
}
84+
85+
/**
86+
* 修改
87+
*/
88+
@RequestMapping("/modify")
89+
public String modify(Model model, AdDto adDto) {
90+
model.addAttribute("modifyObj", adDto);
91+
if (adService.modify(adDto)) {
92+
model.addAttribute(PageCodeEnum.KEY, PageCodeEnum.MODIFY_SUCCESS);
93+
} else {
94+
model.addAttribute(PageCodeEnum.KEY, PageCodeEnum.MODIFY_FAIL);
95+
}
96+
return "/content/adModify";
97+
}
98+
}

BusinessesController.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package org.imooc.controller.content;
2+
3+
import javax.annotation.Resource;
4+
5+
import org.imooc.constant.DicTypeConst;
6+
import org.imooc.constant.PageCodeEnum;
7+
import org.imooc.dto.BusinessDto;
8+
import org.imooc.service.BusinessService;
9+
import org.imooc.service.DicService;
10+
import org.springframework.stereotype.Controller;
11+
import org.springframework.ui.Model;
12+
import org.springframework.web.bind.annotation.PathVariable;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestMethod;
15+
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
16+
17+
@Controller
18+
@RequestMapping("/businesses")
19+
public class BusinessesController {
20+
21+
@Resource
22+
private DicService dicService;
23+
24+
@Resource
25+
private BusinessService businessService;
26+
27+
/**
28+
* 商户列表
29+
*/
30+
@RequestMapping(method = RequestMethod.GET)
31+
public String search(Model model, BusinessDto dto) {
32+
model.addAttribute("list", businessService.searchByPage(dto));
33+
model.addAttribute("searchParam", dto);
34+
return "/content/businessList";
35+
}
36+
37+
/**
38+
* 删除商户
39+
*/
40+
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
41+
public String remove(@PathVariable("id") Long id) {
42+
return "redirect:/businesses";
43+
}
44+
45+
/**
46+
* 商户新增页初始化
47+
*/
48+
@RequestMapping(value = "/addPage", method = RequestMethod.GET)
49+
public String addInit(Model model) {
50+
model.addAttribute("cityList", dicService.getListByType(DicTypeConst.CITY));
51+
model.addAttribute("categoryList", dicService.getListByType(DicTypeConst.CATEGORY));
52+
return "/content/businessAdd";
53+
}
54+
55+
/**
56+
* 商户新增
57+
*/
58+
@RequestMapping(method = RequestMethod.POST)
59+
public String add(BusinessDto dto,RedirectAttributes attr) {
60+
if(businessService.add(dto)) {
61+
attr.addAttribute(PageCodeEnum.KEY, PageCodeEnum.ADD_SUCCESS);
62+
return "redirect:/businesses";
63+
} else {
64+
attr.addAttribute(PageCodeEnum.KEY, PageCodeEnum.ADD_FAIL);
65+
return "redirect:/businesses/addPage";
66+
}
67+
}
68+
69+
/**
70+
* 商户修改页初始化
71+
*/
72+
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
73+
public String modifyInit(Model model, @PathVariable("id") Long id) {
74+
model.addAttribute("cityList", dicService.getListByType(DicTypeConst.CITY));
75+
model.addAttribute("categoryList", dicService.getListByType(DicTypeConst.CATEGORY));
76+
model.addAttribute("modifyObj", businessService.getById(id));
77+
return "/content/businessModify";
78+
}
79+
80+
/**
81+
* 商户修改
82+
*/
83+
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
84+
public String modify(@PathVariable("id") Long id, BusinessDto dto) {
85+
System.out.println(id);
86+
return "/content/businessModify";
87+
}
88+
}

CommentsController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.imooc.controller.content;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
6+
@Controller
7+
@RequestMapping("/comments")
8+
public class CommentsController {
9+
@RequestMapping
10+
public String init() {
11+
return "/content/commentList";
12+
}
13+
}

OrdersController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.imooc.controller.content;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
6+
@Controller
7+
@RequestMapping("/orders")
8+
public class OrdersController {
9+
10+
@RequestMapping
11+
public String init() {
12+
return "/content/orderList";
13+
}
14+
}

0 commit comments

Comments
 (0)