新增权限模块功能代码

master
星期八 5 years ago
parent 509d35e64c
commit ff44e19af9
  1. 12
      src/main/java/com/lq/cms/service/SysPermissionService.java
  2. 49
      src/main/java/com/lq/cms/service/impl/SysPermissionServiceImpl.java
  3. 10
      src/main/java/com/lq/cms/vo/SysPermissionVo.java
  4. 66
      src/main/java/com/lq/cms/web/sys/PermissionController.java
  5. 4
      src/main/java/com/lq/code/util/mybatisPlus/CreateMapperFileUtil.java
  6. 6
      src/main/java/com/lq/dao/SysPermissionDao.java
  7. 63
      src/main/resources/mybatis/mapping/SysPermissionDao.xml
  8. 122
      src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/edit.jsp
  9. 167
      src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp

@ -0,0 +1,12 @@
package com.lq.cms.service;
import com.lq.cms.vo.SysPermissionVo;
import com.lq.entity.SysPermission;
/**
* @Author: qi
* @Description:
* @Date: Create in 11:59 PM 2019/7/22
*/
public interface SysPermissionService extends AdminBaseService<SysPermission,SysPermissionVo> {
}

@ -0,0 +1,49 @@
package com.lq.cms.service.impl;
import com.lq.cms.service.SysPermissionService;
import com.lq.cms.vo.SysPermissionVo;
import com.lq.code.dao.BaseDao;
import com.lq.code.service.impl.BaseServiceImpl;
import com.lq.dao.SysPermissionDao;
import com.lq.entity.SysPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: qi
* @Description:
* @Date: Create in 12:06 AM 2019/7/23
*/
@Service
public class SysPermissionServiceImpl extends BaseServiceImpl<SysPermission> implements SysPermissionService{
@Autowired
private SysPermissionDao sysPermissionDao;
@Override
public List<SysPermissionVo> findListPage(SysPermissionVo vo) {
return null;
}
@Override
public int count(SysPermissionVo vo) {
return 0;
}
@Override
public SysPermission save(SysPermissionVo vo) throws IllegalAccessException, InstantiationException {
return null;
}
@Override
public SysPermission update(SysPermissionVo vo) {
return null;
}
@Override
public BaseDao<SysPermission> getBaseDao() {
return sysPermissionDao;
}
}

@ -0,0 +1,10 @@
package com.lq.cms.vo;
/**
* @Author: qi
* @Description:
* @Date: Create in 11:27 PM 2019/7/22
*/
public class SysPermissionVo extends AdminBaseVo {
}

@ -0,0 +1,66 @@
package com.lq.cms.web.sys;
import com.lq.cms.mode.AdminDataGridParam;
import com.lq.cms.service.SysPermissionService;
import com.lq.cms.vo.SysPermissionVo;
import com.lq.code.entity.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @Author: qi
* @Description:权限控制类
* @Date: Create in 11:21 PM 2019/7/22
*/
@Controller
@RequestMapping("/cms/permission")
public class PermissionController {
@Autowired
private SysPermissionService sysPermissionService;
@RequestMapping("/index")
public String index(){
return "cms/sys/permission/index";
}
@RequestMapping("/edit")
public String edit(){
return "cms/sys/permission/edit";
}
@RequestMapping("/list")
@ResponseBody
public Object list(SysPermissionVo vo){
AdminDataGridParam<SysPermissionVo> adminDataGridParam = new AdminDataGridParam<>();
adminDataGridParam.setRows(sysPermissionService.findListPage(vo));
adminDataGridParam.setTotal(sysPermissionService.count(vo));
return adminDataGridParam;
}
@RequestMapping("/save")
@ResponseBody
public Object save(SysPermissionVo vo){
return new AjaxResult();
}
@RequestMapping("/update")
@ResponseBody
public Object update(SysPermissionVo vo){
return new AdminDataGridParam<SysPermissionVo>();
}
@RequestMapping("/delete")
@ResponseBody
public Object delete(SysPermissionVo vo){
return new AdminDataGridParam<SysPermissionVo>();
}
}

