代码提交
This commit is contained in:
parent
f3e48f62ea
commit
8c1ad942d4
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wuzhen.web.controller.busi;
|
package com.wuzhen.web.controller.busi;
|
||||||
|
|
||||||
import com.wuzhen.common.annotation.Log;
|
import com.wuzhen.common.annotation.Log;
|
||||||
|
import com.wuzhen.common.config.RuoYiConfig;
|
||||||
import com.wuzhen.common.core.controller.BaseController;
|
import com.wuzhen.common.core.controller.BaseController;
|
||||||
import com.wuzhen.common.core.domain.AjaxResult;
|
import com.wuzhen.common.core.domain.AjaxResult;
|
||||||
import com.wuzhen.common.core.page.TableDataInfo;
|
import com.wuzhen.common.core.page.TableDataInfo;
|
||||||
|
|
@ -15,6 +16,10 @@ import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,14 +84,29 @@ public class ActiveInfoController extends BaseController
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated ActiveInfo activeInfo)
|
public AjaxResult addSave(@Validated ActiveInfo activeInfo)
|
||||||
{
|
{
|
||||||
// if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(activeInfoService.checkNameUnique(role)))
|
MultipartFile file = activeInfo.getActivePic();
|
||||||
// {
|
// 获取上传文件名
|
||||||
// return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
String filename = file.getOriginalFilename();
|
||||||
// }
|
if (!"".equals(filename)){
|
||||||
// else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
|
||||||
// {
|
// 定义上传文件保存路径
|
||||||
// return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
String path = RuoYiConfig.getUploadPath();
|
||||||
// }
|
// 新建文件
|
||||||
|
File filepath = new File(path, filename);
|
||||||
|
// 判断路径是否存在,如果不存在就创建一个
|
||||||
|
if (!filepath.getParentFile().exists()) {
|
||||||
|
filepath.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
String picUrl = path + File.separator + filename;
|
||||||
|
try {
|
||||||
|
// 写入文件
|
||||||
|
file.transferTo(new File(picUrl));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
activeInfo.setActivePicUrl(picUrl);
|
||||||
|
}
|
||||||
|
|
||||||
activeInfo.setCreateBy(getLoginName());
|
activeInfo.setCreateBy(getLoginName());
|
||||||
AuthorizationUtils.clearAllCachedAuthorizationInfo();
|
AuthorizationUtils.clearAllCachedAuthorizationInfo();
|
||||||
return toAjax(activeInfoService.insertActive(activeInfo));
|
return toAjax(activeInfoService.insertActive(activeInfo));
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import com.wuzhen.common.utils.file.FileUtils;
|
||||||
* @author zhengzheng
|
* @author zhengzheng
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/common")
|
@RequestMapping("/common/upload")
|
||||||
public class CommonController
|
public class CommonController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# 项目相关配置
|
# 项目相关配置
|
||||||
ruoyi:
|
wuzhen:
|
||||||
# 名称
|
# 名称
|
||||||
name: 乌镇展厅小程序
|
name: 乌镇展厅小程序
|
||||||
# 版本
|
# 版本
|
||||||
|
|
@ -7,7 +7,7 @@ ruoyi:
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2022
|
copyrightYear: 2022
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: false
|
||||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||||
profile: D:/ruoyi/uploadPath
|
profile: D:/ruoyi/uploadPath
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body class="white-bg">
|
<body class="white-bg">
|
||||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||||
<form class="form-horizontal m" id="form-role-add">
|
<form class="form-horizontal m" id="form-role-add" enctype="multipart/form-data">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label is-required">活动标题:</label>
|
<label class="col-sm-3 control-label is-required">活动标题:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|
@ -33,8 +33,11 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label is-required">活动图片:</label>
|
<label class="col-sm-3 control-label is-required">活动图片:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" type="text" name="activePic" id="activePic" required>
|
<!-- <label for="uploadFile">或者 上传本地文件</label>-->
|
||||||
|
<input type="file" class="form-control-file" id="activePic" name="activePic">
|
||||||
|
<!-- <input class="form-control" type="text" name="activePic" id="activePic" required>-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group draggable">
|
<div class="form-group draggable">
|
||||||
|
|
@ -93,28 +96,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
var activeTitle = $("input[name='activeTitle']").val();
|
|
||||||
var activeDesc =$("textarea[name='activeDesc']").val();
|
<!-- var activeTitle = $("input[name='activeTitle']").val();-->
|
||||||
var activeType = $("select[name='activeType']").val();
|
<!-- var activeDesc =$("textarea[name='activeDesc']").val();-->
|
||||||
var activePic = $("input[name='activePic']").val();
|
<!-- var activeType = $("select[name='activeType']").val();-->
|
||||||
var activeStartDate = $("input[name='activeStartDate']").val();
|
<!-- var activeStartDate = $("input[name='activeStartDate']").val();-->
|
||||||
var activeEndDate = $("input[name='activeEndDate']").val();
|
<!-- var activeEndDate = $("input[name='activeEndDate']").val();-->
|
||||||
var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
|
<!-- var status = $("input[id='status']").is(':checked') == true ? 0 : 1;-->
|
||||||
var remark = $("input[name='remark']").val();
|
<!-- var remark = $("input[name='remark']").val();-->
|
||||||
|
<!-- var activePic = $('#activePic')[0].files[0];-->
|
||||||
|
var formData = new FormData($("#form-role-add")[0])
|
||||||
|
formData.append('activePic', activePic);
|
||||||
|
<!-- formData.append('activeDesc', activeDesc);-->
|
||||||
|
<!-- formData.append('activeType', activeType);-->
|
||||||
|
<!-- formData.append('activeStartDate', activeStartDate);-->
|
||||||
|
<!-- formData.append('activeEndDate', activeEndDate);-->
|
||||||
|
<!-- formData.append('status', status);-->
|
||||||
|
<!-- formData.append('remark', remark);-->
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache : true,
|
cache: false,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
type : "POST",
|
type : "POST",
|
||||||
url : ctx + "active/info/add",
|
url : ctx + "active/info/add",
|
||||||
data : {
|
data : formData,
|
||||||
"activeTitle": activeTitle,
|
|
||||||
"activeDesc": activeDesc,
|
|
||||||
"activeType": activeType,
|
|
||||||
"activePic": activePic,
|
|
||||||
"activeStartDate": activeStartDate,
|
|
||||||
"activeEndDate": activeEndDate,
|
|
||||||
"status": status,
|
|
||||||
"remark": remark
|
|
||||||
},
|
|
||||||
async : false,
|
async : false,
|
||||||
error : function(request) {
|
error : function(request) {
|
||||||
$.modal.alertError("系统错误");
|
$.modal.alertError("系统错误");
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label is-required">活动图片:</label>
|
<label class="col-sm-3 control-label is-required">活动图片:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" type="text" name="activePic" id="activePic" th:field="*{activePic}" required>
|
<input class="form-control" type="text" name="activePicUrl" id="activePicUrl" th:field="*{activePicUrl}" disabled required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.wuzhen.common.annotation.Excel.ColumnType;
|
||||||
import com.wuzhen.common.core.domain.BaseEntity;
|
import com.wuzhen.common.core.domain.BaseEntity;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动信息 active_info
|
* 活动信息 active_info
|
||||||
|
|
@ -59,7 +60,15 @@ public class ActiveInfo extends BaseEntity {
|
||||||
* 活动图片
|
* 活动图片
|
||||||
*/
|
*/
|
||||||
@Excel(name = "活动图片")
|
@Excel(name = "活动图片")
|
||||||
private String activePic;
|
private MultipartFile activePic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动图片地址
|
||||||
|
*/
|
||||||
|
@Excel(name = "活动图片地址")
|
||||||
|
private String activePicUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推荐人编号
|
* 推荐人编号
|
||||||
|
|
@ -126,11 +135,11 @@ public class ActiveInfo extends BaseEntity {
|
||||||
this.activeType = activeType;
|
this.activeType = activeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActivePic() {
|
public MultipartFile getActivePic() {
|
||||||
return activePic;
|
return activePic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivePic(String activePic) {
|
public void setActivePic(MultipartFile activePic) {
|
||||||
this.activePic = activePic;
|
this.activePic = activePic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,6 +151,15 @@ public class ActiveInfo extends BaseEntity {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getActivePicUrl() {
|
||||||
|
return activePicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivePicUrl(String activePicUrl) {
|
||||||
|
this.activePicUrl = activePicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="activeStartDate" column="active_start_date" />
|
<result property="activeStartDate" column="active_start_date" />
|
||||||
<result property="activeEndDate" column="active_end_date" />
|
<result property="activeEndDate" column="active_end_date" />
|
||||||
<result property="activeType" column="active_type" />
|
<result property="activeType" column="active_type" />
|
||||||
<result property="activePic" column="active_pic" />
|
<result property="activePicUrl" column="active_pic_url" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
|
|
@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectActiveVo">
|
<sql id="selectActiveVo">
|
||||||
select r.id, r.active_title, r.active_desc,r.active_start_date,r.active_end_date, r.active_pic, r.active_type, r.status, r.del_flag, r.create_time, r.remark
|
select r.id, r.active_title, r.active_desc,r.active_start_date,r.active_end_date, r.active_pic_url, r.active_type, r.status, r.del_flag, r.create_time, r.remark
|
||||||
from active_info r
|
from active_info r
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="activeStartDate != null and activeStartDate != ''">active_start_date = #{activeStartDate},</if>
|
<if test="activeStartDate != null and activeStartDate != ''">active_start_date = #{activeStartDate},</if>
|
||||||
<if test="activeEndDate != null and activeEndDate != ''">active_end_date = #{activeEndDate},</if>
|
<if test="activeEndDate != null and activeEndDate != ''">active_end_date = #{activeEndDate},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
<if test="activePic != null and activePic != ''">active_pic = #{activePic},</if>
|
<if test="activePicUrl != null and activePicUrl != ''">active_pic = #{active_pic_url},</if>
|
||||||
<if test="activeType != null and activeType != ''">active_type = #{activeType},</if>
|
<if test="activeType != null and activeType != ''">active_type = #{activeType},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
|
@ -100,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="activeStartDate != null and activeStartDate != ''">active_start_date,</if>
|
<if test="activeStartDate != null and activeStartDate != ''">active_start_date,</if>
|
||||||
<if test="activeEndDate != null and activeEndDate != ''">active_end_date,</if>
|
<if test="activeEndDate != null and activeEndDate != ''">active_end_date,</if>
|
||||||
<if test="activeType != null and activeType != ''">active_type,</if>
|
<if test="activeType != null and activeType != ''">active_type,</if>
|
||||||
<if test="activePic != null and activePic != ''">active_pic,</if>
|
<if test="activePicUrl != null and activePicUrl != ''">active_pic_url,</if>
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
|
@ -111,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="activeStartDate != null and activeStartDate != ''">#{activeStartDate},</if>
|
<if test="activeStartDate != null and activeStartDate != ''">#{activeStartDate},</if>
|
||||||
<if test="activeEndDate != null and activeEndDate != ''">#{activeEndDate},</if>
|
<if test="activeEndDate != null and activeEndDate != ''">#{activeEndDate},</if>
|
||||||
<if test="activeType != null and activeType != ''">#{activeType},</if>
|
<if test="activeType != null and activeType != ''">#{activeType},</if>
|
||||||
<if test="activePic != null and activeType != ''">#{activePic},</if>
|
<if test="activePicUrl != null and activePicUrl != ''">#{activePicUrl},</if>
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue