@Data
public class CmsPageResult extends ResponseResult {
CmsPage cmsPage;
public CmsPageResult(ResultCode resultCode,CmsPage cmsPage) {
super(resultCode);
this.cmsPage
=
cmsPage;
}
}
@ApiOperation(
"
添加页面
"
)
public CmsPageResult add(CmsPage cmsPage);
public interface CmsPageRepository extends MongoRepository<CmsPage,String> {
//根据页面名称、站点id、页面访问路径查询
CmsPage findByPageNameAndSiteIdAndPageWebPath(String pageName,String siteId,String
pageWebPath);
。。。
public CmsPageResult add(CmsPage cmsPage){
//校验页面是否存在,根据页面名称、站点Id、页面webpath查询
CmsPage cmsPage1 =
cmsPageRepository
.findByPageNameAndSiteIdAndPageWebPath(cmsPage.
getPageName(),
cmsPage.
getSiteId(), cmsPage.
getPageWebPath());
if(cmsPage1==null){
cmsPage.setPageId(null);//添加页面主键由spring data 自动生成
cmsPageRepository
.save(cmsPage);
//返回结果
CmsPageResult cmsPageResult
= new CmsPageResult(CommonCode.SUCCESS,cmsPage);
return cmsPageResult;
}
return new CmsPageResult(CommonCode.FAIL,null);
}
@Override
@PostMapping(
"
/add
"
)
public CmsPageResult add(@RequestBody CmsPage cmsPage) {
return pageService.add(cmsPage);
}
{
"
dataUrl
"
:
"
string
"
,
"
htmlFileId
"
:
"
string
"
,
"
pageAliase
"
:
"
string
"
,
"
pageCreateTime
"
:
"
2018
‐
06
‐
11T02:01:25.667Z
"
,
"
pageHtml
"
:
"
string
"
,
"
pageName
"
:
"
测试页面
"
,
"
pageParameter
"
:
"
string
"
,
"
pagePhysicalPath
"
:
"
string
"
,
"
pageStatus
"
:
"
string
"
,
"
pageTemplate
"
:
"
string
"
,
"
pageType
"
:
"
string
"
,
"
pageWebPath
"
:
"
string
"
,
"
siteId
"
:
"
string
"
,
"
templateId
"
:
"
string
"
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |