代码提交

This commit is contained in:
zhengzheng 2022-04-15 21:26:09 +08:00
parent 435defcf84
commit e5f9f26408
11 changed files with 305 additions and 29 deletions

View File

@ -90,7 +90,7 @@ public class ActiveInfoController extends BaseController
if (!"".equals(filename)){
// 定义上传文件保存路径
String path = RuoYiConfig.getUploadPath();
String path = RuoYiConfig.getLPUploadPath();
// 新建文件
File filepath = new File(path, filename);
// 判断路径是否存在如果不存在就创建一个
@ -125,6 +125,56 @@ public class ActiveInfoController extends BaseController
return prefix + "/edit";
}
/**
* 修改活动
*/
@RequiresPermissions("active:info:edit")
@GetMapping("/first/{id}")
public String first(@PathVariable("id") Long id, ModelMap mmap)
{
mmap.put("active", activeInfoService.selectActiveById(id));
return prefix + "/first";
}
/**
*保存首页
*/
@RequiresPermissions("active:info:edit")
@Log(title = "保存首页", businessType = BusinessType.UPDATE)
@PostMapping("/firstSave")
@ResponseBody
public AjaxResult firstSave(@Validated ActiveInfo activeInfo)
{
MultipartFile file = activeInfo.getActiveFirstPic();
// 获取上传文件名
String filename = file.getOriginalFilename();
if (!"".equals(filename)){
// 定义上传文件保存路径
String path = RuoYiConfig.getFPUploadPath();
// 新建文件
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.setActiveFirstPicUrl(filename);
}
activeInfo.setUpdateBy(getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(activeInfoService.saveFistPage(activeInfo));
}
/**
* 修改保存活动
*/
@ -134,16 +184,7 @@ public class ActiveInfoController extends BaseController
@ResponseBody
public AjaxResult editSave(@Validated ActiveInfo activeInfo)
{
// roleService.checkRoleAllowed(role);
// roleService.checkRoleDataScope(role.getRoleId());
// if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
// {
// return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
// }
// else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
// {
// return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
// }
activeInfo.setUpdateBy(getLoginName());
AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(activeInfoService.updateActive(activeInfo));

View File

@ -63,12 +63,11 @@
</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">
<label class="toggle-switch switch-solid">
<input type="checkbox" id="status" checked>
<span></span>
</label>
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_active_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">

View File

@ -63,12 +63,11 @@
</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">
<label class="toggle-switch switch-solid">
<input type="checkbox" id="status" th:checked="${active.status == '0' ? true : false}">
<span></span>
</label>
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_active_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
</select>
</div>
</div>
<div class="form-group">

View File

@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改活动信息')" />
<th:block th:include="include :: ztree-css" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-edit" th:object="${active}" enctype="multipart/form-data">
<input id="roleId" name="id" type="hidden" th:field="*{id}"/>
<div class="form-group">
<label class="col-sm-3 control-label is-required">活动标题:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="activeTitle" id="activeTitle" th:field="*{activeTitle}" disabled required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">首页活动图片:</label>
<div class="col-sm-8">
<!-- <label for="uploadFile">或者 上传本地文件</label>-->
<input type="file" class="form-control-file" id="activeFirstPic" name="activeFirstPic">
<!-- <input class="form-control" type="text" name="activePic" id="activePic" required>-->
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
<script type="text/javascript">
$(document).ready(function(){setup_draggable();$("#n-columns").on("change",function(){var v=$(this).val();if(v==="1"){var $col=$(".form-body .col-md-12").toggle(true);$(".form-body .col-md-6 .draggable").each(function(i,el){$(this).remove().appendTo($col)});$(".form-body .col-md-6").toggle(false)}else{var $col=$(".form-body .col-md-6").toggle(true);$(".form-body .col-md-12 .draggable").each(function(i,el){$(this).remove().appendTo(i%2?$col[1]:$col[0])});$(".form-body .col-md-12").toggle(false)}});$("#copy-to-clipboard").on("click",function(){var $copy=$(".form-body").clone().appendTo(document.body);$copy.find(".tools, :hidden").remove();$.each(["draggable","droppable","sortable","dropped","ui-sortable","ui-draggable","ui-droppable","form-body"],function(i,c){$copy.find("."+c).removeClass(c).removeAttr("style")});var html=html_beautify($copy.html());$copy.remove();$modal=get_modal(html).modal("show");$modal.find(".btn").remove();$modal.find(".modal-title").html("复制HTML代码");$modal.find(":input:first").select().focus();return false})});var setup_draggable=function(){$(".draggable").draggable({appendTo:"body",helper:"clone"});$(".droppable").droppable({accept:".draggable",helper:"clone",hoverClass:"droppable-active",drop:function(event,ui){$(".empty-form").remove();var $orig=$(ui.draggable);if(!$(ui.draggable).hasClass("dropped")){var $el=$orig.clone().addClass("dropped").css({"position":"static","left":null,"right":null}).appendTo(this);if($el.find("label").hasClass("radio-box")){$el=$el.html('<label class="col-sm-3 control-label">单选框:</label>'+'<div class="col-sm-9">'+'<label class="radio-box"><input type="radio" checked="" value="option1" id="optionsRadios1" name="optionsRadios">选项1</label>'+'<label class="radio-box"><input type="radio" value="option2" id="optionsRadios2" name="optionsRadios">选项2</label>'+"</div>")}else{if($el.find("label").hasClass("check-box")){$el=$el.html('<label class="col-sm-3 control-label">复选框:</label>'+'<div class="col-sm-9">'+'<label class="check-box">'+'<input type="checkbox" value="option1" id="inlineCheckbox1">选项1</label>'+'<label class="check-box">'+'<input type="checkbox" value="option2" id="inlineCheckbox2">选项2</label>'+'<label class="check-box">'+'<input type="checkbox" value="option3" id="inlineCheckbox3">选项3</label>'+"</div>")}}var id=$orig.find(":input").attr("id");if(id){id=id.split("-").slice(0,-1).join("-")+"-"+(parseInt(id.split("-").slice(-1)[0])+1);$orig.find(":input").attr("id",id);$orig.find("label").attr("for",id)}$('<p class="tools col-sm-12 col-sm-offset-3"> <a class="edit-link">编辑HTML<a> | <a class="remove-link">移除</a></p>').appendTo($el)}else{if($(this)[0]!=$orig.parent()[0]){var $el=$orig.clone().css({"position":"static","left":null,"right":null}).appendTo(this);$orig.remove()}}}}).sortable()};var get_modal=function(content){var modal=$('<div class="modal" style="overflow: auto;" tabindex="-1"> <div class="modal-dialog"><div class="modal-content"><div class="modal-header"><a type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</a><h4 class="modal-title">编辑HTML</h4></div><div class="modal-body ui-front"> <textarea class="form-control textarea-show-src" style="min-height: 200px; margin-bottom: 10px;font-family: Monaco, Fixed"></textarea><button class="btn btn-success">更新HTML</button></div></div></div></div>').appendTo(document.body);var doms=document.getElementsByClassName("textarea-show-src");for(var i=0;i<doms.length;i++){doms.item(i).innerHTML=content}return modal};$(document).on("click",".edit-link",function(ev){var $el=$(this).parent().parent();var $el_copy=$el.clone();var $edit_btn=$el_copy.find(".edit-link").parent().remove();var $modal=get_modal(html_beautify($el_copy.html())).modal("show");$modal.find(":input:first").focus();$modal.find(".btn-success").click(function(ev2){var html=$modal.find("textarea").val();if(!html){$el.remove()}else{$el.html(html);$edit_btn.appendTo($el)}$modal.modal("hide");return false})});$(document).on("click",".remove-link",function(ev){$(this).parent().parent().remove()});$(".input-group.date").datetimepicker({format:"yyyy-mm-dd",minView:"month",autoclose:true});
</script>
<script type="text/javascript">
<!-- function edit() {-->
<!--&lt;!&ndash; var id = $("input[name='id']").val();&ndash;&gt;-->
<!--&lt;!&ndash; var activeFirstPic = $("input[name='activeFirstPic']").val();&ndash;&gt;-->
<!--&lt;!&ndash; var formData = new FormData($("#form-role-edit")[0])&ndash;&gt;-->
<!-- var formData = new FormData($("#form-role-edit")[0])-->
<!-- formData.append('activeFirstPic', activeFirstPic);-->
<!-- $.ajax({-->
<!-- cache : true,-->
<!-- type : "POST",-->
<!-- url : ctx + "active/info/firstSave",-->
<!-- data : formData,-->
<!-- async : false,-->
<!-- error : function(request) {-->
<!-- $.modal.alertError("系统错误");-->
<!-- },-->
<!-- success : function(data) {-->
<!-- $.operate.successCallback(data);-->
<!-- }-->
<!-- });-->
<!-- }-->
<!-- function submitHandler() {-->
<!-- edit();-->
<!-- }-->
<!-- -->
<!-- -->
function submitHandler() {
add();
}
function add() {
<!-- var activeTitle = $("input[name='activeTitle']").val();-->
<!-- var activeDesc =$("textarea[name='activeDesc']").val();-->
<!-- var activeType = $("select[name='activeType']").val();-->
<!-- var activeStartDate = $("input[name='activeStartDate']").val();-->
<!-- var activeEndDate = $("input[name='activeEndDate']").val();-->
<!-- var status = $("input[id='status']").is(':checked') == true ? 0 : 1;-->
<!-- var remark = $("input[name='remark']").val();-->
<!-- var activePic = $('#activePic')[0].files[0];-->
var formData = new FormData($("#form-role-edit")[0])
formData.append('activeFirstPic', activeFirstPic);
<!-- 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({
cache: false,
contentType: false,
processData: false,
type : "POST",
url : ctx + "active/info/firstSave",
data : formData,
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
$.operate.successCallback(data);
}
});
}
</script>
</body>
</html>

View File

@ -65,6 +65,7 @@
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('active:info:list')}]];
var removeFlag = [[${@permission.hasPermi('active:info:remove')}]];
var addFlag = [[${@permission.hasPermi('active:info:list')}]];
var prefix = ctx + "active/info";
@ -105,6 +106,19 @@
return '<span class="label label-primary">智会</span>';
}
}
},
{
field: 'activeType',
title: '是否设置首页',
sortable: true,
formatter: function(value, item, index) {
if (item.isFristPage == '0') {
return '非首页';
}
else if (item.isFristPage == '1') {
return '已为首页';
}
}
},
{
@ -114,7 +128,7 @@
},
{
field: 'activeEndDate',
title: '活动开始日期',
title: '活动结束日期',
sortable: true
},
@ -131,6 +145,7 @@
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><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.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="authFirstPage(\'' + row.id + '\')"><i class="fa fa-plus"></i>设为首页</a> ');
return actions.join('');
} else {
return "";
@ -146,6 +161,13 @@
var url = prefix + '/authDataScope/' + roleId;
$.modal.open("分配数据权限", url);
}
/* 设置首页 */
function authFirstPage(roleId) {
var url = prefix + '/first/'+roleId;
$.modal.open("增加首页", url);
}
/* 角色管理-分配用户 */
function authUser(roleId) {

View File

@ -115,10 +115,27 @@ public class RuoYiConfig
}
/**
* 获取上传路径
* 获取首页上传路径
*/
public static String getUploadPath()
public static String getFPUploadPath()
{
return getProfile() + "/upload/fp";
}
/**
* 获取列表上传路径
*/
public static String getLPUploadPath()
{
return getProfile() + "/upload/fp";
}
/**
* 获取列表上传路径
*/
public static String getUploadPath()
{
return getProfile();
}
}