@ -4,8 +4,10 @@ import com.lq.code.util.FileUtil;
import com.lq.code.util.sql.AbstractDbBuiler;
import com.lq.code.util.sql.MysqlBuilder;
import com.lq.code.util.sql.SqlUtil;
import com.lq.dao.SysPermissionDao;
import com.lq.dao.WechatKeywordDao;
import com.lq.dao.WechatRuleMessageDao;
import com.lq.entity.SysPermission;
import com.lq.entity.WechatKeyword;
import com.lq.entity.WechatRuleMessage;
@ -63,7 +65,7 @@ public class CreateMapperFileUtil {
public static void main(String[] args) throws IOException {
AbstractDbBuiler abstractDbBuiler = new MysqlBuilder();
createXml(WechatRuleMessageDao.class, WechatRuleMessage.class,abstractDbBuiler);
createXml(SysPermissionDao.class, SysPermission.class,abstractDbBuiler);
}

@ -1,12 +1,18 @@
package com.lq.dao;
import com.lq.cms.vo.SysPermissionVo;
import com.lq.code.dao.BaseDao;
import com.lq.entity.SysPermission;
import java.util.List;
/**
* Created by qi on 2017-11-29.
*/
public interface SysPermissionDao extends BaseDao<SysPermission>{
List<SysPermissionVo> findListPage(SysPermissionVo vo);
int count(SysPermissionVo vo);
}

@ -1,29 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lq.dao.SysPermissionDao">
<!-- namespace命名空间,作用是对sql进行分类化管理,理解sql隔离 -->
<!-- 注意:使用mapper代理方法开发 ,namespace有着特殊作用-->
<sql id="column_list">
id,name,status
permission_type,permission_key,name,sys_resource_id,id,status
</sql>
<select id="findAll" resultType="SysPermission">
SELECT <include refid="column_list"/> FROM sys_permission WHERE status = 1
<select id="findOne" resultType="com.lq.entity.SysPermission" parameterType="long">
SELECT <include refid="column_list"/>
FROM sys_permission
WHERE id=#{id} AND status = 1
</select>
<select id="findAll" resultType="com.lq.entity.SysPermission">
SELECT <include refid="column_list"/>
FROM sys_permission
WHERE status = 1
</select>
<select id="count" resultType="int">
SELECT count(id)
FROM sys_permission
WHERE status = 1
</select>
<insert id="save" parameterType="SysPermission">
<insert id="save" parameterType="com.lq.entity.SysPermission" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" order="AFTER" resultType="long">
<selectKey keyProperty="id" order="AFTER" resultType="Long">
SELECT LAST_INSERT_ID()
</selectKey>
INSERT INTO
sys_permission(name)
sys_permission(permission_type,permission_key,name,sys_resource_id,id,status)
VALUES
(
#{name}
#{permissionType},#{permissionKey},#{name},#{sysResourceId},#{id},#{status}
)
</insert>
<update id="update" parameterType="com.lq.entity.SysPermission">
UPDATE
sys_permission
<trim prefix="set" suffixOverrides=",">
<if test="permissionType!=null">permission_type=#{permissionType},</if>
<if test="permissionKey!=null">permission_key=#{permissionKey},</if>
<if test="name!=null">name=#{name},</if>
<if test="sysResourceId!=null">sys_resource_id=#{sysResourceId},</if>
<if test="id!=null">id=#{id},</if>
<if test="status!=null">status=#{status},</if>
</trim>
WHERE
id=#{id}
</update>
<update id="delete" parameterType="Long">
UPDATE
sys_permission
SET
status = 0
WHERE
id=#{id}
</update>
</mapper>

@ -0,0 +1,122 @@
<%--
Created by IntelliJ IDEA.
User: qi_liang
Date: 2018/1/28
Time: 下午10:03
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../../common/import-tag.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>编辑</title>
<script type="text/javascript">
$(function () {
$("#menuIco").val('${sysResource.menuIco}');
})
</script>
<link href="${ctx}/resources/aceAdmin/assets/css/font-awesome.min.css">
</head>
<body>
<div style="margin:20px 0;"></div>
<div style="padding:10px 60px 20px 60px">
<table cellpadding="4">
<input type="hidden" value="${sysResource.id}" id="id">
<tr>
<td>上级目录:</td>
<td>
<select class="easyui-combobox" id="parentId" <c:if test="${sysResource.parentId==0}">disabled="disabled"</c:if> >
<option value="0" <c:if test="${sysResource.parentId==0}">selected</c:if> >顶级目录</option>
<c:forEach var="menu" items="${menuList}">
<option value="${menu.id}" <c:if test="${menu.id==sysResource.parentId}">selected</c:if> onclick="showUrlPath()" >${menu.menuName}</option>
</c:forEach>
</select>
</td>
</tr>
<tr id="tr_urlPath">
<td>路径:</td>
<td><input class="easyui-textbox" type="text" id="urlPath" data-options="required:true" value="${sysResource.urlPath}"></input></td>
</tr>
<tr>
<td>排序:</td>
<td><input class="easyui-textbox" type="text" id="sort" data-options="required:true'" value="${sysResource.sort}"></input></td>
</tr>
<tr>
<td>目录名称:</td>
<td><input class="easyui-textbox" type="text" id="menuName" data-options="required:true" value="${sysResource.menuName}" ></input></td>
</tr>
<tr id="tr_menuIco">
<td >目录图标:</td>
<td >
<select id="menuIco" class="easyui-combobox">
</select>
<!--
<div id="menuIco">
</div>
-->
</td>
</tr>
</table>
</div>
</body>
<script type="text/javascript">
var selectIco = '${sysResource.menuIco}';
$(function () {
addControlFunction();
appendSelect();
});
function addControlFunction() {
$('#parentId').combobox({
onChange: function (newValue, oldValue) {
if(newValue==0){
$("#tr_urlPath").hide();
$("#tr_menuIco").show();
}else{
$("#tr_urlPath").show();
$("#tr_menuIco").hide();
}
}
});
}
function appendSelect() {
var valArray = new Array(
'icon-asterisk','icon-ban-circle','icon-bar-chart','icon-barcode','icon-beaker',
'icon-beer','icon-bell','icon-bell-alt','icon-bolt','icon-book','icon-bookmark',
'icon-bookmark-empty','icon-briefcase','icon-bullhorn','icon-calendar','icon-camera',
'icon-camera-retro','icon-certificate','icon-check','icon-check-empty','icon-circle',
'icon-circle-blank','icon-cloud','icon-cloud-download','icon-cloud-upload','icon-coffee',
'icon-cog','icon-cogs','icon-comment','icon-comment-alt','icon-comments','icon-comments-alt',
'icon-credit-card','icon-dashboard','icon-desktop','icon-download','icon-download-alt',
'icon-edit','icon-envelope','icon-envelope-alt','icon-exchange','icon-exclamation-sign',
'icon-external-link','icon-eye-close','icon-eye-open','icon-facetime-video','icon-fighter-jet',
'icon-film','icon-filter','icon-fire','icon-flag','icon-folder-close','icon-folder-open',
'icon-folder-close-alt','icon-folder-open-alt','icon-food','icon-gift','icon-glass','icon-globe',
'icon-group','icon-hdd','icon-headphones','icon-heart','icon-heart-empty','icon-home',
'icon-inbox','icon-info-sign','icon-key','icon-leaf','icon-laptop','icon-legal',
'icon-lemon','icon-lightbulb','icon-lock','icon-unlock');
var html = '';
var isSelect = '';
for (var i = 0 ; i <valArray.length ; i++){
if(selectIco==valArray[i]){
isSelect = 'selected';
}else {
isSelect = '';
}
html+= '<option value="'+valArray[i]+'" '+isSelect+'>'+valArray[i]+'</option>';
// html+= '<i class='+valArray[i]+'></i>';
}
$("#menuIco").append(html);
}
</script>
</html>

@ -0,0 +1,167 @@
<%--
Created by IntelliJ IDEA.
User: qi_liang
Date: 2018/1/25
Time: 下午10:46
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../../common/import-tag.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>菜单列表</title>
<link rel="stylesheet" type="text/css" href="${ctx}/resources/code/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/resources/code/easyui/themes/icon.css" />
<script type="text/javascript" src="${ctx}/resources/code/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/code/easyui/jquery.easyui.min.1.2.2.js"></script>
<script type="text/javascript">
$(function() {// 初始化内容
$("#dataList").datagrid({
url:'list',
pagination :"true",
columns:[[
{field:'id',title:'编号',width:50},
{field:'urlPath',title:'路径',width:200},
{field:'sort',title:'排序',width:45},
{field:'parentMenuName',title:'上级目录名称',width:120},
{field:'menuName',title:'目录名称',editor:'text',width:120},
{field:'userName',title:'创建用户',width:100},
{field:'createTimeStr',title:'创建时间',width:150},
{field:'updateTimeStr',title:'更新时间',width:150},
/* formatter 不能重复field,否则会失效**/
{field:'editId',title:'编辑',width:100,formatter:function (value,row,index) {
var html="<a href='#' onclick='openEdit(\"编辑\","+row.id+")'>编辑</a>&nbsp&nbsp";
html+="<a href='#' onclick='del("+row.id+")'>删除</a>";
return html;
}}
]],
toolbar: [{
iconCls: 'icon-add',
handler: function(){openEdit('新增',null)}
}]
})
});
</script>
</head>
<body>
<table id="dataList"></table>
<div id="editDate"></div>
</body>
<script type="text/javascript">
function openEdit(title,id) {
var url='edit';
if(id!=null){
url=url+'?id='+id;
}
$("#editDate").dialog({
title:title,
width:400,
height:400,
closed:false,
cache:false,
href:url,
model:true,
buttons:[
{text:'保存',handler:function () {
var id = $("#id").val();
if(id == null || id ==''){
save();
}
else{
update();
}
}},{
text:'取消',handler:function () {
$("#editDate").dialog('close');
}
},
]
});
$("#editDate").dialog('open').dialog('refresh',url);
}
function save() {
var url = 'save';
var data = getData();
post(url,data);
}
function update() {
var url = 'update';
var data = getData();
post(url,data);
}
function post(url,data) {
var obj=new Object();
obj.id=$("#id").val();
obj.urlPath=$("#urlPath").val();
obj.parentId=$("#parentId").combobox("getValue");
obj.sort=$("#sort").val();
obj.menuName=$("#menuName").val();
obj.menuIco=$("#menuIco").combobox("getValue");
$.ajax({
url: url,
dataType:"json",
type:"post",
data: data,
success: function(result){
if(result.success==true){
$.messager.alert('提醒','提交成功','warning');
$("#editDate").dialog('close');
$('#dataList').datagrid('reload',{});
}
}});
}
//获取控件数据
function getData() {
var data = new Object();
var id = $("#id").val();
if (id != null&& id != '' ){
data.id= id;
}
data.urlPath=$("#urlPath").val();
data.parentId=$("#parentId").combobox("getValue");
data.sort=$("#sort").val();
data.menuName=$("#menuName").val();
data.menuIco=$("#menuIco").combobox("getValue");
return data;
}
function del(parameters) {
var obj=new Object();
obj.id=parameters;
$.messager.confirm('消息提醒','确定是否删除该项数据?',function (result) {
if (result){
$.ajax({
url: "delete",
dataType:"json",
type:"post",
data:obj,
success: function(result){
if(result.success==true){
$.messager.alert('提醒','删除成功','warning');
$('#dataList').datagrid('reload',{});
}else{
$.messager.alert('操作失败','删除失败','error');
}
}});
}
})
}
</script>
</html>
Loading…
Cancel
Save