当前位置: 首页 > 后端技术 > Node.js

只需要几行代码就可以快速写出crud界面

时间:2023-04-03 23:24:15 Node.js

背景随着互联网的飞速发展,软件的开发越来越讲究效率,无论是各种跨端框架如:electronuni-app,也就是serverless,最近比较流行。生来就有这种趋势。后台的快速开发其实后台的开发中有很多重复性的工作,有的程序员甚至自嘲是crud(增删改查)开发人员。酷团队在开发软件时也遇到了类似的问题。正好伴随着阿里巴巴集团中途2.0的发布。它是一个不仅可以开发通用应用程序,还可以将应用程序打包部署为serverless的工具。基于此,我们封装了cool-admin这个后台快速开发的框架。快速开发定义表/***Goods*/@EntityModel('demo_app_goods')exportclassDemoAppGoodsEntityextendsBaseEntity{@Column({comment:'title'})title:string;@Column({comment:'picture'})图片:字符串;@Column({comment:'price',type:'decimal',precision:5,scale:2})price:number;}writeinterfaceimport{Provide}from'@midwayjs/decorator';import{CoolController,BaseController}from'midwayjs-cool-core';import{DemoAppGoodsEntity}from'../../entity/goods';/***Goods*/@Provide()@CoolController({api:['添加','删除','update','info','list','page'],entity:DemoAppGoodsEntity})exportclassDemoAppGoodsControllerextendsBaseController{/***其他接口*/@Get('/other')asyncother(){returnthis.ok('你好,cool-admin!!!');}}这样,我们就完成了6个界面的编写,对应的界面如下:POST/app/demo/goods/addAddPOST/app/demo/goods/deleteDeletePOST/app/demo/goods/update更新GET/app/demo/goods/info单条信息POST/app/demo/goods/list列表信息POST/app/demo/goods/页面分页查询(含模糊查询,字段全匹配等)开源免费为了分享我们的成果,我们将其开源,让开发者可以快速开发,专注于业务后台https://github.com/cool-team-...https://gitee。com/cool-team-o...前端https://github.com/cool-team-...https://gitee.com/cool-team-o...