Former-commit-id: 3c59756b7f7c4eb5f39f0188812efb0e875f115d
master
wangbing 5 years ago
parent 945db2f157
commit 8726265999

@ -1,35 +1,37 @@
package ${basePackage}.action.ajax.system; package xyz.wbsite.action.ajax.system;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import ${basePackage}.frame.excel.WSheet; import xyz.wbsite.frame.auth.LocalData;
import ${basePackage}.frame.utils.LogUtil; import xyz.wbsite.frame.base.BaseResponse;
import ${basePackage}.frame.auth.LocalData; import xyz.wbsite.frame.base.ErrorType;
import ${basePackage}.frame.base.ErrorType; import xyz.wbsite.frame.excel.WSheet;
import ${basePackage}.frame.utils.MapperUtil; import xyz.wbsite.frame.excel.exception.ReadErrorException;
import ${basePackage}.frame.base.BaseResponse; import xyz.wbsite.frame.excel.exception.TemplateNotMatchException;
import ${basePackage}.frame.utils.ResponseUtil; import xyz.wbsite.frame.utils.LogUtil;
import ${basePackage}.frame.utils.ValidationUtil; import xyz.wbsite.frame.utils.MapperUtil;
import ${basePackage}.frame.excel.exception.ReadErrorException; import xyz.wbsite.frame.utils.ResponseUtil;
import ${basePackage}.frame.excel.exception.TemplateNotMatchException; import xyz.wbsite.frame.utils.ValidationUtil;
import ${basePackage}.module.system.ent.Resource; import xyz.wbsite.module.system.ent.Resource;
import ${basePackage}.module.system.mgr.ResourceManager; import xyz.wbsite.module.system.mgr.ResourceManager;
import ${basePackage}.module.system.req.ResourceCreateRequest; import xyz.wbsite.module.system.req.ResourceCreateRequest;
import ${basePackage}.module.system.req.ResourceDeleteRequest; import xyz.wbsite.module.system.req.ResourceDeleteRequest;
import ${basePackage}.module.system.req.ResourceFindRequest; import xyz.wbsite.module.system.req.ResourceFindRequest;
import ${basePackage}.module.system.req.ResourceGetRequest; import xyz.wbsite.module.system.req.ResourceGetRequest;
import ${basePackage}.module.system.req.ResourceUpdateRequest; import xyz.wbsite.module.system.req.ResourceLoadRequest;
import ${basePackage}.module.system.rsp.ResourceCreateResponse; import xyz.wbsite.module.system.req.ResourceUpdateRequest;
import ${basePackage}.module.system.rsp.ResourceDeleteResponse; import xyz.wbsite.module.system.rsp.ResourceCreateResponse;
import ${basePackage}.module.system.rsp.ResourceFindResponse; import xyz.wbsite.module.system.rsp.ResourceDeleteResponse;
import ${basePackage}.module.system.rsp.ResourceGetResponse; import xyz.wbsite.module.system.rsp.ResourceFindResponse;
import ${basePackage}.module.system.rsp.ResourceUpdateResponse; import xyz.wbsite.module.system.rsp.ResourceGetResponse;
import xyz.wbsite.module.system.rsp.ResourceLoadResponse;
import xyz.wbsite.module.system.rsp.ResourceUpdateResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
public class ResourceAjax{ public class ResourceAjax {
@Autowired @Autowired
private ResourceManager resourceManager; private ResourceManager resourceManager;
@ -54,7 +56,11 @@ public class ResourceAjax{
return resourceManager.get(request, LocalData.getToken()); return resourceManager.get(request, LocalData.getToken());
} }
public Object template(){ public ResourceLoadResponse load(ResourceLoadRequest request) {
return resourceManager.load(request, LocalData.getToken());
}
public Object template() {
return ResponseUtil.apply(new WSheet<>(Resource.class)); return ResponseUtil.apply(new WSheet<>(Resource.class));
} }

@ -0,0 +1,33 @@
package ${basePackage}.module.system.ent;
public class ResourceCheck {
private long resourceId;
private String resourceValue;
private boolean check;
public long getResourceId() {
return resourceId;
}
public void setResourceId(long resourceId) {
this.resourceId = resourceId;
}
public String getResourceValue() {
return resourceValue;
}
public void setResourceValue(String resourceValue) {
this.resourceValue = resourceValue;
}
public boolean isCheck() {
return check;
}
public void setCheck(boolean check) {
this.check = check;
}
}

@ -0,0 +1,26 @@
package ${basePackage}.module.system.ent;
import java.util.List;
public class ResourceTree {
private String resourceModule;
private List<ResourceCheck> resourceChecks;
public String getResourceModule() {
return resourceModule;
}
public void setResourceModule(String resourceModule) {
this.resourceModule = resourceModule;
}
public List<ResourceCheck> getResourceChecks() {
return resourceChecks;
}
public void setResourceChecks(List<ResourceCheck> resourceChecks) {
this.resourceChecks = resourceChecks;
}
}

@ -5,11 +5,13 @@ import ${basePackage}.module.system.req.ResourceCreateRequest;
import ${basePackage}.module.system.req.ResourceDeleteRequest; import ${basePackage}.module.system.req.ResourceDeleteRequest;
import ${basePackage}.module.system.req.ResourceFindRequest; import ${basePackage}.module.system.req.ResourceFindRequest;
import ${basePackage}.module.system.req.ResourceGetRequest; import ${basePackage}.module.system.req.ResourceGetRequest;
import ${basePackage}.module.system.req.ResourceLoadRequest;
import ${basePackage}.module.system.req.ResourceUpdateRequest; import ${basePackage}.module.system.req.ResourceUpdateRequest;
import ${basePackage}.module.system.rsp.ResourceCreateResponse; import ${basePackage}.module.system.rsp.ResourceCreateResponse;
import ${basePackage}.module.system.rsp.ResourceDeleteResponse; import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
import ${basePackage}.module.system.rsp.ResourceFindResponse; import ${basePackage}.module.system.rsp.ResourceFindResponse;
import ${basePackage}.module.system.rsp.ResourceGetResponse; import ${basePackage}.module.system.rsp.ResourceGetResponse;
import ${basePackage}.module.system.rsp.ResourceLoadResponse;
import ${basePackage}.module.system.rsp.ResourceUpdateResponse; import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
/** /**
@ -65,4 +67,6 @@ public interface ResourceManager {
* @return * @return
*/ */
ResourceGetResponse get(ResourceGetRequest request, Token token); ResourceGetResponse get(ResourceGetRequest request, Token token);
ResourceLoadResponse load(ResourceLoadRequest request, Token token);
} }

