fix
wangpengfei
2023-07-19 e5e75fcbb5b5115da6e5069817a4bfdd892b95bb
fix

Add user.uuid field, change id

add vetting temp
1个文件已添加
9个文件已修改
303 ■■■■■ 已修改文件
api/v1/salesReturn.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/user.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/user.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/vetting.go 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/container_docker.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/user.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
source/user.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesReturn.go
@@ -104,7 +104,7 @@
//    @Tags        SalesReturn
//    @Summary    获取销售退货列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{}
//    @Success    200    {object}    contextx.Response{data=response.SalesReturnResponse}
//    @Router        /api/salesReturn/list [get]
func (s *SalesReturnApi) List(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
api/v1/user.go
@@ -59,7 +59,7 @@
        return
    }
    // 赋值菜单ID列表
    //user.MenuIds, _ = menuService.GetUserMenuIds(user.ID, user.UserType)
    //user.MenuIds, _ = menuService.GetUserMenuIds(user.UUID, user.UserType)
    slf.TokenNext(ctx, *user)
    return
    //}
@@ -74,7 +74,7 @@
    logx.Infof("TokenNext user:%+v", user)
    j := &utils.JWT{SigningKey: []byte(conf.Conf.JWT.SigningKey)} // 唯一签名
    claims := j.CreateClaims(request.BaseClaims{
        UserId:      user.ID,
        UserId:      user.UUID,
        Username:    user.Username,
        UserType:    user.UserType,
        AuthorityId: user.AuthorityId,
@@ -157,7 +157,7 @@
    var passWord = encrypt.BcryptHash(params.Password)
    var userType constvar.UserType
    user := &model.User{ID: userId, Username: params.Username, UserType: userType, NickName: params.NickName, Password: passWord, HeaderImg: params.HeaderImg, Phone: params.Phone, Email: params.Email, DepartmentId: params.DepartmentId, AuthorityId: params.AuthorityId}
    user := &model.User{UUID: userId, Username: params.Username, UserType: userType, NickName: params.NickName, Password: passWord, HeaderImg: params.HeaderImg, Phone: params.Phone, Email: params.Email, DepartmentId: params.DepartmentId, AuthorityId: params.AuthorityId}
    userReturn, errCode := userService.Register(user)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
@@ -197,7 +197,7 @@
        return
    }
    u := &model.User{ID: utils.GetUserID(c), Password: params.Password}
    u := &model.User{UUID: utils.GetUserID(c), Password: params.Password}
    _, errCode := userService.ChangePassword(u, params.NewPassword)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
@@ -284,7 +284,7 @@
    }
    err := userService.SetUserInfo(model.User{
        ID:        params.ID,
        UUID:      params.ID,
        NickName:  params.NickName,
        HeaderImg: params.HeaderImg,
        Phone:     params.Phone,
@@ -316,7 +316,7 @@
    params.ID = utils.GetUserID(c)
    err := userService.SetUserInfo(model.User{
        ID:        params.ID,
        UUID:      params.ID,
        NickName:  params.NickName,
        HeaderImg: params.HeaderImg,
        Phone:     params.Phone,
@@ -371,7 +371,7 @@
        return
    }
    err := userService.ResetPassword(params.ID)
    err := userService.ResetPassword(params.UUID)
    if err != nil {
        logx.Errorf("重置失败! err:%v", err)
        ctx.Fail(ecode.DBErr)
docs/docs.go
@@ -3995,7 +3995,19 @@
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.SalesReturnResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
@@ -6110,6 +6122,41 @@
                }
            }
        },
        "model.SalesReturn": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "products": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "reason": {
                    "type": "string"
                },
                "repository": {
                    "type": "string"
                },
                "returnDate": {
                    "type": "string"
                },
                "status": {
                    "type": "integer"
                }
            }
        },
        "model.SalesSources": {
            "type": "object",
            "properties": {
@@ -6302,7 +6349,7 @@
                    "type": "string"
                },
                "id": {
                    "type": "string"
                    "type": "integer"
                },
                "menuIds": {
                    "description": "菜单ID列表",
@@ -6327,6 +6374,9 @@
                    "$ref": "#/definitions/constvar.UserType"
                },
                "username": {
                    "type": "string"
                },
                "uuid": {
                    "type": "string"
                }
            }
