feat: 前后端联调代码生成接口

This commit is contained in:
橙子
2024-02-16 17:16:54 +08:00
parent 12ec7a0392
commit 6675376241
20 changed files with 62 additions and 50 deletions

View File

@@ -76,7 +76,7 @@ namespace Yi.Framework.Ddd.Application
{ {
entites = await Repository.GetListAsync(); entites = await Repository.GetListAsync();
} }
var total = await Repository.CountAsync(); var total = await Repository.GetCountAsync();
var output = await MapToGetListOutputDtosAsync(entites); var output = await MapToGetListOutputDtosAsync(entites);
return new PagedResultDto<TGetListOutputDto>(total, output); return new PagedResultDto<TGetListOutputDto>(total, output);
//throw new NotImplementedException($"【{typeof(TEntity)}】实体的CrudAppService查询为具体业务通用查询几乎无实际场景请重写实现"); //throw new NotImplementedException($"【{typeof(TEntity)}】实体的CrudAppService查询为具体业务通用查询几乎无实际场景请重写实现");

View File

@@ -139,7 +139,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
public virtual async Task<long> GetCountAsync(CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{ {
return await this.CountAsync(); return await this.CountAsync(_=>true);
} }
public virtual async Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default) public virtual async Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)

View File

@@ -9,6 +9,6 @@ namespace Yi.Framework.CodeGun.Application.Contracts.Dtos.Field
/// </summary> /// </summary>
public string? Name { get; set; } public string? Name { get; set; }
public long? TableId { get; set; } public Guid? TableId { get; set; }
} }
} }

View File

@@ -1,5 +1,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Yi.Framework.CodeGun.Application.Contracts.IServices; using Yi.Framework.CodeGun.Application.Contracts.IServices;
@@ -79,7 +80,8 @@ namespace Yi.Framework.CodeGun.Application.Services
/// 打开目录 /// 打开目录
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task PostDir(string path) [HttpPost("code-gun/dir/{**path}")]
public async Task PostDir([FromRoute]string path)
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {

View File

@@ -45,7 +45,7 @@ namespace Yi.Framework.CodeGun.Application.Services
/// 获取类型枚举 /// 获取类型枚举
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Route("type")] [Route("field/type")]
public object GetFieldTypeEnum() public object GetFieldTypeEnum()
{ {
return typeof(FieldTypeEnum).GetFields(BindingFlags.Static | BindingFlags.Public).Select(x => new { lable = x.Name, value = (int)Enum.Parse(typeof(FieldTypeEnum), x.Name) }).ToList(); return typeof(FieldTypeEnum).GetFields(BindingFlags.Static | BindingFlags.Public).Select(x => new { lable = x.Name, value = (int)Enum.Parse(typeof(FieldTypeEnum), x.Name) }).ToList();

View File

@@ -1,4 +1,5 @@
using Volo.Abp.Domain.Repositories; using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.CodeGun.Application.Contracts.Dtos.Table; using Yi.Framework.CodeGun.Application.Contracts.Dtos.Table;
using Yi.Framework.CodeGun.Application.Contracts.IServices; using Yi.Framework.CodeGun.Application.Contracts.IServices;
using Yi.Framework.CodeGun.Domain.Entities; using Yi.Framework.CodeGun.Domain.Entities;
@@ -11,5 +12,10 @@ namespace Yi.Framework.CodeGun.Application.Services
public TableService(IRepository<TableAggregateRoot, Guid> repository) : base(repository) public TableService(IRepository<TableAggregateRoot, Guid> repository) : base(repository)
{ {
} }
public override Task<PagedResultDto<TableDto>> GetListAsync(TableGetListInput input)
{
return base.GetListAsync(input);
}
} }
} }

View File