View File

@ -59,7 +59,6 @@ public class ActiveInfo extends BaseEntity {
/**
* 活动图片
*/
@Excel(name = "活动图片")
private MultipartFile activePic;
@ -70,6 +69,51 @@ public class ActiveInfo extends BaseEntity {
@Excel(name = "活动图片地址")
private String activePicUrl;
/**
* 活动图片
*/
private MultipartFile activeFirstPic;
/**
* 活动图片地址
*/
@Excel(name = "活动首页图片地址")
private String activeFirstPicUrl;
/**
* 活动图片地址
*/
private String isFristPage;
public MultipartFile getActiveFirstPic() {
return activeFirstPic;
}
public void setActiveFirstPic(MultipartFile activeFirstPic) {
this.activeFirstPic = activeFirstPic;
}
public String getActiveFirstPicUrl() {
return activeFirstPicUrl;
}
public void setActiveFirstPicUrl(String activeFirstPicUrl) {
this.activeFirstPicUrl = activeFirstPicUrl;
}
public String getIsFristPage() {
return isFristPage;
}
public void setIsFristPage(String isFristPage) {
this.isFristPage = isFristPage;
}
/**
* 推荐人编号
*/

View File

@ -62,4 +62,13 @@ public interface ActiveInfoMapper
public int insertActive(ActiveInfo activeInfo);
/**
* 保存首页图片
*
* @param activeInfo 角色信息
* @return 结果
*/
public int saveFistPage(ActiveInfo activeInfo);
}

View File

@ -69,4 +69,14 @@ public interface IActiveInfoService
public int updateActive(ActiveInfo activeInfo);
/**
* 保存首页图片
*
* @param activeInfo 保存首页图片
* @return 结果
*/
public int saveFistPage(ActiveInfo activeInfo);
}

