Merge remote-tracking branch 'origin/master' into activity

# Conflicts:
#	pom.xml
#	ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
This commit is contained in:
dy 2021-04-25 14:39:31 +08:00
commit c38d7c50ec
21 changed files with 1750 additions and 6 deletions

27
pom.xml
View File

@ -29,6 +29,7 @@
<jna.version>5.7.0</jna.version>
<commons.io.version>2.5</commons.io.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.pool.version>2.6.2</commons.pool.version>
<poi.version>4.1.2</poi.version>
<velocity.version>1.7</velocity.version>
</properties>
@ -146,6 +147,13 @@
</dependency>
<!--io常用工具类 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${commons.pool.version}</version>
</dependency>
<!--常用工具类 -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
@ -185,7 +193,14 @@
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- aliyun oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.8.0</version>
</dependency>
<!-- 定时任务-->
<dependency>
<groupId>com.ruoyi</groupId>
@ -227,6 +242,13 @@
<version>${ruoyi.version}</version>
</dependency>
<!-- 内容中心-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-content</artifactId>
<version>${ruoyi.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -238,8 +260,7 @@
<module>ruoyi-generator</module>
<module>sino-activity</module>
<module>ruoyi-common</module>
<module>sino-act-web</module>
<module>ruoyi-content</module>
</modules>
<packaging>pom</packaging>

View File

@ -84,6 +84,12 @@
<artifactId>sino-activity</artifactId>
</dependency>
<!-- 内容中心-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-content</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -54,4 +54,17 @@ spring:
merge-sql: true
wall:
config:
multi-statement-allow: true
multi-statement-allow: true
# redis配置
redis:
database: 5
host: db.sinosoftec.com
port: 6379
password: sinosoft@ec~123
timeout: 6000ms # 连接超时时长(毫秒)
lettuce:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title>互联网营销平台首页</title>
<title>互联网营销平台</title>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link th:href="@{favicon.ico}" rel="shortcut icon"/>

View File

@ -59,6 +59,12 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<!--常用工具类 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- JSON工具类 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@ -101,6 +107,18 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<!-- aliyun oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<!-- springboot整合redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -19,9 +19,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static String YYYY_MM_DD = "yyyy-MM-dd";
public static String HH_MM_SS = "HH:mm:ss";
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static String YYYYMMDDHHMMSSS = "yyyyMMddHHmmssSSS";
public static String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS";
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
@ -50,6 +52,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return dateTimeNow(YYYY_MM_DD);
}
public static String getTimeNow()
{
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);

28
ruoyi-content/pom.xml Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>4.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-content</artifactId>
<description>
内容中心模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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";
}

View File

