From b9437e3e8c07cd403fd04d3344107f42d7bb14fb Mon Sep 17 00:00:00 2001 From: zkr_liushenlu Date: Wed, 24 Mar 2021 10:09:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=B9=BF=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AdvertisementController.java | 108 ++++++++++++-- .../mapper/CmsArticleAdInfoMapper.java | 19 +-- .../impl/CmsArticleAdInfoServiceImpl.java | 37 +++-- .../mapper.content/CmsArticleAdInfoMapper.xml | 132 ------------------ .../templates/content/adverts/adverts.html | 10 +- 5 files changed, 130 insertions(+), 176 deletions(-) delete mode 100644 ruoyi-content/src/main/resources/mapper.content/CmsArticleAdInfoMapper.xml diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/controller/AdvertisementController.java b/ruoyi-content/src/main/java/com/ruoyi/content/controller/AdvertisementController.java index 2429c3b28..be716afd1 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/controller/AdvertisementController.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/controller/AdvertisementController.java @@ -1,21 +1,113 @@ package com.ruoyi.content.controller; -import com.ruoyi.common.core.controller.BaseController; +import java.util.List; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.content.domain.CmsArticleAdInfo; +import com.ruoyi.content.service.ICmsArticleAdInfoService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; /** - * @program: ruoyi->AdvertisementController - * @description: 广告 - * @author: LiuShenlu - * @create: 2021-03-23 16:26 - **/ + * 文章广告Controller + * + * @author ruoyi + * @date 2021-03-23 + */ @Controller -@RequestMapping("adverts") +@RequestMapping("/content/adverts") public class AdvertisementController extends BaseController { - private String prefix = "adverts"; + private String prefix = "content/adverts"; + @Autowired + private ICmsArticleAdInfoService cmsArticleAdInfoService; + @RequiresPermissions("content:adverts:view") + @GetMapping() + public String adverts() { + return prefix + "/adverts"; + } + /** + * 查询文章广告列表 + */ + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(CmsArticleAdInfo cmsArticleAdInfo) { + startPage(); + List list = cmsArticleAdInfoService.selectCmsArticleAdInfoList(cmsArticleAdInfo); + return getDataTable(list); + } + + /** + * 导出文章广告列表 + */ + @Log(title = "文章广告", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(CmsArticleAdInfo cmsArticleAdInfo) { + List list = cmsArticleAdInfoService.selectCmsArticleAdInfoList(cmsArticleAdInfo); + ExcelUtil util = new ExcelUtil(CmsArticleAdInfo.class); + return util.exportExcel(list, "adverts"); + } + + /** + * 新增文章广告 + */ + @GetMapping("/add") + public String add() { + return prefix + "/add"; + } + + /** + * 新增保存文章广告 + */ + @Log(title = "文章广告", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(CmsArticleAdInfo cmsArticleAdInfo) { + return toAjax(cmsArticleAdInfoService.insertCmsArticleAdInfo(cmsArticleAdInfo)); + } + + /** + * 修改文章广告 + */ + public String edit(@PathVariable("adId") Long adId, ModelMap mmap) { + CmsArticleAdInfo cmsArticleAdInfo = cmsArticleAdInfoService.selectCmsArticleAdInfoById(adId); + mmap.put("cmsArticleAdInfo", cmsArticleAdInfo); + return prefix + "/edit"; + } + + /** + * 修改保存文章广告 + */ + @Log(title = "文章广告", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(CmsArticleAdInfo cmsArticleAdInfo) { + return toAjax(cmsArticleAdInfoService.updateCmsArticleAdInfo(cmsArticleAdInfo)); + } + + /** + * 删除文章广告 + */ + @Log(title = "文章广告", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) { + return toAjax(cmsArticleAdInfoService.deleteCmsArticleAdInfoByIds(ids)); + } } diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsArticleAdInfoMapper.java b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsArticleAdInfoMapper.java index 69c5a61e6..f3af767b5 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsArticleAdInfoMapper.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsArticleAdInfoMapper.java @@ -2,20 +2,21 @@ package com.ruoyi.content.mapper; import com.ruoyi.content.domain.CmsArticleAdInfo; +import org.springframework.stereotype.Repository; import java.util.List; /** * 文章广告Mapper接口 - * + * * @author ruoyi * @date 2021-03-23 */ -public interface CmsArticleAdInfoMapper -{ +@Repository +public interface CmsArticleAdInfoMapper { /** * 查询文章广告 - * + * * @param adId 文章广告ID * @return 文章广告 */ @@ -23,7 +24,7 @@ public interface CmsArticleAdInfoMapper /** * 查询文章广告列表 - * + * * @param cmsArticleAdInfo 文章广告 * @return 文章广告集合 */ @@ -31,7 +32,7 @@ public interface CmsArticleAdInfoMapper /** * 新增文章广告 - * + * * @param cmsArticleAdInfo 文章广告 * @return 结果 */ @@ -39,7 +40,7 @@ public interface CmsArticleAdInfoMapper /** * 修改文章广告 - * + * * @param cmsArticleAdInfo 文章广告 * @return 结果 */ @@ -47,7 +48,7 @@ public interface CmsArticleAdInfoMapper /** * 删除文章广告 - * + * * @param adId 文章广告ID * @return 结果 */ @@ -55,7 +56,7 @@ public interface CmsArticleAdInfoMapper /** * 批量删除文章广告 - * + * * @param adIds 需要删除的数据ID * @return 结果 */ diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsArticleAdInfoServiceImpl.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsArticleAdInfoServiceImpl.java index 5f6dc6b36..0a034be41 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsArticleAdInfoServiceImpl.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsArticleAdInfoServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.content.service.impl; import java.util.List; + import com.ruoyi.common.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -11,87 +12,81 @@ import com.ruoyi.common.core.text.Convert; /** * 文章广告Service业务层处理 - * + * * @author ruoyi * @date 2021-03-23 */ @Service -public class CmsArticleAdInfoServiceImpl implements ICmsArticleAdInfoService -{ +public class CmsArticleAdInfoServiceImpl implements ICmsArticleAdInfoService { + @Autowired private CmsArticleAdInfoMapper cmsArticleAdInfoMapper; /** * 查询文章广告 - * + * * @param adId 文章广告ID * @return 文章广告 */ @Override - public CmsArticleAdInfo selectCmsArticleAdInfoById(Long adId) - { + public CmsArticleAdInfo selectCmsArticleAdInfoById(Long adId) { return cmsArticleAdInfoMapper.selectCmsArticleAdInfoById(adId); } /** * 查询文章广告列表 - * + * * @param cmsArticleAdInfo 文章广告 * @return 文章广告 */ @Override - public List selectCmsArticleAdInfoList(CmsArticleAdInfo cmsArticleAdInfo) - { + public List selectCmsArticleAdInfoList(CmsArticleAdInfo cmsArticleAdInfo) { return cmsArticleAdInfoMapper.selectCmsArticleAdInfoList(cmsArticleAdInfo); } /** * 新增文章广告 - * + * * @param cmsArticleAdInfo 文章广告 * @return 结果 */ @Override - public int insertCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) - { + public int insertCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) { cmsArticleAdInfo.setCreateTime(DateUtils.getNowDate()); return cmsArticleAdInfoMapper.insertCmsArticleAdInfo(cmsArticleAdInfo); } /** * 修改文章广告 - * + * * @param cmsArticleAdInfo 文章广告 * @return 结果 */ @Override - public int updateCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) - { + public int updateCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) { cmsArticleAdInfo.setUpdateTime(DateUtils.getNowDate()); return cmsArticleAdInfoMapper.updateCmsArticleAdInfo(cmsArticleAdInfo); } /** * 删除文章广告对象 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @Override - public int deleteCmsArticleAdInfoByIds(String ids) - { + public int deleteCmsArticleAdInfoByIds(String ids) { return cmsArticleAdInfoMapper.deleteCmsArticleAdInfoByIds(Convert.toStrArray(ids)); } /** * 删除文章广告信息 - * + * * @param adId 文章广告ID * @return 结果 */ @Override - public int deleteCmsArticleAdInfoById(Long adId) - { + public int deleteCmsArticleAdInfoById(Long adId) { return cmsArticleAdInfoMapper.deleteCmsArticleAdInfoById(adId); } } diff --git a/ruoyi-content/src/main/resources/mapper.content/CmsArticleAdInfoMapper.xml b/ruoyi-content/src/main/resources/mapper.content/CmsArticleAdInfoMapper.xml deleted file mode 100644 index edc0eac1c..000000000 --- a/ruoyi-content/src/main/resources/mapper.content/CmsArticleAdInfoMapper.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - select AD_ID, COMPANY_ID, AD_TYPE, AD_TYPE_NAME, AD_LINK_URL, AD_TITLE, AD_NAME, AD_SUMMARY, AD_COLOR_TYPE, AD_IMAGE_URL, AD_STATE, CREATE_DATE, CREATE_TIME, CREATE_USER, UPDATE_USER, UPDATE_DATE, UPDATE_TIME from cms_article_ad_info - - - - - - - - insert into cms_article_ad_info - - COMPANY_ID, - AD_TYPE, - AD_TYPE_NAME, - AD_LINK_URL, - AD_TITLE, - AD_NAME, - AD_SUMMARY, - AD_COLOR_TYPE, - AD_IMAGE_URL, - AD_STATE, - CREATE_DATE, - CREATE_TIME, - CREATE_USER, - UPDATE_USER, - UPDATE_DATE, - UPDATE_TIME, - - - #{companyId}, - #{adType}, - #{adTypeName}, - #{adLinkUrl}, - #{adTitle}, - #{adName}, - #{adSummary}, - #{adColorType}, - #{adImageUrl}, - #{adState}, - #{createDate}, - #{createTime}, - #{createUser}, - #{updateUser}, - #{updateDate}, - #{updateTime}, - - - - - update cms_article_ad_info - - COMPANY_ID = #{companyId}, - AD_TYPE = #{adType}, - AD_TYPE_NAME = #{adTypeName}, - AD_LINK_URL = #{adLinkUrl}, - AD_TITLE = #{adTitle}, - AD_NAME = #{adName}, - AD_SUMMARY = #{adSummary}, - AD_COLOR_TYPE = #{adColorType}, - AD_IMAGE_URL = #{adImageUrl}, - AD_STATE = #{adState}, - CREATE_DATE = #{createDate}, - CREATE_TIME = #{createTime}, - CREATE_USER = #{createUser}, - UPDATE_USER = #{updateUser}, - UPDATE_DATE = #{updateDate}, - UPDATE_TIME = #{updateTime}, - - where AD_ID = #{adId} - - - - delete from cms_article_ad_info where AD_ID = #{adId} - - - - delete from cms_article_ad_info where AD_ID in - - #{adId} - - - - \ No newline at end of file diff --git a/ruoyi-content/src/main/resources/templates/content/adverts/adverts.html b/ruoyi-content/src/main/resources/templates/content/adverts/adverts.html index 4f3767c5a..0a425bfe2 100644 --- a/ruoyi-content/src/main/resources/templates/content/adverts/adverts.html +++ b/ruoyi-content/src/main/resources/templates/content/adverts/adverts.html @@ -90,16 +90,16 @@ @@ -110,8 +110,6 @@