-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarrageController.java
More file actions
59 lines (52 loc) · 1.99 KB
/
BarrageController.java
File metadata and controls
59 lines (52 loc) · 1.99 KB
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
package controller;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import entity.Barrage;
import entity.JsonResult;
import entity.User;
import service.IBarrageService;
@Controller
public class BarrageController {
private IBarrageService barrageService;
public IBarrageService getBarrageService() {
return barrageService;
}
@Resource
public void setBarrageService(IBarrageService barrageService) {
this.barrageService = barrageService;
}
@RequestMapping(value="/customer/restBarrageJson", method = RequestMethod.GET)
public @ResponseBody JsonResult<Barrage> showBarrage(int pageSize,int pageNum,
String sort,String order,HttpServletRequest req) {
int pn=pageNum/10+1;
User user=(User) req.getSession().getAttribute("user");
PageHelper.startPage(pn,pageSize,sort+" "+order);
PageInfo<Barrage> page = new PageInfo<Barrage>(barrageService.uniteBarrage(user.getUserid()));
return new JsonResult<Barrage>(page);
}
@RequestMapping(value = "/customer/{barrageid}/restBarrageJson", method = RequestMethod.DELETE)
public @ResponseBody
JsonResult barrageidDelete(@PathVariable int barrageid) {
boolean res = barrageService.deleteBarrage(barrageid);
if (res) {
return new JsonResult("删除成功");
} else {
return new JsonResult(JsonResult.ERROR, "删除失败!");
}
}
@RequestMapping("/{userid}/getBarragePage")
public @ResponseBody JsonResult<Barrage> getPage(@PathVariable String userid){
PageHelper.startPage(1,3);
List<Barrage> barrage = barrageService.findAllBarrage(userid);
PageInfo<Barrage> page = new PageInfo<Barrage>(barrage);
return new JsonResult<Barrage>(page);
}
}