1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package main
- import (
- "strings"
- "github.com/shopspring/decimal"
- "github.com/sirupsen/logrus"
- "github.com/spf13/viper"
- "gogs.daxia.dev/huanan/pkg.daxia.dev/db"
- "nn.daxia.dev/model"
- )
- func main() {
- viper.Set("gormlog", true)
- viper.AddConfigPath("conf")
- viper.AddConfigPath("configs/qznn")
- viper.SetConfigName("config")
- viper.SetConfigType("yaml")
- viper.AutomaticEnv()
- viper.SetEnvPrefix("web")
- viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
- // 从环境变量总读取
- err := viper.ReadInConfig()
- if err != nil {
- logrus.Fatal(err)
- }
- db.InitTest()
- createUser()
- //createDBTable()
- }
- func createUser() {
- var err error
- err = db.GetDB().Create(&model.User{
- Pid: 0,
- Name: "test1",
- Nickname: "test1",
- Mobile: "1888888888",
- AccountType: 0,
- Status: 1,
- Balance: decimal.NewFromInt(100),
- HeadImg: "",
- Token: "8bc766ae05120ad091e8e52c29e23c1e",
- City: "shenzhen",
- ParentTree: "group",
- ParentTreeStr: "",
- }).Error
- if err != nil {
- logrus.Fatal(err)
- }
- }
|