@@ -9433,6 +9483,17 @@
                }
            }
        },
        "response.SalesReturnResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.SalesReturn"
                    }
                }
            }
        },
        "response.SalesSourceResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -3983,7 +3983,19 @@
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.SalesReturnResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
@@ -6098,6 +6110,41 @@
                }
            }
        },
        "model.SalesReturn": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "products": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.Product"
                    }
                },
                "reason": {
                    "type": "string"
                },
                "repository": {
                    "type": "string"
                },
                "returnDate": {
                    "type": "string"
                },
                "status": {
                    "type": "integer"
                }
            }
        },
        "model.SalesSources": {
            "type": "object",
            "properties": {
@@ -6290,7 +6337,7 @@
                    "type": "string"
                },
                "id": {
                    "type": "string"
                    "type": "integer"
                },
                "menuIds": {
                    "description": "菜单ID列表",
@@ -6315,6 +6362,9 @@
                    "$ref": "#/definitions/constvar.UserType"
                },
                "username": {
                    "type": "string"
                },
                "uuid": {
                    "type": "string"
                }
            }
@@ -9421,6 +9471,17 @@
                }
            }
        },
        "response.SalesReturnResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.SalesReturn"
                    }
                }
            }
        },
        "response.SalesSourceResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -747,6 +747,29 @@
      refundMethod:
        type: string
    type: object
  model.SalesReturn:
    properties:
      clientId:
        type: integer
      id:
        type: integer
      memberId:
        type: integer
      number:
        type: string
      products:
        items:
          $ref: '#/definitions/model.Product'
        type: array
      reason:
        type: string
      repository:
        type: string
      returnDate:
        type: string
      status:
        type: integer
    type: object
  model.SalesSources:
    properties:
      id:
@@ -874,7 +897,7 @@
      headerImg:
        type: string
      id:
        type: string
        type: integer
      menuIds:
        description: 菜单ID列表
        items:
@@ -891,6 +914,8 @@
      userType:
        $ref: '#/definitions/constvar.UserType'
      username:
        type: string
      uuid:
        type: string
    type: object
  request.AddAuthority:
@@ -2977,6 +3002,13 @@
      list:
        items:
          $ref: '#/definitions/model.SalesRefund'
        type: array
    type: object
  response.SalesReturnResponse:
    properties:
      list:
        items:
          $ref: '#/definitions/model.SalesReturn'
        type: array
    type: object
  response.SalesSourceResponse:
@@ -5463,7 +5495,12 @@
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.SalesReturnResponse'
              type: object
      summary: 获取销售退货列表
      tags:
      - SalesReturn