@@ -42,31 +42,31 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
}; };
entities.Add(system); entities.Add(system);
//WebFirst //代码生成
MenuEntity webfirst = new MenuEntity(_guidGenerator.Create(), Guid.Empty) MenuEntity code = new MenuEntity(_guidGenerator.Create(), Guid.Empty)
{ {
MenuName = "WebFirst", MenuName = "代码生成",
MenuType = MenuTypeEnum.Catalogue, MenuType = MenuTypeEnum.Catalogue,
Router = "/webfirst", Router = "/code",
IsShow = true, IsShow = true,
IsLink = false, IsLink = false,
MenuIcon = "build", MenuIcon = "build",
OrderNum = 91, OrderNum = 91,
IsDeleted = false IsDeleted = false
}; };
entities.Add(webfirst); entities.Add(code);
//数据表管理 //数据表管理
MenuEntity table = new MenuEntity(_guidGenerator.Create(), webfirst.Id) MenuEntity table = new MenuEntity(_guidGenerator.Create(), code.Id)
{ {
MenuName = "数据表管理", MenuName = "数据表管理",
PermissionCode = "webfirst:table:list", PermissionCode = "code:table:list",
MenuType = MenuTypeEnum.Menu, MenuType = MenuTypeEnum.Menu,
Router = "table", Router = "table",
IsShow = true, IsShow = true,
IsLink = false, IsLink = false,
IsCache = true, IsCache = true,
Component = "webfirst/table/index", Component = "code/table/index",
MenuIcon = "online", MenuIcon = "online",
OrderNum = 100, OrderNum = 100,
IsDeleted = false IsDeleted = false
@@ -74,35 +74,35 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
entities.Add(table); entities.Add(table);
//字段管理 //字段管理
MenuEntity field = new MenuEntity(_guidGenerator.Create(), webfirst.Id) MenuEntity field = new MenuEntity(_guidGenerator.Create(), code.Id)
{ {
MenuName = "字段管理", MenuName = "字段管理",
PermissionCode = "webfirst:field:list", PermissionCode = "code:field:list",
MenuType = MenuTypeEnum.Menu, MenuType = MenuTypeEnum.Menu,
Router = "field", Router = "field",
IsShow = true, IsShow = true,
IsLink = false, IsLink = false,
IsCache = true, IsCache = true,
Component = "webfirst/field/index", Component = "code/field/index",
MenuIcon = "number", MenuIcon = "number",
OrderNum = 99, OrderNum = 99,
ParentId = webfirst.Id, ParentId = code.Id,
IsDeleted = false IsDeleted = false
}; };
entities.Add(field); entities.Add(field);
//模板管理 //模板管理
MenuEntity template = new MenuEntity(_guidGenerator.Create(), webfirst.Id) MenuEntity template = new MenuEntity(_guidGenerator.Create(), code.Id)
{ {
MenuName = "模板管理", MenuName = "模板管理",
PermissionCode = "webfirst:template:list", PermissionCode = "code:template:list",
MenuType = MenuTypeEnum.Menu, MenuType = MenuTypeEnum.Menu,
Router = "template", Router = "template",
IsShow = true, IsShow = true,
IsLink = false, IsLink = false,
IsCache = true, IsCache = true,
Component = "webfirst/template/index", Component = "code/template/index",
MenuIcon = "documentation", MenuIcon = "documentation",
OrderNum = 98, OrderNum = 98,
IsDeleted = false IsDeleted = false
@@ -230,7 +230,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
//ERP //ERP
MenuEntity erp = new MenuEntity(_guidGenerator.Create()) MenuEntity erp = new MenuEntity(_guidGenerator.Create())
{ {
MenuName = "ERP", MenuName = "ERP(待更新)",
MenuType = MenuTypeEnum.Catalogue, MenuType = MenuTypeEnum.Catalogue,
Router = "/erp", Router = "/erp",
IsShow = true, IsShow = true,

View File

@@ -2,6 +2,7 @@
using Yi.Abp.Application.Contracts; using Yi.Abp.Application.Contracts;
using Yi.Abp.Domain; using Yi.Abp.Domain;
using Yi.Framework.Bbs.Application; using Yi.Framework.Bbs.Application;
using Yi.Framework.CodeGun.Application;
using Yi.Framework.Ddd.Application; using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Application; using Yi.Framework.Rbac.Application;
using Yi.Framework.TenantManagement.Application; using Yi.Framework.TenantManagement.Application;
@@ -16,7 +17,7 @@ namespace Yi.Abp.Application
typeof(YiFrameworkRbacApplicationModule), typeof(YiFrameworkRbacApplicationModule),
typeof(YiFrameworkBbsApplicationModule), typeof(YiFrameworkBbsApplicationModule),
typeof(YiFrameworkTenantManagementApplicationModule), typeof(YiFrameworkTenantManagementApplicationModule),
typeof(YiFrameworkCodeGunApplicationModule),
typeof(YiFrameworkDddApplicationModule) typeof(YiFrameworkDddApplicationModule)
)] )]

View File

@@ -5,7 +5,8 @@
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development",
//"ASPNETCORE_ENVIRONMENT": "Staging"
}, },
"dotnetRunMessages": true, "dotnetRunMessages": true,
"applicationUrl": "http://localhost:19001" "applicationUrl": "http://localhost:19001"