@ -0,0 +1,111 @@
package com.ruoyi.content.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.content.domain.CmsArticleAdInfo;
import com.ruoyi.content.service.ICmsArticleAdInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 文章广告Controller
*
* @author ruoyi
* @date 2021-03-23
*/
@Controller
@RequestMapping("/content/adverts")
public class AdvertisementController extends BaseController {
private String prefix = "content/adverts";
@Autowired
private ICmsArticleAdInfoService cmsArticleAdInfoService;
@GetMapping()
public String adverts() {
return prefix + "/adverts";
}
/**
* 查询文章广告列表
*/
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(CmsArticleAdInfo cmsArticleAdInfo) {
startPage();
List<CmsArticleAdInfo> list = cmsArticleAdInfoService.selectCmsArticleAdInfoList(cmsArticleAdInfo);
return getDataTable(list);
}
/**
* 导出文章广告列表
*/
@Log(title = "文章广告", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(CmsArticleAdInfo cmsArticleAdInfo) {
List<CmsArticleAdInfo> list = cmsArticleAdInfoService.selectCmsArticleAdInfoList(cmsArticleAdInfo);
ExcelUtil<CmsArticleAdInfo> util = new ExcelUtil<CmsArticleAdInfo>(CmsArticleAdInfo.class);
return util.exportExcel(list, "adverts");
}
/**
* 新增文章广告
*/
@GetMapping("/add")
public String add() {
return prefix + "/add";
}
/**
* 新增保存文章广告
*/
@Log(title = "文章广告", businessType = BusinessType.INSERT)
@RequestMapping("/add")
@ResponseBody
public AjaxResult addSave(@RequestParam("addImg") MultipartFile[] files, CmsArticleAdInfo cmsArticleAdInfo) {
MultipartFile file = files[0];
return toAjax(cmsArticleAdInfoService.insertCmsArticleAdInfo(file, cmsArticleAdInfo));
}
/**
* 修改文章广告
*/
@RequestMapping("/edit/{adId}")
public String edit(@PathVariable("adId") Long adId, ModelMap mmap) {
CmsArticleAdInfo cmsArticleAdInfo = cmsArticleAdInfoService.selectCmsArticleAdInfoById(adId);
mmap.put("cmsArticleAdInfo", cmsArticleAdInfo);
return prefix + "/edit";
}
/**
* 修改保存文章广告
*/
@Log(title = "文章广告", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(CmsArticleAdInfo cmsArticleAdInfo) {
return toAjax(cmsArticleAdInfoService.updateCmsArticleAdInfo(cmsArticleAdInfo));
}
/**
* 删除文章广告
*/
@Log(title = "文章广告", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(cmsArticleAdInfoService.deleteCmsArticleAdInfoByIds(ids));
}
}

View File

@ -0,0 +1,277 @@
package com.ruoyi.content.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 文章广告对象 cms_article_ad_info
*
* @author ruoyi
* @date 2021-03-23
*/
public class CmsArticleAdInfo {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long adId;
/**
* 公司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不可用
*/
@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 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() {
return adId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getCompanyId() {
return companyId;
}
public void setAdType(String adType) {
this.adType = adType;
}
public String getAdType() {
return adType;
}
public void setAdTypeName(String adTypeName) {
this.adTypeName = adTypeName;
}
public String getAdTypeName() {
return adTypeName;
}
public void setAdLinkUrl(String adLinkUrl) {
this.adLinkUrl = adLinkUrl;
}
public String getAdLinkUrl() {
return adLinkUrl;
}
public void setAdTitle(String adTitle) {
this.adTitle = adTitle;
}
public String getAdTitle() {
return adTitle;
}
public void setAdName(String adName) {
this.adName = adName;
}
public String getAdName() {
return adName;
}
public void setAdSummary(String adSummary) {
this.adSummary = adSummary;
}
public String getAdSummary() {
return adSummary;
}
public void setAdColorType(String adColorType) {
this.adColorType = adColorType;
}
public String getAdColorType() {
return adColorType;
}
public void setAdImageUrl(String adImageUrl) {
this.adImageUrl = adImageUrl;
}
public String getAdImageUrl() {
return adImageUrl;
}
public void setAdState(String adState) {
this.adState = adState;
}
public String getAdState() {
return adState;
}
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;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("adId", getAdId())
.append("companyId", getCompanyId())
.append("adType", getAdType())
.append("adTypeName", getAdTypeName())
.append("adLinkUrl", getAdLinkUrl())
.append("adTitle", getAdTitle())
.append("adName", getAdName())
.append("adSummary", getAdSummary())
.append("adColorType", getAdColorType())
.append("adImageUrl", getAdImageUrl())
.append("adState", getAdState())
.append("createDate", getCreateDate())
.append("createTime", getCreateTime())
.append("createUser", getCreateUser())
.append("updateUser", getUpdateUser())
.append("updateDate", getUpdateDate())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,64 @@
package com.ruoyi.content.mapper;
import com.ruoyi.content.domain.CmsArticleAdInfo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 文章广告Mapper接口
*
* @author ruoyi
* @date 2021-03-23
*/
@Repository
public interface CmsArticleAdInfoMapper {
/**
* 查询文章广告
*
* @param adId 文章广告ID
* @return 文章广告
*/
public CmsArticleAdInfo selectCmsArticleAdInfoById(Long adId);
/**
* 查询文章广告列表
*
* @param cmsArticleAdInfo 文章广告
* @return 文章广告集合
*/
public List<CmsArticleAdInfo> selectCmsArticleAdInfoList(CmsArticleAdInfo cmsArticleAdInfo);
/**
* 新增文章广告
*
* @param cmsArticleAdInfo 文章广告
* @return 结果
*/
public int insertCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo);
/**
* 修改文章广告
*
* @param cmsArticleAdInfo 文章广告
* @return 结果
*/
public int updateCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo);
/**
* 删除文章广告
*
* @param adId 文章广告ID
* @return 结果
*/
public int deleteCmsArticleAdInfoById(Long adId);
/**
* 批量删除文章广告
*
* @param adIds 需要删除的数据ID
* @return 结果
*/
public int deleteCmsArticleAdInfoByIds(String[] adIds);
}

View File

@ -0,0 +1,63 @@
package com.ruoyi.content.service;
import java.util.List;
import com.ruoyi.content.domain.CmsArticleAdInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 文章广告Service接口
*
* @author ruoyi
* @date 2021-03-23
*/
public interface ICmsArticleAdInfoService {
/**
* 查询文章广告
*
* @param adId 文章广告ID
* @return 文章广告
*/
public CmsArticleAdInfo selectCmsArticleAdInfoById(Long adId);
/**
* 查询文章广告列表
*
* @param cmsArticleAdInfo 文章广告
* @return 文章广告集合
*/
public List<CmsArticleAdInfo> selectCmsArticleAdInfoList(CmsArticleAdInfo cmsArticleAdInfo);
/**
* 新增文章广告
*
* @param file 广告图片
* @param cmsArticleAdInfo 文章广告
* @return
*/
public int insertCmsArticleAdInfo(MultipartFile file, CmsArticleAdInfo cmsArticleAdInfo);
/**
* 修改文章广告
*
* @param cmsArticleAdInfo 文章广告
* @return 结果
*/
public int updateCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo);
/**
* 批量删除文章广告
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteCmsArticleAdInfoByIds(String ids);
/**
* 删除文章广告信息
*
* @param adId 文章广告ID
* @return 结果
*/
public int deleteCmsArticleAdInfoById(Long adId);
}

View File

@ -0,0 +1,132 @@
package com.ruoyi.content.service.impl;
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 org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
/**
* 文章广告Service业务层处理
*
* @author ruoyi
* @date 2021-03-23
*/
@Service
public class CmsArticleAdInfoServiceImpl implements ICmsArticleAdInfoService {
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleAdInfoServiceImpl.class);
@Autowired
private CmsArticleAdInfoMapper cmsArticleAdInfoMapper;
/**
* 查询文章广告
*
* @param adId 文章广告ID
* @return 文章广告
*/
@Override
public CmsArticleAdInfo selectCmsArticleAdInfoById(Long adId) {
return cmsArticleAdInfoMapper.selectCmsArticleAdInfoById(adId);
}
/**
* 查询文章广告列表
*
* @param cmsArticleAdInfo 文章广告
* @return 文章广告
*/
@Override
public List<CmsArticleAdInfo> selectCmsArticleAdInfoList(CmsArticleAdInfo cmsArticleAdInfo) {
cmsArticleAdInfo.setAdState("0");
cmsArticleAdInfo.setCompanyId("1");
return cmsArticleAdInfoMapper.selectCmsArticleAdInfoList(cmsArticleAdInfo);
}
/**
* 新增文章广告
*
* @param file 广告图片
* @param cmsArticleAdInfo 文章广告
* @return
*/
@Override
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);
}
/**
* 修改文章广告
*
* @param cmsArticleAdInfo 文章广告
* @return 结果
*/
@Override
public int updateCmsArticleAdInfo(CmsArticleAdInfo cmsArticleAdInfo) {
cmsArticleAdInfo.setUpdateTime(DateUtils.getDate());
return cmsArticleAdInfoMapper.updateCmsArticleAdInfo(cmsArticleAdInfo);
}
/**
* 删除文章广告对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteCmsArticleAdInfoByIds(String ids) {
return cmsArticleAdInfoMapper.deleteCmsArticleAdInfoByIds(Convert.toStrArray(ids));
}
/**
* 删除文章广告信息
*
* @param adId 文章广告ID
* @return 结果
*/
@Override
public int deleteCmsArticleAdInfoById(Long adId) {
return cmsArticleAdInfoMapper.deleteCmsArticleAdInfoById(adId);
}
}

View File

@ -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);
}
}
}
}
}

View File

@ -0,0 +1,133 @@
<?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.CmsArticleAdInfoMapper">
<resultMap type="CmsArticleAdInfo" id="CmsArticleAdInfoResult">
<result property="adId" column="AD_ID" />
<result property="companyId" column="COMPANY_ID" />
<result property="adType" column="AD_TYPE" />
<result property="adTypeName" column="AD_TYPE_NAME" />
<result property="adLinkUrl" column="AD_LINK_URL" />
<result property="adTitle" column="AD_TITLE" />
<result property="adName" column="AD_NAME" />
<result property="adSummary" column="AD_SUMMARY" />
<result property="adColorType" column="AD_COLOR_TYPE" />
<result property="adImageUrl" column="AD_IMAGE_URL" />
<result property="adState" column="AD_STATE" />
<result property="createDate" column="CREATE_DATE" />
<result property="createTime" column="CREATE_TIME" />
<result property="createUser" column="CREATE_USER" />
<result property="updateUser" column="UPDATE_USER" />
<result property="updateDate" column="UPDATE_DATE" />
<result property="updateTime" column="UPDATE_TIME" />
</resultMap>
<sql id="selectCmsArticleAdInfoVo">
select AD_ID, COMPANY_ID, AD_TYPE, AD_TYPE_NAME, AD_LINK_URL, AD_TITLE, AD_NAME, AD_SUMMARY, AD_COLOR_TYPE, AD_IMAGE_URL, AD_STATE, CREATE_DATE, CREATE_TIME, CREATE_USER, UPDATE_USER, UPDATE_DATE, UPDATE_TIME from cms_article_ad_info
</sql>
<select id="selectCmsArticleAdInfoList" parameterType="CmsArticleAdInfo" resultMap="CmsArticleAdInfoResult">
<include refid="selectCmsArticleAdInfoVo"/>
<where>
<if test="companyId != null and companyId != ''"> and COMPANY_ID = #{companyId}</if>
<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 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>
<if test="adImageUrl != null and adImageUrl != ''"> and AD_IMAGE_URL = #{adImageUrl}</if>
<if test="adState != null and adState != ''"> and AD_STATE = #{adState}</if>
<if test="createDate != null and createDate != ''"> and CREATE_DATE = #{createDate}</if>
<if test="createTime != null and createTime != ''"> and CREATE_TIME = #{createTime}</if>
<if test="createUser != null and createUser != ''"> and CREATE_USER = #{createUser}</if>
<if test="updateUser != null and updateUser != ''"> and UPDATE_USER = #{updateUser}</if>
<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">
<include refid="selectCmsArticleAdInfoVo"/>
where AD_ID = #{adId}
</select>
<insert id="insertCmsArticleAdInfo" parameterType="CmsArticleAdInfo" useGeneratedKeys="true" keyProperty="adId">
insert into cms_article_ad_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyId != null">COMPANY_ID,</if>
<if test="adType != null">AD_TYPE,</if>
<if test="adTypeName != null">AD_TYPE_NAME,</if>
<if test="adLinkUrl != null">AD_LINK_URL,</if>
<if test="adTitle != null">AD_TITLE,</if>
<if test="adName != null">AD_NAME,</if>
<if test="adSummary != null">AD_SUMMARY,</if>
<if test="adColorType != null">AD_COLOR_TYPE,</if>
<if test="adImageUrl != null">AD_IMAGE_URL,</if>
<if test="adState != null">AD_STATE,</if>
<if test="createDate != null">CREATE_DATE,</if>
<if test="createTime != null">CREATE_TIME,</if>
<if test="createUser != null">CREATE_USER,</if>
<if test="updateUser != null">UPDATE_USER,</if>
<if test="updateDate != null">UPDATE_DATE,</if>
<if test="updateTime != null">UPDATE_TIME,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyId != null">#{companyId},</if>
<if test="adType != null">#{adType},</if>
<if test="adTypeName != null">#{adTypeName},</if>
<if test="adLinkUrl != null">#{adLinkUrl},</if>
<if test="adTitle != null">#{adTitle},</if>
<if test="adName != null">#{adName},</if>
<if test="adSummary != null">#{adSummary},</if>
<if test="adColorType != null">#{adColorType},</if>
<if test="adImageUrl != null">#{adImageUrl},</if>
<if test="adState != null">#{adState},</if>
<if test="createDate != null">#{createDate},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUser != null">#{createUser},</if>
<if test="updateUser != null">#{updateUser},</if>
<if test="updateDate != null">#{updateDate},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateCmsArticleAdInfo" parameterType="CmsArticleAdInfo">
update cms_article_ad_info
<trim prefix="SET" suffixOverrides=",">
<if test="companyId != null">COMPANY_ID = #{companyId},</if>
<if test="adType != null">AD_TYPE = #{adType},</if>
<if test="adTypeName != null">AD_TYPE_NAME = #{adTypeName},</if>
<if test="adLinkUrl != null">AD_LINK_URL = #{adLinkUrl},</if>
<if test="adTitle != null">AD_TITLE = #{adTitle},</if>
<if test="adName != null">AD_NAME = #{adName},</if>
<if test="adSummary != null">AD_SUMMARY = #{adSummary},</if>
<if test="adColorType != null">AD_COLOR_TYPE = #{adColorType},</if>
<if test="adImageUrl != null">AD_IMAGE_URL = #{adImageUrl},</if>
<if test="adState != null">AD_STATE = #{adState},</if>
<if test="createDate != null">CREATE_DATE = #{createDate},</if>
<if test="createTime != null">CREATE_TIME = #{createTime},</if>
<if test="createUser != null">CREATE_USER = #{createUser},</if>
<if test="updateUser != null">UPDATE_USER = #{updateUser},</if>
<if test="updateDate != null">UPDATE_DATE = #{updateDate},</if>
<if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
</trim>
where AD_ID = #{adId}
</update>
<delete id="deleteCmsArticleAdInfoById" parameterType="Long">
delete from cms_article_ad_info where AD_ID = #{adId}
</delete>
<delete id="deleteCmsArticleAdInfoByIds" parameterType="String">
delete from cms_article_ad_info where AD_ID in
<foreach item="adId" collection="array" open="(" separator="," close=")">
#{adId}
</foreach>
</delete>
</mapper>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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: '选择 &hellip;',
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} &hellip;',
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: '拖拽文件到这里 &hellip;',
slugCallback: function(text) {
return text ? text.split(/(\\|\/)/g).pop().replace(/[^\w\u4e00-\u9fa5\-.\\\/ ]+/g, '') : '';
},
fileActionSettings: {
removeTitle: '删除文件',
uploadTitle: '上传文件',
indicatorNewTitle: '没有上传',
indicatorSuccessTitle: '上传',
indicatorErrorTitle: '上传错误',
indicatorLoadingTitle: '上传 ...'
}
};
})(window.jQuery);

View File

@ -0,0 +1,157 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
<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" action="" enctype="multipart/form-data" method="post">
<div class="form-group">
<label class="col-sm-3 control-label is-required">广告标题:</label>
<div class="col-sm-8">
<input name="adTitle" th:id="adTitle" 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">
<input name="adName" th:id="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>
</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" th:id="adLinkUrl" 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">
<input name="adSummary" th:id="adSummary" 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">
<input type="radio" class="addColor" id="addColor_a" th:name="adColorType" value="1" checked="checked">
<label class="lab" style="background-color: #67c5ab"></label>
<input type="radio" class="addColor" id="addColor_b" th:name="adColorType" value="2">
<label class="lab" style="background-color: #b6d882"></label>
<input type="radio" class="addColor" id="addColor_c" th: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 is-required">广告图片:</label>
<div class="col-sm-8">
<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-7">
<input type="file" class="file projectfile" multiple th:id="addImg" name="addImg" required>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<link th:href="@{/css/fileinput.min.css}" rel="stylesheet"/>
<script th:src="@{/js/fileinput.min.js}"></script>
<script th:src="@{/js/fileinput_locale_zh.js}"></script>
<script th:inline="javascript">
var prefix = ctx + "content/adverts"
chooseAdType();
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");
});
function submitHandler() {
if ($.validate.form()) {
var data = new FormData();
data.append('adTitle', $("#adTitle").val());
data.append('adName', $("#adName").val());
data.append('adType', $("#addType").val());
data.append('adTypeName', $("#adTypeName").val());
data.append('adLinkUrl', $("#adLinkUrl").val());
data.append('adSummary', $("#adSummary").val());
data.append('adColorType',$("input[name='adColorType']:checked").val());
data.append('addImg', $("#addImg")[0].files[0]);
$.ajax({
url : prefix + "/add",
data : data,
dataType : "json",
type : "post",
processData: false,//不需要对数据进行处理
contentType:false,
cache : false,
success : function(result) {
$.operate.successCallback(result);
},
error : function(textStatus, e) {
}
});
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,143 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<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">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>广告标题:</label>
<input type="text" name="adTitle"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()">
<i class="fa fa-plus"></i> 添加
</a>
<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>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "content/adverts";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "文章广告",
columns: [{
checkbox: true
},
{
field: 'adId',
title: '',
visible: false
},
{
field: 'adTitle',
title: '广告标题'
},
{
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: '简介',
width: '20',
widthUnit: '%'
},
{
field: 'adColorType',
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: '广告图片',
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 " 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('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>

View File

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改文章广告')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-adverts-edit" th:object="${cmsArticleAdInfo}">
<input name="adId" th:field="*{adId}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">公司id</label>
<div class="col-sm-8">
<input name="companyId" th:field="*{companyId}" 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="adType" 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="adTypeName" th:field="*{adTypeName}" 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="adLinkUrl" th:field="*{adLinkUrl}" 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="adTitle" th:field="*{adTitle}" 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="adName" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{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" th:field="*{updateDate}" class="form-control" type="text">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "content/adverts";
$("#form-adverts-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-adverts-edit').serialize());
}
}
</script>
</body>
</html>