model/user.go
@@ -10,7 +10,8 @@
type (
    // User token里边把用户ID、父用户ID、角色都带上
    User struct {
        ID           string            `json:"id" gorm:"primaryKey;type:varchar(255);comment:用户ID"`
        ID           int               `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        UUID         string            `json:"uuid" gorm:"primaryKey;type:varchar(255);comment:用户ID"`
        Username     string            `json:"username" gorm:"index;type:varchar(255);comment:用户登录名"`
        UserType     constvar.UserType `json:"userType" gorm:"type:int(11);comment:用户类型 1超级管理员 2主账户 3子账户"`
        Password     string            `json:"-"  gorm:"type:varchar(255);comment:用户登录密码"`
@@ -65,7 +66,7 @@
}
func (slf *UserSearch) SetId(id string) *UserSearch {
    slf.ID = id
    slf.UUID = id
    return slf
}
@@ -82,8 +83,8 @@
func (slf *UserSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&User{}).Preload("Menus")
    if slf.ID != "" {
        db = db.Where("id = ?", slf.ID)
    if slf.UUID != "" {
        db = db.Where("id = ?", slf.UUID)
    }
    if slf.Username != "" {
model/vetting.go
New file
@@ -0,0 +1,95 @@
package model
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
type (
    Vetting struct {
        Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        // 审批意见
        Opinion string `json:"opinion" gorm:"column:opinion;type:varchar(255);comment:审批意见"`
        // 审批状态
        Status int `json:"status" gorm:"column:status;type:int;comment:审批状态"`
        // 审批人
        UserId     int `json:"userId" gorm:"column:user_id;type:int;comment:审批人"`
        gorm.Model `json:"-"`
    }
    VettingSearch struct {
        Vetting
        Orm *gorm.DB
    }
)
func (Vetting) TableName() string {
    return "vetting"
}
func NewVettingSearch() *VettingSearch {
    return &VettingSearch{
        Orm: mysqlx.GetDB(),
    }
}
func (slf *VettingSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&Vetting{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.UserId != 0 {
        db = db.Where("user_id = ?", slf.UserId)
    }
    if slf.Status != 0 {
        db = db.Where("status = ?", slf.Status)
    }
    return db
}
func (slf *VettingSearch) Create(record *Vetting) error {
    var db = slf.build()
    return db.Create(record).Error
}
func (slf *VettingSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&Vetting{}).Error
}
func (slf *VettingSearch) Update(record *Vetting) error {
    var db = slf.build()
    return db.Updates(record).Error
}
func (slf *VettingSearch) Get() (*Vetting, error) {
    var db = slf.build()
    var record = &Vetting{}
    err := db.First(record).Error
    return record, err
}
func (slf *VettingSearch) FindAll() ([]*Vetting, error) {
    var db = slf.build()
    var records = make([]*Vetting, 0)
    err := db.Find(&records).Error
    return records, err
}
func (slf *VettingSearch) SetId(id int) *VettingSearch {
    slf.Id = id
    return slf
}
func (slf *VettingSearch) SetUserId(userId int) *VettingSearch {
    slf.UserId = userId
    return slf
}
func (slf *VettingSearch) SetStatus(status int) *VettingSearch {
    slf.Status = status
    return slf
}
service/container_docker.go
@@ -236,11 +236,11 @@
    //    if u.ParentId == "" { //是主账号
    //        //判断容器是否存在时是否需要加锁?用户注册主账号时是异步请求,创建docker容器没有冲突,因为容器的id不同。
    //        //拉起容器和用户主动启动容器也没有时间冲突
    //        _, e := slf.Exist(u.ID)
    //        _, e := slf.Exist(u.UUID)
    //        if e != ContainerNotFound {
    //            continue
    //        }
    //        if err := slf.Init(u.ID); err != nil {
    //        if err := slf.Init(u.UUID); err != nil {
    //            logx.Errorf("init ContainerNotFound err:", err)
    //        }
    //    }
service/user.go
@@ -35,7 +35,7 @@
}
func (userService *UserService) ChangePassword(u *model.User, newPassword string) (userInter *model.User, errCode int) {
    user, err := model.NewUserSearch(nil).SetId(u.ID).First()
    user, err := model.NewUserSearch(nil).SetId(u.UUID).First()
    if err != nil {
        return nil, ecode.UserNotExist
    }
@@ -45,7 +45,7 @@
    }
    user.Password = encrypt.BcryptHash(newPassword)
    err = model.NewUserSearch(nil).SetId(u.ID).UpdateByMap(map[string]interface{}{
    err = model.NewUserSearch(nil).SetId(u.UUID).UpdateByMap(map[string]interface{}{
        "password": user.Password})
    return user, ecode.OK
@@ -71,7 +71,7 @@
}
func (userService *UserService) SetUserInfo(req model.User) error {
    return model.NewUserSearch(nil).SetId(req.ID).UpdateByMap(map[string]interface{}{
    return model.NewUserSearch(nil).SetId(req.UUID).UpdateByMap(map[string]interface{}{
        "nick_name":  req.NickName,
        "header_img": req.HeaderImg,
        "phone":      req.Phone,
source/user.go
@@ -33,7 +33,7 @@
    adminPassword := encrypt.BcryptHash("123456")
    entities := []*model.User{
        {
            ID:       fmt.Sprintf("u%v", snowflake.GenerateId()),
            UUID:     fmt.Sprintf("u%v", snowflake.GenerateId()),
            Username: "admin",
            Password: adminPassword,
            NickName: "admin",