Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

modify

  • Loading branch information...
commit a8c06920776e69d42a5ce02590654c1416938239 1 parent 83bc723
@bucketli authored
View
24 src/main/java/com/cinlii/seekyours/web/detail/controller/CommentController.java
@@ -4,25 +4,31 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import net.sf.json.JSONObject;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import com.cinlii.seekyours.comment.biz.CommentUpdateService;
import com.cinlii.seekyours.module.Comment;
+import com.cinlii.seekyours.module.User;
+import com.cinlii.seekyours.util.SeekYoursConstant;
public class CommentController extends MultiActionController {
private CommentUpdateService commentUpdateService;
public void doAdd(HttpServletRequest request, HttpServletResponse response,
- long itemId, String content) throws IOException {
+ @RequestParam("itemId") long itemId,
+ @RequestParam("content") String content) throws IOException {
Comment comment = new Comment();
comment.setAgree(1);
comment.setDisagree(0);
comment.setItemId(itemId);
- // FIXME:userId´ÓsessionÖÐÈ¡
- comment.setUserId(1);
+ HttpSession session=request.getSession();
+ User user=(User)session.getAttribute(SeekYoursConstant.USER_INFO_IN_SESSION);
+ comment.setUserId(user.getId());
comment.setContent(content);
commentUpdateService.addComment(comment);
JSONObject jsonObj = new JSONObject();
@@ -31,26 +37,30 @@ public void doAdd(HttpServletRequest request, HttpServletResponse response,
}
public void doDelete(HttpServletRequest request,
- HttpServletResponse response, long commentId) throws IOException {
+ HttpServletResponse response,
+ @RequestParam("commentId") long commentId) throws IOException {
commentUpdateService.deleteComment(commentId);
response.getWriter().write("success");
}
public void doUpdateAgree(HttpServletRequest request,
- HttpServletResponse response, long commentId) throws IOException {
+ HttpServletResponse response,
+ @RequestParam("commentId") long commentId) throws IOException {
// FIXME:check the guy can update the comment agree
commentUpdateService.updateCommentAgreeOnce(commentId);
response.getWriter().write("success");
}
public void doUpdateDisagree(HttpServletRequest request,
- HttpServletResponse response, long commentId) throws IOException {
+ HttpServletResponse response,
+ @RequestParam("commentId") long commentId) throws IOException {
// FIXME:check the guy can update the comment disagree
commentUpdateService.updateCommentDisagreeOnce(commentId);
response.getWriter().write("success");
}
- public void setCommentUpdateService(CommentUpdateService commentUpdateService) {
+ public void setCommentUpdateService(
+ CommentUpdateService commentUpdateService) {
this.commentUpdateService = commentUpdateService;
}
}
View
3  src/main/java/com/cinlii/seekyours/web/detail/controller/DetailController.java
@@ -5,6 +5,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
@@ -19,7 +20,7 @@
private CommentQueryService commentQueryService;
public ModelAndView queryItemById(HttpServletRequest request,
- HttpServletResponse response, long itemId) {
+ HttpServletResponse response, @RequestParam("itemId") long itemId) {
Item item = itemQueryService.getItemById(itemId);
List<Comment> comments = commentQueryService.getCommentsByItemId(itemId);
View
6 src/main/java/com/cinlii/seekyours/web/list/controller/ListController.java
@@ -6,6 +6,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
@@ -16,12 +17,13 @@
private ItemQueryService itemQueryService;
public ModelAndView doSearch(HttpServletRequest request,
- HttpServletResponse response, String value) {
- ModelAndView mav = new ModelAndView("/list/list");
+ HttpServletResponse response,@RequestParam String value) {
List<Item> items = new ArrayList<Item>();
if (value != null && !value.trim().equals("")) {
items = itemQueryService.getItemListByKeyWord(value);
}
+
+ ModelAndView mav = new ModelAndView("/list/list");
mav.addObject("items", items);
return mav;
}
View
9 src/main/java/com/cinlii/seekyours/web/user/controller/LoginController.java
@@ -8,6 +8,7 @@
import net.sf.json.JSONObject;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
@@ -20,8 +21,8 @@
private UserQueryService userQueryService;
public void doLogin(HttpServletRequest request,
- HttpServletResponse response, HttpSession session, String userName,
- String password) throws IOException {
+ HttpServletResponse response,@RequestParam("userName") String userName,
+ @RequestParam("password") String password) throws IOException {
User user = new User();
user.setUserName(userName);
user.setUserPasswd(password);
@@ -38,6 +39,7 @@ public void doLogin(HttpServletRequest request,
if (re == null) {
jsonObj.put("message", "密码不正确");
} else {
+ HttpSession session=request.getSession();
jsonObj.put("message", "success");
jsonObj.put("username", userName);
SeekUser seekUser = (SeekUser) session
@@ -53,7 +55,8 @@ public void doLogin(HttpServletRequest request,
}
public ModelAndView doLogout(HttpServletRequest request,
- HttpServletResponse response, HttpSession session) {
+ HttpServletResponse response) {
+ HttpSession session=request.getSession();
// 清除session中的user
session.removeAttribute(SeekYoursConstant.USER_INFO_IN_SESSION);
View
71 src/main/java/com/cinlii/seekyours/web/user/controller/RegisterController.java
@@ -8,6 +8,7 @@
import net.sf.json.JSONObject;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import com.cinlii.seekyours.auth.SeekUser;
@@ -16,40 +17,46 @@
import com.cinlii.seekyours.user.biz.UserUpdateService;
import com.cinlii.seekyours.util.SeekYoursConstant;
-public class RegisterController extends MultiActionController{
+public class RegisterController extends MultiActionController {
private UserQueryService userQueryService;
-
+
private UserUpdateService userUpdateService;
-
- public void doRegister(HttpServletRequest request,
- HttpServletResponse response, HttpSession session,String userName,String password,String repassword) throws IOException{
- JSONObject jsonObj=new JSONObject();
- if(!password.equals(repassword)){
- jsonObj.put("message","密码和确认密码不一致");
- }else{
- User user=new User();
- user.setUserName(userName);
- user.setUserPasswd(password);
- if(userQueryService.isUserNameDublicate(user)){
- jsonObj.put("message", "用户名重复");
- }else{
- userUpdateService.register(user);
- SeekUser seekUser = (SeekUser) session.getAttribute(SeekYoursConstant.USER_INFO_IN_SESSION);
-
- if(seekUser==null||!seekUser.hasLoggedIn()){
- seekUser=new SeekUser(SeekYoursConstant.ACCESS_COMMENT_REALM);
- }
- seekUser.upgrade(user.getUserName());
- session.setAttribute(SeekYoursConstant.USER_INFO_IN_SESSION,
- seekUser);
-
- jsonObj.put("message", "success");
- jsonObj.put("username", userName);
- }
- }
-
- response.getWriter().write(jsonObj.toString());
- }
+
+ public void doRegister(HttpServletRequest request,
+ HttpServletResponse response,
+ @RequestParam("userName") String userName,
+ @RequestParam("password") String password,
+ @RequestParam("repassword") String repassword) throws IOException {
+ JSONObject jsonObj = new JSONObject();
+ if (!password.equals(repassword)) {
+ jsonObj.put("message", "密码和确认密码不一致");
+ } else {
+ User user = new User();
+ user.setUserName(userName);
+ user.setUserPasswd(password);
+ if (userQueryService.isUserNameDublicate(user)) {
+ jsonObj.put("message", "用户名重复");
+ } else {
+ HttpSession session = request.getSession();
+ userUpdateService.register(user);
+ SeekUser seekUser = (SeekUser) session
+ .getAttribute(SeekYoursConstant.USER_INFO_IN_SESSION);
+
+ if (seekUser == null || !seekUser.hasLoggedIn()) {
+ seekUser = new SeekUser(
+ SeekYoursConstant.ACCESS_COMMENT_REALM);
+ }
+ seekUser.upgrade(user.getUserName());
+ session.setAttribute(SeekYoursConstant.USER_INFO_IN_SESSION,
+ seekUser);
+
+ jsonObj.put("message", "success");
+ jsonObj.put("username", userName);
+ }
+ }
+
+ response.getWriter().write(jsonObj.toString());
+ }
public void setUserQueryService(UserQueryService userQueryService) {
this.userQueryService = userQueryService;
View
2  src/main/webapp/WEB-INF/spring/servlet-context.xml
@@ -11,7 +11,7 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/t
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
- <!-- <mvc:annotation-driven /> -->
+ <mvc:annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />
View
4 src/main/webapp/WEB-INF/views/home/index.vm
@@ -33,8 +33,8 @@
<div id="search-bar">
<div id="input-border">
<input type="hidden" name="method" value="doSearch"/>
- <input type="text" name="value" id="value" />
- <input type="submit" name="event_submit_do_search" id="search-bt" value="����" />
+ <input type="text" name="value" id="value"/>
+ <input type="submit" id="search-bt" value="����" />
<div class="clear"></div>
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.