|
|
@ -11,11 +11,12 @@ import com.hai.common.security.SessionObject; |
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.bweb.config.SysConfig; |
|
|
|
import com.bweb.config.SysConfig; |
|
|
|
import com.hai.entity.CmsContent; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.CmsPatch; |
|
|
|
|
|
|
|
import com.hai.model.CmsContentModel; |
|
|
|
import com.hai.model.CmsContentModel; |
|
|
|
|
|
|
|
import com.hai.model.OutRechargePriceModel; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
|
|
|
|
import com.hai.service.CmsCategoryService; |
|
|
|
import com.hai.service.CmsContentService; |
|
|
|
import com.hai.service.CmsContentService; |
|
|
|
import com.hai.service.CmsPatchService; |
|
|
|
import com.hai.service.CmsPatchService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
@ -45,9 +47,13 @@ public class CmsContentController { |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private CmsContentService cmsContentService; |
|
|
|
private CmsContentService cmsContentService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private CmsPatchService cmsPatchService; |
|
|
|
private CmsPatchService cmsPatchService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private CmsCategoryService cmsCategoryService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/addContent", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/addContent", method = RequestMethod.POST) |
|
|
|
@ApiOperation(value = "创建内容") |
|
|
|
@ApiOperation(value = "创建内容") |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
@ -180,9 +186,10 @@ public class CmsContentController { |
|
|
|
@ApiOperation(value = "查询内容列表(不包括附件)") |
|
|
|
@ApiOperation(value = "查询内容列表(不包括附件)") |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
public ResponseData getListContent(@RequestParam(value = "title", required = false) String title, |
|
|
|
public ResponseData getListContent(@RequestParam(value = "title", required = false) String title, |
|
|
|
@RequestParam(value = "category", required = false) Long category, |
|
|
|
@RequestParam(value = "categoryId", required = false) Long categoryId, |
|
|
|
@RequestParam(value = "categoryCode", required = false) String categoryCode, |
|
|
|
@RequestParam(value = "categoryCode", required = false) String categoryCode, |
|
|
|
@RequestParam(value = "tag", required = false) String tag, |
|
|
|
@RequestParam(value = "tag", required = false) String tag, |
|
|
|
|
|
|
|
@RequestParam(value = "platform", required = false) String platform, |
|
|
|
@RequestParam(value = "status", required = false) Integer status, |
|
|
|
@RequestParam(value = "status", required = false) Integer status, |
|
|
|
@RequestParam(value = "companyId", required = false) Long companyId, |
|
|
|
@RequestParam(value = "companyId", required = false) Long companyId, |
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
@ -192,8 +199,11 @@ public class CmsContentController { |
|
|
|
if (StringUtils.isNotBlank(title)) { |
|
|
|
if (StringUtils.isNotBlank(title)) { |
|
|
|
paramsMap.put("title", title); |
|
|
|
paramsMap.put("title", title); |
|
|
|
} |
|
|
|
} |
|
|
|
if (category != null) { |
|
|
|
if (categoryId != null) { |
|
|
|
paramsMap.put("category", category.toString()); |
|
|
|
paramsMap.put("categoryId", categoryId.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (platform != null) { |
|
|
|
|
|
|
|
paramsMap.put("platform", platform); |
|
|
|
} |
|
|
|
} |
|
|
|
if (categoryCode != null) { |
|
|
|
if (categoryCode != null) { |
|
|
|
paramsMap.put("categoryCode", categoryCode); |
|
|
|
paramsMap.put("categoryCode", categoryCode); |
|
|
@ -216,7 +226,35 @@ public class CmsContentController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getListCmsContent", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ApiOperation(value = "查询内容列表(不包括附件)") |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
public ResponseData getListCmsContent(@RequestParam(value = "title", required = false) String title, |
|
|
|
|
|
|
|
@RequestParam(value = "categoryId", required = false) Long categoryId, |
|
|
|
|
|
|
|
@RequestParam(value = "platform", required = false) Integer platform, |
|
|
|
|
|
|
|
@RequestParam(value = "status", required = false) Integer status, |
|
|
|
|
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
|
|
|
|
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> paramsMap = new HashMap<>(); |
|
|
|
|
|
|
|
paramsMap.put("title", title); |
|
|
|
|
|
|
|
paramsMap.put("platform", platform); |
|
|
|
|
|
|
|
paramsMap.put("categoryId", categoryId); |
|
|
|
|
|
|
|
paramsMap.put("status", status); |
|
|
|
|
|
|
|
paramsMap.put("companyId", userInfoModel.getBsCompany().getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(cmsContentService.getListCmsContent(paramsMap))); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("CmsContentController --> getListContent() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/updateStatusOfContent", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/updateStatusOfContent", method = RequestMethod.POST) |
|
|
|
@ApiOperation(value = "更新 内容发布状态") |
|
|
|
@ApiOperation(value = "更新 内容发布状态") |
|
|
@ -391,4 +429,160 @@ public class CmsContentController { |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/insertCmsContent", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "新增CMS内容") |
|
|
|
|
|
|
|
public ResponseData insertCmsContent(@RequestBody CmsContent cmsContent, HttpServletRequest request) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cmsContent == null || |
|
|
|
|
|
|
|
cmsContent.getCategoryId() == null || |
|
|
|
|
|
|
|
cmsContent.getTitle() == null || |
|
|
|
|
|
|
|
cmsContent.getSortId() == null || |
|
|
|
|
|
|
|
cmsContent.getDescription() == null |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("CmsContentController -> insertPrice() error!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 获取分类信息
|
|
|
|
|
|
|
|
CmsCategory category = cmsCategoryService.getCategoryById(cmsContent.getCategoryId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Integer platform : cmsContent.getPlatformArray()) { |
|
|
|
|
|
|
|
cmsContent.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
cmsContent.setCreateTime(new Date()); |
|
|
|
|
|
|
|
cmsContent.setStatus(1); |
|
|
|
|
|
|
|
cmsContent.setPlatform(platform); |
|
|
|
|
|
|
|
cmsContent.setCategoryCode(category.getCode()); |
|
|
|
|
|
|
|
cmsContent.setCompanyId(userInfoModel.getBsCompany().getId()); |
|
|
|
|
|
|
|
cmsContent.setCompanyName(userInfoModel.getBsCompany().getName()); |
|
|
|
|
|
|
|
cmsContent.setOpId(userInfoModel.getSecUser().getId()); |
|
|
|
|
|
|
|
cmsContent.setUserName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
|
|
|
cmsContent.setTag(category.getName()); |
|
|
|
|
|
|
|
cmsContentService.insertCmsContent(cmsContent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("新增成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("CmsContentController --> insertPrice() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/updateCmsContent", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "修改CMS内容") |
|
|
|
|
|
|
|
public ResponseData updateCmsContent(@RequestBody CmsContent cmsContent, HttpServletRequest request) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cmsContent == null || |
|
|
|
|
|
|
|
cmsContent.getId() == null || |
|
|
|
|
|
|
|
cmsContent.getCategoryId() == null || |
|
|
|
|
|
|
|
cmsContent.getTitle() == null || |
|
|
|
|
|
|
|
cmsContent.getSortId() == null || |
|
|
|
|
|
|
|
cmsContent.getDescription() == null |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("CmsContentController -> updateCmsContent() error!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CmsContent content = cmsContentService.findById(cmsContent.getId()); |
|
|
|
|
|
|
|
// 获取分类信息
|
|
|
|
|
|
|
|
CmsCategory category = cmsCategoryService.getCategoryById(cmsContent.getCategoryId()); |
|
|
|
|
|
|
|
if (content == null) { |
|
|
|
|
|
|
|
log.error("CmsContentController -> updateCmsContent() error!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "未找到匹配数据!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmsContent.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
cmsContent.setStatus(1); |
|
|
|
|
|
|
|
cmsContent.setCreateTime(content.getCreateTime()); |
|
|
|
|
|
|
|
cmsContent.setOpId(userInfoModel.getSecUser().getId()); |
|
|
|
|
|
|
|
cmsContent.setUserName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
|
|
|
cmsContent.setCompanyName(content.getCompanyName()); |
|
|
|
|
|
|
|
cmsContent.setCompanyId(content.getCompanyId()); |
|
|
|
|
|
|
|
cmsContent.setCategoryCode(category.getCode()); |
|
|
|
|
|
|
|
cmsContent.setTag(category.getName()); |
|
|
|
|
|
|
|
cmsContentService.updateCmsContent(cmsContent); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success("修改成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("CmsContentController --> updateCmsContent() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/updateContentStatus",method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "修改内容状态") |
|
|
|
|
|
|
|
public ResponseData updateContentStatus(@RequestParam(name = "id", required = true) Long id, |
|
|
|
|
|
|
|
@RequestParam(name = "status", required = true) Integer status) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 查询优惠券
|
|
|
|
|
|
|
|
CmsContent cmsContent = cmsContentService.findById(id); |
|
|
|
|
|
|
|
if (cmsContent == null) { |
|
|
|
|
|
|
|
log.error("CmsContentController -> updateContentStatus() error!","未找到相关信息"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相关信息"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cmsContent.setStatus(status); |
|
|
|
|
|
|
|
cmsContent.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
cmsContentService.updateCmsContent(cmsContent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighDiscountController -> updateDiscountStatus() error!",e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/findById", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "根据id查询详情") |
|
|
|
|
|
|
|
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(cmsContentService.findById(id)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("CmsContentController --> findById() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/deleteById", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "根据id删除内容") |
|
|
|
|
|
|
|
public ResponseData deleteById(@RequestParam(value = "id", required = true) Long id) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CmsContent content = cmsContentService.findById(id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content == null) { |
|
|
|
|
|
|
|
log.error("CmsContentController -> updateCmsContent() error!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "未找到匹配数据!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content.getStatus() == 2) { |
|
|
|
|
|
|
|
log.error("CmsContentController -> updateCmsContent() error!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "当前状态不可删除!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
content.setStatus(0); |
|
|
|
|
|
|
|
cmsContentService.updateCmsContent(content); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success("删除成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("CmsContentController --> findById() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|