forked from shuzheng/zheng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.zheng.cms.web.controller; | ||
|
||
import com.zheng.cms.common.constant.CmsResult; | ||
import com.zheng.cms.common.constant.CmsResultConstant; | ||
import com.zheng.cms.dao.model.CmsComment; | ||
import com.zheng.cms.rpc.api.CmsCommentService; | ||
import com.zheng.common.base.BaseController; | ||
import com.zheng.common.util.RequestUtil; | ||
import org.apache.shiro.authz.annotation.RequiresPermissions; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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 javax.servlet.http.HttpServletRequest; | ||
|
||
/** | ||
* 评论控制器 | ||
* Created by shuzheng on 2017/3/26. | ||
*/ | ||
@Controller | ||
@RequestMapping(value = "/comment") | ||
public class CommentController extends BaseController { | ||
|
||
private static Logger _log = LoggerFactory.getLogger(CommentController.class); | ||
|
||
@Autowired | ||
private CmsCommentService cmsCommentService; | ||
|
||
@RequiresPermissions("cms:comment:create") | ||
@RequestMapping(value = "/create/{articleId}", method = RequestMethod.POST) | ||
@ResponseBody | ||
public Object create(@PathVariable("articleId") int articleId, CmsComment cmsComment, HttpServletRequest request) { | ||
long time = System.currentTimeMillis(); | ||
cmsComment.setCtime(time); | ||
cmsComment.setArticleId(articleId); | ||
cmsComment.setUserId(1); | ||
cmsComment.setStatus((byte) 1); | ||
cmsComment.setIp(RequestUtil.getIpAddr(request)); | ||
cmsComment.setAgent(request.getHeader("User-Agent")); | ||
int count = cmsCommentService.insertSelective(cmsComment); | ||
return new CmsResult(CmsResultConstant.SUCCESS, count); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters