Coder Social home page Coder Social logo

xinnix / cool-admin-midway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cool-team-official/cool-admin-midway

0.0 0.0 0.0 2.14 MB

🔥 cool-admin(midway版)一个很酷的后台权限管理框架,模块化、插件化、CRUD极速开发,永久开源免费,基于midway.js 3.x、typescript、typeorm、mysql、jwt、vue3、vite、element-ui等构建

Home Page: https://cool-js.com

License: MIT License

JavaScript 0.29% TypeScript 67.47% CSS 0.61% HTML 0.42% PLpgSQL 30.82% Dockerfile 0.38%

cool-admin-midway's Introduction

Midway Logo

cool-admin(midway版)一个很酷的后台权限管理系统,开源免费,模块化、插件化、极速开发CRUD,方便快速构建迭代后台管理系统,支持serverless、docker、普通服务器等多种方式部署 到 文档 进一步了解

GitHub license GitHub tag GitHub tag

技术栈

  • 后端:node.js midway.js koa.js mysql typescript
  • 前端:vue.js element-plus jsx pinia vue-router

如果你是前端,后端的这些技术选型对你是特别友好的,前端开发者可以较快速地上手。 如果你是后端,Typescript 的语法又跟 java、php 等特别类似,一切看起来也是那么得熟悉。

演示

AI极速编码

https://show.cool-admin.com

  • 账户:admin
  • 密码:123456

Admin Home

文档

https://cool-js.com

项目前端

https://github.com/cool-team-official/cool-admin-vue

微信群

Admin Wechat

运行

修改数据库配置,配置文件位于src/config/config.local.ts

数据库为 mysql(>=5.7版本),建议 8.0,node 版本(>=16.x),建议 18.x,首次启动会自动初始化并导入数据

typeorm: {
    dataSource: {
      default: {
        type: 'mysql',
        host: '127.0.0.1',
        port: 3306,
        username: 'root',
        password: '123456',
        database: 'cool',
        // 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
        synchronize: true,
        // 打印日志
        logging: false,
        // 字符集
        charset: 'utf8mb4',
        // 是否开启缓存
        cache: true,
        // 实体路径
        entities: ['**/modules/*/entity'],
      },
    },
  },

安装依赖并运行

$ npm i
$ npm run dev
$ open http://localhost:8001/

注: npm i如果安装失败可以尝试使用cnpm,或者切换您的镜像源

CURD(快速增删改查)

大部分的后台管理系统,或者 API 服务都是对数据进行管理,所以可以看到大量的 CRUD 场景(增删改查),cool-admin 对此进行了大量地封装,让这块的编码量变得极其地少。

新建一个数据表

src/modules/demo/entity/goods.ts,项目启动数据库会自动创建该表,无需手动创建

import { BaseEntity } from '@cool-midway/core';
import { Column, Entity, Index } from 'typeorm';

/**
 * 商品
 */
@Entity('demo_app_goods')
export class DemoAppGoodsEntity extends BaseEntity {
  @Column({ comment: '标题' })
  title: string;

  @Column({ comment: '图片' })
  pic: string;

  @Column({ comment: '价格', type: 'decimal', precision: 5, scale: 2 })
  price: number;
}

编写 api 接口

src/modules/demo/controller/app/goods.ts,快速编写 6 个 api 接口

import { CoolController, BaseController } from '@cool-midway/core';
import { DemoAppGoodsEntity } from '../../entity/goods';

/**
 * 商品
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: DemoAppGoodsEntity,
})
export class DemoAppGoodsController extends BaseController {
  /**
   * 其他接口
   */
  @Get('/other')
  async other() {
    return this.ok('hello, cool-admin!!!');
  }
}

这样我们就完成了 6 个接口的编写,对应的接口如下:

  • POST /app/demo/goods/add 新增
  • POST /app/demo/goods/delete 删除
  • POST /app/demo/goods/update 更新
  • GET /app/demo/goods/info 单个信息
  • POST /app/demo/goods/list 列表信息
  • POST /app/demo/goods/page 分页查询(包含模糊查询、字段全匹配等)

部署

部署教程

内置指令

  • 使用 npm run lint 来做代码风格检查。

低价服务器

阿里云、腾讯云、华为云低价云服务器,不限新老

cool-admin-midway's People

Contributors

cool-team-official avatar apgzs avatar gcslaoli avatar canfeit avatar selicens avatar coder-huo avatar sanqi377 avatar tiplan avatar weiyunpeng avatar lhx6538665 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.