控制器添加复杂接口

This commit is contained in:
橙子
2021-10-14 13:15:00 +08:00
parent 93b8434857
commit 395a0350d6
16 changed files with 390 additions and 62 deletions

View File

@@ -5,12 +5,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[Route("api/[controller]")]
[Route("api/[controller]/[action]")]
[ApiController]
public class MenuController : ControllerBase
{
@@ -61,5 +62,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
await _menuService.AddAsync(_menu);
return Result.Success();
}
/// <summary>
/// 给一个菜单设置一个接口,Id1为菜单id,Id2为接口id
/// </summary>
/// <param name="idDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<Result> SetMouldByMenu(IdDto<int> idDto)
{
}
}
}

View File

@@ -10,7 +10,7 @@ using Yi.Framework.Model.Models;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[Route("api/[controller]")]
[Route("api/[controller]/[action]")]
[ApiController]
public class MouldController : ControllerBase
{

View File

@@ -5,12 +5,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[Route("api/[controller]")]
[Route("api/[controller]/[action]")]
[ApiController]
public class RoleController : ControllerBase
{
@@ -20,7 +21,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_roleService = roleService;
}
[HttpGet]
public async Task<Result> GetURole()
public async Task<Result> GetRole()
{
return Result.Success().SetData(await _roleService.GetAllEntitiesTrueAsync());
}
@@ -61,5 +62,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
await _roleService.AddAsync(_role);
return Result.Success();
}
/// <summary>
/// 给角色设置菜单多个角色与多个菜单让每一个角色都设置ids1为角色ids2为菜单
/// </summary>
/// <param name="idsListDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<Result> SetMenuByRole(IdsListDto<int> idsListDto)
{
}
}
}

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.WebCore;
@@ -82,5 +83,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
var menu_data = await _userService.GetMenusByUser(_user);
return Result.Success().SetData(menu_data);
}
/// <summary>
/// 给单个用户设置多个角色ids有用户id与 角列表色ids1对多
/// </summary>
/// <param name="idsDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<Result> SetRoleByUser(IdsDto<int> idsDto)
{
}
}
}

View File

@@ -4,6 +4,97 @@
<name>Yi.Framework.ApiMicroservice</name>
</assembly>
<members>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.Model.Models.user)">
<summary>
登录方法要返回data:{user,token} token先写123456789,不要有导航属性
</summary>
<param name="_user"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Logout">
<summary>
不用写,单纯制作日志
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Register(Yi.Framework.Model.Models.user,System.String)">
<summary>
code为验证码,判断一下,假装验证码都是对的
</summary>
<param name="_user"></param>
<param name="code"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Email(System.String)">
<summary>
传入邮箱需要先到数据库判断该邮箱是否被人注册过到userservice写mail_exist方法还有接口别忘了。这个接口不需要洞只需要完成userservice写mail_exist与接口即可
</summary>
<param name="emailAddress"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.UpdateMenu(Yi.Framework.Model.Models.menu)">
<summary>
</summary>
<param name="_menu"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.DelListMenu(System.Collections.Generic.List{System.Int32})">
<summary>
</summary>
<param name="_ids"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.AddMenu(Yi.Framework.Model.Models.menu)">
<summary>
</summary>
<param name="_menu"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MouldController.UpdateMould(Yi.Framework.Model.Models.mould)">
<summary>
</summary>
<param name="_mould"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MouldController.DelListMould(System.Collections.Generic.List{System.Int32})">
<summary>
</summary>
<param name="_ids"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MouldController.AddMould(Yi.Framework.Model.Models.mould)">
<summary>
</summary>
<param name="_mould"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.UpdateRole(Yi.Framework.Model.Models.role)">
<summary>
</summary>
<param name="_role"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.DelListRole(System.Collections.Generic.List{System.Int32})">
<summary>
</summary>
<param name="_ids"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.AddRole(Yi.Framework.Model.Models.role)">
<summary>
</summary>
<param name="_role"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetUser">
<summary>
@@ -31,6 +122,12 @@
<param name="_user"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetMenuMould">
<summary>
通过上下文对象获取user注意_user下只有userId返回值为该用户下所有的menu(注意子类递归)并且需要关联mould
</summary>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup">
<summary>
必须实现IHostingStartup接口

View File

