33import com .alibaba .fastjson .JSON ;
44import com .alibaba .fastjson .JSONArray ;
55import com .alibaba .fastjson .JSONObject ;
6- import com .danbai .ys .entity .Acces ;
7- import com .danbai .ys .entity .Config ;
8- import com .danbai .ys .entity .Ysb ;
9- import com .danbai .ys .service .impl .AdminServiceImpl ;
10- import com .danbai .ys .service .impl .StatisticalImpl ;
11- import com .danbai .ys .service .impl .UserServiceImpl ;
12- import com .danbai .ys .service .impl .YsServiceImpl ;
6+ import com .danbai .ys .entity .*;
7+ import com .danbai .ys .service .impl .*;
138import com .github .pagehelper .PageInfo ;
9+ import io .swagger .annotations .Api ;
10+ import io .swagger .annotations .ApiOperation ;
1411import org .springframework .beans .factory .annotation .Autowired ;
1512import org .springframework .data .redis .core .RedisTemplate ;
1613import org .springframework .stereotype .Controller ;
2825 * @date 2019/10/13
2926 */
3027@ Controller
28+ @ Api (tags = "管理api" )
3129public class AdminController {
3230 @ Autowired
3331 RedisTemplate redisTemplate ;
@@ -39,13 +37,19 @@ public class AdminController {
3937 StatisticalImpl statistical ;
4038 @ Autowired
4139 AdminServiceImpl adminService ;
40+ @ Autowired
41+ DmServiceImpl dmService ;
42+ @ Autowired
43+ CommImpl comm ;
4244
4345 @ RequestMapping (value = "/admin" , produces = "text/plain;charset=UTF-8" , method = RequestMethod .GET )
44- String admin (Model model ) {
46+ @ ApiOperation (value = "管理视图框架首页" )
47+ String admin () {
4548 return "admin/index" ;
4649 }
4750
4851 @ RequestMapping (value = "/admin/index_v1" , produces = "text/plain;charset=UTF-8" , method = RequestMethod .GET )
52+ @ ApiOperation (value = "管理视图首页" )
4953 String adminIndex (Model model ) {
5054 model .addAttribute ("yssize" , ysService .contYs ());
5155 model .addAttribute ("usersize" , userService .contUser ());
@@ -64,12 +68,38 @@ String adminIndex(Model model) {
6468 }
6569
6670 @ RequestMapping (value = "/admin/ystable" , produces = "text/plain;charset=UTF-8" , method = RequestMethod .GET )
67- String adminYstable (Model model ) {
71+ @ ApiOperation (value = "影视表视图" )
72+ String adminYstable () {
6873 return "admin/ystable" ;
6974 }
7075
76+ @ RequestMapping (value = "/admin/dmtable" , produces = "text/plain;charset=UTF-8" , method = RequestMethod .GET )
77+ @ ApiOperation (value = "弹幕表视图" )
78+ String adminDmtable () {
79+ return "admin/dmtable" ;
80+ }
81+
82+ @ RequestMapping (value = "/admin/feedback" , produces = "text/plain;charset=UTF-8" , method = RequestMethod .GET )
83+ @ ApiOperation (value = "反馈处理视图" )
84+ String adminFeedback (Model model ) {
85+ List <Feedback > allFeedback = comm .getAllFeedback ();
86+ List tList = new ArrayList ();
87+ List fList = new ArrayList ();
88+ allFeedback .forEach (b -> {
89+ if (b .getDispose ()) {
90+ tList .add (b );
91+ } else {
92+ fList .add (b );
93+ }
94+ model .addAttribute ("tlist" , tList );
95+ model .addAttribute ("flist" , fList );
96+ });
97+ return "admin/fb" ;
98+ }
99+
71100 @ RequestMapping (value = "/admin/getysb" , produces = "application/json;charset=UTF-8" , method = RequestMethod .GET )
72101 @ ResponseBody
102+ @ ApiOperation (value = "获取影视表api" )
73103 String adminGetysb (@ RequestParam ("rows" ) Integer rows , @ RequestParam ("page" ) Integer page , String searchString ,
74104 String searchField ) {
75105 JSONObject re = new JSONObject ();
@@ -84,7 +114,7 @@ String adminGetysb(@RequestParam("rows") Integer rows, @RequestParam("page") Int
84114 JSONArray array = JSONArray .parseArray (JSON .toJSONString (p .getList ()));
85115 re .put ("rows" , array );
86116 re .put ("page" , p .getPageNum ());
87- re .put ("total" , p .getPageSize ());
117+ re .put ("total" , p .getPages ());
88118 re .put ("records" , ysService .contYs ());
89119
90120 } else {
@@ -107,6 +137,7 @@ String adminGetysb(@RequestParam("rows") Integer rows, @RequestParam("page") Int
107137
108138 @ RequestMapping (value = "/admin/ysedit" , produces = "application/json;charset=UTF-8" , method = RequestMethod .POST )
109139 @ ResponseBody
140+ @ ApiOperation (value = "影视编辑api" )
110141 String adminYsedit (Ysb ysb , @ RequestParam (value = "oper" , required = false ) String oper ) {
111142 JSONObject re = new JSONObject ();
112143 //noinspection AlibabaSwitchStatement,AlibabaSwitchStatement
@@ -126,11 +157,77 @@ String adminYsedit(Ysb ysb, @RequestParam(value = "oper", required = false) Stri
126157 }
127158
128159 @ RequestMapping (value = "/admin/config" , produces = "text/plain;charset=UTF-8" , method = RequestMethod .GET )
160+ @ ApiOperation (value = "配置视图" )
129161 String adminConfig (Model model ) {
130162 List <Config > config = adminService .getConfig ();
131163 for (Config c : config ) {
132164 model .addAttribute (c .getItem (), c .getValue ());
133165 }
134166 return "admin/config" ;
135167 }
168+
169+ @ RequestMapping (value = "/admin/getdmb" , produces = "application/json;charset=UTF-8" , method = RequestMethod .GET )
170+ @ ResponseBody
171+ @ ApiOperation (value = "获取弹幕表api" )
172+ String adminGetDmb (@ RequestParam ("rows" ) Integer rows , @ RequestParam ("page" ) Integer page , String searchString ,
173+ String searchField ) {
174+ JSONObject re = new JSONObject ();
175+ if (searchString == null ) {
176+ searchString = "" ;
177+ }
178+ if (searchField == null ) {
179+ searchField = "" ;
180+ }
181+ PageResult <Dan > dmList = null ;
182+ if ("" .equals (searchString ) && "" .equals (searchField )) {
183+ dmList = dmService .getDmList (rows , page );
184+ } else {
185+ switch (searchField ) {
186+ case "id" :
187+ dmList = dmService .getDmListById (searchString , rows , page );
188+ break ;
189+ case "author" :
190+ dmList = dmService .getDmListByYsUsername (searchString , rows , page );
191+ break ;
192+ case "player" :
193+ dmList = dmService .getDmListByYsJi (searchString , rows , page );
194+ break ;
195+ default :
196+ dmList = dmService .getDmList (rows , page );
197+ }
198+ }
199+ JSONArray array = JSONArray .parseArray (JSON .toJSONString (dmList .getList ()));
200+ re .put ("rows" , array );
201+ re .put ("page" , page );
202+ re .put ("total" , dmList .getPages ());
203+ re .put ("records" , dmList .getTotal ());
204+ return re .toJSONString ();
205+ }
206+
207+ @ RequestMapping (value = "/admin/dmedit" , produces = "application/json;charset=UTF-8" , method = RequestMethod .POST )
208+ @ ResponseBody
209+ @ ApiOperation (value = "弹幕编辑api" )
210+ String adminDmedit (Dan dan , @ RequestParam (value = "oper" , required = false ) String oper ) {
211+ JSONObject re = new JSONObject ();
212+ switch (oper ) {
213+ case "add" :
214+ dmService .addDm (dan );
215+ break ;
216+ case "edit" :
217+ dmService .updateDm (dan );
218+ break ;
219+ case "del" :
220+ dmService .delDm (dan );
221+ break ;
222+ default :
223+ }
224+ return re .toJSONString ();
225+ }
226+
227+ @ RequestMapping (value = "/admin/okfb" , produces = "application/json;charset=UTF-8" , method = RequestMethod .POST )
228+ @ ResponseBody
229+ @ ApiOperation (value = "完成反馈处理" )
230+ void adminGetDmb (Integer id ) {
231+ comm .okFeedback (id );
232+ }
136233}
0 commit comments