diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/controller/GalleryController.java b/ruoyi-content/src/main/java/com/ruoyi/content/controller/GalleryController.java index c0a2fc2f1..5663bd700 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/controller/GalleryController.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/controller/GalleryController.java @@ -1,6 +1,9 @@ package com.ruoyi.content.controller; import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.content.domain.GalleryPicInfoEx; import com.ruoyi.content.message.Message; import com.ruoyi.content.service.GalleryService; import org.slf4j.Logger; @@ -10,6 +13,9 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import java.util.List; + /** * @program: ruoyi->GalleryController * @description: @@ -53,4 +59,56 @@ public class GalleryController extends BaseController { return msg; } + /** + * 根据栏目图库列表 + * + * @param request + * @return + */ + @RequestMapping("/galleryImgList") + @ResponseBody + public TableDataInfo galleryImgList(HttpServletRequest request) { + LOGGER.info("上传图库图片控制层方法开始"); + String channel = request.getParameter("channel"); + String picState = "0"; + String special = "GALLERY"; + startPage(); + List galleryPicInfos = galleryService.galleryImgList(channel, picState, special); + LOGGER.info("查询图库列表的控制层方法结束!"); + return getDataTable(galleryPicInfos); + } + + /** + * 图片删除 + * + * @return + */ + @RequestMapping("/remove") + @ResponseBody + public AjaxResult delGalleryPic(String ids) { + LOGGER.info("删除图片信息控制层方法开始"); + try { + return toAjax(galleryService.delGalleryPic(ids)); + } catch (Exception e) { + LOGGER.info("删除文章信息失败【{}】", e.getMessage()); + } + LOGGER.info("删除图片信息的控制层方法结束!"); + return toAjax(0); + } + + /** + * 图片图库栏目录入 + * + * @return + */ + @PostMapping("/addGallery") + @ResponseBody + public Message addGallery(String channelId, String picId) { + LOGGER.info("图库图片分配栏目控制层方法开始"); + LOGGER.info(channelId + "------" + picId); + Message msg = galleryService.addGallery(channelId, picId); + LOGGER.info("图库图片分配栏目控制层方法结束"); + return msg; + } + } diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/domain/GalleryPicInfoEx.java b/ruoyi-content/src/main/java/com/ruoyi/content/domain/GalleryPicInfoEx.java new file mode 100644 index 000000000..9a87baddc --- /dev/null +++ b/ruoyi-content/src/main/java/com/ruoyi/content/domain/GalleryPicInfoEx.java @@ -0,0 +1,14 @@ +package com.ruoyi.content.domain; + +public class GalleryPicInfoEx extends GalleryPicInfo { + + private String codeName; + + public String getCodeName() { + return codeName; + } + + public void setCodeName(String codeName) { + this.codeName = codeName; + } +} \ No newline at end of file diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/GalleryQueryMapper.java b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/GalleryQueryMapper.java index 3cfb4b4a8..e0d6e68a9 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/GalleryQueryMapper.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/GalleryQueryMapper.java @@ -1,6 +1,7 @@ package com.ruoyi.content.mapper; import com.ruoyi.content.domain.GalleryPicInfo; +import com.ruoyi.content.domain.GalleryPicInfoEx; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -9,9 +10,8 @@ import java.util.List; @Repository public interface GalleryQueryMapper { - public List selectAllWithLimit(@Param(value = "companyId") String companyId, @Param(value = "branchId") String branchId, - @Param(value = "picState") List picState, @Param(value = "picId") List picId, - @Param(value = "startRow") int startRow, @Param(value = "rows") int rows); + public List selectAllWithLimit(@Param(value = "companyId") String companyId, @Param(value = "branchId") String branchId, + @Param(value = "picState") List picState, @Param(value = "picId") List picId); public List selectChannelId(@Param(value = "picId") Integer picId); diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/GalleryService.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/GalleryService.java index a694f79ba..cf9acf385 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/service/GalleryService.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/GalleryService.java @@ -1,6 +1,6 @@ package com.ruoyi.content.service; -import com.ruoyi.content.domain.GalleryDTO; +import com.ruoyi.content.domain.GalleryPicInfoEx; import com.ruoyi.content.message.Message; import org.springframework.web.multipart.MultipartFile; @@ -25,7 +25,7 @@ public interface GalleryService { * @param picState * @return */ - public List galleryImgList(int startRow, int rows, String channelId, String picState, String special); + public List galleryImgList(String channelId, String picState, String special); /** * 图片个数 @@ -60,5 +60,5 @@ public interface GalleryService { * @param ids * @return */ - public Message delGalleryPic(String ids); + public Integer delGalleryPic(String ids); } diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/GalleryServiceImpl.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/GalleryServiceImpl.java index 2e46cac76..71cda5091 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/GalleryServiceImpl.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/GalleryServiceImpl.java @@ -130,8 +130,8 @@ public class GalleryServiceImpl implements GalleryService { } @Override - public List galleryImgList(int startRow, int rows, String channelId, String picState, String special) { - LOGGER.info("拿到的参数startRow【{}】,rows【{}】,所属栏目【{}】,图片状态【{}】", startRow, rows, channelId, picState); + public List galleryImgList(String channelId, String picState, String special) { + LOGGER.info("拿到的参数,所属栏目【{}】,图片状态【{}】", channelId, picState); String companyId = "1";// 公司id String branchId = "86"; List list = new ArrayList(); @@ -161,32 +161,15 @@ public class GalleryServiceImpl implements GalleryService { } } - List galleryList = galleryQueryMapper.selectAllWithLimit(companyId, branchId, list, picIds, startRow, rows); + List galleryList = galleryQueryMapper.selectAllWithLimit(companyId, branchId, list, picIds); if (galleryList == null || galleryList.size() < 1) { LOGGER.info("未查询到数据"); throw new BusinessException("图库暂没有海报!"); } //所属二级栏目 - List galleryDTOs = new ArrayList<>(); - for (GalleryPicInfo galleryPicInfo : galleryList) { - GalleryDTO galleryDTO = new GalleryDTO(); - galleryDTO.setPicId(galleryPicInfo.getPicId()); - galleryDTO.setImgUrl(galleryPicInfo.getImgUrl()); - galleryDTO.setPicAdId(galleryPicInfo.getPicAdId()); - galleryDTO.setPicState(galleryPicInfo.getPicState()); - galleryDTO.setCompanyId(galleryPicInfo.getCompanyId()); - galleryDTO.setCreateDate(galleryPicInfo.getCreateDate()); - galleryDTO.setCreateTime(galleryPicInfo.getCreateTime()); - LOGGER.info("图库数据【{}】", JsonUtil.objectToJackson(galleryDTO)); - List codeName = new ArrayList<>(); -// List channelIds = galleryQueryMapper.selectChannelId(galleryPicInfo.getPicId()); -// for (String string : channelIds) { -// LOGGER.info("栏目id【{}】", string); -// BaseCodeExample example = new BaseCodeExample(); -// BaseCodeExample.Criteria criteria = example.createCriteria(); -// criteria.andCodeCodeEqualTo(string).andStateEqualTo("0").andCodeTypeEqualTo("GALLERY"); - + for (GalleryPicInfoEx galleryPicInfo : galleryList) { + String codeName = ""; GalleryChannelExample channelexample = new GalleryChannelExample(); channelexample.createCriteria().andPicIdEqualTo(galleryPicInfo.getPicId()).andStateEqualTo("0"); List galleryChannels = this.galleryChannelMapper.selectByExample(channelexample); @@ -199,14 +182,13 @@ public class GalleryServiceImpl implements GalleryService { List baseCodes = this.baseCodeMapper.selectByExample(example); LOGGER.info("栏目数据【{}】", JsonUtil.objectToJackson(baseCodes)); if ((baseCodes != null) && (baseCodes.size() > 0)) { - codeName.add(((BaseCode) baseCodes.get(0)).getCodeCname()); + codeName = codeName + baseCodes.get(0).getCodeCname() + ","; } } - galleryDTO.setCodeName(codeName); - galleryDTOs.add(galleryDTO); + galleryPicInfo.setCodeName(StringUtils.isNotBlank(codeName) ? codeName.substring(0, codeName.length() - 1) : ""); } - return galleryDTOs; + return galleryList; } @Override @@ -348,16 +330,13 @@ public class GalleryServiceImpl implements GalleryService { } @Override - public Message delGalleryPic(String ids) { + public Integer delGalleryPic(String ids) { LOGGER.info("删除图片信息的业务层方法开始!"); LOGGER.info("删除图片信息的业务层方法中拿到的图片的id【{}】", ids); - Message msg = new Message(); if (StringUtils.isBlank(ids)) { LOGGER.info("删除图片信息失败,缺少参数"); throw new ParameterException("未查询到图片信息"); } - msg.setInfo("删除失败!"); - msg.setResult(false); try { String[] arrId = ids.split(","); for (String picId : arrId) { @@ -369,8 +348,6 @@ public class GalleryServiceImpl implements GalleryService { for (GalleryChannel galleryChannel : galleryChannels) { galleryChannel.setState("1"); if (galleryChannelMapper.updateByPrimaryKey(galleryChannel) > 0) { - msg.setInfo("删除成功!"); - msg.setResult(true); LOGGER.info("删除此图片图库栏目关系成功!"); //redisManager.deleteZSet("gallery_channel_"+galleryChannel.getChannelId(),picId); // redisManager.delete("gallery_channel_"+galleryChannel.getChannelId()); @@ -381,8 +358,6 @@ public class GalleryServiceImpl implements GalleryService { if (galleryPicInfo != null) { galleryPicInfo.setPicState("1"); if (galleryInfoMapper.updateByPrimaryKey(galleryPicInfo) > 0) { - msg.setInfo("删除成功!"); - msg.setResult(true); LOGGER.info("删除图片信息成功!"); redisManager.delete("gallery_pic_Id" + galleryPicInfo.getPicId()); } @@ -391,13 +366,10 @@ public class GalleryServiceImpl implements GalleryService { } } catch (Exception e) { - LOGGER.info("删除图片信息失败【{}】", e.getMessage()); - e.printStackTrace(); - msg.setInfo("删除失败,请稍候再试!"); - msg.setResult(true); + LOGGER.error("删除图片信息失败【{}】", e); } LOGGER.info("删除图片信息的业务层方法结束!"); - return msg; + return 1; } } diff --git a/ruoyi-content/src/main/resources/mapper/content/GalleryQueryMapper.xml b/ruoyi-content/src/main/resources/mapper/content/GalleryQueryMapper.xml index c1317e675..abb28fe7d 100644 --- a/ruoyi-content/src/main/resources/mapper/content/GalleryQueryMapper.xml +++ b/ruoyi-content/src/main/resources/mapper/content/GalleryQueryMapper.xml @@ -1,118 +1,115 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + SELECT ad.PIC_AD_NAME FROM pic_ad_info ad WHERE ad.PIC_AD_ID = pi.PIC_AD_ID - + SELECT + pi.PIC_ID, + pi.IMG_URL, + ( + + ) as PIC_AD_ID, + pi.PIC_STATE, + pi.COMPANY_ID, + pi.CREATE_DATE, + pi.CREATE_TIME, + pi.CREATE_USER, + pi.UPDATE_DATE, + pi.UPDATE_TIME + FROM gallery_pic_info pi + WHERE + 1=1 + + and pi.COMPANY_ID = #{companyId,jdbcType=VARCHAR} + + + and pi.BRANCH_ID like CONCAT(CONCAT('%',#{branchId,jdbcType=VARCHAR},'%')) + + + and pi.PIC_STATE in + + #{picState} + - - - and pi.PIC_ID in - - #{picId} - - - order by pi.CREATE_DATE DESC,pi.CREATE_TIME DESC, pi.UPDATE_DATE - DESC,pi.UPDATE_TIME DESC - limit - #{startRow,jdbcType=DECIMAL},#{rows,jdbcType=DECIMAL} - - - + + - - + \ 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 669943484..d16627776 100644 --- a/ruoyi-content/src/main/resources/templates/content/adverts/adverts.html +++ b/ruoyi-content/src/main/resources/templates/content/adverts/adverts.html @@ -90,7 +90,7 @@ title: '跳转地址', formatter: function (value, row, index) { var actions = []; - actions.push('展示 '); + actions.push('展示 '); return actions.join(''); } }, diff --git a/ruoyi-content/src/main/resources/templates/content/gallery/list.html b/ruoyi-content/src/main/resources/templates/content/gallery/list.html new file mode 100644 index 000000000..8b71e5d72 --- /dev/null +++ b/ruoyi-content/src/main/resources/templates/content/gallery/list.html @@ -0,0 +1,241 @@ + + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + + \ 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 index b9ab23cd9..dd80c88d3 100644 --- a/ruoyi-content/src/main/resources/templates/content/picAdverts/picAdverts.html +++ b/ruoyi-content/src/main/resources/templates/content/picAdverts/picAdverts.html @@ -71,7 +71,7 @@ title: '广告链接', formatter: function (value, row, index) { var actions = []; - actions.push('展示 '); + actions.push('展示 '); return actions.join(''); } },