View File

@@ -2,14 +2,14 @@ import request from '@/utils/request'
// code to web // code to web
export function codeToWeb() { export function codeToWeb() {
return request({ return request({
url: 'web-first/code-build-web', url: 'code-gun/code-build-web',
method: 'post' method: 'post'
}) })
} }
// code to web // code to web
export function webToCode(ids) { export function webToCode(ids) {
return request({ return request({
url: 'web-first/web-build-code', url: 'code-gun/web-build-code',
method: 'post', method: 'post',
data:ids data:ids
}) })
@@ -18,7 +18,7 @@ export function webToCode(ids) {
// open zhe path // open zhe path
export function openPath(path) { export function openPath(path) {
return request({ return request({
url: `web-first/dir/${encodeURIComponent(path)}`, url: `code-gun/dir/${encodeURIComponent(path)}`,
method: 'post' method: 'post'
}) })
} }

View File

@@ -50,5 +50,6 @@ export function delData(ids) {
return request({ return request({
url: `/field/${ids}`, url: `/field/${ids}`,
method: 'delete', method: 'delete',
params:{id:ids}
}) })
} }

View File

@@ -224,7 +224,7 @@ import {
updateData, updateData,
delData, delData,
getType getType
} from "@/api/webfirst/fieldApi"; } from "@/api/code/fieldApi";
import { computed, onMounted, defineProps, ref } from "vue"; import { computed, onMounted, defineProps, ref } from "vue";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
@@ -267,7 +267,8 @@ const data = reactive({
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rules } = toRefs(data);
const getFieldTypeEnum=(field)=>{ const getFieldTypeEnum=(field)=>{
return fieldList.value.filter(x=>x.value==field)[0].lable; return field;
// return fieldList.value.filter(x=>x.value==field)[0]?.lable??'未知';
} }
watch( watch(

View File

@@ -1,4 +1,4 @@
import {listData} from "@/api/webfirst/tableApi.js" import {listData} from "@/api/code/tableApi.js"
const useTable=()=>{ const useTable=()=>{
const dataList=ref([]); const dataList=ref([]);

View File

@@ -61,7 +61,7 @@
plain plain
icon="Plus" icon="Plus"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['webfirst:table:add']" v-hasPermi="['codeGun:table:add']"
>新增</el-button >新增</el-button
> >
</el-col> </el-col>
@@ -72,7 +72,7 @@
icon="Edit" icon="Edit"
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['webfirst:table:edit']" v-hasPermi="['codeGun:table:edit']"
>修改</el-button >修改</el-button
> >
</el-col> </el-col>
@@ -83,7 +83,7 @@
icon="Delete" icon="Delete"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['webfirst:table:remove']" v-hasPermi="['codeGun:table:remove']"
>删除</el-button >删除</el-button
> >
</el-col> </el-col>
@@ -93,7 +93,7 @@
plain plain
icon="Download" icon="Download"
@click="handleExport" @click="handleExport"
v-hasPermi="['webfirst:table:export']" v-hasPermi="['codeGun:table:export']"
>导出</el-button >导出</el-button
> >
</el-col> </el-col>
@@ -104,7 +104,7 @@
plain plain
icon="Switch" icon="Switch"
@click="handleExport" @click="handleExport"
v-hasPermi="['webfirst:table:export']" v-hasPermi="['codeGun:table:export']"
>同步数据库WebToDb</el-button >同步数据库WebToDb</el-button
> >
</el-col> --> </el-col> -->
@@ -115,7 +115,7 @@
icon="Switch" icon="Switch"
@click="handleWebToCode" @click="handleWebToCode"
:disabled="ids.length==0" :disabled="ids.length==0"
v-hasPermi="['webfirst:table:export']" v-hasPermi="['codeGun:table:export']"
>代码生成WebToCode</el-button >代码生成WebToCode</el-button
> >
</el-col> </el-col>
@@ -126,7 +126,7 @@
plain plain
icon="Switch" icon="Switch"
@click="handleCodeToWeb" @click="handleCodeToWeb"
v-hasPermi="['webfirst:table:export']" v-hasPermi="['codeGun:table:export']"
>实体同步CodeToWeb</el-button >实体同步CodeToWeb</el-button
> >
</el-col> </el-col>
@@ -242,8 +242,8 @@ import {
delData, delData,
addData, addData,
updateData, updateData,
} from "@/api/webfirst/tableApi"; } from "@/api/code/tableApi";
import { codeToWeb,webToCode } from "@/api/webfirst/webfirstApi"; import { codeToWeb,webToCode } from "@/api/code/codeGunApi";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const { sys_normal_disable } = proxy.useDict("sys_normal_disable"); const { sys_normal_disable } = proxy.useDict("sys_normal_disable");

View File

@@ -46,7 +46,7 @@
plain plain
icon="Plus" icon="Plus"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['webfirst:template:add']" v-hasPermi="['codeGun:template:add']"
>新增</el-button >新增</el-button
> >
</el-col> </el-col>
@@ -57,7 +57,7 @@
icon="Edit" icon="Edit"
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['webfirst:template:edit']" v-hasPermi="['codeGun:template:edit']"
>修改</el-button >修改</el-button
> >
</el-col> </el-col>
@@ -68,7 +68,7 @@
icon="Delete" icon="Delete"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['webfirst:template:remove']" v-hasPermi="['codeGun:template:remove']"
>删除</el-button >删除</el-button
> >
</el-col> </el-col>
@@ -78,7 +78,7 @@
plain plain
icon="Download" icon="Download"
@click="handleExport" @click="handleExport"
v-hasPermi="['webfirst:template:export']" v-hasPermi="['codeGun:template:export']"
>导出</el-button >导出</el-button
> >
</el-col> </el-col>
@@ -145,14 +145,14 @@
type="text" type="text"
icon="Edit" icon="Edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['webfirst:template:edit']" v-hasPermi="['codeGun:template:edit']"
>修改</el-button >修改</el-button
> >
<el-button <el-button
type="text" type="text"
icon="Delete" icon="Delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['webfirst:template:remove']" v-hasPermi="['codeGun:template:remove']"
>删除</el-button >删除</el-button
> >
</template> </template>
@@ -231,8 +231,8 @@ import {
delData, delData,
addData, addData,
updateData, updateData,
} from "@/api/webfirst/templateApi"; } from "@/api/code/templateApi";
import {openPath} from "@/api/webfirst/webfirstApi"; import {openPath} from "@/api/code/codeGunApi";
import { ref } from "@vue/reactivity"; import { ref } from "@vue/reactivity";
import ReplaceText from './components/ReplaceText' import ReplaceText from './components/ReplaceText'
import TempalteTip from './components/TempalteTip.vue' import TempalteTip from './components/TempalteTip.vue'

View File

@@ -78,7 +78,7 @@
<h4>后端技术</h4> <h4>后端技术</h4>
<ul> <ul>
<li>.Net6</li> <li>.Net6</li>
<li>WebFirst</li> <li>CodeFirst</li>
<li>JWT</li> <li>JWT</li>
<li>Sqlsugar</li> <li>Sqlsugar</li>
<li>Redis</li> <li>Redis</li>

View File

@@ -6,7 +6,7 @@
该文件为通用Crud模板文件按照规范只需要 替换以下变量即可 该文件为通用Crud模板文件按照规范只需要 替换以下变量即可
租户 实体中文名称 租户 实体中文名称
system:tenant crud权限编码 system:tenant crud权限编码
system/tenant : api文件路径,例如webfirst/tableApi system/tenant : api文件路径,例如codeGun/tableApi
</div> --> </div> -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="租户名称" prop="name"> <el-form-item label="租户名称" prop="name">

View File

@@ -6,7 +6,7 @@
该文件为通用Crud模板文件按照规范只需要 替换以下变量即可, 该文件为通用Crud模板文件按照规范只需要 替换以下变量即可,
@Name@ 实体中文名称 @Name@ 实体中文名称
@per:per@ crud权限编码 @per:per@ crud权限编码
@api@ : api文件路径,例如webfirst/tableApi @api@ : api文件路径,code/tableApi
</div> --> </div> -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="@Name@名称" prop="name"> <el-form-item label="@Name@名称" prop="name">