Browse Source

添加角色后端API

master
wanggang 1 year ago
parent
commit
ab1743e738
  1. 67
      code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs
  2. 9
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/html.js
  3. 85
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/index.html
  4. 1987
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/lib/pinia.esm-browser.js
  5. 3613
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/lib/vue-router.esm-browser.js
  6. 15377
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/lib/vue.esm-browser.js
  7. 78
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/pages/component.html
  8. 0
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/pages/slot.html
  9. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/docs/vue.md
  10. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

67
code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Omu.ValueInjecter;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
namespace BaseService.UserManagement
{
[Route("api/[controller]/[action]")]
[Authorize(IdentityPermissions.Roles.Default)]
public class RoleAppService : ApplicationService
{
private IdentityRoleManager _roleManager { get; }
private IIdentityRoleRepository _repository { get; }
public RoleAppService(IdentityRoleManager roleManager, IIdentityRoleRepository roleRepository)
{
_roleManager = roleManager;
_repository = roleRepository;
}
[HttpGet]
public async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input)
{
var totalCount = await _repository.GetCountAsync(input.Filter).ConfigureAwait(false);
var items = await _repository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount,
input.Filter).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(items);
return new PagedResultDto<IdentityRoleDto>(totalCount, dtos);
}
[HttpPost]
[Authorize(IdentityPermissions.Roles.Create)]
public async Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input)
{
var role = new IdentityRole(GuidGenerator.Create(), input.Name);
role.InjectFrom(input);
await _roleManager.CreateAsync(role).ConfigureAwait(false);
var dto = ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
return dto;
}
[HttpPut("{id}")]
[Authorize(IdentityPermissions.Roles.Update)]
public async Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
{
var role = await _roleManager.GetByIdAsync(id).ConfigureAwait(false);
role.InjectFrom(input);
await _roleManager.UpdateAsync(role).ConfigureAwait(false);
var dto = ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
return dto;
}
[HttpDelete("{id}")]
[Authorize(IdentityPermissions.Roles.Delete)]
public async Task<IActionResult> Delete(Guid id)
{
var role = await _roleManager.GetByIdAsync(id).ConfigureAwait(false);
await _roleManager.DeleteAsync(role).ConfigureAwait(false);
return new OkResult();
}
}
}

9
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/html.js

@ -0,0 +1,9 @@
export default function html(strings, ...values) {
let output = "";
let index;
for (index = 0; index < values.length; index += 1) {
output += strings[index] + values[index];
}
output += strings[index];
return output;
}

85
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/index.html

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="./" />
<title></title>
<style>
body {
margin: 0;
padding: 0;
}
body * {
box-sizing: border-box;
}
#app {
width: 100vw;
height: 100vh;
overflow-y: scroll;
display: flex;
}
#app>ul {
margin: 0;
padding: 0;
list-style: none;
width: 200px;
border: 1px solid gray;
}
#app>ul>li {
padding: .5em;
}
#app>iframe {
width: calc(100vw - 200px);
}
</style>
</head>
<body>
<div id="app"></div>
<script type="importmap">
{
"imports": {
"vue": "./lib/vue.esm-browser.js",
"vue-router": "./lib/vue-router.esm-browser.js",
"pinia": "./lib/pinia.esm-browser.js"
}
}
</script>
<script>
window.process = { env: { NODE_ENV: 'production' } };
</script>
<script type="module">
import { createApp, ref } from "vue";
const app = createApp({
template: `<ul>
<li v-for="item in links"><a href="javascript:;" @click="load(item.href)">{{item.text}}</a></li>
</ul>
<iframe :src="src" frameborder="0" />`,
setup() {
const links = [
{ text: "组件基础", href: "./pages/component.html" }
];
const src = ref("");
function load(href) {
src.value = href;
}
return {
links,
src,
load
}
}
});
app.mount("#app");
</script>
</body>
</html>

1987
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/lib/pinia.esm-browser.js

File diff suppressed because it is too large

3613
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/lib/vue-router.esm-browser.js

File diff suppressed because it is too large

15377
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/lib/vue.esm-browser.js

File diff suppressed because it is too large

78
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/pages/component.html

@ -0,0 +1,78 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="./" />
<title>双向绑定</title>
</head>
<body>
<div id="app"></div>
<script type="importmap">
{
"imports": {
"vue": "../lib/vue.esm-browser.js",
"vue-router": "../lib/vue-router.esm-browser.js",
"pinia": "../lib/pinia.esm-browser.js"
}
}
</script>
<script>
window.process = { env: { NODE_ENV: 'production' } };
</script>
<script type="module">
import { createApp, ref, reactive, watch, onMounted } from "vue";
const simpleComponent = {
components: {},//组件注册
template: `<label>子组件:<input type="text" v-model="model.value"></label>
<button @click="$emit('click','call parent method from child')">click</button>`,
props: ['modelValue'],
emit: ["update:modelValue"],
setup(props, context) {
const model = reactive(props.modelValue);
watch(model, (value) => context.emit('update:modelValue', value));
const childMethod = () => {
alert('child method');
}
context.expose({ childMethod });
return {
model,
childMethod
};
}
};
const appComponent = {
components: { simpleComponent },
template: `<label>父组件:<input type="text" v-model="model.value" /></label>
<button @click="onClick">click</button>
<simple-component ref="childRef" v-model="model" @click="parentMethod" />`,
props: ['modelValue'],
setup(props, context) {
const childRef = ref(null);
const model = reactive({
value: "test"
});
const onClick = () => {
childRef.value.childMethod();
};
const parentMethod = o => alert(o);
return {
model,
onClick,
parentMethod
};
}
};
const app = createApp(appComponent);
app.mount("#app");
</script>
</body>
</html>

0
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/demo/pages/slot.html

6
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/assets/docs/vue.md

@ -0,0 +1,6 @@
# vue 3
```javascript
import { createApp } from "vue";
createApp().mount("#app");
```

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -589,7 +589,7 @@ export default {
await load();
} else if (item.path === "export") {
//export
if (item.pattern === "paged") {
if (item.meta.pattern === "paged") {
const url = config.edit.exportUrl;
const method = config.edit.exportMethod;
const postData = buildQuery();
@ -597,6 +597,8 @@ export default {
if (!response.errors) {
window.open(getUrl(`settleaccount/getblobfile/download/${response.data}`));
}
} else {
console.log(item);
}
} else if (item.path === "compare") {
exportModel.value = defaultExportModel;

Loading…
Cancel
Save