From 4027bafbacc23baffa32b1de1012d15b04cc0fde Mon Sep 17 00:00:00 2001 From: zkr_liushenlu Date: Thu, 25 Mar 2021 11:02:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=B9=BF=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CmsPicAdInfoController.java | 108 +++++++++ .../ruoyi/content/domain/CmsPicAdInfo.java | 216 ++++++++++++++++++ .../content/mapper/CmsPicAdInfoMapper.java | 63 +++++ .../content/service/ICmsPicAdInfoService.java | 62 +++++ .../service/impl/CmsPicAdInfoServiceImpl.java | 130 +++++++++++ .../mapper/content/CmsPicAdInfoMapper.xml | 113 +++++++++ .../templates/content/picAdverts/add.html | 56 +++++ .../templates/content/picAdverts/edit.html | 57 +++++ .../content/picAdverts/picAdverts.html | 93 ++++++++ 9 files changed, 898 insertions(+) create mode 100644 ruoyi-content/src/main/java/com/ruoyi/content/controller/CmsPicAdInfoController.java create mode 100644 ruoyi-content/src/main/java/com/ruoyi/content/domain/CmsPicAdInfo.java create mode 100644 ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsPicAdInfoMapper.java create mode 100644 ruoyi-content/src/main/java/com/ruoyi/content/service/ICmsPicAdInfoService.java create mode 100644 ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsPicAdInfoServiceImpl.java create mode 100644 ruoyi-content/src/main/resources/mapper/content/CmsPicAdInfoMapper.xml create mode 100644 ruoyi-content/src/main/resources/templates/content/picAdverts/add.html create mode 100644 ruoyi-content/src/main/resources/templates/content/picAdverts/edit.html create mode 100644 ruoyi-content/src/main/resources/templates/content/picAdverts/picAdverts.html diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/controller/CmsPicAdInfoController.java b/ruoyi-content/src/main/java/com/ruoyi/content/controller/CmsPicAdInfoController.java new file mode 100644 index 000000000..4cde6b827 --- /dev/null +++ b/ruoyi-content/src/main/java/com/ruoyi/content/controller/CmsPicAdInfoController.java @@ -0,0 +1,108 @@ +package com.ruoyi.content.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.content.domain.CmsPicAdInfo; +import com.ruoyi.content.service.ICmsPicAdInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 图片广告Controller + * + * @author liushenlu + * @date 2021-03-25 + */ +@Controller +@RequestMapping("/content/picAdverts") +public class CmsPicAdInfoController extends BaseController { + + private String prefix = "content/picAdverts"; + + @Autowired + private ICmsPicAdInfoService cmsPicAdInfoService; + + @GetMapping() + public String picAdverts() { + return prefix + "/picAdverts"; + } + + /** + * 查询图片广告列表 + */ + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(CmsPicAdInfo cmsPicAdInfo) { + startPage(); + List list = cmsPicAdInfoService.selectCmsPicAdInfoList(cmsPicAdInfo); + return getDataTable(list); + } + + /** + * 导出图片广告列表 + */ + @Log(title = "图片广告", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(CmsPicAdInfo cmsPicAdInfo) { + List list = cmsPicAdInfoService.selectCmsPicAdInfoList(cmsPicAdInfo); + ExcelUtil util = new ExcelUtil(CmsPicAdInfo.class); + return util.exportExcel(list, "picAdverts"); + } + + /** + * 新增图片广告 + */ + @GetMapping("/add") + public String add() { + return prefix + "/add"; + } + + /** + * 新增保存图片广告 + */ + @Log(title = "图片广告", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(CmsPicAdInfo cmsPicAdInfo) { + return toAjax(cmsPicAdInfoService.insertCmsPicAdInfo(cmsPicAdInfo)); + } + + /** + * 修改图片广告 + */ + @GetMapping("/edit/{picAdId}") + public String edit(@PathVariable("picAdId") Long picAdId, ModelMap mmap) { + CmsPicAdInfo cmsPicAdInfo = cmsPicAdInfoService.selectCmsPicAdInfoById(picAdId); + mmap.put("cmsPicAdInfo", cmsPicAdInfo); + return prefix + "/edit"; + } + + /** + * 修改保存图片广告 + */ + @Log(title = "图片广告", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(CmsPicAdInfo cmsPicAdInfo) { + return toAjax(cmsPicAdInfoService.updateCmsPicAdInfo(cmsPicAdInfo)); + } + + /** + * 删除图片广告 + */ + @Log(title = "图片广告", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) { + return toAjax(cmsPicAdInfoService.deleteCmsPicAdInfoByIds(ids)); + } +} diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/domain/CmsPicAdInfo.java b/ruoyi-content/src/main/java/com/ruoyi/content/domain/CmsPicAdInfo.java new file mode 100644 index 000000000..e5c926121 --- /dev/null +++ b/ruoyi-content/src/main/java/com/ruoyi/content/domain/CmsPicAdInfo.java @@ -0,0 +1,216 @@ +package com.ruoyi.content.domain; + +import com.ruoyi.common.annotation.Excel; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 图片广告对象 cms_pic_ad_info + * + * @author liushenlu + * @date 2021-03-25 + */ +public class CmsPicAdInfo { + + private static final long serialVersionUID = 1L; + + /** + * 广告编号 + */ + private Long picAdId; + + /** + * 广告类型 + */ + @Excel(name = "广告类型") + private String picAdType; + + /** + * 产品标题 + */ + @Excel(name = "产品标题") + private String picAdTitle; + + /** + * 广告特有名称 + */ + @Excel(name = "广告特有名称") + private String picAdName; + + /** + * 广告链接 + */ + @Excel(name = "广告链接") + private String picAdUrl; + + /** + * 广告状态,0:可展示,1:不可展示 + */ + @Excel(name = "广告状态,0:可展示,1:不可展示") + private String picAdState; + + /** + * 公司id + */ + @Excel(name = "公司id") + private String companyId; + + /** + * + */ + @Excel(name = "") + private String createDate; + + /** + * + */ + @Excel(name = "") + private String createTime; + + /** + * + */ + @Excel(name = "") + private String createUser; + + /** + * + */ + @Excel(name = "") + private String updateUser; + + /** + * + */ + @Excel(name = "") + private String updateDate; + + /** + * + */ + @Excel(name = "") + private String updateTime; + + public void setPicAdId(Long picAdId) { + this.picAdId = picAdId; + } + + public Long getPicAdId() { + return picAdId; + } + + public void setPicAdType(String picAdType) { + this.picAdType = picAdType; + } + + public String getPicAdType() { + return picAdType; + } + + public void setPicAdTitle(String picAdTitle) { + this.picAdTitle = picAdTitle; + } + + public String getPicAdTitle() { + return picAdTitle; + } + + public void setPicAdName(String picAdName) { + this.picAdName = picAdName; + } + + public String getPicAdName() { + return picAdName; + } + + public void setPicAdUrl(String picAdUrl) { + this.picAdUrl = picAdUrl; + } + + public String getPicAdUrl() { + return picAdUrl; + } + + public void setPicAdState(String picAdState) { + this.picAdState = picAdState; + } + + public String getPicAdState() { + return picAdState; + } + + public void setCompanyId(String companyId) { + this.companyId = companyId; + } + + public String getCompanyId() { + return companyId; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public String getCreateDate() { + return createDate; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public String getCreateUser() { + return createUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateDate(String updateDate) { + this.updateDate = updateDate; + } + + public String getUpdateDate() { + return updateDate; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("picAdId", getPicAdId()) + .append("picAdType", getPicAdType()) + .append("picAdTitle", getPicAdTitle()) + .append("picAdName", getPicAdName()) + .append("picAdUrl", getPicAdUrl()) + .append("picAdState", getPicAdState()) + .append("companyId", getCompanyId()) + .append("createDate", getCreateDate()) + .append("createTime", getCreateTime()) + .append("createUser", getCreateUser()) + .append("updateUser", getUpdateUser()) + .append("updateDate", getUpdateDate()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsPicAdInfoMapper.java b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsPicAdInfoMapper.java new file mode 100644 index 000000000..ed4547520 --- /dev/null +++ b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/CmsPicAdInfoMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.content.mapper; + +import java.util.List; + +import com.ruoyi.content.domain.CmsPicAdInfo; +import org.springframework.stereotype.Repository; + +/** + * 图片广告Mapper接口 + * + * @author liushenlu + * @date 2021-03-25 + */ +@Repository +public interface CmsPicAdInfoMapper { + /** + * 查询图片广告 + * + * @param picAdId 图片广告ID + * @return 图片广告 + */ + public CmsPicAdInfo selectCmsPicAdInfoById(Long picAdId); + + /** + * 查询图片广告列表 + * + * @param cmsPicAdInfo 图片广告 + * @return 图片广告集合 + */ + public List selectCmsPicAdInfoList(CmsPicAdInfo cmsPicAdInfo); + + /** + * 新增图片广告 + * + * @param cmsPicAdInfo 图片广告 + * @return 结果 + */ + public int insertCmsPicAdInfo(CmsPicAdInfo cmsPicAdInfo); + + /** + * 修改图片广告 + * + * @param cmsPicAdInfo 图片广告 + * @return 结果 + */ + public int updateCmsPicAdInfo(CmsPicAdInfo cmsPicAdInfo); + + /** + * 删除图片广告 + * + * @param picAdId 图片广告ID + * @return 结果 + */ + public int deleteCmsPicAdInfoById(Long picAdId); + + /** + * 批量删除图片广告 + * + * @param picAdIds 需要删除的数据ID + * @return 结果 + */ + public int deleteCmsPicAdInfoByIds(String[] picAdIds); +} diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/ICmsPicAdInfoService.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/ICmsPicAdInfoService.java new file mode 100644 index 000000000..b5011813a --- /dev/null +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/ICmsPicAdInfoService.java @@ -0,0 +1,62 @@ +package com.ruoyi.content.service; + +import java.util.List; + +import com.ruoyi.content.domain.CmsPicAdInfo; + +/** + * 图片广告Service接口 + * + * @author liushenlu + * @date 2021-03-25 + */ +public interface ICmsPicAdInfoService { + + /** + * 查询图片广告 + * + * @param picAdId 图片广告ID + * @return 图片广告 + */ + public CmsPicAdInfo selectCmsPicAdInfoById(Long picAdId); + + /** + * 查询图片广告列表 + * + * @param cmsPicAdInfo 图片广告 + * @return 图片广告集合 + */ + public List selectCmsPicAdInfoList(CmsPicAdInfo cmsPicAdInfo); + + /** + * 新增图片广告 + * + * @param cmsPicAdInfo 图片广告 + * @return 结果 + */ + public int insertCmsPicAdInfo(CmsPicAdInfo cmsPicAdInfo); + + /** + * 修改图片广告 + * + * @param cmsPicAdInfo 图片广告 + * @return 结果 + */ + public int updateCmsPicAdInfo(CmsPicAdInfo cmsPicAdInfo); + + /** + * 批量删除图片广告 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteCmsPicAdInfoByIds(String ids); + + /** + * 删除图片广告信息 + * + * @param picAdId 图片广告ID + * @return 结果 + */ + public int deleteCmsPicAdInfoById(Long picAdId); +} diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsPicAdInfoServiceImpl.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsPicAdInfoServiceImpl.java new file mode 100644 index 000000000..8b22be310 --- /dev/null +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/CmsPicAdInfoServiceImpl.java @@ -0,0 +1,130 @@ +package com.ruoyi.content.service.impl; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.content.domain.CmsArticleAdInfo; +import com.ruoyi.content.domain.CmsPicAdInfo; +import com.ruoyi.content.mapper.CmsPicAdInfoMapper; +import com.ruoyi.content.redis.RedisManager; +import com.ruoyi.content.service.ICmsPicAdInfoService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 图片广告Service业务层处理 + * + * @author liushenlu + * @date 2021-03-25 + */ +@Service +public class CmsPicAdInfoServiceImpl implements ICmsPicAdInfoService { + + private static final Logger LOGGER = LoggerFactory.getLogger(CmsPicAdInfoServiceImpl.class); + + @Autowired + private CmsPicAdInfoMapper cmsPicAdInfoMapper; + @Autowired + private RedisManager redisManager; + + /** + * 查询图片广告 + * + * @param picAdId 图片广告ID + * @return 图片广告 + */ + @Override + public CmsPicAdInfo selectCmsPicAdInfoById(Long picAdId) { + return cmsPicAdInfoMapper.selectCmsPicAdInfoById(picAdId); + } + + /** + * 查询图片广告列表 + * + * @param cmsPicAdInfo 图片广告 + * @return 图片广告 + */ + @Override + public List selectCmsPicAdInfoList(CmsPicAdInfo cmsPicAdInfo) { + cmsPicAdInfo.setCompanyId("1"); + return cmsPicAdInfoMapper.selectCmsPicAdInfoList(cmsPicAdInfo); + } + + /** + * 新增图片广告 + * + * @param cmsPicAdInfo 图片广告 + * @return 结果 + */ + @Override + public int insertCmsPicAdInfo(CmsPicAdInfo cmsPicAdInfo) { + String date = DateUtils.getDate(); + String time = DateUtils.getTimeNow(); + cmsPicAdInfo.setCompanyId("1"); + cmsPicAdInfo.setPicAdUrl(cmsPicAdInfo.getPicAdUrl() + "("); + cmsPicAdInfo.setCreateDate(date); + cmsPicAdInfo.setCreateTime(time); + cmsPicAdInfo.setCreateUser("company"); + cmsPicAdInfo.setUpdateUser("company"); + cmsPicAdInfo.setUpdateDate(date); + cmsPicAdInfo.setUpdateTime(time); + cmsPicAdInfo.setPicAdState("0"); + return cmsPicAdInfoMapper.insertCmsPicAdInfo(cmsPicAdInfo); + } + + /** + * 修改图片广告 + * + * @param cmsPicAdInfo 图片广告 + * @return 结果 + */ + @Override + public int updateCmsPicAdInfo(CmsPicAdInfo cmsPicAdInfo) { + if (StringUtils.isNotBlank(cmsPicAdInfo.getPicAdUrl()) && cmsPicAdInfo.getPicAdUrl().indexOf("(") == -1) { + cmsPicAdInfo.setPicAdUrl(cmsPicAdInfo.getPicAdUrl() + "("); + } + cmsPicAdInfo.setUpdateDate(DateUtils.getDate()); + cmsPicAdInfo.setUpdateTime(DateUtils.getTimeNow()); + if (cmsPicAdInfoMapper.updateCmsPicAdInfo(cmsPicAdInfo) > 0) { + redisManager.delete("picAdInfo_1"); + } else { + LOGGER.info("编辑广告失败"); + return 0; + } + return 1; + } + + /** + * 删除图片广告对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteCmsPicAdInfoByIds(String ids) { + String[] arrId = ids.split(","); + for (String id : arrId) { + CmsPicAdInfo delType = cmsPicAdInfoMapper.selectCmsPicAdInfoById(Long.valueOf(id)); + if (delType != null) { + redisManager.delete("picAdInfo_1"); + cmsPicAdInfoMapper.deleteCmsPicAdInfoById(Long.valueOf(id)); + } + } + return 1; + } + + /** + * 删除图片广告信息 + * + * @param picAdId 图片广告ID + * @return 结果 + */ + @Override + public int deleteCmsPicAdInfoById(Long picAdId) { + return cmsPicAdInfoMapper.deleteCmsPicAdInfoById(picAdId); + } +} diff --git a/ruoyi-content/src/main/resources/mapper/content/CmsPicAdInfoMapper.xml b/ruoyi-content/src/main/resources/mapper/content/CmsPicAdInfoMapper.xml new file mode 100644 index 000000000..b70854fad --- /dev/null +++ b/ruoyi-content/src/main/resources/mapper/content/CmsPicAdInfoMapper.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + select PIC_AD_ID, PIC_AD_TYPE, PIC_AD_TITLE, PIC_AD_NAME, PIC_AD_URL, PIC_AD_STATE, COMPANY_ID, CREATE_DATE, CREATE_TIME, CREATE_USER, UPDATE_USER, UPDATE_DATE, UPDATE_TIME from cms_pic_ad_info + + + + + + + + insert into cms_pic_ad_info + + PIC_AD_TYPE, + PIC_AD_TITLE, + PIC_AD_NAME, + PIC_AD_URL, + PIC_AD_STATE, + COMPANY_ID, + CREATE_DATE, + CREATE_TIME, + CREATE_USER, + UPDATE_USER, + UPDATE_DATE, + UPDATE_TIME, + + + #{picAdType}, + #{picAdTitle}, + #{picAdName}, + #{picAdUrl}, + #{picAdState}, + #{companyId}, + #{createDate}, + #{createTime}, + #{createUser}, + #{updateUser}, + #{updateDate}, + #{updateTime}, + + + + + update cms_pic_ad_info + + PIC_AD_TYPE = #{picAdType}, + PIC_AD_TITLE = #{picAdTitle}, + PIC_AD_NAME = #{picAdName}, + PIC_AD_URL = #{picAdUrl}, + PIC_AD_STATE = #{picAdState}, + COMPANY_ID = #{companyId}, + CREATE_DATE = #{createDate}, + CREATE_TIME = #{createTime}, + CREATE_USER = #{createUser}, + UPDATE_USER = #{updateUser}, + UPDATE_DATE = #{updateDate}, + UPDATE_TIME = #{updateTime}, + + where PIC_AD_ID = #{picAdId} + + + + delete from cms_pic_ad_info where PIC_AD_ID = #{picAdId} + + + + delete from cms_pic_ad_info where PIC_AD_ID in + + #{picAdId} + + + + \ No newline at end of file diff --git a/ruoyi-content/src/main/resources/templates/content/picAdverts/add.html b/ruoyi-content/src/main/resources/templates/content/picAdverts/add.html new file mode 100644 index 000000000..ffa6deff4 --- /dev/null +++ b/ruoyi-content/src/main/resources/templates/content/picAdverts/add.html @@ -0,0 +1,56 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/ruoyi-content/src/main/resources/templates/content/picAdverts/edit.html b/ruoyi-content/src/main/resources/templates/content/picAdverts/edit.html new file mode 100644 index 000000000..1f34dc7c0 --- /dev/null +++ b/ruoyi-content/src/main/resources/templates/content/picAdverts/edit.html @@ -0,0 +1,57 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/ruoyi-content/src/main/resources/templates/content/picAdverts/picAdverts.html b/ruoyi-content/src/main/resources/templates/content/picAdverts/picAdverts.html new file mode 100644 index 000000000..b9ab23cd9 --- /dev/null +++ b/ruoyi-content/src/main/resources/templates/content/picAdverts/picAdverts.html @@ -0,0 +1,93 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file