文章广告
This commit is contained in:
parent
df4c741d62
commit
9080a5574c
|
|
@ -23,6 +23,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
|
|
@ -55,6 +57,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
return dateTimeNow(HH_MM_SS);
|
||||
}
|
||||
|
||||
public static String getMillisecond()
|
||||
{
|
||||
return dateTimeNow(YYYYMMDDHHMMSSSSS);
|
||||
}
|
||||
|
||||
public static final String getTime()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.ruoyi.content.constants;
|
||||
|
||||
/**
|
||||
* 配置文件常量
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class PropertiesConstants {
|
||||
|
||||
public static final String TEMPLATE_VIEW_PATH = "/WEB-INF/static/template/view.flt";
|
||||
public static final String TEMPLATE_EDIT_PATH = "/WEB-INF/static/template/edit.flt";
|
||||
|
||||
public static final String FILE_PATH = "/app/contentMKTCms/webapp/WEB-INF/static/";
|
||||
public static final String PROJECT_LOCALPATH = "/app/contentMKTCms/webapp";
|
||||
public static final String ONLINE_IMG_PATH = "network/article/";
|
||||
public static final String OSS_URL = "http://cdn.sinosoftec.com/";
|
||||
public static final String OSS_URL_HTTPS = "https://cdn.sinosoftec.com/";
|
||||
public static final String OSSENDPOINT = "oss-cn-qingdao.aliyuncs.com";
|
||||
public static final String OSSID = "LTAI4GFWLJ2Wtbyj1x5wDoA4";
|
||||
public static final String OSSKEY = "7n4eLwnFaHAh40hPMOfNpK4yYNvmLG";
|
||||
public static final String BUCKETNAME = "sinosoftec";
|
||||
public static final String OSSPATH = "mkt/YXPT/";
|
||||
|
||||
public static final String IS_NULL2 = "\"\"";
|
||||
public static final String CURRENT_USER = "user";
|
||||
public static final String I_SUCC = "succ";
|
||||
public static final String GALLERY_IMG_PATH = "gallery/img/";
|
||||
public static final String GALLERY_MINIMG_PATH = "gallery/min-img/";
|
||||
public static final String REDIRECT_ARTICLE_VIEW = "http://uat-mktasst.ihxlife.com/api/v1.0/articleView?";
|
||||
public static final String GVQYH_ARTICLE_WRITE = "http://qyhgateway.ihxlife.com/api/v2/article/write?redirectUrl=";
|
||||
public static final String GVQYH_INDEX = "http://qyhgateway.ihxlife.com/api/v1/oauth2/index?state=";
|
||||
public static final String AD_IMG_PATH = "ad/";
|
||||
|
||||
//信鸽系统相关配置
|
||||
public static final String NOTIFY_UID = "pyqzs";
|
||||
public static final String NOTIFY_KEY = "a12dadf_12asdinktn0091d1fzxpyqzs1da249kk";
|
||||
public static final String NOTIFY_URL = "http://uat-notify.ihxlife.com/notify/api/v1/qyh/img/send";
|
||||
public static final String NOTIFY_AGENTID = "1000024";
|
||||
|
||||
}
|
||||
|
|
@ -6,11 +6,7 @@ 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 org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.content.domain.CmsArticleAdInfo;
|
||||
|
|
@ -19,6 +15,7 @@ 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;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文章广告Controller
|
||||
|
|
@ -35,7 +32,6 @@ public class AdvertisementController extends BaseController {
|
|||
@Autowired
|
||||
private ICmsArticleAdInfoService cmsArticleAdInfoService;
|
||||
|
||||
@RequiresPermissions("content:adverts:view")
|
||||
@GetMapping()
|
||||
public String adverts() {
|
||||
return prefix + "/adverts";
|
||||
|
|
@ -78,8 +74,9 @@ public class AdvertisementController extends BaseController {
|
|||
@Log(title = "文章广告", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(CmsArticleAdInfo cmsArticleAdInfo) {
|
||||
return toAjax(cmsArticleAdInfoService.insertCmsArticleAdInfo(cmsArticleAdInfo));
|
||||
public AjaxResult addSave(@RequestParam("addImg") MultipartFile[] files, CmsArticleAdInfo cmsArticleAdInfo) {
|
||||
MultipartFile file = files[0];
|
||||
return toAjax(cmsArticleAdInfoService.insertCmsArticleAdInfo(file, cmsArticleAdInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,208 +11,250 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|||
* @author ruoyi
|
||||
* @date 2021-03-23
|
||||
*/
|
||||
public class CmsArticleAdInfo extends BaseEntity
|
||||
{
|
||||
public class CmsArticleAdInfo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** */
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long adId;
|
||||
|
||||
/** 公司id */
|
||||
/**
|
||||
* 公司id
|
||||
*/
|
||||
@Excel(name = "公司id")
|
||||
private String companyId;
|
||||
|
||||
/** 广告类型 */
|
||||
/**
|
||||
* 广告类型
|
||||
*/
|
||||
@Excel(name = "广告类型")
|
||||
private String adType;
|
||||
|
||||
/** 广告类型名 */
|
||||
/**
|
||||
* 广告类型名
|
||||
*/
|
||||
@Excel(name = "广告类型名")
|
||||
private String adTypeName;
|
||||
|
||||
/** 广告跳转地址 */
|
||||
/**
|
||||
* 广告跳转地址
|
||||
*/
|
||||
@Excel(name = "广告跳转地址")
|
||||
private String adLinkUrl;
|
||||
|
||||
/** 广告标题 */
|
||||
/**
|
||||
* 广告标题
|
||||
*/
|
||||
@Excel(name = "广告标题")
|
||||
private String adTitle;
|
||||
|
||||
/** 广告名称 */
|
||||
/**
|
||||
* 广告名称
|
||||
*/
|
||||
@Excel(name = "广告名称")
|
||||
private String adName;
|
||||
|
||||
/** 广告简介 */
|
||||
/**
|
||||
* 广告简介
|
||||
*/
|
||||
@Excel(name = "广告简介")
|
||||
private String adSummary;
|
||||
|
||||
/** 广告背景颜色 */
|
||||
/**
|
||||
* 广告背景颜色
|
||||
*/
|
||||
@Excel(name = "广告背景颜色")
|
||||
private String adColorType;
|
||||
|
||||
/** 广告图片地址 */
|
||||
/**
|
||||
* 广告图片地址
|
||||
*/
|
||||
@Excel(name = "广告图片地址")
|
||||
private String adImageUrl;
|
||||
|
||||
/** 广告状态 0:展示 1:不可用 */
|
||||
/**
|
||||
* 广告状态 0:展示 1:不可用
|
||||
*/
|
||||
@Excel(name = "广告状态 0:展示 1:不可用")
|
||||
private String adState;
|
||||
|
||||
/** */
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
public void setAdId(Long adId)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Excel(name = "")
|
||||
private String updateTime;
|
||||
|
||||
public void setAdId(Long adId) {
|
||||
this.adId = adId;
|
||||
}
|
||||
|
||||
public Long getAdId()
|
||||
{
|
||||
public Long getAdId() {
|
||||
return adId;
|
||||
}
|
||||
public void setCompanyId(String companyId)
|
||||
{
|
||||
|
||||
public void setCompanyId(String companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getCompanyId()
|
||||
{
|
||||
public String getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
public void setAdType(String adType)
|
||||
{
|
||||
|
||||
public void setAdType(String adType) {
|
||||
this.adType = adType;
|
||||
}
|
||||
|
||||
public String getAdType()
|
||||
{
|
||||
public String getAdType() {
|
||||
return adType;
|
||||
}
|
||||
public void setAdTypeName(String adTypeName)
|
||||
{
|
||||
|
||||
public void setAdTypeName(String adTypeName) {
|
||||
this.adTypeName = adTypeName;
|
||||
}
|
||||
|
||||
public String getAdTypeName()
|
||||
{
|
||||
public String getAdTypeName() {
|
||||
return adTypeName;
|
||||
}
|
||||
public void setAdLinkUrl(String adLinkUrl)
|
||||
{
|
||||
|
||||
public void setAdLinkUrl(String adLinkUrl) {
|
||||
this.adLinkUrl = adLinkUrl;
|
||||
}
|
||||
|
||||
public String getAdLinkUrl()
|
||||
{
|
||||
public String getAdLinkUrl() {
|
||||
return adLinkUrl;
|
||||
}
|
||||
public void setAdTitle(String adTitle)
|
||||
{
|
||||
|
||||
public void setAdTitle(String adTitle) {
|
||||
this.adTitle = adTitle;
|
||||
}
|
||||
|
||||
public String getAdTitle()
|
||||
{
|
||||
public String getAdTitle() {
|
||||
return adTitle;
|
||||
}
|
||||
public void setAdName(String adName)
|
||||
{
|
||||
|
||||
public void setAdName(String adName) {
|
||||
this.adName = adName;
|
||||
}
|
||||
|
||||
public String getAdName()
|
||||
{
|
||||
public String getAdName() {
|
||||
return adName;
|
||||
}
|
||||
public void setAdSummary(String adSummary)
|
||||
{
|
||||
|
||||
public void setAdSummary(String adSummary) {
|
||||
this.adSummary = adSummary;
|
||||
}
|
||||
|
||||
public String getAdSummary()
|
||||
{
|
||||
public String getAdSummary() {
|
||||
return adSummary;
|
||||
}
|
||||
public void setAdColorType(String adColorType)
|
||||
{
|
||||
|
||||
public void setAdColorType(String adColorType) {
|
||||
this.adColorType = adColorType;
|
||||
}
|
||||
|
||||
public String getAdColorType()
|
||||
{
|
||||
public String getAdColorType() {
|
||||
return adColorType;
|
||||
}
|
||||
public void setAdImageUrl(String adImageUrl)
|
||||
{
|
||||
|
||||
public void setAdImageUrl(String adImageUrl) {
|
||||
this.adImageUrl = adImageUrl;
|
||||
}
|
||||
|
||||
public String getAdImageUrl()
|
||||
{
|
||||
public String getAdImageUrl() {
|
||||
return adImageUrl;
|
||||
}
|
||||
public void setAdState(String adState)
|
||||
{
|
||||
|
||||
public void setAdState(String adState) {
|
||||
this.adState = adState;
|
||||
}
|
||||
|
||||
public String getAdState()
|
||||
{
|
||||
public String getAdState() {
|
||||
return adState;
|
||||
}
|
||||
public void setCreateDate(String createDate)
|
||||
{
|
||||
|
||||
public void setCreateDate(String createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public String getCreateDate()
|
||||
{
|
||||
public String getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
public void setCreateUser(String createUser)
|
||||
{
|
||||
|
||||
public void setCreateUser(String createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public String getCreateUser()
|
||||
{
|
||||
public String getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
public void setUpdateUser(String updateUser)
|
||||
{
|
||||
|
||||
public void setUpdateUser(String updateUser) {
|
||||
this.updateUser = updateUser;
|
||||
}
|
||||
|
||||
public String getUpdateUser()
|
||||
{
|
||||
public String getUpdateUser() {
|
||||
return updateUser;
|
||||
}
|
||||
public void setUpdateDate(String updateDate)
|
||||
{
|
||||
|
||||
public void setUpdateDate(String updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
public String getUpdateDate()
|
||||
{
|
||||
public String getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("adId", getAdId())
|
||||
.append("companyId", getCompanyId())
|
||||
.append("adType", getAdType())
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.ruoyi.content.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.content.domain.CmsArticleAdInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文章广告Service接口
|
||||
|
|
@ -9,8 +11,7 @@ import com.ruoyi.content.domain.CmsArticleAdInfo;
|
|||
* @author ruoyi
|
||||
* @date 2021-03-23
|
||||
*/
|
||||
public interface ICmsArticleAdInfoService
|
||||
{
|
||||
public interface ICmsArticleAdInfoService {
|
||||
/**
|
||||
* 查询文章广告
|
||||
*
|
||||
|
|
@ -30,10 +31,11 @@ public interface ICmsArticleAdInfoService
|
|||
/**
|
||||
* 新增文章广告
|
||||
*
|
||||
* @param file 广告图片
|
||||
* @param cmsArticleAdInfo 文章广告
|
||||
* @return 结果
|
||||
* @return
|
||||
*/
|
||||
public int insertCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo);
|
||||
public int insertCmsArticleAdInfo(MultipartFile file, CmsArticleAdInfo cmsArticleAdInfo);
|
||||
|
||||
/**
|
||||
* 修改文章广告
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
package com.ruoyi.content.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.content.constants.PropertiesConstants;
|
||||
import com.ruoyi.content.domain.CmsArticleAdInfo;
|
||||
import com.ruoyi.content.mapper.CmsArticleAdInfoMapper;
|
||||
import com.ruoyi.content.service.ICmsArticleAdInfoService;
|
||||
import com.ruoyi.content.utils.OSSUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.content.mapper.CmsArticleAdInfoMapper;
|
||||
import com.ruoyi.content.domain.CmsArticleAdInfo;
|
||||
import com.ruoyi.content.service.ICmsArticleAdInfoService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章广告Service业务层处理
|
||||
|
|
@ -19,6 +25,8 @@ import com.ruoyi.common.core.text.Convert;
|
|||
@Service
|
||||
public class CmsArticleAdInfoServiceImpl implements ICmsArticleAdInfoService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleAdInfoServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private CmsArticleAdInfoMapper cmsArticleAdInfoMapper;
|
||||
|
||||
|
|
@ -41,18 +49,50 @@ public class CmsArticleAdInfoServiceImpl implements ICmsArticleAdInfoService {
|
|||
*/
|
||||
@Override
|
||||
public List<CmsArticleAdInfo> selectCmsArticleAdInfoList(CmsArticleAdInfo cmsArticleAdInfo) {
|
||||
cmsArticleAdInfo.setAdState("0");
|
||||
cmsArticleAdInfo.setCompanyId("1");
|
||||
return cmsArticleAdInfoMapper.selectCmsArticleAdInfoList(cmsArticleAdInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文章广告
|
||||
*
|
||||
* @param file 广告图片
|
||||
* @param cmsArticleAdInfo 文章广告
|
||||
* @return 结果
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int insertCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) {
|
||||
cmsArticleAdInfo.setCreateTime(DateUtils.getNowDate());
|
||||
public int insertCmsArticleAdInfo(MultipartFile file, CmsArticleAdInfo cmsArticleAdInfo) {
|
||||
if (!file.isEmpty()) {
|
||||
String fileName = file.getOriginalFilename();// 文件名
|
||||
String ext = fileName.substring(fileName.lastIndexOf("."), fileName.length());// 文件后缀
|
||||
String fileTime = DateUtils.getMillisecond();
|
||||
fileName = PropertiesConstants.AD_IMG_PATH + fileTime + ext;// OSS保存路径
|
||||
String flag = null;
|
||||
try {
|
||||
flag = OSSUtil.uploadFileByInputStream(PropertiesConstants.OSSENDPOINT, PropertiesConstants.OSSID, PropertiesConstants.OSSKEY,
|
||||
PropertiesConstants.BUCKETNAME, file.getInputStream(), PropertiesConstants.OSSPATH + fileName);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("上传阿里云失败!", e);
|
||||
}
|
||||
if (null == flag || flag.equals("false")) {
|
||||
LOGGER.info("广告图片上传oss失败");
|
||||
return 0;
|
||||
} else {
|
||||
cmsArticleAdInfo.setAdImageUrl(PropertiesConstants.OSS_URL + PropertiesConstants.OSSPATH + fileName);
|
||||
}
|
||||
}
|
||||
String date = DateUtils.getDate();
|
||||
String time = DateUtils.getTimeNow();
|
||||
cmsArticleAdInfo.setAdLinkUrl(cmsArticleAdInfo.getAdLinkUrl() + "(");
|
||||
cmsArticleAdInfo.setCompanyId("1");
|
||||
cmsArticleAdInfo.setAdState("0");
|
||||
cmsArticleAdInfo.setCreateDate(date);
|
||||
cmsArticleAdInfo.setCreateTime(time);
|
||||
cmsArticleAdInfo.setCreateUser("company");
|
||||
cmsArticleAdInfo.setUpdateDate(date);
|
||||
cmsArticleAdInfo.setUpdateTime(time);
|
||||
cmsArticleAdInfo.setUpdateUser("company");
|
||||
return cmsArticleAdInfoMapper.insertCmsArticleAdInfo(cmsArticleAdInfo);
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +104,7 @@ public class CmsArticleAdInfoServiceImpl implements ICmsArticleAdInfoService {
|
|||
*/
|
||||
@Override
|
||||
public int updateCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) {
|
||||
cmsArticleAdInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
cmsArticleAdInfo.setUpdateTime(DateUtils.getDate());
|
||||
return cmsArticleAdInfoMapper.updateCmsArticleAdInfo(cmsArticleAdInfo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,324 @@
|
|||
package com.ruoyi.content.utils;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.model.*;
|
||||
import com.ruoyi.content.constants.PropertiesConstants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OSSUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OSSUtil.class);
|
||||
|
||||
/**
|
||||
* 上传文件(文件输入流)到阿里云OSS
|
||||
*
|
||||
* @param ossEndPoint 阿里云OSS提供的ossEndPoint
|
||||
* @param ossId 阿里云OSS提供的ossId
|
||||
* @param ossKey 阿里云OSS提供的ossKey
|
||||
* @param bucketName 阿里云OSS提供的ossBucket
|
||||
* @param input 文件输入流 * @param ossPath oss上保存文件的路径
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String uploadFileByInputStream(String ossEndPoint, String ossId, String ossKey, String bucketName,
|
||||
InputStream input, String ossPath) {
|
||||
try {
|
||||
ObjectMetadata objectMeta = new ObjectMetadata();
|
||||
// objectMeta.setContentLength(file.length());
|
||||
// 可以在metadata中标记文件类型
|
||||
objectMeta.setContentType("multipart/form-data");
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
PutObjectResult result = client.putObject(bucketName, ossPath, input, objectMeta);
|
||||
client.shutdown();
|
||||
logger.info("上传阿里云OSS结果【{}】", result.getETag());
|
||||
return "success";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("上传阿里云OSS出错!!");
|
||||
return "false";
|
||||
} finally {
|
||||
if (null != input) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("上传阿里云OSS出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到阿里云OSS
|
||||
*
|
||||
* @param ossEndPoint 阿里云OSS提供的ossEndPoint
|
||||
* @param ossId 阿里云OSS提供的ossId
|
||||
* @param ossKey 阿里云OSS提供的ossKey
|
||||
* @param bucketName 阿里云OSS提供的ossBucket
|
||||
* @param localPath 本地文件的路径
|
||||
* @param ossPath oss上保存文件的路径
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void uploadFile(String ossEndPoint, String ossId, String ossKey, String bucketName, String localPath,
|
||||
String ossPath) {
|
||||
InputStream input = null;
|
||||
try {
|
||||
File file = new File(localPath);
|
||||
ObjectMetadata objectMeta = new ObjectMetadata();
|
||||
objectMeta.setContentLength(file.length());
|
||||
// 可以在metadata中标记文件类型
|
||||
objectMeta.setContentType("multipart/form-data");
|
||||
input = new FileInputStream(file);
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
PutObjectResult result = client.putObject(bucketName, ossPath, input, objectMeta);
|
||||
client.shutdown();
|
||||
logger.info("上传阿里云OSS结果【{}】", result.getETag());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("上传阿里云OSS出错!!");
|
||||
} finally {
|
||||
if (null != input) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("上传阿里云OSS出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传html文件到阿里云OSS
|
||||
*
|
||||
* @param ossEndPoint 阿里云OSS提供的ossEndPoint
|
||||
* @param ossId 阿里云OSS提供的ossId
|
||||
* @param ossKey 阿里云OSS提供的ossKey
|
||||
* @param bucketName 阿里云OSS提供的ossBucket
|
||||
* @param localPath 本地文件的路径
|
||||
* @param ossPath oss上保存文件的路径
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void uploadFileHtml(String ossEndPoint, String ossId, String ossKey, String bucketName, String localPath,
|
||||
String ossPath) {
|
||||
InputStream input = null;
|
||||
try {
|
||||
File file = new File(localPath);
|
||||
ObjectMetadata objectMeta = new ObjectMetadata();
|
||||
objectMeta.setContentLength(file.length());
|
||||
// 可以在metadata中标记文件类型
|
||||
objectMeta.setContentType("text/html");
|
||||
input = new FileInputStream(file);
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
PutObjectResult result = client.putObject(bucketName, ossPath, input, objectMeta);
|
||||
client.shutdown();
|
||||
logger.info("上传阿里云OSS结果【{}】", result.getETag());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("上传阿里云OSS出错!!");
|
||||
} finally {
|
||||
if (null != input) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("上传阿里云OSS出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从阿里云OSS上下载文件 (不保存本地)
|
||||
*
|
||||
* @param ossEndPoint 阿里云OSS提供的ossEndPointOut
|
||||
* @param ossId 阿里云OSS提供的ossId
|
||||
* @param ossKey 阿里云OSS提供的ossKey
|
||||
* @param ossBucket 阿里云OSS提供的ossBucket
|
||||
* @param path 阿里云OSS上保存文件的路径
|
||||
* @return
|
||||
*/
|
||||
public static byte[] downloadFile(String ossEndPoint, String ossId, String ossKey, String ossBucket, String path) {
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
OSSObject ossObject = client.getObject(ossBucket, path);
|
||||
ObjectMetadata meta = client.getObjectMetadata(ossBucket, path);
|
||||
client.shutdown();
|
||||
meta.getContentEncoding();
|
||||
InputStream inputStream = null;
|
||||
ByteArrayOutputStream bos = null;
|
||||
byte[] b = new byte[1024];
|
||||
int len;
|
||||
try {
|
||||
inputStream = ossObject.getObjectContent();
|
||||
bos = new ByteArrayOutputStream();
|
||||
while ((len = inputStream.read(b)) != -1) {
|
||||
bos.write(b, 0, len);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("从阿里云OSS下载文件出错!");
|
||||
} finally {
|
||||
if (null != inputStream) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("从阿里云OSS下载文件出错!");
|
||||
}
|
||||
}
|
||||
if (null != bos) {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("从阿里云OSS下载文件出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从阿里云OSS上下载文件 并保存指定路径下
|
||||
*
|
||||
* @param ossEndPoint 阿里云OSS提供的ossEndPoint
|
||||
* @param ossId 阿里云OSS提供的ossId
|
||||
* @param ossKey 阿里云OSS提供的ossKey
|
||||
* @param bucketName 阿里云OSS提供的ossBucket
|
||||
* @param ossPath 阿里云OSS上保存文件的路径
|
||||
* @param localPath 保存本地的路径(包括文件名)
|
||||
* @return oss上下载下来的文件的字节数组
|
||||
*/
|
||||
public static void downloadAndSaveFile(String ossEndPoint, String ossId, String ossKey, String bucketName,
|
||||
String ossPath, String localPath) {
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
|
||||
File localFileDir = new File(localPath);
|
||||
if (!localFileDir.exists()) {
|
||||
localFileDir.mkdirs();
|
||||
if (!localFileDir.exists()) {
|
||||
logger.info("本地目录不存在,且尝试创建失败!");
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(localPath);
|
||||
logger.info("创建文件目录:" + localPath);
|
||||
client.getObject(new GetObjectRequest(bucketName, ossPath), file);
|
||||
client.shutdown();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除阿里云OSS文件
|
||||
*
|
||||
* @param ossEndPoint 阿里云OSS提供的ossEndPoint
|
||||
* @param ossId 阿里云OSS提供的ossId
|
||||
* @param ossKey 阿里云OSS提供的ossKey
|
||||
* @param ossBucket 阿里云OSS提供的ossBucket
|
||||
* @param path 阿里云OSS上保存文件的路径
|
||||
* @return
|
||||
*/
|
||||
public static void deleteFile(String ossEndPoint, String ossId, String ossKey, String ossBucket, String path) {
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
client.deleteObject(ossBucket, path);
|
||||
client.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OSS内的文件列表
|
||||
*
|
||||
* @param ossEndPoint
|
||||
* @param ossId
|
||||
* @param ossKey
|
||||
* @param bucketName
|
||||
* @param path
|
||||
*/
|
||||
public static void findFileList(String ossEndPoint, String ossId, String ossKey, String bucketName, String path) {
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
// 构造ListObjectsRequest请求
|
||||
ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
|
||||
if (StringUtils.isNotBlank(path)) {
|
||||
listObjectsRequest.setPrefix(path); // fun/
|
||||
}
|
||||
// 递归列出fun目录下的所有文件
|
||||
ObjectListing listing = client.listObjects(listObjectsRequest);
|
||||
// 遍历所有Object
|
||||
logger.info("Objects内的文件:");
|
||||
for (OSSObjectSummary objectSummary : listing.getObjectSummaries()) {
|
||||
logger.info("文件名【{}】, 文件大小【{}】", objectSummary.getKey(), objectSummary.getSize());
|
||||
}
|
||||
// 遍历所有CommonPrefix
|
||||
logger.info("\nCommonPrefixs:");
|
||||
for (String commonPrefix : listing.getCommonPrefixes()) {
|
||||
logger.info(commonPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
private static OSSClient createOSSClient(String ossEndPoint, String ossId, String ossKey) {
|
||||
// ClientConfiguration config = new ClientConfiguration();
|
||||
// config.setProxyHost("10.0.251.94");
|
||||
// config.setProxyPort(8080);
|
||||
// config.setProxyUsername("gaining");
|
||||
// config.setProxyPassword("abcd123%");
|
||||
// TODO
|
||||
// 本地设置代理
|
||||
// OSSClient client = new OSSClient(ossEndPoint, ossId, ossKey, config);
|
||||
OSSClient client = new OSSClient(ossEndPoint, ossId, ossKey);
|
||||
return client;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
uploadFile("oss-cn-szfinance.aliyuncs.com",
|
||||
"LTAIsVIQ8j9WueV2", "Il5Y1tugBi9u8giGi9n4lQhAWwkcih",
|
||||
"hx-cdn-int", "G:\\111.jpg", "gv/YXPT/network/article/450.jpg");
|
||||
// uploadFile("oss-cn-beijing.aliyuncs.com", "6TpnBLywxITY6YNA",
|
||||
// "dbYhx45upstobHmBBErQQkZlrC017X", "lifeilong", "F:\\图片\\460.jpg",
|
||||
// "我的照片/460.jpg");
|
||||
}
|
||||
|
||||
public static Map<String, Object> uploadFileByInputStreamReturnUrl(String ossEndPoint, String ossId, String ossKey,
|
||||
String bucketName, InputStream input, String ossPath) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
ObjectMetadata objectMeta = new ObjectMetadata();
|
||||
// objectMeta.setContentLength(file.length());
|
||||
// 可以在metadata中标记文件类型
|
||||
objectMeta.setContentType("multipart/form-data");
|
||||
OSSClient client = createOSSClient(ossEndPoint, ossId, ossKey);
|
||||
PutObjectResult result = client.putObject(bucketName, ossPath, input, objectMeta);
|
||||
client.shutdown();
|
||||
logger.info("上传阿里云OSS结果【{}】", result.getETag());
|
||||
map.put("ossFIleId", result.getETag());
|
||||
// 设置URL过期时间为10年 3600l* 1000*24*365*10
|
||||
// Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 10);
|
||||
// 生成URL
|
||||
// URL url = client.generatePresignedUrl(bucketName, ossPath, expiration);
|
||||
// if (url != null) {
|
||||
map.put("result", true);
|
||||
map.put("url", PropertiesConstants.OSS_URL + ossPath);
|
||||
// } else {
|
||||
// msg.setResult(false);
|
||||
// msg.setInfo("上传阿里云获取访问地址失败!");
|
||||
// }
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
logger.error("上传阿里云OSS出错!!", e);
|
||||
map.put("result", false);
|
||||
return map;
|
||||
} finally {
|
||||
if (null != input) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("上传阿里云OSS出错!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="adType != null and adType != ''"> and AD_TYPE = #{adType}</if>
|
||||
<if test="adTypeName != null and adTypeName != ''"> and AD_TYPE_NAME like concat('%', #{adTypeName}, '%')</if>
|
||||
<if test="adLinkUrl != null and adLinkUrl != ''"> and AD_LINK_URL = #{adLinkUrl}</if>
|
||||
<if test="adTitle != null and adTitle != ''"> and AD_TITLE = #{adTitle}</if>
|
||||
<if test="adTitle != null and adTitle != ''"> and AD_TITLE like concat('%', #{adTitle}, '%')</if>
|
||||
<if test="adName != null and adName != ''"> and AD_NAME like concat('%', #{adName}, '%')</if>
|
||||
<if test="adSummary != null and adSummary != ''"> and AD_SUMMARY = #{adSummary}</if>
|
||||
<if test="adColorType != null and adColorType != ''"> and AD_COLOR_TYPE = #{adColorType}</if>
|
||||
|
|
@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="updateDate != null and updateDate != ''"> and UPDATE_DATE = #{updateDate}</if>
|
||||
<if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime}</if>
|
||||
</where>
|
||||
order by CREATE_DATE DESC,CREATE_TIME DESC, UPDATE_DATE DESC,UPDATE_TIME DESC
|
||||
</select>
|
||||
|
||||
<select id="selectCmsArticleAdInfoById" parameterType="Long" resultMap="CmsArticleAdInfoResult">
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,62 @@
|
|||
/*!
|
||||
* FileInput Chinese Translations
|
||||
*
|
||||
* This file must be loaded after 'fileinput.js'. Patterns in braces '{}', or
|
||||
* any HTML markup tags in the messages must not be converted or translated.
|
||||
*
|
||||
* @see http://github.com/kartik-v/bootstrap-fileinput
|
||||
* @author kangqf <kangqingfei@gmail.com>
|
||||
*
|
||||
* NOTE: this file must be saved in UTF-8 encoding.
|
||||
*/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
$.fn.fileinputLocales['zh'] = {
|
||||
fileSingle: '文件',
|
||||
filePlural: '多个文件',
|
||||
browseLabel: '选择 …',
|
||||
removeLabel: '移除',
|
||||
removeTitle: '清除选中文件',
|
||||
cancelLabel: '取消',
|
||||
cancelTitle: '取消进行中的上传',
|
||||
uploadLabel: '上传',
|
||||
uploadTitle: '上传选中文件',
|
||||
msgZoomTitle: '查看详情',
|
||||
msgZoomModalHeading: '详细预览',
|
||||
msgSizeTooLarge: '文件 "{name}" (<b>{size} KB</b>) 超过了允许大小 <b>{maxSize} KB</b>.',
|
||||
msgFilesTooLess: '你必须选择最少 <b>{n}</b> {files} 来上传. ',
|
||||
msgFilesTooMany: '选择的上传文件个数 <b>({n})</b> 超出最大文件的限制个数 <b>{m}</b>.',
|
||||
msgFileNotFound: '文件 "{name}" 未找到!',
|
||||
msgFileSecured: '安全限制,为了防止读取文件 "{name}".',
|
||||
msgFileNotReadable: '文件 "{name}" 不可读.',
|
||||
msgFilePreviewAborted: '取消 "{name}" 的预览.',
|
||||
msgFilePreviewError: '读取 "{name}" 时出现了一个错误.',
|
||||
msgInvalidFileType: '不正确的类型 "{name}". 只支持 "{types}" 类型的文件.',
|
||||
msgInvalidFileExtension: '不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名.',
|
||||
msgUploadAborted: '该文件上传被中止',
|
||||
msgValidationError: '文件上传错误',
|
||||
msgLoading: '加载第 {index} 文件 共 {files} …',
|
||||
msgProgress: '加载第 {index} 文件 共 {files} - {name} - {percent}% 完成.',
|
||||
msgSelected: '{n} {files} 选中',
|
||||
msgFoldersNotAllowed: '只支持拖拽文件! 跳过 {n} 拖拽的文件夹.',
|
||||
msgImageWidthSmall: '宽度的图像文件的"{name}"的必须是至少{size}像素.',
|
||||
msgImageHeightSmall: '图像文件的"{name}"的高度必须至少为{size}像素.',
|
||||
msgImageWidthLarge: '宽度的图像文件"{name}"不能超过{size}像素.',
|
||||
msgImageHeightLarge: '图像文件"{name}"的高度不能超过{size}像素.',
|
||||
msgImageResizeError: '无法获取的图像尺寸调整。',
|
||||
msgImageResizeException: '错误而调整图像大小。<pre>{errors}</pre>',
|
||||
dropZoneTitle: '拖拽文件到这里 …',
|
||||
slugCallback: function(text) {
|
||||
return text ? text.split(/(\\|\/)/g).pop().replace(/[^\w\u4e00-\u9fa5\-.\\\/ ]+/g, '') : '';
|
||||
},
|
||||
fileActionSettings: {
|
||||
removeTitle: '删除文件',
|
||||
uploadTitle: '上传文件',
|
||||
indicatorNewTitle: '没有上传',
|
||||
indicatorSuccessTitle: '上传',
|
||||
indicatorErrorTitle: '上传错误',
|
||||
indicatorLoadingTitle: '上传 ...'
|
||||
}
|
||||
};
|
||||
})(window.jQuery);
|
||||
|
|
@ -3,113 +3,131 @@
|
|||
<head>
|
||||
<th:block th:include="include :: header('新增文章广告')" />
|
||||
</head>
|
||||
<style>
|
||||
.lab {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
display: inline-block;
|
||||
border-radius: 20%;
|
||||
margin-bottom: 0px;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.addColor {
|
||||
|
||||
}
|
||||
</style>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-adverts-add">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">公司id:</label>
|
||||
<label class="col-sm-3 control-label is-required">广告标题:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="companyId" class="form-control" type="text">
|
||||
<input name="adTitle" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告类型:</label>
|
||||
<label class="col-sm-3 control-label is-required">广告名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="adType" class="form-control m-b">
|
||||
<option value="">所有</option>
|
||||
<input name="adName" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">广告类型:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="adType" class="form-control" th:id="addType" th:onchange="chooseAdType()">
|
||||
<option selected value="1">名片</option>
|
||||
<option value="2">招募</option>
|
||||
<option value="3">增员</option>
|
||||
<option value="4">产品</option>
|
||||
</select>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" th:hidden="true">
|
||||
<input name="adTypeName" th:id="adTypeName" class="form-control" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">跳转地址:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adLinkUrl" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告类型名:</label>
|
||||
<label class="col-sm-3 control-label is-required">简介:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adTypeName" class="form-control" type="text">
|
||||
<input name="adSummary" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告跳转地址:</label>
|
||||
<label class="col-sm-3 control-label is-required">背景颜色:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adLinkUrl" class="form-control" type="text">
|
||||
<input type="radio" class="addColor" id="addColor_a" name="adColorType" value="1" checked="checked">
|
||||
<label class="lab" style="background-color: #67c5ab"></label>
|
||||
<input type="radio" class="addColor" id="addColor_b" name="adColorType" value="2">
|
||||
<label class="lab" style="background-color: #b6d882"></label>
|
||||
<input type="radio" class="addColor" id="addColor_c" name="adColorType" value="3">
|
||||
<label class="lab" style="background-color: #f88f81"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告标题:</label>
|
||||
<label class="col-sm-3 control-label is-required">广告图片:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adTitle" class="form-control" type="text">
|
||||
<img id="addImgContent" class="form-control" style="width: 50px;height: 50px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adName" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告简介:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adSummary" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告背景颜色:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="adColorType" class="form-control m-b">
|
||||
<option value="">所有</option>
|
||||
</select>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告图片地址:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adImageUrl" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告状态 0:展示 1:不可用:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="adState" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="createDate" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">广告创建者:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="createUser" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="updateUser" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="updateDate" class="form-control" type="text">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
<input type="file" class="file projectfile" id="addImg" name="addImg" required>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:src="@{/js/fileinput.min.js}"></script>
|
||||
<script th:src="@{/js/fileinput_locale_zh.js}"></script>
|
||||
<link th:href="@{/css/fileinput.min.css}" rel="stylesheet"/>
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "content/adverts"
|
||||
$("#form-adverts-add").validate({
|
||||
focusCleanup: true
|
||||
});
|
||||
|
||||
chooseAdType();
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-adverts-add').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
function chooseAdType() {
|
||||
$('#adTypeName').val($("#addType option:selected").text());
|
||||
}
|
||||
|
||||
var fileoptions = {
|
||||
showUpload : false,
|
||||
showRemove : true,
|
||||
language : 'zh',
|
||||
allowedPreviewTypes : [ 'image' ],
|
||||
allowedFileExtensions : [ 'jpg', 'png', 'gif' ],
|
||||
maxFileSize : 0,
|
||||
autoReplace : true,// 是否自动替换图片
|
||||
uploadAsync : false,// 异步上传
|
||||
maxFileCount : 1,
|
||||
maxFilesNum : 1,
|
||||
dropZoneEnabled : false,
|
||||
showPreview : true,
|
||||
msgUploadThreshold : '上传中',
|
||||
msgUploadEnd : '完成'
|
||||
}
|
||||
|
||||
//点击创建后
|
||||
$("#addImg").fileinput(fileoptions).on("change" , function(event){
|
||||
$(".file-preview").css("display", "none");
|
||||
}).on("filebatchselected",function(event, files) {
|
||||
$("#addImgContent").attr("src",$(".file-preview-image.kv-preview-data").attr('src'));
|
||||
}).on("filecleared",function (event){
|
||||
$("#addImgContent").removeAttr("src");
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -3,6 +3,20 @@
|
|||
<head>
|
||||
<th:block th:include="include :: header('文章广告列表')" />
|
||||
</head>
|
||||
<style>
|
||||
.article-table-img {
|
||||
width: 120%;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
border-style: none;
|
||||
}
|
||||
.article-color {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 2px;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
|
|
@ -10,76 +24,10 @@
|
|||
<form id="formId">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
<label>公司id:</label>
|
||||
<input type="text" name="companyId"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告类型:</label>
|
||||
<select name="adType">
|
||||
<option value="">所有</option>
|
||||
<option value="-1">代码生成请选择字典属性</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告类型名:</label>
|
||||
<input type="text" name="adTypeName"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告跳转地址:</label>
|
||||
<input type="text" name="adLinkUrl"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告标题:</label>
|
||||
<input type="text" name="adTitle"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告名称:</label>
|
||||
<input type="text" name="adName"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告简介:</label>
|
||||
<input type="text" name="adSummary"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告背景颜色:</label>
|
||||
<select name="adColorType">
|
||||
<option value="">所有</option>
|
||||
<option value="-1">代码生成请选择字典属性</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告图片地址:</label>
|
||||
<input type="text" name="adImageUrl"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告状态 0:展示 1:不可用:</label>
|
||||
<input type="text" name="adState"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>:</label>
|
||||
<input type="text" name="createDate"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>:</label>
|
||||
<input type="text" name="createTime"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>广告创建者:</label>
|
||||
<input type="text" name="createUser"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>:</label>
|
||||
<input type="text" name="updateUser"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>:</label>
|
||||
<input type="text" name="updateDate"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>:</label>
|
||||
<input type="text" name="updateTime"/>
|
||||
</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>
|
||||
|
|
@ -93,15 +41,9 @@
|
|||
<a class="btn btn-success" onclick="$.operate.add()">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
|
|
@ -128,22 +70,6 @@
|
|||
title: '',
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'companyId',
|
||||
title: '公司id'
|
||||
},
|
||||
{
|
||||
field: 'adType',
|
||||
title: '广告类型'
|
||||
},
|
||||
{
|
||||
field: 'adTypeName',
|
||||
title: '广告类型名'
|
||||
},
|
||||
{
|
||||
field: 'adLinkUrl',
|
||||
title: '广告跳转地址'
|
||||
},
|
||||
{
|
||||
field: 'adTitle',
|
||||
title: '广告标题'
|
||||
|
|
@ -152,53 +78,60 @@
|
|||
field: 'adName',
|
||||
title: '广告名称'
|
||||
},
|
||||
{
|
||||
field: 'adTypeName',
|
||||
title: '广告类型名'
|
||||
},
|
||||
{
|
||||
field: 'adLinkUrl',
|
||||
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> ');
|
||||
return actions.join('');
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'adSummary',
|
||||
title: '广告简介'
|
||||
title: '简介',
|
||||
width: '20',
|
||||
widthUnit: '%'
|
||||
},
|
||||
{
|
||||
field: 'adColorType',
|
||||
title: '广告背景颜色'
|
||||
title: '背景颜色',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
if (row.adColorType === '1') {
|
||||
actions.push('<div class="article-color" style="background-color: #67c5ab"></div>');
|
||||
}
|
||||
if (row.adColorType === '2') {
|
||||
actions.push('<div class="article-color" style="background-color: #b6d882"></div>');
|
||||
}
|
||||
if (row.adColorType === '3') {
|
||||
actions.push('<div class="article-color" style="background-color: #f88f81"></div>');
|
||||
}
|
||||
return actions.join('');
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'adImageUrl',
|
||||
title: '广告图片地址'
|
||||
},
|
||||
{
|
||||
field: 'adState',
|
||||
title: '广告状态 0:展示 1:不可用'
|
||||
},
|
||||
{
|
||||
field: 'createDate',
|
||||
title: ''
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: ''
|
||||
},
|
||||
{
|
||||
field: 'createUser',
|
||||
title: '广告创建者'
|
||||
},
|
||||
{
|
||||
field: 'updateUser',
|
||||
title: ''
|
||||
},
|
||||
{
|
||||
field: 'updateDate',
|
||||
title: ''
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: ''
|
||||
title: '广告图片',
|
||||
width: '10',
|
||||
widthUnit: 'px',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<img class="article-table-img" src="'+row.adImageUrl+'" ></img> ');
|
||||
return actions.join('');
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.adId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.adId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.adId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.adId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
|
|
|
|||
Loading…
Reference in New Issue