();
queryWrapper.like(StringUtils.isNotBlank(roleVo.getName()),"name",roleVo.getName());
queryWrapper.like(StringUtils.isNotBlank(roleVo.getRemark()),"remark",roleVo.getRemark());
+ queryWrapper.eq(roleVo.getAvailable()!=null,"available",roleVo.getAvailable());
queryWrapper.ge(roleVo.getStartTime()!=null,"createtime",roleVo.getStartTime());
queryWrapper.le(roleVo.getEndTime()!=null,"createtime",roleVo.getEndTime());
+ queryWrapper.orderByDesc("createtime");
roleService.page(page,queryWrapper);
return new DataGridView(page.getTotal(),page.getRecords());
}
@@ -85,19 +87,18 @@ public class RoleController {
/**
* 删除角色
- * @param roleVo
+ * @param id
* @return
*/
@RequestMapping("deleteRole")
- public ResultObj deleteRole(RoleVo roleVo){
+ public ResultObj deleteRole(Integer id){
try {
- roleService.removeById(roleVo);
+ this.roleService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
-
}
}
diff --git a/src/main/java/com/yeqifu/sys/entity/Role.java b/src/main/java/com/yeqifu/sys/entity/Role.java
index 68445cf..abbd07a 100644
--- a/src/main/java/com/yeqifu/sys/entity/Role.java
+++ b/src/main/java/com/yeqifu/sys/entity/Role.java
@@ -3,7 +3,6 @@ package com.yeqifu.sys.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
diff --git a/src/main/java/com/yeqifu/sys/mapper/RoleMapper.java b/src/main/java/com/yeqifu/sys/mapper/RoleMapper.java
index 4c19a60..6cde0c4 100644
--- a/src/main/java/com/yeqifu/sys/mapper/RoleMapper.java
+++ b/src/main/java/com/yeqifu/sys/mapper/RoleMapper.java
@@ -2,6 +2,10 @@ package com.yeqifu.sys.mapper;
import com.yeqifu.sys.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.io.Serializable;
/**
*
@@ -11,6 +15,18 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author luoyi-
* @since 2019-11-28
*/
+@Mapper
public interface RoleMapper extends BaseMapper {
+ /**
+ * 根据角色ID删除sys_role_permission表中的数据
+ * @param id 角色的id
+ */
+ void deleteRolePermissionByRid(@Param("pid") Serializable id);
+
+ /**
+ * 根据角色ID删除sys_user_role表中的数据
+ * @param id 角色的id
+ */
+ void deleteUserRoleByRid(@Param("pid") Serializable id);
}
diff --git a/src/main/java/com/yeqifu/sys/service/impl/RoleServiceImpl.java b/src/main/java/com/yeqifu/sys/service/impl/RoleServiceImpl.java
index a3e8e2f..0e24892 100644
--- a/src/main/java/com/yeqifu/sys/service/impl/RoleServiceImpl.java
+++ b/src/main/java/com/yeqifu/sys/service/impl/RoleServiceImpl.java
@@ -6,6 +6,8 @@ import com.yeqifu.sys.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
+import java.io.Serializable;
+
/**
*
* InnoDB free: 9216 kB 服务实现类
@@ -17,4 +19,12 @@ import org.springframework.stereotype.Service;
@Service
public class RoleServiceImpl extends ServiceImpl implements IRoleService {
+ @Override
+ public boolean removeById(Serializable id) {
+ //根据角色ID删除sys_role_permission表中的数据
+ this.getBaseMapper().deleteRolePermissionByRid(id);
+ //根据角色ID删除sys_user_role表中的数据
+ this.getBaseMapper().deleteUserRoleByRid(id);
+ return super.removeById(id);
+ }
}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 5645580..e2404ea 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,4 +1,3 @@
-
#配置数据源
spring:
datasource:
@@ -31,8 +30,7 @@ spring:
#配置mybatisplus
mybatis-plus:
- mapper-locations:
- -classpath: mapper/*/*Mapper.xml
+ mapper-locations: classpath*:mapper/**/*Mapper.xml
global-config:
db-config:
id-type: auto
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
new file mode 100644
index 0000000..f15f1e7
--- /dev/null
+++ b/src/main/resources/log4j.properties
@@ -0,0 +1,5 @@
+log4j.rootLogger=DEBUG, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
\ No newline at end of file
diff --git a/src/main/resources/mapper/sys/RoleMapper.xml b/src/main/resources/mapper/sys/RoleMapper.xml
index 4baf616..3f69227 100644
--- a/src/main/resources/mapper/sys/RoleMapper.xml
+++ b/src/main/resources/mapper/sys/RoleMapper.xml
@@ -1,5 +1,10 @@
-
+
+ delete from sys_role_permission where rid = #{pid}
+
+
+ delete from sys_user_role where rid = #{pid}
+
diff --git a/src/main/resources/templates/system/role/roleManager.html b/src/main/resources/templates/system/role/roleManager.html
index 08374a1..72acb92 100644
--- a/src/main/resources/templates/system/role/roleManager.html
+++ b/src/main/resources/templates/system/role/roleManager.html
@@ -53,11 +53,18 @@
@@ -154,8 +164,11 @@
{field: 'id', title: 'ID', align: 'center'},
{field: 'name', title: '角色名称', align: 'center'},
{field: 'remark', title: '角色备注', align: 'center'},
+ {field: 'available', title: '是否可用', align: 'center',templet:function (d) {
+ return d.available==1?'可用':'不可用';
+ }},
{field: 'createtime', title: '创建时间', align: 'center'},
- {fixed: 'right', title: '操作', toolbar: '#roleRowBar', align: 'center'}
+ {fixed: 'right', title: '操作', toolbar: '#roleRowBar', align: 'center',width:280}
] ],
done:function (data, curr, count) {
//不是第一页时,如果当前返回的数据为0那么就返回上一页
@@ -178,10 +191,17 @@
}
});
+ //点击重置按钮时,重置表单的值
+ $("#resetRole").click(function () {
+ $("#searchFrm")[0].reset();
+ });
+
//监控模糊查询按钮事件
form.on("submit(doSearch)", function (data) {
+ var params = $("#searchFrm").serialize();
tableIns.reload({
- where: data.field,
+// where: data.field,
+ url:"/role/loadAllRole?"+params,
page: {
curr: 1
}
@@ -209,6 +229,9 @@
case 'delete':
deleteRole(data);
break;
+ case 'selectPermission':
+ selectPermission(data);
+ break;
};
});
@@ -256,7 +279,7 @@
layer.close(mainIndex);
});
return false;
- })
+ });
//删除
function deleteRole(data) {