Giter VIP home page Giter VIP logo

mogutouerp's Introduction

mogutouERP 蘑菇头进存销管理系统

Go Report Card Codacy Badge

mogutouERP 是一个前后端分离的微型进存销系统,采用 Gin + Vue 开发。

主要功能及效果图

  • 员工账号管理
  • 采购订单管理
  • 销售订单管理
  • 商品信息、库存管理
  • 财务信息报表

财务信息,添加员工,商品进价管理等操作只有管理员账号可以查看并操作

image image image image image

本地运行使用

后端

准备一个 mysql本地 Docker 启一个 mysql,或者其它方式启动。

在 mysql 中创建一个 database

下载本仓库源码(后端)

git clone https://github.com/Allenxuxu/mogutouERP.git

进入源码目录查看并修改 conf 目录下的配置文件(mysql 连接信息)

cd mogutouERP/conf
vi conf.json

最后 cd 回顶层目录启动程序

cd ..
make run

前端

下载前端仓库源码

git clone https://github.com/Allenxuxu/mogutouERP-vue
cd mogutouERP-vue
npm install
# develop
npm run dev

然后查看浏览器 http://localhost:9528

登陆

默认管理员登陆账号和密码都是 11223344556 , 登陆后修改。

前后端分离部署

后端部署

数据库

后端数据存储使用 mysql 数据库,需要提前在 mysql 中建库,数据库名称随意定义,只需与配置文件中一致即可。无需提前建表,项目中采用 Gorm 自动生成。

配置文件

在服务器上创建一个目录存放配置文件, 并创建两个配置文件(仓库源码 conf 目录中为 模版)

cd /opt/mogutouERP-demo

mkdir conf && touch conf.json  jwt.json

配置文件内容模版如下

conf.json

{
    "mysql": {
        "name": "root",
        "password": "123",
        "DBname": "mgt",
        "addr": "127.0.0.1:3306"
    },
    "listen": "127.0.0.1:8088"
}

jwt.json

{
    "jwt-key": "asdfasf"
}

Docker 运行

docker pull xuxu123/mogutou:v0.1.0

这里网络模式 --net=host , 主要是考虑大多数人都是在本机安装的 mysql,服务在容器中无法通过 127.0.0.1 直接访问 mysql 。并不建议采用 host 网络模式,但是作为演示这是最方便的。

docker run --name mogutou -v /opt/mogutouERP-demo/conf:/etc/conf  --net=host -d   xuxu123/mogutou:v0.1.0

查看输出日志,确认服务正常启动

docker logs mogutou

前端部署

修改 config 目录下 prod.env.js 中的 BASE_API ,改成你的域名或者服务器公网 IP 加端口即可

'use strict'
module.exports = {
  NODE_ENV: '"production"',
  BASE_API: '"https://xxx.xxxxx.com/api/v1"'
}

进入仓库顶层目录 build 生成静态文件

npm run build

生成 dist 目录,将 dist 目录拷贝到服务器中,使用 nginx反向代理就可以了

Nginx 参考配置

server {
    listen 80;
    server_name demo.mogutou.xyz;

    root /opt/mogutouERP-demo/dist;
    index index.html;

    location / {
       try_files $uri $uri/ /index.html;
    }

    location /api {
       proxy_pass http://127.0.0.1:8088;
    }
}

mogutouerp's People

Contributors

allenxuxu avatar codacy-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mogutouerp's Issues

跨域问题

后端采用的docker 部署
image
image

前端配置
image

结果
image

缺少index.html文件

运行命令$ go run main.go router.go -c conf/
router.go:13:12: pattern index.html: no matching files found

报错缺少index.html文件,请问index.html文件在哪?

运行问题

用go mod 初始化后,下载不了依赖。
image

Gorm选择与字段冲突

2022/10/26 20:26:18 D:/golang/data/src/mogutouERP/mogutouERP/models/purchaseOrder.go:162
[error] invalid field found for struct github.com/Allenxuxu/mogutouERP/models.PurchaseOrderInfo's field Goods, need to define a valid foreign key for relations or it need to implement the Valuer/Scanner interface

func getPurchaseOrder(tx *gorm.DB, orderID string) (*PurchaseOrderInfo, error) {
	var order PurchaseOrderInfo
	err := tx.Table("purchase_orders").Select(
		"id, created_at, operator, amount, remarks, state, freight").Where("id = ?", orderID).First(&order).Error
	if err != nil {
		return nil, err
	}

	err = tx.Raw(`select t2.id, t2.name, t2.colour, t2.size, t2.brand, t1.number from purchase_goods as t1 left outer join
			commodities as t2 on t1.goods_id = t2.id where t1.purchase_order_id = ?`, orderID).Scan(&order.Goods).Error
	if err != nil {
		return nil, err
	}
	return &order, nil
}

order 的数据结构是:

type PurchaseOrderInfo struct {
	PurchaseOrder
	Goods []Commodity
}
type PurchaseOrder struct {
	gorm.Model
	Operator string `gorm:"size:255"`
	Remarks  string
	Amount   float32
	Freight  float32
	State    string `gorm:"default:'未完成'"`
}
// Commodity 商品表
type Commodity struct {
	ID            string `gorm:"primary_key"`
	Name          string
	Colour        string
	Size          string
	Brand         string
	Number        uint
	PresaleNumber uint
	SalesVolume   uint
	Price         float32
	PurchasePrice float32
}

你好,编译的时候出现报错

go build -o mogutou main.go router.go
router.go:4:2: cannot find package "github.com/Allenxuxu/mogutouERP/api" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/Allenxuxu/mogutouERP/api (from $GOROOT)
/Users/jacky/go/src/github.com/Allenxuxu/mogutouERP/api (from $GOPATH)
router.go:5:2: cannot find package "github.com/Allenxuxu/mogutouERP/middleware" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/Allenxuxu/mogutouERP/middleware (from $GOROOT)
/Users/jacky/go/src/github.com/Allenxuxu/mogutouERP/middleware (from $GOPATH)
main.go:7:2: cannot find package "github.com/Allenxuxu/mogutouERP/tree/master/models" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/Allenxuxu/mogutouERP/tree/master/models (from $GOROOT)
/Users/jacky/go/src/github.com/Allenxuxu/mogutouERP/tree/master/models (from $GOPATH)
main.go:8:2: cannot find package "github.com/Allenxuxu/mogutouERP/tree/master/pkg/token" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/Allenxuxu/mogutouERP/tree/master/pkg/token (from $GOROOT)
/Users/jacky/go/src/github.com/Allenxuxu/mogutouERP/tree/master/pkg/token (from $GOPATH)
router.go:6:2: cannot find package "github.com/gin-contrib/cors" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/gin-contrib/cors (from $GOROOT)
/Users/jacky/go/src/github.com/gin-contrib/cors (from $GOPATH)
main.go:9:2: cannot find package "github.com/gin-gonic/gin" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/gin-gonic/gin (from $GOROOT)
/Users/jacky/go/src/github.com/gin-gonic/gin (from $GOPATH)
main.go:10:2: cannot find package "github.com/jinzhu/gorm/dialects/mysql" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/jinzhu/gorm/dialects/mysql (from $GOROOT)
/Users/jacky/go/src/github.com/jinzhu/gorm/dialects/mysql (from $GOPATH)
main.go:11:2: cannot find package "github.com/micro/go-micro/config" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/micro/go-micro/config (from $GOROOT)
/Users/jacky/go/src/github.com/micro/go-micro/config (from $GOPATH)
main.go:12:2: cannot find package "github.com/micro/go-micro/config/source/file" in any of:
/usr/local/Cellar/go/1.13.4/libexec/src/github.com/micro/go-micro/config/source/file (from $GOROOT)
/Users/jacky/go/src/github.com/micro/go-micro/config/source/file (from $GOPATH)
make: *** [build] Error 1

google了一下没找到解决办法,请问怎么弄?macos下的go环境
谢谢

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.