View File

@ -148,7 +148,6 @@ public class ActiveInfoServiceImpl implements IActiveInfoService {
@Transactional
public int insertActive(ActiveInfo activeInfo) {
// 新增角色信息
// activeInfoMapper.insertActive(activeInfo);
return activeInfoMapper.insertActive(activeInfo);
}
@ -162,10 +161,24 @@ public class ActiveInfoServiceImpl implements IActiveInfoService {
@Transactional
public int updateActive(ActiveInfo activeInfo) {
// 修改角色信息
activeInfoMapper.updateActive(activeInfo);
return activeInfoMapper.updateActive(activeInfo);
}
/**
*保存首页图片
*
* @param activeInfo 活动信息
* @return 结果
*/
@Override
@Transactional
public int saveFistPage(ActiveInfo activeInfo) {
// 修改角色信息
return activeInfoMapper.saveFistPage(activeInfo);
}
/**
* 修改数据权限信息
*

View File

@ -12,6 +12,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="activeEndDate" column="active_end_date" />
<result property="activeType" column="active_type" />
<result property="activePicUrl" column="active_pic_url" />
<result property="activeFirstPicUrl" column="active_frist_pic_url" />
<result property="isFristPage" column="is_frist_page" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
@ -23,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectActiveVo">
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
select r.id, r.active_title, r.active_desc,r.active_start_date,r.active_end_date, r.active_pic_url, r.active_frist_pic_url,r.is_frist_page, r.active_type, r.status, r.del_flag, r.create_time, r.remark
from active_info r
</sql>
@ -84,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="activeStartDate != null and activeStartDate != ''">active_start_date = #{activeStartDate},</if>
<if test="activeEndDate != null and activeEndDate != ''">active_end_date = #{activeEndDate},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="activePicUrl != null and activePicUrl != ''">active_pic = #{active_pic_url},</if>
<if test="activePicUrl != null and activePicUrl != ''">active_pic_url = #{active_pic_url},</if>
<if test="activeType != null and activeType != ''">active_type = #{activeType},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
@ -92,6 +94,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where id = #{id}
</update>
<update id="saveFistPage" parameterType="ActiveInfo">
update active_info
<set>
<if test="activeFirstPicUrl != null and activeFirstPicUrl != ''">active_frist_pic_url = #{activeFirstPicUrl},</if>
<if test="isFristPage != null and isFristPage != ''">is_frist_page = #{isFristPage},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where id = #{id}
</update>
<insert id="insertActive" parameterType="ActiveInfo" useGeneratedKeys="true" keyProperty="id">
insert into active_info(