master
parent
1def0926a5
commit
48d727f018
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.edu.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -124,4 +126,15 @@ public class EduClazzController extends BaseController
|
|||
{
|
||||
return toAjax(eduClazzService.deleteEduClazzByIds(ids));
|
||||
}
|
||||
|
||||
@Log(title = "班级管理", businessType = BusinessType.UPDATE)
|
||||
@RequiresPermissions("edu:clazz:edit")
|
||||
@PostMapping("/changeStatus")
|
||||
@ResponseBody
|
||||
public AjaxResult changeStatus(EduClazz clazz)
|
||||
{
|
||||
eduClazzService.checkClazzAllowed(clazz);
|
||||
eduClazzService.checkClazzDataScope(clazz.getId());
|
||||
return toAjax(eduClazzService.changeStatus(clazz));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class EduClazz extends BaseEntity
|
|||
private String clazzCount;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String visible;
|
||||
|
||||
public void setId(Long id)
|
||||
|
@ -67,6 +67,16 @@ public class EduClazz extends BaseEntity
|
|||
return visible;
|
||||
}
|
||||
|
||||
public boolean isAdmin()
|
||||
{
|
||||
return isAdmin(this.id);
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Long id)
|
||||
{
|
||||
return id != null && 1L == id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
@ -58,4 +58,10 @@ public interface IEduClazzService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteEduClazzById(Long id);
|
||||
|
||||
void checkClazzAllowed(EduClazz clazz);
|
||||
|
||||
void checkClazzDataScope(Long id);
|
||||
|
||||
int changeStatus(EduClazz clazz);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package com.ruoyi.edu.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.edu.mapper.EduClazzMapper;
|
||||
|
@ -91,4 +97,33 @@ public class EduClazzServiceImpl implements IEduClazzService
|
|||
{
|
||||
return eduClazzMapper.deleteEduClazzById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClazzAllowed(EduClazz clazz) {
|
||||
if (StringUtils.isNotNull(clazz.getId()) && clazz.isAdmin())
|
||||
{
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClazzDataScope(Long id) {
|
||||
|
||||
if (!EduClazz.isAdmin(ShiroUtils.getUserId()))
|
||||
{
|
||||
EduClazz clazz = new EduClazz();
|
||||
clazz.setId(id);
|
||||
List<EduClazz> clazzs = SpringUtils.getAopProxy(this).selectEduClazzList(clazz);
|
||||
if (StringUtils.isEmpty(clazzs))
|
||||
{
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int changeStatus(EduClazz clazz) {
|
||||
return eduClazzMapper.updateEduClazz(clazz);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">状态:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="visible" class="form-control" type="text">
|
||||
<!-- <input name="visible" class="form-control" type="text">-->
|
||||
<label class="toggle-switch switch-solid">
|
||||
<input type="checkbox" id="visible" checked>
|
||||
<span></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -35,7 +39,11 @@
|
|||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-clazz-add').serialize());
|
||||
var data = $("#form-clazz-add").serializeArray();
|
||||
var visible=$("input[id='visible']").is(':checked') == true ? 0 : 1;
|
||||
console.log(visible);
|
||||
data.push({"name": "visible", "value": visible});
|
||||
$.operate.save(prefix + "/add", data);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -19,8 +19,12 @@
|
|||
<input type="text" name="clazzCount"/>
|
||||
</li>
|
||||
<li>
|
||||
<label>状态:</label>
|
||||
<input type="text" name="visible"/>
|
||||
<!-- <label>状态:</label>-->
|
||||
<!-- <input type="text" name="visible"/>-->
|
||||
班级状态:<select name="visible" th:with="type=${@dict.getType('sys_normal_disable')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
|
@ -81,8 +85,13 @@
|
|||
title: '班级人数'
|
||||
},
|
||||
{
|
||||
visible: editFlag == 'hidden' ? false : true,
|
||||
field: 'visible',
|
||||
title: '状态'
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
formatter: function (value, row, index) {
|
||||
return statusTools(row);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
@ -97,6 +106,30 @@
|
|||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
|
||||
/* 用户状态显示 */
|
||||
function statusTools(row) {
|
||||
if (row.visible == 1) {
|
||||
return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
|
||||
} else {
|
||||
return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
|
||||
}
|
||||
}
|
||||
|
||||
/* 用户管理-停用 */
|
||||
function disable(id) {
|
||||
$.modal.confirm("确认要停用用户吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "id": id, "visible": 1 });
|
||||
})
|
||||
}
|
||||
|
||||
/* 用户管理启用 */
|
||||
function enable(id) {
|
||||
$.modal.confirm("确认要启用用户吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "id": id, "visible": 0 });
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue