diff --git a/Makefile b/Makefile index 7705906..b7936fd 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,12 @@ build-sqlite: # docker build . -t go-admin:latest -build-dev: +dev-windows: set GOARCH=amd64 set GOOS=linux go build -o dev-go-admin main.go -build: - GOOS=linux GOARCH=amd64 go build -o go-admin main.go +dev: + GOOS=linux GOARCH=amd64 go build -o dev-go-admin main.go diff --git a/app/admin/apis/basic/cashier.go b/app/admin/apis/basic/cashier.go index 9c46add..553dfa3 100644 --- a/app/admin/apis/basic/cashier.go +++ b/app/admin/apis/basic/cashier.go @@ -148,9 +148,9 @@ func CashierDelete(c *gin.Context) { } type CashierListRequest struct { - StoreId uint32 `json:"store_id"` // 门店编号 - PageNum int `json:"page_num"` // 页码 - PageSize int `json:"page_size"` // 页条数 + StoreId uint32 `json:"store_id"` // 门店编号 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 页条数 } // CashierList 查询收付款账号列表 @@ -170,7 +170,7 @@ func CashierList(c *gin.Context) { return } - list, err := models.GetAccountList(int(req.StoreId), req.PageSize, req.PageNum) + list, err := models.GetAccountList(int(req.StoreId), req.PageSize, req.PageIndex) if err != nil { app.Error(c, http.StatusBadRequest, err, err.Error()) return diff --git a/app/admin/apis/system/sysuser.go b/app/admin/apis/system/sysuser.go index b42b46d..96f7139 100644 --- a/app/admin/apis/system/sysuser.go +++ b/app/admin/apis/system/sysuser.go @@ -1,17 +1,18 @@ package system import ( + "encoding/json" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "github.com/google/uuid" - "go-admin/logger" - "go-admin/app/admin/models" + "go-admin/logger" "go-admin/tools" "go-admin/tools/app" ) -// @Summary 列表用户信息数据 +// GetSysUserList +// @Summary 列表用户信息数据(update) // @Description 获取JSON // @Tags system/用户 // @Param username query string false "username" @@ -142,39 +143,116 @@ func GetSysUserInit(c *gin.Context) { app.OK(c, mp, "") } -// @Summary 创建用户 +// InsertSysUser +// @Summary 创建用户(update) // @Description 获取JSON // @Tags system/用户 // @Accept application/json // @Product application/json -// @Param data body models.SysUser true "用户数据" +// @Param data body models.InsertSysUserReq true "用户数据" // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /api/v1/sysUser [post] func InsertSysUser(c *gin.Context) { - var sysuser models.SysUser - err := c.BindWith(&sysuser, binding.JSON) + var req models.InsertSysUserReq + err := c.BindWith(&req, binding.JSON) tools.HasError(err, "非法数据格式", 500) - sysuser.CreateBy = tools.GetUserIdStr(c) - id, err := sysuser.Insert() + SalesCommRateFloat, err := models.StringToFloat(req.SalesCommRate) + if err != nil { + //logger.Error("brokerage1 err:", err) + tools.HasError(err, "数据解析失败", 500) + } + + sysUser := models.SysUser{ + SysUserId: req.SysUserId, + LoginM: req.LoginM, + SysUserB: models.SysUserB{ + NickName: req.NickName, + Phone: req.Phone, + RoleId: req.RoleId, + Salt: req.Salt, + Avatar: req.Avatar, + Sex: req.Sex, + Email: req.Email, + DeptId: req.DeptId, + PostId: req.PostId, + Remark: req.Remark, + Status: req.Status, + AccountType: req.AccountType, + CooperativeBusinessId: req.CooperativeBusinessId, + CooperativeName: req.CooperativeName, + SalesCommRate: SalesCommRateFloat, + }, + } + + if len(req.StoreList) != 0 { + // 将 StoreData 转换为 JSON 字符串 + storeDataJSON, err := json.Marshal(req.StoreList) + if err != nil { + tools.HasError(err, "数据解析失败", 500) + } + sysUser.StoreData = string(storeDataJSON) + } + + sysUser.CreateBy = tools.GetUserIdStr(c) + id, err := sysUser.Insert() tools.HasError(err, "添加失败", 500) app.OK(c, id, "添加成功") } -// @Summary 修改用户数据 +// UpdateSysUser +// @Summary 修改用户数据(update) // @Description 获取JSON // @Tags system/用户 // @Accept application/json // @Product application/json -// @Param data body models.SysUser true "body" +// @Param data body models.InsertSysUserReq true "body" // @Success 200 {string} string "{"code": 200, "message": "修改成功"}" // @Success 200 {string} string "{"code": -1, "message": "修改失败"}" // @Router /api/v1/sysuser/{userId} [put] func UpdateSysUser(c *gin.Context) { - var data models.SysUser - err := c.Bind(&data) - tools.HasError(err, "数据解析失败", -1) + var req models.InsertSysUserReq + err := c.BindWith(&req, binding.JSON) + tools.HasError(err, "非法数据格式", 500) + + SalesCommRateFloat, err := models.StringToFloat(req.SalesCommRate) + if err != nil { + //logger.Error("brokerage1 err:", err) + tools.HasError(err, "数据解析失败", 500) + } + + data := models.SysUser{ + SysUserId: req.SysUserId, + LoginM: req.LoginM, + SysUserB: models.SysUserB{ + NickName: req.NickName, + Phone: req.Phone, + RoleId: req.RoleId, + Salt: req.Salt, + Avatar: req.Avatar, + Sex: req.Sex, + Email: req.Email, + DeptId: req.DeptId, + PostId: req.PostId, + Remark: req.Remark, + Status: req.Status, + AccountType: req.AccountType, + CooperativeBusinessId: req.CooperativeBusinessId, + CooperativeName: req.CooperativeName, + SalesCommRate: SalesCommRateFloat, + }, + } + + if len(req.StoreList) != 0 { + // 将 StoreData 转换为 JSON 字符串 + storeDataJSON, err := json.Marshal(req.StoreList) + if err != nil { + tools.HasError(err, "数据解析失败", 500) + } + data.StoreData = string(storeDataJSON) + } + data.UpdateBy = tools.GetUserIdStr(c) result, err := data.Update(data.UserId) tools.HasError(err, "修改失败", 500) diff --git a/app/admin/models/cashier.go b/app/admin/models/cashier.go index 6a878b8..1552794 100644 --- a/app/admin/models/cashier.go +++ b/app/admin/models/cashier.go @@ -46,10 +46,10 @@ type ErpCashierDetail struct { } type ErpCashierListResp struct { - Total int `json:"total"` - PageNum int `json:"page_num"` - PageSize int `json:"page_size"` - List []ErpCashier `json:"list"` + Total int `json:"count"` // 数据总条数 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 每页展示条数 + List []ErpCashier `json:"list"` } // CreateAccount 创建账号 @@ -242,13 +242,13 @@ func DeleteAccount(cashierId uint32) error { } // GetAccountList 查询账号列表 -func GetAccountList(storeId, pageSize, pageNum int) (*ErpCashierListResp, error) { +func GetAccountList(storeId, pageSize, pageIndex int) (*ErpCashierListResp, error) { resp := ErpCashierListResp{ - PageNum: pageNum, - PageSize: pageSize, + PageIndex: pageIndex, + PageSize: pageSize, } - page := pageNum - 1 + page := pageIndex - 1 if page < 0 { page = 0 } @@ -271,7 +271,7 @@ func GetAccountList(storeId, pageSize, pageNum int) (*ErpCashierListResp, error) offset := page * pageSize limit := pageSize - resp.Total = int(count)/pageSize + 1 + //resp.Total = int(count)/pageSize + 1 var categories []ErpCashier if storeId == 0 { // 只查询账号信息 @@ -297,6 +297,12 @@ func GetAccountList(storeId, pageSize, pageNum int) (*ErpCashierListResp, error) } resp.List = categories + + //跟之前保持一致 + resp.Total = int(count) + resp.PageIndex = page + 1 + resp.PageSize = pageSize + return &resp, nil } diff --git a/app/admin/models/commodity.go b/app/admin/models/commodity.go index e7da0ee..6f94a47 100644 --- a/app/admin/models/commodity.go +++ b/app/admin/models/commodity.go @@ -248,24 +248,24 @@ type ErpCommodityListReq struct { ErpCategoryId uint32 `json:"erp_category_id"` // 商品分类id IMEI string `json:"imei"` // 串码 ErpSupplierId uint32 `json:"erp_supplier_id"` // 供应商id - PageNum int `json:"page_num"` // 页码 - PageSize int `json:"page_size"` // 每页展示数据条数 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 每页展示数据条数 IsExport uint32 `json:"is_export"` // 1-导出 } type ErpCommodityListResp struct { List []ErpCommodity `json:"list"` - Total int `json:"total"` // 总页数 - PageNum int `json:"page_num"` // 页码 - PageSize int `json:"page_size"` // 每页展示数据条数 + Total int `json:"count"` // 数据总条数 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 每页展示条数 ExportUrl string `json:"export_url"` // 1-导出 } func (m *ErpCommodityListReq) List() (*ErpCommodityListResp, error) { resp := &ErpCommodityListResp{ - PageNum: m.PageNum, - PageSize: m.PageSize, + PageIndex: m.PageIndex, + PageSize: m.PageSize, } - page := m.PageNum - 1 + page := m.PageIndex - 1 if page < 0 { page = 0 } @@ -296,7 +296,7 @@ func (m *ErpCommodityListReq) List() (*ErpCommodityListResp, error) { //logger.Error("count err:", err) return resp, err } - resp.Total = int(count)/m.PageSize + 1 + //resp.Total = int(count)/m.PageSize + 1 var commodities []ErpCommodity if m.IsExport == 1 { @@ -328,6 +328,11 @@ func (m *ErpCommodityListReq) List() (*ErpCommodityListResp, error) { } } + //跟之前保持一致 + resp.Total = int(count) + resp.PageIndex = page + 1 + resp.PageSize = m.PageSize + return resp, nil } @@ -1049,25 +1054,25 @@ type ErpStockListReq struct { ErpCategoryId uint32 `json:"erp_category_id"` // 商品分类 StockType uint32 `json:"stock_type"` // 库存情况:1-全部 2-有库存 3-无库存 StoreId uint32 `json:"store_id"` // 门店编号 - PageNum int `json:"page_num"` // 页面条数 - PageSize int `json:"page_size"` // 页码 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 页面条数 //IsExport uint32 `json:"is_export"` // 1-导出 } type ErpStockListResp struct { List []ErpStock `json:"list"` - Total int `json:"total"` - PageNum int `json:"page_num"` - PageSize int `json:"page_size"` + Total int `json:"count"` // 数据总条数 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 每页展示条数 ExportUrl string `json:"export_url"` } func (m *ErpStockListReq) List() (*ErpStockListResp, error) { resp := &ErpStockListResp{ - PageNum: m.PageNum, - PageSize: m.PageSize, + PageIndex: m.PageIndex, + PageSize: m.PageSize, } - page := m.PageNum - 1 + page := m.PageIndex - 1 if page < 0 { page = 0 } @@ -1099,7 +1104,6 @@ func (m *ErpStockListReq) List() (*ErpStockListResp, error) { //logger.Error("count err:", err) return resp, err } - resp.Total = int(count)/m.PageSize + 1 var commodities []ErpStock err := qs.Order("id DESC").Offset(page * m.PageSize).Limit(m.PageSize).Find(&commodities).Error @@ -1109,6 +1113,11 @@ func (m *ErpStockListReq) List() (*ErpStockListResp, error) { } resp.List = commodities + //跟之前保持一致 + resp.Total = int(count) + resp.PageIndex = page + 1 + resp.PageSize = m.PageSize + return resp, nil } @@ -1137,27 +1146,27 @@ type ErpStockCommodityListReq struct { StockTimeEnd string `json:"stock_time_end"` // 最近入库结束时间 Age uint32 `json:"age"` // 最近库龄 AllAge uint32 `json:"all_age"` // 总库龄 - PageNum int `json:"page_num"` // 页面条数 - PageSize int `json:"page_size"` // 页码 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 每页展示数据条数 IsExport uint32 `json:"is_export"` // 是否导出excel:1-导出 } // ErpStockCommodityListResp 库存详情接口响应参数 type ErpStockCommodityListResp struct { List []ErpStockCommodity `json:"list"` - Total int `json:"total"` - PageNum int `json:"page_num"` - PageSize int `json:"page_size"` + Total int `json:"count"` // 数据总条数 + PageIndex int `json:"pageIndex"` // 页码 + PageSize int `json:"pageSize"` // 每页展示条数 ExportUrl string `json:"export_url"` } // GetDetailList 查看库存详情 func (m *ErpStockCommodityListReq) GetDetailList() (*ErpStockCommodityListResp, error) { resp := &ErpStockCommodityListResp{ - PageNum: m.PageNum, - PageSize: m.PageSize, + PageIndex: m.PageIndex, + PageSize: m.PageSize, } - page := m.PageNum - 1 + page := m.PageIndex - 1 if page < 0 { page = 0 } @@ -1175,7 +1184,6 @@ func (m *ErpStockCommodityListReq) GetDetailList() (*ErpStockCommodityListResp, //logger.Error("count err:", err) return resp, err } - resp.Total = int(count)/m.PageSize + 1 //获取库存商品列表 var commodities []ErpStockCommodity @@ -1201,6 +1209,16 @@ func (m *ErpStockCommodityListReq) GetDetailList() (*ErpStockCommodityListResp, resp.List = commodities } + ////正常返回 + //resp.Total = int(count)/m.PageSize + 1 + //resp.PageNum = page + 1 + //resp.PageSize = len(resp.List) + + //跟之前保持一致 + resp.Total = int(count) + resp.PageIndex = page + 1 + resp.PageSize = m.PageSize + return resp, nil } diff --git a/app/admin/models/sysuser.go b/app/admin/models/sysuser.go index ecd8fb7..f5625e3 100644 --- a/app/admin/models/sysuser.go +++ b/app/admin/models/sysuser.go @@ -1,6 +1,7 @@ package models import ( + "encoding/json" "errors" "log" "strings" @@ -41,36 +42,68 @@ type SysUserId struct { } type SysUserB struct { - NickName string `gorm:"size:128" json:"nickName"` // 昵称 - Phone string `gorm:"size:11" json:"phone"` // 手机号 - RoleId int `gorm:"" json:"roleId"` // 角色编码 - Salt string `gorm:"size:255" json:"salt"` // 盐 - Avatar string `gorm:"size:255" json:"avatar"` // 头像 - Sex string `gorm:"size:255" json:"sex"` // 性别 - Email string `gorm:"size:128" json:"email"` // 邮箱 - DeptId int `gorm:"" json:"deptId"` // 部门编码 - PostId int `gorm:"" json:"postId"` // 职位编码 - CreateBy string `gorm:"size:128" json:"createBy"` // - UpdateBy string `gorm:"size:128" json:"updateBy"` // - Remark string `gorm:"size:255" json:"remark"` // 备注 - Status string `gorm:"size:4;" json:"status"` // 状态 - StoreId uint32 `json:"store_id"` // 门店id - StoreName string `json:"store_name"` // 门店名称 - CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id - CooperativeName string `json:"cooperative_name"` // 合作商名称 - AccountType uint32 `json:"account_type"` // 账号类型:1-管理端 + NickName string `gorm:"size:128" json:"nickName"` // 昵称 + Phone string `gorm:"size:11" json:"phone"` // 手机号 + RoleId int `gorm:"" json:"roleId"` // 角色编码 + Salt string `gorm:"size:255" json:"salt"` // 盐 + Avatar string `gorm:"size:255" json:"avatar"` // 头像 + Sex string `gorm:"size:255" json:"sex"` // 性别 + Email string `gorm:"size:128" json:"email"` // 邮箱 + DeptId int `gorm:"" json:"deptId"` // 部门编码 + PostId int `gorm:"" json:"postId"` // 职位编码 + CreateBy string `gorm:"size:128" json:"createBy"` // + UpdateBy string `gorm:"size:128" json:"updateBy"` // + Remark string `gorm:"size:255" json:"remark"` // 备注 + Status string `gorm:"size:4;" json:"status"` // 状态 + StoreId uint32 `json:"store_id"` // 门店id + StoreName string `json:"store_name"` // 门店名称 + CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id + CooperativeName string `json:"cooperative_name"` // 合作商名称 + AccountType uint32 `json:"account_type"` // 账号类型:1-管理端 + StoreData string `gorm:"type:json" json:"store_data,omitempty"` // 有效门店 + StoreList []StoreInfo `gorm:"-" json:"store_list"` // 有效门店列表 + SalesCommRate float64 `json:"sales_comm_rate"` // 销售提成比例 BaseModel DataScope string `gorm:"-" json:"dataScope"` Params string `gorm:"-" json:"params"` } +type StoreInfo struct { + StoreID int `json:"storeId"` //门店id + StoreName string `json:"storeName"` //门店名称 + ExpireTime string `json:"expireTime"` //有效期 +} + type SysUser struct { SysUserId LoginM SysUserB } +type InsertSysUserReq struct { + SysUserId + LoginM + NickName string `json:"nickName"` // 昵称 + Phone string `json:"phone"` // 手机号 + RoleId int `json:"roleId"` // 角色编码 + Salt string `json:"salt"` // 盐 + Avatar string `json:"avatar"` // 头像 + Sex string `json:"sex"` // 性别 + Email string `json:"email"` // 邮箱 + DeptId int `json:"deptId"` // 部门编码 + PostId int `json:"postId"` // 职位编码 + Remark string `json:"remark"` // 备注 + Status string `json:"status"` // 状态 + StoreId uint32 `json:"store_id"` // 门店id + StoreName string `json:"store_name"` // 门店名称 + CooperativeBusinessId uint32 `json:"cooperative_business_id"` // 合作商id + CooperativeName string `json:"cooperative_name"` // 合作商名称 + AccountType uint32 `json:"account_type"` // 账号类型:1-管理端 + SalesCommRate string `json:"sales_comm_rate"` // 销售提成比例 + StoreList []StoreInfo `json:"store_list"` // 有效门店 +} + func (SysUser) TableName() string { return "sys_user" } @@ -128,6 +161,9 @@ func (e *SysUser) Get() (SysUserView SysUserView, err error) { } SysUserView.Password = "" + if SysUserView.StoreData != "" { + SysUserView.StoreList = deserializeStoreData(SysUserView.StoreData) + } return } @@ -231,9 +267,28 @@ func (e *SysUser) GetPage(pageSize int, pageIndex int) ([]SysUserPage, int, erro if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Offset(-1).Limit(-1).Count(&count).Error; err != nil { return nil, 0, err } + + // 反序列化 StoreData + for i, v := range doc { + if doc[i].StoreData != "" { + doc[i].StoreList = deserializeStoreData(v.StoreData) + doc[i].StoreData = "" + } + } + return doc, int(count), nil } +// 反序列化 StoreData +func deserializeStoreData(storeData string) []StoreInfo { + var StoreData []StoreInfo + if err := json.Unmarshal([]byte(storeData), &StoreData); err != nil { + // 可以根据实际情况处理反序列化失败的情况 + log.Println("反序列化 StoreData 失败:", err) + } + return StoreData +} + // 加密 func (e *SysUser) Encrypt() (err error) { if e.Password == "" { @@ -285,6 +340,15 @@ func (e *SysUser) Update(id int) (update SysUser, err error) { e.RoleId = update.RoleId } + if len(e.StoreList) != 0 { + // 将 StoreData 转换为 JSON 字符串 + storeDataJSON, err := json.Marshal(e.StoreList) + if err != nil { + return SysUser{}, err + } + e.StoreData = string(storeDataJSON) + } + //参数1:是要修改的数据 //参数2:是修改的数据 if err = orm.Eloquent.Table(e.TableName()).Model(&update).Updates(&e).Error; err != nil { diff --git a/app/admin/router/sysrouter.go b/app/admin/router/sysrouter.go index 54ab2fa..34fda15 100644 --- a/app/admin/router/sysrouter.go +++ b/app/admin/router/sysrouter.go @@ -147,7 +147,7 @@ func registerPageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar { v1auth.GET("/deptList", system.GetDeptList) v1auth.GET("/deptTree", system.GetDeptTree) - v1auth.GET("/sysUserList", system.GetSysUserList) + v1auth.GET("/sysUserList", system.GetSysUserList) //系统设置-系统用户-列表用户信息数据 v1auth.GET("/rolelist", system.GetRoleList) v1auth.GET("/configList", system.GetConfigList) v1auth.GET("/postlist", system.GetPostList) @@ -229,8 +229,8 @@ func registerSysUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle { sysuser.GET("/:userId", system.GetSysUser) sysuser.GET("/", system.GetSysUserInit) - sysuser.POST("", system.InsertSysUser) - sysuser.PUT("", system.UpdateSysUser) + sysuser.POST("", system.InsertSysUser) //创建用户 + sysuser.PUT("", system.UpdateSysUser) //修改用户数据 sysuser.DELETE("/:userId", system.DeleteSysUser) } } diff --git a/cmd/migrate/migration/version/1599190683670_migrate.go b/cmd/migrate/migration/version/1599190683670_migrate.go index 01bb77c..cdc6934 100644 --- a/cmd/migrate/migration/version/1599190683670_migrate.go +++ b/cmd/migrate/migration/version/1599190683670_migrate.go @@ -290,7 +290,7 @@ func _1599190683670Test(db *gorm.DB, version string) error { } list8 := []models.SysUser{ - {models.SysUserId{1}, models.LoginM{models.UserName{"admin"}, models.PassWord{"$2a$10$cKFFTCzGOvaIHHJY2K45Zuwt8TD6oPzYi4s5MzYIBAWCLL6ZhouP2"}}, models.SysUserB{"zhangwj", "13818888888", 1, "", "", "0", "1@qq.com", 1, 1, "1", "1", "", "0", 1, "总店", 1, "迪为", 1, models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, "", ""}}, + {SysUserId: models.SysUserId{1}, LoginM: models.LoginM{models.UserName{"admin"}, models.PassWord{"$2a$10$cKFFTCzGOvaIHHJY2K45Zuwt8TD6oPzYi4s5MzYIBAWCLL6ZhouP2"}}, SysUserB: models.SysUserB{"zhangwj", "13818888888", 1, "", "", "0", "1@qq.com", 1, 1, "1", "1", "", "0", 1, "总店", 1, "迪为", 1, "", []models.StoreInfo{{1, "", ""}}, 0, models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, "", ""}}, } list9 := []models.DictData{ diff --git a/docs/docs.go b/docs/docs.go index ced15f0..693cfb9 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3091,7 +3091,7 @@ const docTemplate = `{ "tags": [ "system/用户" ], - "summary": "创建用户", + "summary": "创建用户(update)", "parameters": [ { "description": "用户数据", @@ -3099,7 +3099,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.SysUser" + "$ref": "#/definitions/models.InsertSysUserReq" } } ], @@ -3155,7 +3155,7 @@ const docTemplate = `{ "tags": [ "system/用户" ], - "summary": "列表用户信息数据", + "summary": "列表用户信息数据(update)", "parameters": [ { "type": "string", @@ -3304,7 +3304,7 @@ const docTemplate = `{ "tags": [ "system/用户" ], - "summary": "修改用户数据", + "summary": "修改用户数据(update)", "parameters": [ { "description": "body", @@ -3312,7 +3312,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.SysUser" + "$ref": "#/definitions/models.InsertSysUserReq" } } ], @@ -3575,11 +3575,11 @@ const docTemplate = `{ "basic.CashierListRequest": { "type": "object", "properties": { - "page_num": { + "pageIndex": { "description": "页码", "type": "integer" }, - "page_size": { + "pageSize": { "description": "页条数", "type": "integer" }, @@ -4381,19 +4381,22 @@ const docTemplate = `{ "models.ErpCashierListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "list": { "type": "array", "items": { "$ref": "#/definitions/models.ErpCashier" } }, - "page_num": { + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "type": "integer" - }, - "total": { + "pageSize": { + "description": "每页展示条数", "type": "integer" } } @@ -4561,11 +4564,11 @@ const docTemplate = `{ "description": "1-导出", "type": "integer" }, - "page_num": { + "pageIndex": { "description": "页码", "type": "integer" }, - "page_size": { + "pageSize": { "description": "每页展示数据条数", "type": "integer" }, @@ -4578,6 +4581,10 @@ const docTemplate = `{ "models.ErpCommodityListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "export_url": { "description": "1-导出", "type": "string" @@ -4588,16 +4595,12 @@ const docTemplate = `{ "$ref": "#/definitions/models.ErpCommodity" } }, - "page_num": { + "pageIndex": { "description": "页码", "type": "integer" }, - "page_size": { - "description": "每页展示数据条数", - "type": "integer" - }, - "total": { - "description": "总页数", + "pageSize": { + "description": "每页展示条数", "type": "integer" } } @@ -4829,12 +4832,12 @@ const docTemplate = `{ "description": "是否导出excel:1-导出", "type": "integer" }, - "page_num": { - "description": "页面条数", + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "description": "页码", + "pageSize": { + "description": "每页展示数据条数", "type": "integer" }, "serial_number": { @@ -4874,6 +4877,10 @@ const docTemplate = `{ "models.ErpStockCommodityListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "export_url": { "type": "string" }, @@ -4883,13 +4890,12 @@ const docTemplate = `{ "$ref": "#/definitions/models.ErpStockCommodity" } }, - "page_num": { + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "type": "integer" - }, - "total": { + "pageSize": { + "description": "每页展示条数", "type": "integer" } } @@ -4905,12 +4911,12 @@ const docTemplate = `{ "description": "商品分类", "type": "integer" }, - "page_num": { - "description": "页面条数", + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "description": "页码", + "pageSize": { + "description": "页面条数", "type": "integer" }, "serial_number": { @@ -4930,6 +4936,10 @@ const docTemplate = `{ "models.ErpStockListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "export_url": { "type": "string" }, @@ -4939,14 +4949,105 @@ const docTemplate = `{ "$ref": "#/definitions/models.ErpStock" } }, - "page_num": { + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { + "pageSize": { + "description": "每页展示条数", + "type": "integer" + } + } + }, + "models.InsertSysUserReq": { + "type": "object", + "properties": { + "account_type": { + "description": "账号类型:1-管理端", "type": "integer" }, - "total": { + "avatar": { + "description": "头像", + "type": "string" + }, + "cooperative_business_id": { + "description": "合作商id", "type": "integer" + }, + "cooperative_name": { + "description": "合作商名称", + "type": "string" + }, + "deptId": { + "description": "部门编码", + "type": "integer" + }, + "email": { + "description": "邮箱", + "type": "string" + }, + "nickName": { + "description": "昵称", + "type": "string" + }, + "password": { + "description": "密码", + "type": "string" + }, + "phone": { + "description": "手机号", + "type": "string" + }, + "postId": { + "description": "职位编码", + "type": "integer" + }, + "remark": { + "description": "备注", + "type": "string" + }, + "roleId": { + "description": "角色编码", + "type": "integer" + }, + "sales_comm_rate": { + "description": "销售提成比例", + "type": "string" + }, + "salt": { + "description": "盐", + "type": "string" + }, + "sex": { + "description": "性别", + "type": "string" + }, + "status": { + "description": "状态", + "type": "string" + }, + "store_id": { + "description": "门店id", + "type": "integer" + }, + "store_list": { + "description": "有效门店", + "type": "array", + "items": { + "$ref": "#/definitions/models.StoreInfo" + } + }, + "store_name": { + "description": "门店名称", + "type": "string" + }, + "userId": { + "description": "编码", + "type": "integer" + }, + "username": { + "description": "用户名", + "type": "string" } } }, @@ -5195,6 +5296,23 @@ const docTemplate = `{ } } }, + "models.StoreInfo": { + "type": "object", + "properties": { + "expireTime": { + "description": "有效期", + "type": "string" + }, + "storeId": { + "description": "门店id", + "type": "integer" + }, + "storeName": { + "description": "门店名称", + "type": "string" + } + } + }, "models.Supplier": { "type": "object", "properties": { @@ -5818,6 +5936,10 @@ const docTemplate = `{ "description": "角色编码", "type": "integer" }, + "sales_comm_rate": { + "description": "销售提成比例", + "type": "number" + }, "salt": { "description": "盐", "type": "string" @@ -5830,10 +5952,21 @@ const docTemplate = `{ "description": "状态", "type": "string" }, + "store_data": { + "description": "有效门店", + "type": "string" + }, "store_id": { "description": "门店id", "type": "integer" }, + "store_list": { + "description": "有效门店列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.StoreInfo" + } + }, "store_name": { "description": "门店名称", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 6c5d6e8..0fcebbf 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3080,7 +3080,7 @@ "tags": [ "system/用户" ], - "summary": "创建用户", + "summary": "创建用户(update)", "parameters": [ { "description": "用户数据", @@ -3088,7 +3088,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.SysUser" + "$ref": "#/definitions/models.InsertSysUserReq" } } ], @@ -3144,7 +3144,7 @@ "tags": [ "system/用户" ], - "summary": "列表用户信息数据", + "summary": "列表用户信息数据(update)", "parameters": [ { "type": "string", @@ -3293,7 +3293,7 @@ "tags": [ "system/用户" ], - "summary": "修改用户数据", + "summary": "修改用户数据(update)", "parameters": [ { "description": "body", @@ -3301,7 +3301,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.SysUser" + "$ref": "#/definitions/models.InsertSysUserReq" } } ], @@ -3564,11 +3564,11 @@ "basic.CashierListRequest": { "type": "object", "properties": { - "page_num": { + "pageIndex": { "description": "页码", "type": "integer" }, - "page_size": { + "pageSize": { "description": "页条数", "type": "integer" }, @@ -4370,19 +4370,22 @@ "models.ErpCashierListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "list": { "type": "array", "items": { "$ref": "#/definitions/models.ErpCashier" } }, - "page_num": { + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "type": "integer" - }, - "total": { + "pageSize": { + "description": "每页展示条数", "type": "integer" } } @@ -4550,11 +4553,11 @@ "description": "1-导出", "type": "integer" }, - "page_num": { + "pageIndex": { "description": "页码", "type": "integer" }, - "page_size": { + "pageSize": { "description": "每页展示数据条数", "type": "integer" }, @@ -4567,6 +4570,10 @@ "models.ErpCommodityListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "export_url": { "description": "1-导出", "type": "string" @@ -4577,16 +4584,12 @@ "$ref": "#/definitions/models.ErpCommodity" } }, - "page_num": { + "pageIndex": { "description": "页码", "type": "integer" }, - "page_size": { - "description": "每页展示数据条数", - "type": "integer" - }, - "total": { - "description": "总页数", + "pageSize": { + "description": "每页展示条数", "type": "integer" } } @@ -4818,12 +4821,12 @@ "description": "是否导出excel:1-导出", "type": "integer" }, - "page_num": { - "description": "页面条数", + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "description": "页码", + "pageSize": { + "description": "每页展示数据条数", "type": "integer" }, "serial_number": { @@ -4863,6 +4866,10 @@ "models.ErpStockCommodityListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "export_url": { "type": "string" }, @@ -4872,13 +4879,12 @@ "$ref": "#/definitions/models.ErpStockCommodity" } }, - "page_num": { + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "type": "integer" - }, - "total": { + "pageSize": { + "description": "每页展示条数", "type": "integer" } } @@ -4894,12 +4900,12 @@ "description": "商品分类", "type": "integer" }, - "page_num": { - "description": "页面条数", + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { - "description": "页码", + "pageSize": { + "description": "页面条数", "type": "integer" }, "serial_number": { @@ -4919,6 +4925,10 @@ "models.ErpStockListResp": { "type": "object", "properties": { + "count": { + "description": "数据总条数", + "type": "integer" + }, "export_url": { "type": "string" }, @@ -4928,14 +4938,105 @@ "$ref": "#/definitions/models.ErpStock" } }, - "page_num": { + "pageIndex": { + "description": "页码", "type": "integer" }, - "page_size": { + "pageSize": { + "description": "每页展示条数", + "type": "integer" + } + } + }, + "models.InsertSysUserReq": { + "type": "object", + "properties": { + "account_type": { + "description": "账号类型:1-管理端", "type": "integer" }, - "total": { + "avatar": { + "description": "头像", + "type": "string" + }, + "cooperative_business_id": { + "description": "合作商id", "type": "integer" + }, + "cooperative_name": { + "description": "合作商名称", + "type": "string" + }, + "deptId": { + "description": "部门编码", + "type": "integer" + }, + "email": { + "description": "邮箱", + "type": "string" + }, + "nickName": { + "description": "昵称", + "type": "string" + }, + "password": { + "description": "密码", + "type": "string" + }, + "phone": { + "description": "手机号", + "type": "string" + }, + "postId": { + "description": "职位编码", + "type": "integer" + }, + "remark": { + "description": "备注", + "type": "string" + }, + "roleId": { + "description": "角色编码", + "type": "integer" + }, + "sales_comm_rate": { + "description": "销售提成比例", + "type": "string" + }, + "salt": { + "description": "盐", + "type": "string" + }, + "sex": { + "description": "性别", + "type": "string" + }, + "status": { + "description": "状态", + "type": "string" + }, + "store_id": { + "description": "门店id", + "type": "integer" + }, + "store_list": { + "description": "有效门店", + "type": "array", + "items": { + "$ref": "#/definitions/models.StoreInfo" + } + }, + "store_name": { + "description": "门店名称", + "type": "string" + }, + "userId": { + "description": "编码", + "type": "integer" + }, + "username": { + "description": "用户名", + "type": "string" } } }, @@ -5184,6 +5285,23 @@ } } }, + "models.StoreInfo": { + "type": "object", + "properties": { + "expireTime": { + "description": "有效期", + "type": "string" + }, + "storeId": { + "description": "门店id", + "type": "integer" + }, + "storeName": { + "description": "门店名称", + "type": "string" + } + } + }, "models.Supplier": { "type": "object", "properties": { @@ -5807,6 +5925,10 @@ "description": "角色编码", "type": "integer" }, + "sales_comm_rate": { + "description": "销售提成比例", + "type": "number" + }, "salt": { "description": "盐", "type": "string" @@ -5819,10 +5941,21 @@ "description": "状态", "type": "string" }, + "store_data": { + "description": "有效门店", + "type": "string" + }, "store_id": { "description": "门店id", "type": "integer" }, + "store_list": { + "description": "有效门店列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.StoreInfo" + } + }, "store_name": { "description": "门店名称", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a333643..11c7661 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -82,10 +82,10 @@ definitions: type: object basic.CashierListRequest: properties: - page_num: + pageIndex: description: 页码 type: integer - page_size: + pageSize: description: 页条数 type: integer store_id: @@ -674,15 +674,18 @@ definitions: type: object models.ErpCashierListResp: properties: + count: + description: 数据总条数 + type: integer list: items: $ref: '#/definitions/models.ErpCashier' type: array - page_num: + pageIndex: + description: 页码 type: integer - page_size: - type: integer - total: + pageSize: + description: 每页展示条数 type: integer type: object models.ErpCategory: @@ -804,10 +807,10 @@ definitions: is_export: description: 1-导出 type: integer - page_num: + pageIndex: description: 页码 type: integer - page_size: + pageSize: description: 每页展示数据条数 type: integer serial_number: @@ -816,6 +819,9 @@ definitions: type: object models.ErpCommodityListResp: properties: + count: + description: 数据总条数 + type: integer export_url: description: 1-导出 type: string @@ -823,14 +829,11 @@ definitions: items: $ref: '#/definitions/models.ErpCommodity' type: array - page_num: + pageIndex: description: 页码 type: integer - page_size: - description: 每页展示数据条数 - type: integer - total: - description: 总页数 + pageSize: + description: 每页展示条数 type: integer type: object models.ErpStock: @@ -1001,12 +1004,12 @@ definitions: is_export: description: 是否导出excel:1-导出 type: integer - page_num: - description: 页面条数 - type: integer - page_size: + pageIndex: description: 页码 type: integer + pageSize: + description: 每页展示数据条数 + type: integer serial_number: description: 商品编号 type: string @@ -1034,17 +1037,20 @@ definitions: type: object models.ErpStockCommodityListResp: properties: + count: + description: 数据总条数 + type: integer export_url: type: string list: items: $ref: '#/definitions/models.ErpStockCommodity' type: array - page_num: + pageIndex: + description: 页码 type: integer - page_size: - type: integer - total: + pageSize: + description: 每页展示条数 type: integer type: object models.ErpStockListReq: @@ -1055,12 +1061,12 @@ definitions: erp_category_id: description: 商品分类 type: integer - page_num: - description: 页面条数 - type: integer - page_size: + pageIndex: description: 页码 type: integer + pageSize: + description: 页面条数 + type: integer serial_number: description: 商品编号 type: string @@ -1073,18 +1079,89 @@ definitions: type: object models.ErpStockListResp: properties: + count: + description: 数据总条数 + type: integer export_url: type: string list: items: $ref: '#/definitions/models.ErpStock' type: array - page_num: + pageIndex: + description: 页码 type: integer - page_size: + pageSize: + description: 每页展示条数 type: integer - total: + type: object + models.InsertSysUserReq: + properties: + account_type: + description: 账号类型:1-管理端 type: integer + avatar: + description: 头像 + type: string + cooperative_business_id: + description: 合作商id + type: integer + cooperative_name: + description: 合作商名称 + type: string + deptId: + description: 部门编码 + type: integer + email: + description: 邮箱 + type: string + nickName: + description: 昵称 + type: string + password: + description: 密码 + type: string + phone: + description: 手机号 + type: string + postId: + description: 职位编码 + type: integer + remark: + description: 备注 + type: string + roleId: + description: 角色编码 + type: integer + sales_comm_rate: + description: 销售提成比例 + type: string + salt: + description: 盐 + type: string + sex: + description: 性别 + type: string + status: + description: 状态 + type: string + store_id: + description: 门店id + type: integer + store_list: + description: 有效门店 + items: + $ref: '#/definitions/models.StoreInfo' + type: array + store_name: + description: 门店名称 + type: string + userId: + description: 编码 + type: integer + username: + description: 用户名 + type: string type: object models.Login: properties: @@ -1259,6 +1336,18 @@ definitions: description: 更新时间 type: string type: object + models.StoreInfo: + properties: + expireTime: + description: 有效期 + type: string + storeId: + description: 门店id + type: integer + storeName: + description: 门店名称 + type: string + type: object models.Supplier: properties: account_holder: @@ -1711,6 +1800,9 @@ definitions: roleId: description: 角色编码 type: integer + sales_comm_rate: + description: 销售提成比例 + type: number salt: description: 盐 type: string @@ -1720,9 +1812,17 @@ definitions: status: description: 状态 type: string + store_data: + description: 有效门店 + type: string store_id: description: 门店id type: integer + store_list: + description: 有效门店列表 + items: + $ref: '#/definitions/models.StoreInfo' + type: array store_name: description: 门店名称 type: string @@ -3863,13 +3963,13 @@ paths: name: data required: true schema: - $ref: '#/definitions/models.SysUser' + $ref: '#/definitions/models.InsertSysUserReq' responses: "200": description: '{"code": -1, "message": "添加失败"}' schema: type: string - summary: 创建用户 + summary: 创建用户(update) tags: - system/用户 /api/v1/sysUser/{userId}: @@ -3906,7 +4006,7 @@ paths: type: string security: - Bearer: [] - summary: 列表用户信息数据 + summary: 列表用户信息数据(update) tags: - system/用户 /api/v1/syscategory: @@ -4014,13 +4114,13 @@ paths: name: data required: true schema: - $ref: '#/definitions/models.SysUser' + $ref: '#/definitions/models.InsertSysUserReq' responses: "200": description: '{"code": -1, "message": "修改失败"}' schema: type: string - summary: 修改用户数据 + summary: 修改用户数据(update) tags: - system/用户 /api/v1/user/profile: diff --git a/test/stock_test.go b/test/stock_test.go index 7c9e149..86f1774 100644 --- a/test/stock_test.go +++ b/test/stock_test.go @@ -551,7 +551,7 @@ func CreateInviteMemberReportScript() { var cooperatives []models.CooperativeBusiness err := orm.Eloquent.Table("cooperative_business").Find(&cooperatives).Error if err != nil { - logger.Error("cooperative err:", err) + logger.Errorf("cooperative err:", err) return } for i, _ := range cooperatives { @@ -559,7 +559,7 @@ func CreateInviteMemberReportScript() { var users []models.UserInfo err := orm.Eloquent.Table("user").Where("cooperative_business_id=?", cooperatives[i].ID).Where("user_type=2").Find(&users).Error if err != nil { - logger.Error("cooperative err:", err) + logger.Errorf("cooperative err:", err) return } for j, _ := range users { @@ -573,7 +573,7 @@ func CreateInviteMemberReportScript() { qs = qs.Where("action=2").Where("spend_type=2") err = qs.Find(&userInvites).Error if err != nil && err != models.RecordNotFound { - logger.Error("cooperative err:", err) + logger.Errorf("cooperative err:", err) return } m := cooperatives[i] @@ -597,7 +597,7 @@ func CreateInviteMemberReportScript() { err := orm.Eloquent.Table("invite_member_report").Where("cooperative_business_id=?", userInfo.CooperativeBusinessId). Where("date=?", reportTime).Where("store_id=?", userInfo.StoreId).Where("uid=?", userInfo.Uid).Find(&reportSource).Error if err != nil { - logger.Error("err:", err) + logger.Errorf("err:", err) } report := &models.InviteMemberReport{ @@ -642,14 +642,14 @@ func CreateInviteMemberReportScript() { "updated_at": start, }).Error if err != nil { - logger.Error("err=?", err) + logger.Errorf("err=?", err) } } else { fmt.Println("不存在", report.Uid, report.GoldCount, report.PlatinumCount, report.BlackGoldCount) report.UpdatedAt = start err := orm.Eloquent.Create(report).Error if err != nil { - logger.Error("err=?", err) + logger.Errorf("err=?", err) } }