Skip to content

Commit 73f33e4

Browse files
committed
添加comment 添加重量法计算功能
1 parent 64ab3b1 commit 73f33e4

32 files changed

+2506
-309
lines changed

src/main/java/net/liuxuan/SprKi/controller/admin/UserManagementController.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javax.servlet.http.HttpServletRequest;
2828
import javax.servlet.http.HttpServletResponse;
2929
import java.io.IOException;
30+
import java.lang.reflect.InvocationTargetException;
3031
import java.util.*;
3132

3233
/**
@@ -99,9 +100,9 @@ public String userManage(@ModelAttribute("dto") BaseDTO dto, UserDetailInfo user
99100
// List<String> authslist = userDetailInfoService.listRoles();
100101
List<String> authslist = roleService.findAllRoleNames();
101102
List<Role> allRole = roleService.getAllRole();
102-
redirectAttributesModelMap.put("user", userDetailInfo);
103-
redirectAttributesModelMap.put("authslist", authslist);
104-
redirectAttributesModelMap.put("allRole", allRole);
103+
// redirectAttributesModelMap.put("user", userDetailInfo);
104+
// redirectAttributesModelMap.put("authslist", authslist);
105+
// redirectAttributesModelMap.put("allRole", allRole);
105106
model.put("user", userDetailInfo);
106107
model.put("authslist", authslist);
107108
model.put("allRole", allRole);
@@ -124,7 +125,7 @@ public String userManage(@ModelAttribute("dto") BaseDTO dto, UserDetailInfo user
124125
@RequestMapping("user_ajax")
125126
// @ResponseBody
126127
public void userManageAjax(@ModelAttribute("dto") BaseDTO dto, UserDetailInfo userDetailInfo, HttpServletRequest request,
127-
HttpServletResponse response) throws IOException {
128+
HttpServletResponse response) throws IOException, InvocationTargetException, IllegalAccessException {
128129
// response.setContentType("application/json");
129130
Map<String, Object> rtnData = new HashMap<String, Object>();
130131

@@ -166,7 +167,7 @@ public void userManageAjax(@ModelAttribute("dto") BaseDTO dto, UserDetailInfo us
166167
case "update":
167168
userDetailInfoService.saveUserDetailInfo(userDetailInfo);
168169
SecurityLogHelper.LogHIGHRIGHT(request, LogActionType.USER_UPDATE,userDetailInfo,"更新用户"+userDetailInfo.getDbUser().getUsername(),"");
169-
rtnData.put("success1", "success!");
170+
rtnData.put("success", "success!");
170171
break;
171172
case "list":
172173
List<DbUser> users = userDetailInfoService.listAllUsers();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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.CMSComment;
6+
import net.liuxuan.SprKi.service.CMSCommentService;
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.CMSCommentRepository
28+
* 功能:
29+
* 版本: @version 1.0
30+
* 编制日期: 2017/06/21 14:36
31+
* 修改历史: (主要历史变动原因及说明)
32+
* YYYY-MM-DD | Author | Change Description
33+
* 2017-06-21 | Moses | Created
34+
*/
35+
36+
@Controller
37+
@RequestMapping("/admin")
38+
public class CMSCommentManagementController {
39+
private static Logger log = LoggerFactory.getLogger(CMSCommentManagementController.class);
40+
41+
@Autowired
42+
CMSCommentService cMSCommentService;
43+
44+
@RequestMapping("cMSCommentManage")
45+
@PreAuthorize("hasRole('ROLE_ADMIN')")
46+
public String getPages(Map<String, Object> model) {
47+
48+
return "admin/" + "cMSCommentManage" + " :: middle";
49+
50+
}
51+
52+
@RequestMapping("cMSComment")
53+
public String cMSCommentManage(@ModelAttribute("dto") BaseDTO dto, HttpServletRequest request,
54+
HttpServletResponse response, Map<String, Object> model) throws IOException {
55+
log.info("===cMSCommentManage logged ,the _dto value is : {}", dto.toString());
56+
57+
switch (dto.action) {
58+
case "edit":
59+
CMSComment cMSComment;
60+
Long id = dto.getStr2LongID();
61+
62+
cMSComment = cMSCommentService.findCMSCommentById(id);
63+
if (cMSComment != null) {
64+
} else {
65+
throw new IOException("Got Wrong ID");
66+
}
67+
model.put("cMSComment", cMSComment);
68+
return "admin/snipplets/div_cMSComment :: cMSCommentedit";
69+
default:
70+
return "redirect:/admin/cMSComment_ajax";
71+
// break;
72+
}
73+
}
74+
75+
76+
@RequestMapping("cMSComment_ajax")
77+
// @ResponseBody
78+
public void cMSCommentManageAjax(@ModelAttribute("dto") BaseDTO _dto, CMSComment _cMSComment, HttpServletRequest request,
79+
HttpServletResponse response) throws IOException {
80+
// response.setContentType("application/json");
81+
Map<String, Object> rtnData = new HashMap<String, Object>();
82+
log.info("===cMSCommentManageAjax 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 cMSCommentName = request.getParameter("cMSCommentName");
91+
String cMSCommentNameCN = request.getParameter("cMSCommentNameCN");
92+
String comment = request.getParameter("comment");
93+
// boolean cMSCommentExists = cMSCommentService.checkCMSCommentExists(cMSCommentName);
94+
// if (cMSCommentExists) {
95+
// log.info("===cMSCommentManageAjax logged ,添加CMSComment已存在 : {}");
96+
// rtnData.put("error", "ERROR_CMSCommentExists");
97+
// rtnData.put("status", "fail");
98+
// rtnData.put("msg", "添加CMSComment已存在");
99+
// } else {
100+
rtnData.put("status", "success");
101+
rtnData.put("msg", "成功添加CMSComment");
102+
SecurityLogHelper.LogHIGHRIGHT(request, LogActionType.ADMIN_CREATE, _cMSComment, "添加角色", "");
103+
cMSCommentService.saveCMSComment(_cMSComment);
104+
// }
105+
break;
106+
case "delete":
107+
SecurityLogHelper.LogHIGHRIGHT(request, LogActionType.ADMIN_DELETE, _dto, "删除角色", "");
108+
boolean b = cMSCommentService.deleteCMSCommentById(id);
109+
if (b) {
110+
rtnData.put("status", "success");
111+
rtnData.put("msg", "成功删除CMSComment");
112+
} else {
113+
rtnData.put("error", "ERROR_CMSCommentNotExists");
114+
rtnData.put("status", "fail");
115+
rtnData.put("msg", "CMSComment不存在,删除失败");
116+
}
117+
break;
118+
case "update":
119+
cMSCommentService.saveCMSComment(_cMSComment);
120+
SecurityLogHelper.LogHIGHRIGHT(request, LogActionType.ADMIN_UPDATE, _cMSComment, "更新CMSComment", "");
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("CMSComment_list")
134+
public List<CMSComment> CMSCommentlist() {
135+
return cMSCommentService.getAllCMSComment();
136+
}
137+
}

src/main/java/net/liuxuan/SprKi/controller/faq/FAQController.java

+42-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.liuxuan.SprKi.controller.faq;
22

33
import net.liuxuan.SprKi.entity.CMSCategoryEditor;
4+
import net.liuxuan.SprKi.entity.CMSComment;
45
import net.liuxuan.SprKi.entity.CMSContentTags;
56
import net.liuxuan.SprKi.entity.DTO.FAQSearchDTO;
67
import net.liuxuan.SprKi.entity.labthink.Department;
@@ -12,6 +13,7 @@
1213
import net.liuxuan.SprKi.entity.security.Role;
1314
import net.liuxuan.SprKi.exceptions.ContentNotFoundException;
1415
import net.liuxuan.SprKi.service.CMSCategoryService;
16+
import net.liuxuan.SprKi.service.CMSCommentService;
1517
import net.liuxuan.SprKi.service.CMSContentTagsService;
1618
import net.liuxuan.SprKi.service.labthink.DepartmentService;
1719
import net.liuxuan.SprKi.service.labthink.DeviceTypeService;
@@ -97,9 +99,15 @@ public class FAQController {
9799
@Autowired
98100
FAQContentService faqContentService;
99101

102+
/**
103+
* The Cms content tags service.
104+
*/
100105
@Autowired
101106
CMSContentTagsService cmsContentTagsService;
102107

108+
@Autowired
109+
CMSCommentService cmsCommentService;
110+
103111

104112
/**
105113
* Gets faq.
@@ -228,6 +236,12 @@ public String deleteFAQID(@PathVariable Long id, HttpServletRequest request, Htt
228236
return "redirect:/faq/list";
229237
}
230238

239+
/**
240+
* Create no access right faq content faq content.
241+
*
242+
* @param accessErrorText the access error text
243+
* @return the faq content
244+
*/
231245
@NotNull
232246
public FAQContent createNoAccessRightFaqContent(String accessErrorText) {
233247
FAQContent faq;
@@ -429,6 +443,26 @@ public String postFAQ(FAQContent faq, HttpServletRequest request, Map<String, Ob
429443

430444
}
431445

446+
/**
447+
* Post comment.
448+
*
449+
* @param comment the comment
450+
* @param request the request
451+
* @param response the response
452+
* @param model the model
453+
*/
454+
@RequestMapping(value = "/faq/comment", method = RequestMethod.POST)
455+
// @PreAuthorize("hasRole('ROLE_USER')")
456+
public void postComment(CMSComment comment, HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws IOException {
457+
System.out.println(comment.getId());
458+
FAQContent faq = faqContentService.findById(comment.getId());
459+
comment.setContent(faq);
460+
comment.setId(null);
461+
comment = cmsCommentService.saveCMSComment(comment);
462+
ResponseHelper.writeObjectToResponseAsJson(response,comment);
463+
464+
465+
}
432466

433467
/**
434468
* Gets faq count ajax.
@@ -532,27 +566,28 @@ public String getFAQCount(HttpServletRequest request, HttpServletResponse respon
532566
/**
533567
* Gets faq count ajax.
534568
*
569+
* @param keyword the keyword
535570
* @param request the request
536571
* @param response the response
537572
* @param model the model
538573
* @throws IOException the io exception
539574
*/
540575
@RequestMapping(value = "/tags/{keyword}", method = RequestMethod.GET)
541-
public void getTags_ajax(@PathVariable String keyword,HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws IOException {
576+
public void getTags_ajax(@PathVariable String keyword, HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws IOException {
542577
Map<String, Object> rtnDate = new HashMap<String, Object>();
543578
log.trace("-FAQController.getTags_ajax() Method");
544579

545580
List tagl = cmsContentTagsService.getTagByNameLike(keyword);
546-
rtnDate.put("results",tagl);
581+
rtnDate.put("results", tagl);
547582
ResponseHelper.writeObjectToResponseAsJson(response, rtnDate);
548583
}
549584

550585

551-
/**
552-
* Deviceslist list.
553-
*
554-
* @return the list
555-
*/
586+
/**
587+
* Deviceslist list.
588+
*
589+
* @return the list
590+
*/
556591
@ModelAttribute("Devices_list")
557592
public List<Devices> Deviceslist() {
558593
return devicesService.getAllDevices();
@@ -622,5 +657,4 @@ protected void initBinder(
622657
}
623658

624659

625-
626660
}

src/main/java/net/liuxuan/SprKi/controller/supporttools/FormulaComputeController.java

+17-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.apache.commons.logging.Log;
44
import org.apache.commons.logging.LogFactory;
55
import org.springframework.stereotype.Controller;
6+
import org.springframework.web.bind.annotation.PathVariable;
67
import org.springframework.web.bind.annotation.RequestMapping;
78

89
import javax.servlet.http.HttpServletRequest;
@@ -23,14 +24,21 @@
2324
@Controller
2425
@RequestMapping("/tools")
2526
public class FormulaComputeController {
26-
@RequestMapping("/formula/vacuum")
27-
public String getConverter(HttpServletRequest request,
28-
HttpServletResponse response, Map<String, Object> model){
29-
30-
// model.put("title", "MethodNotSupported");
31-
// model.put("message", "MethodNotSupported");
32-
// model.put("date", new Date());
33-
// model.put("status", "405");
34-
return "tools/vacuum";
27+
// @RequestMapping("/formula/vacuum")
28+
// public String getVacuum(HttpServletRequest request,
29+
// HttpServletResponse response, Map<String, Object> model){
30+
// return "tools/vacuum";
31+
// }
32+
// @RequestMapping("/formula/weight")
33+
// public String getWeight(HttpServletRequest request,
34+
// HttpServletResponse response, Map<String, Object> model){
35+
// return "tools/weight";
36+
// }
37+
// formula/vacuum
38+
// formula/weight
39+
@RequestMapping("/formula/{address}")
40+
public String getXXX(@PathVariable("address") String address, HttpServletRequest request,
41+
HttpServletResponse response, Map<String, Object> model){
42+
return "tools/"+address;
3543
}
3644
}

0 commit comments

Comments
 (0)