1
+ package net .liuxuan .SprKi .controller .admin .labthink ;
2
+
3
+ import net .liuxuan .SprKi .entity .DTO .BaseDTO ;
4
+ import net .liuxuan .SprKi .entity .security .LogActionType ;
5
+ import net .liuxuan .SprKi .entity .CMSContentTags ;
6
+ import net .liuxuan .SprKi .service .CMSContentTagsService ;
7
+ import net .liuxuan .spring .Helper .ResponseHelper ;
8
+ import net .liuxuan .spring .Helper .SecurityLogHelper ;
9
+ import org .slf4j .Logger ;
10
+ import org .slf4j .LoggerFactory ;
11
+ import org .springframework .beans .factory .annotation .Autowired ;
12
+ import org .springframework .security .access .prepost .PreAuthorize ;
13
+ import org .springframework .stereotype .Controller ;
14
+ import org .springframework .web .bind .annotation .ModelAttribute ;
15
+ import org .springframework .web .bind .annotation .RequestMapping ;
16
+
17
+ import javax .servlet .http .HttpServletRequest ;
18
+ import javax .servlet .http .HttpServletResponse ;
19
+ import java .io .IOException ;
20
+ import java .util .HashMap ;
21
+ import java .util .List ;
22
+ import java .util .Map ;
23
+
24
+ /**
25
+ * Copyright (c) 2010-2016. by Liuxuan All rights reserved. <br/>
26
+ * ***************************************************************************
27
+ * 源文件名: net.liuxuan.SprKi.controller.admin.labthink.CMSContentTagsRepository
28
+ * 功能:
29
+ * 版本: @version 1.0
30
+ * 编制日期: 2017/06/19 10:10
31
+ * 修改历史: (主要历史变动原因及说明)
32
+ * YYYY-MM-DD | Author | Change Description
33
+ * 2017-06-19 | Moses | Created
34
+ */
35
+
36
+ @ Controller
37
+ @ RequestMapping ("/admin" )
38
+ public class CMSContentTagsManagementController {
39
+ private static Logger log = LoggerFactory .getLogger (CMSContentTagsManagementController .class );
40
+
41
+ @ Autowired
42
+ CMSContentTagsService cMSContentTagsService ;
43
+
44
+ @ RequestMapping ("cMSContentTagsManage" )
45
+ @ PreAuthorize ("hasRole('ROLE_ADMIN')" )
46
+ public String getPages (Map <String , Object > model ) {
47
+
48
+ return "admin/" + "cMSContentTagsManage" + " :: middle" ;
49
+
50
+ }
51
+
52
+ @ RequestMapping ("cMSContentTags" )
53
+ public String cMSContentTagsManage (@ ModelAttribute ("dto" ) BaseDTO dto , HttpServletRequest request ,
54
+ HttpServletResponse response , Map <String , Object > model ) throws IOException {
55
+ log .info ("===cMSContentTagsManage logged ,the _dto value is : {}" , dto .toString ());
56
+
57
+ switch (dto .action ) {
58
+ case "edit" :
59
+ CMSContentTags cMSContentTags ;
60
+ Long id = dto .getStr2LongID ();
61
+
62
+ cMSContentTags = cMSContentTagsService .findCMSContentTagsById (id );
63
+ if (cMSContentTags != null ) {
64
+ } else {
65
+ throw new IOException ("Got Wrong ID" );
66
+ }
67
+ model .put ("cMSContentTags" , cMSContentTags );
68
+ return "admin/snipplets/div_cMSContentTags :: cMSContentTagsedit" ;
69
+ default :
70
+ return "redirect:/admin/cMSContentTags_ajax" ;
71
+ // break;
72
+ }
73
+ }
74
+
75
+
76
+ @ RequestMapping ("cMSContentTags_ajax" )
77
+ // @ResponseBody
78
+ public void cMSContentTagsManageAjax (@ ModelAttribute ("dto" ) BaseDTO _dto , CMSContentTags _cMSContentTags , HttpServletRequest request ,
79
+ HttpServletResponse response ) throws IOException {
80
+ // response.setContentType("application/json");
81
+ Map <String , Object > rtnData = new HashMap <String , Object >();
82
+ log .info ("===cMSContentTagsManageAjax logged ,the value is : {}" , _dto .toString ());
83
+ Long id = _dto .getStr2LongID ();
84
+
85
+ // response.setContentType("application/json");
86
+ // ObjectMapper mapper = new ObjectMapper();
87
+ // mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
88
+ switch (_dto .action ) {
89
+ case "add" :
90
+ String cMSContentTagsName = request .getParameter ("cMSContentTagsName" );
91
+ String cMSContentTagsNameCN = request .getParameter ("cMSContentTagsNameCN" );
92
+ String comment = request .getParameter ("comment" );
93
+ boolean cMSContentTagsExists = cMSContentTagsService .checkCMSContentTagsExists (cMSContentTagsName );
94
+ if (cMSContentTagsExists ) {
95
+ log .info ("===cMSContentTagsManageAjax logged ,添加CMSContentTags已存在 : {}" );
96
+ rtnData .put ("error" , "ERROR_CMSContentTagsExists" );
97
+ rtnData .put ("status" , "fail" );
98
+ rtnData .put ("msg" , "添加CMSContentTags已存在" );
99
+ } else {
100
+ rtnData .put ("status" , "success" );
101
+ rtnData .put ("msg" , "成功添加CMSContentTags" );
102
+ SecurityLogHelper .LogHIGHRIGHT (request , LogActionType .ADMIN_CREATE , _cMSContentTags , "添加角色" , "" );
103
+ cMSContentTagsService .saveCMSContentTags (_cMSContentTags );
104
+ }
105
+ break ;
106
+ case "delete" :
107
+ SecurityLogHelper .LogHIGHRIGHT (request , LogActionType .ADMIN_DELETE , _dto , "删除角色" , "" );
108
+ boolean b = cMSContentTagsService .deleteCMSContentTagsById (id );
109
+ if (b ) {
110
+ rtnData .put ("status" , "success" );
111
+ rtnData .put ("msg" , "成功删除CMSContentTags" );
112
+ } else {
113
+ rtnData .put ("error" , "ERROR_CMSContentTagsNotExists" );
114
+ rtnData .put ("status" , "fail" );
115
+ rtnData .put ("msg" , "CMSContentTags不存在,删除失败" );
116
+ }
117
+ break ;
118
+ case "update" :
119
+ cMSContentTagsService .saveCMSContentTags (_cMSContentTags );
120
+ SecurityLogHelper .LogHIGHRIGHT (request , LogActionType .ADMIN_UPDATE , _cMSContentTags , "更新CMSContentTags" , "" );
121
+ rtnData .put ("success1" , "success!" );
122
+ break ;
123
+ default :
124
+
125
+ break ;
126
+ }
127
+ // return "";
128
+ // mapper.writeValue(response.getWriter(), rtnData);
129
+ ResponseHelper .writeMapToResponseAsJson (response , rtnData );
130
+ }
131
+
132
+
133
+ @ ModelAttribute ("CMSContentTags_list" )
134
+ public List <CMSContentTags > CMSContentTagslist () {
135
+ return cMSContentTagsService .getAllCMSContentTags ();
136
+ }
137
+ }
0 commit comments