@@ -1,8 +0,0 @@
using System;
namespace Yi.Framework.DTOModel
{
public class Class1
{
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
namespace Yi.Framework.DTOModel
{
public class IdDto<T>
{
public T id1 { get; set; }
public T id2 { get; set; }
}
public class IdsDto<T>
{
public T id{ get; set; }
public List<T> ids { get; set; }
}
public class IdsListDto<T>
{
public List<T> ids1 { get; set; }
public List<T> ids2 { get; set; }
}
}

View File

@@ -10,6 +10,7 @@
v-model="selected"
:search="search"
>
<slot/>
<template v-slot:top>
<!-- 搜索框 -->
<v-toolbar flat>
@@ -23,12 +24,22 @@
class="mx-4"
></v-text-field>
<v-btn color="primary" dark class="mb-2 mx-2" @click="dialog = true">
<v-btn
v-if="axiosUrls.hasOwnProperty('add')"
color="primary"
dark
class="mb-2 mx-2"
@click="dialog = true"
>
添加新项
</v-btn>
<!-- 添加提示框 -->
<v-dialog v-model="dialog" max-width="500px">
<v-dialog
v-if="axiosUrls.hasOwnProperty('add')"
v-model="dialog"
max-width="500px"
>
<v-card>
<v-card-title>
<span class="headline">{{ formTitle }}</span>
@@ -61,35 +72,35 @@
</v-card>
</v-dialog>
<v-btn color="red" dark class="mb-2" @click="deleteItem(null)">
<v-btn
v-if="axiosUrls.hasOwnProperty('del')"
color="red"
dark
class="mb-2"
@click="deleteItem(null)"
>
删除所选
</v-btn>
<!-- 删除提示框 -->
<v-dialog v-model="dialogDelete" max-width="500px">
<v-card>
<v-card-title class="headline"
>你确定要删除此条记录吗</v-card-title
>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="closeDelete"
>取消</v-btn
>
<v-btn color="blue darken-1" text @click="deleteItemConfirm"
>确定</v-btn
>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
</v-dialog>
</v-toolbar>
</template>
<!-- 表格中的删除和修改 -->
<template v-slot:item.actions="{ item }">
<v-icon small class="mr-2" @click="editItem(item)"> mdi-pencil </v-icon>
<v-icon small @click="deleteItem(item)"> mdi-delete </v-icon>
<v-icon
v-if="axiosUrls.hasOwnProperty('update')"
small
class="mr-2"
@click="editItem(item)"
>
mdi-pencil
</v-icon>
<v-icon
v-if="axiosUrls.hasOwnProperty('del')"
small
@click="deleteItem(item)"
>
mdi-delete
</v-icon>
</template>
<!-- 初始化 -->
@@ -100,9 +111,9 @@
</v-card>
</template>
<script>
import itemApi from './TableApi.js'
import itemApi from "./TableApi.js";
export default {
name: 'Tables',
name: "Tables",
props: {
defaultItem: {
type: Object,
@@ -110,9 +121,9 @@ export default {
headers: {
type: Array,
},
axiosUrls:{
type: Object,
}
axiosUrls: {
type: Object,
},
},
data: () => ({
@@ -120,7 +131,6 @@ export default {
selected: [],
search: "",
dialog: false,
dialogDelete: false,
desserts: [],
editedIndex: -1,
editedItem: {},
@@ -135,10 +145,7 @@ export default {
watch: {
dialog(val) {
val || this.close();
},
dialogDelete(val) {
val || this.closeDelete();
},
}
},
created() {
@@ -147,11 +154,11 @@ export default {
methods: {
initialize() {
itemApi.getItem(this.axiosUrls.get).then((resp) => {
const response = resp.data;
this.desserts = response;
});
itemApi.getItem(this.axiosUrls.get).then((resp) => {
const response = resp.data;
this.desserts = response;
});
this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1;
@@ -165,10 +172,21 @@ export default {
this.dialog = true;
},
deleteItem(item) {
async deleteItem(item) {
this.editedIndex = this.desserts.indexOf(item);
this.editedItem = Object.assign({}, item);
this.dialogDelete = true;
var p = await this.$dialog.warning({
text: "你确定要删除此条记录吗??",
title: "警告",
actions: {
false: "取消",
true: "确定",
},
});
if (p) {
this.deleteItemConfirm();
}
},
deleteItemConfirm() {
var Ids = [];
@@ -179,7 +197,9 @@ export default {
Ids.push(item.id);
});
}
itemApi.delItemList(this.axiosUrls.del,Ids).then(() => this.initialize());
itemApi
.delItemList(this.axiosUrls.del, Ids)
.then(() => this.initialize());
this.closeDelete();
},
close() {
@@ -200,9 +220,13 @@ export default {
save() {
if (this.editedIndex > -1) {
itemApi.updateItem(this.axiosUrls.update,this.editedItem).then(() => this.initialize());
itemApi
.updateItem(this.axiosUrls.update, this.editedItem)
.then(() => this.initialize());
} else {
itemApi.addItem(this.axiosUrls.add,this.editedItem).then(() => this.initialize());
itemApi
.addItem(this.axiosUrls.add, this.editedItem)
.then(() => this.initialize());
}
this.close();
},

View File

@@ -120,7 +120,7 @@
{
title:"角色菜单分配管理",
icon:"mdi-account",
to:"/admrole/",
to:"/admRoleMenu/",
children:[]
},
]

View File

@@ -2,11 +2,17 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import vuetify from './plugins/vuetify'
import VuetifyDialog from 'vuetify-dialog'
import 'vuetify-dialog/dist/vuetify-dialog.css'
import './plugins'
import store from './store/index'
Vue.config.productionTip = false
Vue.use(VuetifyDialog, {
context: {
vuetify
}
});
new Vue({
router,
store,

View File

@@ -27,6 +27,7 @@ const router = new VueRouter({
route('AdmRole', null, 'AdmRole'),
route('AdmMenu', null, 'AdmMenu'),
route('AdmMould', null, 'AdmMould'),
route('AdmRoleMenu', null, 'AdmRoleMenu'),
]),
layout('Login', [
route('login', null, 'login'),

View File

@@ -1,5 +1,7 @@
<template>
<v-card class="mx-auto" width="100%">
<v-btn>设置接口权限</v-btn>
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
</v-card>

View File

@@ -1,6 +1,9 @@
<template>
<v-card class="mx-auto" width="100%">
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" >
</ccTable>
</v-card>
</template>

View File

@@ -0,0 +1,148 @@
<template>
<v-card class="mx-auto" width="100%">
<v-row>
<v-col cols="6">
<v-list
flat
subheader
three-line
>
<v-subheader>General</v-subheader>
<v-list-item-group
v-model="settings"
multiple
active-class=""
>
<v-list-item>
<template v-slot:default="{ active }">
<v-list-item-action>
<v-checkbox :input-value="active"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Notifications</v-list-item-title>
<v-list-item-subtitle>Notify me about updates to apps or games that I downloaded</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active }">
<v-list-item-action>
<v-checkbox :input-value="active"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Sound</v-list-item-title>
<v-list-item-subtitle>Auto-update apps at any time. Data charges may apply</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
<v-list-item>
<template v-slot:default="{ active }">
<v-list-item-action>
<v-checkbox :input-value="active"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Auto-add widgets</v-list-item-title>
<v-list-item-subtitle>Automatically add home screen widgets when downloads complete</v-list-item-subtitle>
</v-list-item-content>
</template>
</v-list-item>
</v-list-item-group>
</v-list>
</v-col>
<v-col cols="6"> <v-treeview
selectable
:items="items"
></v-treeview></v-col>
</v-row>
</v-card>
</template>
<script>
export default {
data: () => ({
items: [
{
id: 1,
name: 'Applications :',
children: [
{ id: 2, name: 'Calendar : app' },
{ id: 3, name: 'Chrome : app' },
{ id: 4, name: 'Webstorm : app' },
],
},
{
id: 5,
name: 'Documents :',
children: [
{
id: 6,
name: 'vuetify :',
children: [
{
id: 7,
name: 'src :',
children: [
{ id: 8, name: 'index : ts' },
{ id: 9, name: 'bootstrap : ts' },
],
},
],
},
{
id: 10,
name: 'material2 :',
children: [
{
id: 11,
name: 'src :',
children: [
{ id: 12, name: 'v-btn : ts' },
{ id: 13, name: 'v-card : ts' },
{ id: 14, name: 'v-window : ts' },
],
},
],
},
],
},
{
id: 15,
name: 'Downloads :',
children: [
{ id: 16, name: 'October : pdf' },
{ id: 17, name: 'November : pdf' },
{ id: 18, name: 'Tutorial : html' },
],
},
{
id: 19,
name: 'Videos :',
children: [
{
id: 20,
name: 'Tutorials :',
children: [
{ id: 21, name: 'Basic layouts : mp4' },
{ id: 22, name: 'Advanced techniques : mp4' },
{ id: 23, name: 'All about app : dir' },
],
},
{ id: 24, name: 'Intro : mov' },
{ id: 25, name: 'Conference introduction : avi' },
],
},
],
}),
}
</script>

View File

@@ -1,7 +1,6 @@
<template>
<v-card class="mx-auto" width="100%">
<v-btn>设置角色</v-btn>
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
</v-card>

View File

@@ -1,3 +1,3 @@
<template>
<div>还有谁</div>
<div>首页</div>
</template>