|
|
|
@ -12,6 +12,7 @@ import net.mingsoft.cms.biz.IContentBiz; |
|
|
|
import net.mingsoft.cms.biz.IHistoryLogBiz; |
|
|
|
import net.mingsoft.cms.biz.IHistoryLogBiz; |
|
|
|
import net.mingsoft.cms.entity.ContentEntity; |
|
|
|
import net.mingsoft.cms.entity.ContentEntity; |
|
|
|
import net.mingsoft.cms.entity.HistoryLogEntity; |
|
|
|
import net.mingsoft.cms.entity.HistoryLogEntity; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.ui.ModelMap; |
|
|
|
import org.springframework.ui.ModelMap; |
|
|
|
@ -104,8 +105,8 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{ |
|
|
|
@ApiImplicitParam(name = "contentId", value = "文章编号", required = true,paramType="path") |
|
|
|
@ApiImplicitParam(name = "contentId", value = "文章编号", required = true,paramType="path") |
|
|
|
@GetMapping(value = "/{contentId}/hit") |
|
|
|
@GetMapping(value = "/{contentId}/hit") |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
public String hit(@PathVariable @ApiIgnore int contentId, HttpServletRequest request, HttpServletResponse response){ |
|
|
|
public String hit(@PathVariable @ApiIgnore String contentId, HttpServletRequest request, HttpServletResponse response){ |
|
|
|
if(contentId<=0){ |
|
|
|
if(StringUtils.isEmpty(contentId)){ |
|
|
|
return "document.write(0)"; |
|
|
|
return "document.write(0)"; |
|
|
|
} |
|
|
|
} |
|
|
|
//获取ip
|
|
|
|
//获取ip
|
|
|
|
@ -113,7 +114,7 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{ |
|
|
|
//获取端口(移动/web..)
|
|
|
|
//获取端口(移动/web..)
|
|
|
|
boolean isMobileDevice = BasicUtil.isMobileDevice(); |
|
|
|
boolean isMobileDevice = BasicUtil.isMobileDevice(); |
|
|
|
|
|
|
|
|
|
|
|
ContentEntity content = (ContentEntity)contentBiz.getEntity(contentId); |
|
|
|
ContentEntity content = contentBiz.getById(contentId); |
|
|
|
if(content == null){ |
|
|
|
if(content == null){ |
|
|
|
return "document.write(0)"; |
|
|
|
return "document.write(0)"; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -132,7 +133,10 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{ |
|
|
|
entity.setContentId(content.getId()); |
|
|
|
entity.setContentId(content.getId()); |
|
|
|
entity.setCreateDate(new Date()); |
|
|
|
entity.setCreateDate(new Date()); |
|
|
|
historyLogBiz.saveEntity(entity); |
|
|
|
historyLogBiz.saveEntity(entity); |
|
|
|
if(content.getAppId() == null || content.getAppId() != BasicUtil.getApp().getAppId()){ |
|
|
|
// 单站点不存在appid
|
|
|
|
|
|
|
|
if(content.getAppId() == null ){ |
|
|
|
|
|
|
|
return "document.write(" + content.getContentHit() + ")"; |
|
|
|
|
|
|
|
}else if(content.getAppId() != BasicUtil.getApp().getAppId()){ |
|
|
|
return "document.write(0)"; |
|
|
|
return "document.write(0)"; |
|
|
|
} |
|
|
|
} |
|
|
|
return "document.write(" + content.getContentHit() + ")"; |
|
|
|
return "document.write(" + content.getContentHit() + ")"; |
|
|
|
|