@ -7,24 +7,32 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.ErrorType; import ${basePackage}.frame.base.ErrorType;
import ${basePackage}.frame.base.SortType;
import ${basePackage}.frame.base.Token; import ${basePackage}.frame.base.Token;
import ${basePackage}.frame.utils.IDgenerator; import ${basePackage}.frame.utils.IDgenerator;
import ${basePackage}.frame.utils.MapperUtil; import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.utils.Message; import ${basePackage}.frame.utils.Message;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.module.system.ent.Resource; import ${basePackage}.module.system.ent.Resource;
import ${basePackage}.module.system.ent.ResourceCheck;
import ${basePackage}.module.system.ent.ResourceTree;
import ${basePackage}.module.system.mpr.ResourceMapper; import ${basePackage}.module.system.mpr.ResourceMapper;
import ${basePackage}.module.system.req.ResourceCreateRequest; import ${basePackage}.module.system.req.ResourceCreateRequest;
import ${basePackage}.module.system.req.ResourceDeleteRequest; import ${basePackage}.module.system.req.ResourceDeleteRequest;
import ${basePackage}.module.system.req.ResourceFindRequest; import ${basePackage}.module.system.req.ResourceFindRequest;
import ${basePackage}.module.system.req.ResourceGetRequest; import ${basePackage}.module.system.req.ResourceGetRequest;
import ${basePackage}.module.system.req.ResourceLoadRequest;
import ${basePackage}.module.system.req.ResourceUpdateRequest; import ${basePackage}.module.system.req.ResourceUpdateRequest;
import ${basePackage}.module.system.rsp.ResourceCreateResponse; import ${basePackage}.module.system.rsp.ResourceCreateResponse;
import ${basePackage}.module.system.rsp.ResourceDeleteResponse; import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
import ${basePackage}.module.system.rsp.ResourceFindResponse; import ${basePackage}.module.system.rsp.ResourceFindResponse;
import ${basePackage}.module.system.rsp.ResourceGetResponse; import ${basePackage}.module.system.rsp.ResourceGetResponse;
import ${basePackage}.module.system.rsp.ResourceLoadResponse;
import ${basePackage}.module.system.rsp.ResourceUpdateResponse; import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
import java.util.ArrayList;
import java.util.List;
/** /**
* RESOURCE - * RESOURCE -
* *
@ -38,6 +46,8 @@ public class ResourceManagerImpl implements ResourceManager {
@Autowired @Autowired
private ResourceMapper resourceMapper; private ResourceMapper resourceMapper;
@Autowired
private DictItemManager dictItemManager;
/** /**
* *
@ -172,4 +182,54 @@ public class ResourceManagerImpl implements ResourceManager {
return response; return response;
} }
@Override
public ResourceLoadResponse load(ResourceLoadRequest request, Token token) {
ResourceLoadResponse response = new ResourceLoadResponse();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
ResourceFindRequest resourceFindRequest = new ResourceFindRequest();
resourceFindRequest.setPageSize(0);
resourceFindRequest.setValid(true);
resourceFindRequest.setSortType(SortType.ASC);
resourceFindRequest.setSortKey("RESOURCE_MODULE,RESOURCE_TYPE");
ResourceFindResponse resourceFindResponse = this.find(resourceFindRequest, token);
if (resourceFindResponse.hasError()) {
response.addErrors(resourceFindResponse.getErrors());
return response;
}
List<ResourceTree> data = new ArrayList<>();
ResourceTree tree = null;
List<ResourceCheck> checks = null;
for (Resource resource : resourceFindResponse.getResult()) {
if (tree != null && tree.getResourceModule().equals(resource.getResourceModule())) {
ResourceCheck check = new ResourceCheck();
check.setResourceId(resource.getId());
check.setResourceValue(resource.getValue());
checks.add(check);
} else {
tree = new ResourceTree();
data.add(tree);
tree.setResourceModule(resource.getResourceModule());
checks = new ArrayList<>();
tree.setResourceChecks(checks);
ResourceCheck check = new ResourceCheck();
check.setResourceId(resource.getId());
check.setResourceValue(resource.getValue());
checks.add(check);
}
}
response.setData(data);
return response;
}
} }

@ -0,0 +1,15 @@
package ${basePackage}.module.system.req;
import ${basePackage}.frame.base.BaseRequest;
/**
* ResourceGetRequest -
*
* @author wangbing
* @version 0.0.1
* @since 2019-12-26
*/
public class ResourceLoadRequest extends BaseRequest {
}

@ -0,0 +1,26 @@
package ${basePackage}.module.system.rsp;
import ${basePackage}.frame.base.BaseResponse;
import ${basePackage}.module.system.ent.ResourceTree;
import java.util.List;
/**
* ResourceLoadResponse -
*
* @author author
* @version 0.0.1
* @since 2017-01-01
*/
public class ResourceLoadResponse extends BaseResponse {
private List<ResourceTree> data;
public List<ResourceTree> getData() {
return data;
}
public void setData(List<ResourceTree> data) {
this.data = data;
}
}

@ -40,8 +40,8 @@
} }
.frame { .frame {
width: 600px; width: 500px;
height: 500px; height: 450px;
background: #42424263; background: #42424263;
border-radius: 10px; border-radius: 10px;
display: flex; display: flex;

@ -18,7 +18,7 @@
</el-form> </el-form>
</el-card> </el-card>
<el-card class="box-card data"> <el-card class="box-card resourceChecks">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-button type="success" size="small" icon="el-icon-plus" @click="onCreate">新增</el-button> <el-button type="success" size="small" icon="el-icon-plus" @click="onCreate">新增</el-button>
@ -26,7 +26,8 @@
<el-button type="warning" size="small" icon="el-icon-download" @click="onExport">导出</el-button> <el-button type="warning" size="small" icon="el-icon-download" @click="onExport">导出</el-button>
<el-dialog class="form" :title="form.title" :visible.sync="form.dialog"> <el-dialog class="form" :title="form.title" :visible.sync="form.dialog">
<el-form :model="form" :inline="true" :rules="formRules" ref="form" label-position="right" label-width="90px"> <el-form :model="form" :inline="true" :rules="formRules" ref="form" label-position="right"
label-width="90px">
<el-form-item label="角色名称" prop="roleName"> <el-form-item label="角色名称" prop="roleName">
<el-input v-model="form.roleName" clearable size="small" placeholder="请输入角色名称"></el-input> <el-input v-model="form.roleName" clearable size="small" placeholder="请输入角色名称"></el-input>
</el-form-item> </el-form-item>
@ -34,7 +35,8 @@
<el-input v-model="form.roleCode" clearable size="small" placeholder="请输入角色代码"></el-input> <el-input v-model="form.roleCode" clearable size="small" placeholder="请输入角色代码"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="角色描述" prop="roleComment"> <el-form-item label="角色描述" prop="roleComment">
<el-input v-model="form.roleComment" clearable size="small" placeholder="请输入角色描述"></el-input> <el-input v-model="form.roleComment" clearable size="small"
placeholder="请输入角色描述"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -170,7 +172,8 @@
roleComment: [ roleComment: [
{min: 1, max: 50, message: '角色描述长度在 1 到 50 个字符', trigger: 'blur'} {min: 1, max: 50, message: '角色描述长度在 1 到 50 个字符', trigger: 'blur'}
], ],
} },
resourceTree: {}
}, },
methods: { methods: {
onCreate: function () { onCreate: function () {
@ -202,9 +205,19 @@
break; break;
} }
}, },
ss: function () {
this.$ajax.load("system", "resource", {}).then(function (response) {
if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {
this.resourceTree = response.resourceChecks;
}
}.bind(this))
}
}, },
mounted: function () { mounted: function () {
this.onFind(); this.onFind();
this.ss();
}, },
}) })
</script> </script>

Loading…
Cancel
Save

Powered by TurnKey Linux.