图片管理
This commit is contained in:
parent
6adbcb3c71
commit
aca61b6b79
|
|
@ -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<GalleryPicInfoEx> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<GalleryPicInfo> selectAllWithLimit(@Param(value = "companyId") String companyId, @Param(value = "branchId") String branchId,
|
||||
@Param(value = "picState") List<String> picState, @Param(value = "picId") List<Integer> picId,
|
||||
@Param(value = "startRow") int startRow, @Param(value = "rows") int rows);
|
||||
public List<GalleryPicInfoEx> selectAllWithLimit(@Param(value = "companyId") String companyId, @Param(value = "branchId") String branchId,
|
||||
@Param(value = "picState") List<String> picState, @Param(value = "picId") List<Integer> picId);
|
||||
|
||||
public List<String> selectChannelId(@Param(value = "picId") Integer picId);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<GalleryDTO> galleryImgList(int startRow, int rows, String channelId, String picState, String special);
|
||||
public List<GalleryPicInfoEx> 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ public class GalleryServiceImpl implements GalleryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<GalleryDTO> galleryImgList(int startRow, int rows, String channelId, String picState, String special) {
|
||||
LOGGER.info("拿到的参数startRow【{}】,rows【{}】,所属栏目【{}】,图片状态【{}】", startRow, rows, channelId, picState);
|
||||
public List<GalleryPicInfoEx> galleryImgList(String channelId, String picState, String special) {
|
||||
LOGGER.info("拿到的参数,所属栏目【{}】,图片状态【{}】", channelId, picState);
|
||||
String companyId = "1";// 公司id
|
||||
String branchId = "86";
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
|
@ -161,32 +161,15 @@ public class GalleryServiceImpl implements GalleryService {
|
|||
}
|
||||
}
|
||||
|
||||
List<GalleryPicInfo> galleryList = galleryQueryMapper.selectAllWithLimit(companyId, branchId, list, picIds, startRow, rows);
|
||||
List<GalleryPicInfoEx> galleryList = galleryQueryMapper.selectAllWithLimit(companyId, branchId, list, picIds);
|
||||
if (galleryList == null || galleryList.size() < 1) {
|
||||
LOGGER.info("未查询到数据");
|
||||
throw new BusinessException("图库暂没有海报!");
|
||||
}
|
||||
|
||||
//所属二级栏目
|
||||
List<GalleryDTO> 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<String> codeName = new ArrayList<>();
|
||||
// List<String> 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<GalleryChannel> galleryChannels = this.galleryChannelMapper.selectByExample(channelexample);
|
||||
|
|
@ -199,14 +182,13 @@ public class GalleryServiceImpl implements GalleryService {
|
|||
List<BaseCode> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,118 +1,115 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.ruoyi.content.mapper.GalleryQueryMapper">
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.content.domain.GalleryPicInfo" >
|
||||
<!--
|
||||
WARNING - @mbggenerated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Mon Jun 11 10:57:31 CST 2018.
|
||||
-->
|
||||
<id column="PIC_ID" property="picId" jdbcType="INTEGER" />
|
||||
<result column="IMG_URL" property="imgUrl" jdbcType="VARCHAR" />
|
||||
<result column="PIC_AD_ID" property="picAdId" jdbcType="VARCHAR" />
|
||||
<result column="PIC_STATE" property="picState" jdbcType="VARCHAR" />
|
||||
<result column="COMPANY_ID" property="companyId" jdbcType="VARCHAR" />
|
||||
<result column="CREATE_DATE" property="createDate" jdbcType="VARCHAR" />
|
||||
<result column="CREATE_TIME" property="createTime" jdbcType="VARCHAR" />
|
||||
<result column="CREATE_USER" property="createUser" jdbcType="VARCHAR" />
|
||||
<result column="UPDATE_DATE" property="updateDate" jdbcType="VARCHAR" />
|
||||
<result column="UPDATE_TIME" property="updateTime" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="adTitleSQL">
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.content.domain.GalleryPicInfoEx">
|
||||
<!--
|
||||
WARNING - @mbggenerated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Mon Jun 11 10:57:31 CST 2018.
|
||||
-->
|
||||
<id column="PIC_ID" property="picId" jdbcType="INTEGER"/>
|
||||
<result column="IMG_URL" property="imgUrl" jdbcType="VARCHAR"/>
|
||||
<result column="PIC_AD_ID" property="picAdId" jdbcType="VARCHAR"/>
|
||||
<result column="PIC_STATE" property="picState" jdbcType="VARCHAR"/>
|
||||
<result column="COMPANY_ID" property="companyId" jdbcType="VARCHAR"/>
|
||||
<result column="CREATE_DATE" property="createDate" jdbcType="VARCHAR"/>
|
||||
<result column="CREATE_TIME" property="createTime" jdbcType="VARCHAR"/>
|
||||
<result column="CREATE_USER" property="createUser" jdbcType="VARCHAR"/>
|
||||
<result column="UPDATE_DATE" property="updateDate" jdbcType="VARCHAR"/>
|
||||
<result column="UPDATE_TIME" property="updateTime" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="adTitleSQL">
|
||||
SELECT ad.PIC_AD_NAME
|
||||
FROM pic_ad_info ad
|
||||
WHERE ad.PIC_AD_ID = pi.PIC_AD_ID
|
||||
</sql>
|
||||
<select id="selectAllWithLimit"
|
||||
resultMap="BaseResultMap">
|
||||
SELECT
|
||||
pi.PIC_ID,
|
||||
pi.IMG_URL,
|
||||
(
|
||||
<include refid="adTitleSQL" />
|
||||
) 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
|
||||
<if test="companyId != null and companyId !=''">
|
||||
and pi.COMPANY_ID = #{companyId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="branchId != null and branchId !=''">
|
||||
and pi.BRANCH_ID like CONCAT(CONCAT('%',#{branchId,jdbcType=VARCHAR},'%'))
|
||||
</if>
|
||||
<if test="picState != null">
|
||||
and pi.PIC_STATE in
|
||||
<foreach collection="picState" item="picState" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picState}
|
||||
</foreach>
|
||||
<select id="selectAllWithLimit"
|
||||
resultMap="BaseResultMap">
|
||||
SELECT
|
||||
pi.PIC_ID,
|
||||
pi.IMG_URL,
|
||||
(
|
||||
<include refid="adTitleSQL"/>
|
||||
) 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
|
||||
<if test="companyId != null and companyId !=''">
|
||||
and pi.COMPANY_ID = #{companyId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="branchId != null and branchId !=''">
|
||||
and pi.BRANCH_ID like CONCAT(CONCAT('%',#{branchId,jdbcType=VARCHAR},'%'))
|
||||
</if>
|
||||
<if test="picState != null">
|
||||
and pi.PIC_STATE in
|
||||
<foreach collection="picState" item="picState" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picState}
|
||||
</foreach>
|
||||
|
||||
</if>
|
||||
<if test="picId != null and picId.size() > 0">
|
||||
and pi.PIC_ID in
|
||||
<foreach collection="picId" item="picId" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picId}
|
||||
</foreach>
|
||||
</if>
|
||||
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}
|
||||
</select>
|
||||
|
||||
<select id="selectChannelId" resultType="java.lang.String" parameterType="java.lang.Integer" >
|
||||
</if>
|
||||
<if test="picId != null and picId.size() > 0">
|
||||
and pi.PIC_ID in
|
||||
<foreach collection="picId" item="picId" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picId}
|
||||
</foreach>
|
||||
</if>
|
||||
order by pi.CREATE_DATE DESC,pi.CREATE_TIME DESC, pi.UPDATE_DATE DESC,pi.UPDATE_TIME DESC
|
||||
</select>
|
||||
|
||||
<select id="selectChannelId" resultType="java.lang.String" parameterType="java.lang.Integer">
|
||||
SELECT distinct CHANNEL_ID
|
||||
FROM cms_gallery_channel
|
||||
WHERE PIC_ID = #{picId,jdbcType=INTEGER} and STATE = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectAllPicInfo"
|
||||
resultMap="BaseResultMap">
|
||||
SELECT
|
||||
pi.PIC_ID,
|
||||
pi.IMG_URL,
|
||||
(
|
||||
<include refid="adTitleSQL" />
|
||||
) 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
|
||||
<if test="companyId != null and companyId !=''">
|
||||
and pi.COMPANY_ID = #{companyId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="branchId != null and branchId !=''">
|
||||
and pi.BRANCH_ID like CONCAT(CONCAT('%',#{branchId,jdbcType=VARCHAR},'%'))
|
||||
</if>
|
||||
<if test="picState != null">
|
||||
and pi.PIC_STATE in
|
||||
<foreach collection="picState" item="picState" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picState}
|
||||
</foreach>
|
||||
|
||||
</if>
|
||||
<if test="picId != null and picId.size() > 0">
|
||||
and pi.PIC_ID in
|
||||
<foreach collection="picId" item="picId" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectAllPicInfo"
|
||||
resultMap="BaseResultMap">
|
||||
SELECT
|
||||
pi.PIC_ID,
|
||||
pi.IMG_URL,
|
||||
(
|
||||
<include refid="adTitleSQL"/>
|
||||
) 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
|
||||
<if test="companyId != null and companyId !=''">
|
||||
and pi.COMPANY_ID = #{companyId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="branchId != null and branchId !=''">
|
||||
and pi.BRANCH_ID like CONCAT(CONCAT('%',#{branchId,jdbcType=VARCHAR},'%'))
|
||||
</if>
|
||||
<if test="picState != null">
|
||||
and pi.PIC_STATE in
|
||||
<foreach collection="picState" item="picState" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picState}
|
||||
</foreach>
|
||||
|
||||
</if>
|
||||
<if test="picId != null and picId.size() > 0">
|
||||
and pi.PIC_ID in
|
||||
<foreach collection="picId" item="picId" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{picId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
title: '跳转地址',
|
||||
formatter: function (value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.modal.msg(\'' + row.adLinkUrl + '\');" ><i class="fa"></i>展示</a> ');
|
||||
actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.modal.alertSuccess(\'' + row.adLinkUrl + '\');" ><i class="fa"></i>展示</a> ');
|
||||
return actions.join('');
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,241 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<th:block th:include="include :: header('图片列表')"/>
|
||||
</head>
|
||||
<style>
|
||||
.article-table-img {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
border-style: none;
|
||||
}
|
||||
</style>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
<label>所属栏目:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="channel" th:id="channel" class="form-control" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
|
||||
class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
|
||||
class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content animated flipInY">
|
||||
<div class="modal-header">
|
||||
<input th:hidden="true" value="" th:id="pictureId"/>
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
|
||||
class="sr-only">Close</span>
|
||||
</button>
|
||||
<h5 class="modal-title" style="text-align: left;">分配栏目</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="select-list">
|
||||
<ul style="margin-top: -15px;">
|
||||
<li>
|
||||
<label style="width: 80px;"><i style="color: #dc1212">*</i>专栏选择:</label>
|
||||
<div class="col-sm-8">
|
||||
<select th:id="columnId" class="form-control">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
|
||||
<button type="button" class="btn btn-primary" th:onclick="saveData()">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer"/>
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "content/gallery";
|
||||
var prefix1 = ctx + "column/queryBasicData";
|
||||
var prefix2 = ctx + "column/queryColumn";
|
||||
var prefix3 = ctx + "content/gallery/addGallery";
|
||||
|
||||
$(function () {
|
||||
var options = {
|
||||
url: prefix + "/galleryImgList",
|
||||
createUrl: prefix + "/add",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
modalName: "图片列表",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'picId',
|
||||
title: '图片编号',
|
||||
},
|
||||
{
|
||||
field: 'imgUrl',
|
||||
title: '图片',
|
||||
formatter: function (value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<img class="article-table-img" src="' + row.imgUrl + '" ></img> ');
|
||||
return actions.join('');
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'picAdId',
|
||||
title: '广告'
|
||||
},
|
||||
{
|
||||
field: 'codeName',
|
||||
title: '所属栏目'
|
||||
},
|
||||
{
|
||||
field: 'picState',
|
||||
title: '状态',
|
||||
formatter: function (value, row, index) {
|
||||
if (row.picState == '0') {
|
||||
return '展示';
|
||||
} else {
|
||||
return '不展示';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createDate',
|
||||
title: '创建日期'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function (value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs" data-toggle="modal" data-target="#myModal2" onclick="changeId(\'' + row.picId + '\')"><i class="fa fa-object-group"></i>分配栏目</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.picId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: prefix1,
|
||||
data: {
|
||||
"bType": "GALLERY"
|
||||
},
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data.result) {// 跳转到列表页面
|
||||
var baseDataList = data.object.baseList;
|
||||
$("#channel").append("<option value=''>请选择</option>");
|
||||
for (var i = 0; i < baseDataList.length; i++) {
|
||||
$("#channel").append("<option value='" + baseDataList[i].codeCode + "' data-value='" + baseDataList[i].codeType + "'>" + baseDataList[i].codeCname + "</option>");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: prefix2,
|
||||
data: {},
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data.result) {
|
||||
var obj = data.object.columnList;
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
if (obj[i].codeType == "FIRST_COLUMN" && obj[i].codeCode.indexOf("GALLERY") != -1) {
|
||||
$("#columnId").append("<optgroup id=" + obj[i].codeCode + " label=" + obj[i].codeCname + "></optgroup>");
|
||||
}
|
||||
//先循环出标签并给标签id
|
||||
if (obj[i].codeType != "FIRST_COLUMN") {
|
||||
if (obj[i].codeType == "GALLERY") {
|
||||
$("#GALLERY").append("<option value='" + obj[i].id + "'>" + obj[i].codeCname + "</option>");
|
||||
}
|
||||
|
||||
if (obj[i].codeType == "INCREASE_GALLERY") {
|
||||
if ($("#INCREASE_GALLERY").length == 0) {
|
||||
$("#columnId").append("<optgroup id='INCREASE_GALLERY' label='增员图库'></optgroup>");
|
||||
}
|
||||
$("#INCREASE_GALLERY").append("<option value='" + obj[i].id + "'>" + obj[i].codeCname + "</option>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function changeId(id) {
|
||||
$('#pictureId').val(id);
|
||||
}
|
||||
|
||||
function saveData() {
|
||||
// 打开遮罩层
|
||||
$.modal.loading("请稍后...");
|
||||
var channelId = $('#columnId').val();//栏目id
|
||||
var picId = $('#pictureId').val();
|
||||
$.ajax({
|
||||
url: prefix3,
|
||||
data: {
|
||||
"channelId": channelId,
|
||||
"picId": picId,
|
||||
},
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
cache: false,
|
||||
success: function (data) {
|
||||
const code = {
|
||||
'code': 0
|
||||
};
|
||||
$.operate.successCallback(code);
|
||||
},
|
||||
error: function (textStatus, e) {
|
||||
const code = {
|
||||
'code' : 500,
|
||||
'msg' : '操作失败'
|
||||
}
|
||||
$.operate.successCallback(code);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
title: '广告链接',
|
||||
formatter: function (value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.modal.msg(\'' + row.picAdUrl + '\');" ><i class="fa"></i>展示</a> ');
|
||||
actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.modal.alertSuccess(\'' + row.picAdUrl + '\');" ><i class="fa"></i>展示</a> ');
|
||||
return actions.join('');
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue