Browse Source

freature(销售区域): 销售区域授权后台接口实现

likai 2 years ago
parent
commit
01974698ae

+ 36 - 0
opms_admin/app/dao/base_region_auth.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package dao
+
+import (
+	"dashoo.cn/micro/app/dao/internal"
+)
+
+// baseRegionAuthDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type baseRegionAuthDao struct {
+	internal.BaseRegionAuthDao
+}
+
+var (
+	// BaseRegionAuth is globally public accessible object for table base_region_auth operations.
+	BaseRegionAuth = baseRegionAuthDao{
+		internal.BaseRegionAuth,
+	}
+)
+
+type BaseRegionAuthDao struct {
+	internal.BaseRegionAuthDao
+}
+
+func NewBaseRegionAuthDao(tenant string) *BaseRegionAuthDao {
+	dao := internal.NewBaseRegionAuthDao(tenant)
+	return &BaseRegionAuthDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 450 - 0
opms_admin/app/dao/internal/base_region_auth.go

@@ -0,0 +1,450 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"time"
+
+	"dashoo.cn/micro/app/model"
+)
+
+// BaseRegionAuthDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type BaseRegionAuthDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns baseRegionAuthColumns
+}
+
+// BaseRegionAuthColumns defines and stores column names for table base_region_auth.
+type baseRegionAuthColumns struct {
+	Id             string // 主键
+	UserId         string // 用户ID
+	UserName       string // 姓名
+	UserPost       string // 岗位
+	UserPhone      string // 电话
+	SaleRegionId   string // 销售区域ID
+	SaleRegionName string // 销售区域名称
+	ProvinceId     string // 省ID
+	ProvinceName   string // 省名称
+	CityId         string // 市ID
+	CityName       string // 市名称
+	Remark         string // 备注
+	CreatedBy      string // 创建者
+	CreatedName    string // 创建人
+	CreatedTime    string // 创建时间
+	UpdatedBy      string // 更新者
+	UpdatedName    string // 更新人
+	UpdatedTime    string // 更新时间
+	DeletedTime    string // 删除时间
+}
+
+var (
+	// BaseRegionAuth is globally public accessible object for table base_region_auth operations.
+	BaseRegionAuth = BaseRegionAuthDao{
+		M:     g.DB("default").Model("base_region_auth").Safe(),
+		DB:    g.DB("default"),
+		Table: "base_region_auth",
+		Columns: baseRegionAuthColumns{
+			Id:             "id",
+			UserId:         "user_id",
+			UserName:       "user_name",
+			UserPost:       "user_post",
+			UserPhone:      "user_phone",
+			SaleRegionId:   "sale_region_id",
+			SaleRegionName: "sale_region_name",
+			ProvinceId:     "province_id",
+			ProvinceName:   "province_name",
+			CityId:         "city_id",
+			CityName:       "city_name",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
+		},
+	}
+)
+
+func NewBaseRegionAuthDao(tenant string) BaseRegionAuthDao {
+	var dao BaseRegionAuthDao
+	dao = BaseRegionAuthDao{
+		M:     g.DB(tenant).Model("base_region_auth").Safe(),
+		DB:    g.DB(tenant),
+		Table: "base_region_auth",
+		Columns: baseRegionAuthColumns{
+			Id:             "id",
+			UserId:         "user_id",
+			UserName:       "user_name",
+			UserPost:       "user_post",
+			UserPhone:      "user_phone",
+			SaleRegionId:   "sale_region_id",
+			SaleRegionName: "sale_region_name",
+			ProvinceId:     "province_id",
+			ProvinceName:   "province_name",
+			CityId:         "city_id",
+			CityName:       "city_name",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *BaseRegionAuthDao) Ctx(ctx context.Context) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *BaseRegionAuthDao) As(as string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *BaseRegionAuthDao) TX(tx *gdb.TX) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *BaseRegionAuthDao) Master() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *BaseRegionAuthDao) Slave() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *BaseRegionAuthDao) Args(args ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *BaseRegionAuthDao) LeftJoin(table ...string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *BaseRegionAuthDao) RightJoin(table ...string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *BaseRegionAuthDao) InnerJoin(table ...string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *BaseRegionAuthDao) Fields(fieldNamesOrMapStruct ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *BaseRegionAuthDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *BaseRegionAuthDao) Option(option int) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *BaseRegionAuthDao) OmitEmpty() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *BaseRegionAuthDao) Filter() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *BaseRegionAuthDao) Where(where interface{}, args ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *BaseRegionAuthDao) WherePri(where interface{}, args ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *BaseRegionAuthDao) And(where interface{}, args ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *BaseRegionAuthDao) Or(where interface{}, args ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *BaseRegionAuthDao) Group(groupBy string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *BaseRegionAuthDao) Order(orderBy ...string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *BaseRegionAuthDao) Limit(limit ...int) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *BaseRegionAuthDao) Offset(offset int) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *BaseRegionAuthDao) Page(page, limit int) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *BaseRegionAuthDao) Batch(batch int) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *BaseRegionAuthDao) Cache(duration time.Duration, name ...string) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *BaseRegionAuthDao) Data(data ...interface{}) *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.BaseRegionAuth.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *BaseRegionAuthDao) All(where ...interface{}) ([]*model.BaseRegionAuth, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.BaseRegionAuth
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.BaseRegionAuth.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *BaseRegionAuthDao) One(where ...interface{}) (*model.BaseRegionAuth, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.BaseRegionAuth
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *BaseRegionAuthDao) FindOne(where ...interface{}) (*model.BaseRegionAuth, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.BaseRegionAuth
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *BaseRegionAuthDao) FindAll(where ...interface{}) ([]*model.BaseRegionAuth, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.BaseRegionAuth
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *BaseRegionAuthDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *BaseRegionAuthDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *BaseRegionAuthDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *BaseRegionAuthDao) Chunk(limit int, callback func(entities []*model.BaseRegionAuth, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.BaseRegionAuth
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *BaseRegionAuthDao) LockUpdate() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *BaseRegionAuthDao) LockShared() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *BaseRegionAuthDao) Unscoped() *BaseRegionAuthDao {
+	return &BaseRegionAuthDao{M: d.M.Unscoped()}
+}

+ 2 - 2
opms_admin/app/handler/base_product_auth.go

@@ -20,11 +20,11 @@ func (h *BaseProductAuthHandler) GetList(ctx context.Context, req *model.BasePro
 		g.Log().Error(err)
 		return errors.New("系统异常,请重新尝试")
 	}
-	total, list, err := lineService.GetList(req)
+	list, err := lineService.GetList(req)
 	if err != nil {
 		return err
 	}
-	rsp.Data = g.Map{"list": list, "total": total}
+	rsp.Data = g.Map{"list": list}
 	return nil
 }
 

+ 64 - 0
opms_admin/app/handler/base_region_auth.go

@@ -0,0 +1,64 @@
+package handler
+
+import (
+	"context"
+	"errors"
+	"github.com/gogf/gf/util/gvalid"
+
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/micro/app/model"
+	"dashoo.cn/micro/app/service"
+	"github.com/gogf/gf/frame/g"
+)
+
+type BaseRegionAuthHandler struct{}
+
+// GetList 获取列表
+func (h *BaseRegionAuthHandler) GetList(ctx context.Context, req *model.BaseRegionAuthSearchReq, rsp *comm_def.CommonMsg) error {
+	regionService, err := service.NewRegionService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return errors.New("系统异常,请重新尝试")
+	}
+	list, err := regionService.GetList(req)
+	if err != nil {
+		return err
+	}
+	rsp.Data = g.Map{"list": list}
+	return nil
+}
+
+// Save 保存数据
+func (h *BaseRegionAuthHandler) Save(ctx context.Context, req *model.SaveBaseRegionAuthReq, rsp *comm_def.CommonMsg) (err error) {
+	// 检查请求参数
+	if v := gvalid.CheckStruct(ctx, req, nil); v != nil {
+		return v
+	}
+	// 检查列表数据
+	for _, region := range req.Regions {
+		if v := gvalid.CheckStruct(ctx, region, nil); v != nil {
+			return v
+		}
+	}
+	regionService, err := service.NewRegionService(ctx)
+	if err != nil {
+		return err
+	}
+	err = regionService.Save(req)
+	return err
+}
+
+// GetRegionUsers 获取列表
+func (h *BaseRegionAuthHandler) GetRegionUsers(ctx context.Context, req *model.SysUserSearchReq, rsp *comm_def.CommonMsg) error {
+	regionService, err := service.NewRegionService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return errors.New("系统异常,请重新尝试")
+	}
+	total, list, err := regionService.GetRegionUsers(req)
+	if err != nil {
+		return err
+	}
+	rsp.Data = g.Map{"list": list, "total": total}
+	return nil
+}

+ 17 - 7
opms_admin/app/model/base_product_auth.go

@@ -14,7 +14,17 @@ type BaseProductAuth internal.BaseProductAuth
 
 // Fill with you ideas below.
 
-// BaseProductAuthSearchReq 产品线受权查询
+// ReturnBaseProductAuth 返回前端的数据
+type ReturnBaseProductAuth struct {
+	UserId      int    `orm:"user_id"      json:"userId"`      // 用户ID
+	UserName    string `orm:"user_name"    json:"userName"`    // 用户姓名
+	UserPost    string `orm:"user_post"    json:"userPost"`    // 岗位
+	UserPhone   string `orm:"user_phone"   json:"userPhone"`   // 电话
+	ProductCode string `orm:"product_code" json:"productCode"` // 产品线编码
+	ProductName string `orm:"product_name" json:"productName"` // 产品线名称
+}
+
+// BaseProductAuthSearchReq 产品线授权查询
 type BaseProductAuthSearchReq struct {
 	UserId      int    `orm:"user_id"      json:"userId"`      // 用户ID
 	UserName    string `orm:"user_name"    json:"userName"`    // 用户姓名
@@ -27,16 +37,16 @@ type BaseProductAuthSearchReq struct {
 
 // SaveBaseProductAuthReq 产品线更新
 type SaveBaseProductAuthReq struct {
-	UserId    int            `orm:"user_id"      json:"userId"      v:"required|min:1#用户ID不能为空|用户ID不能为空"` // 用户ID
-	UserName  string         `orm:"user_name"    json:"userName"    v:"required#用户姓名不能为空"`                    // 用户姓名
-	UserPost  string         `orm:"user_post"    json:"userPost"`                                                     // 岗位
-	UserPhone string         `orm:"user_phone"   json:"userPhone"`                                                    // 电话
-	Lines     []*ProductLine `json:"lines"    v:"required#产品线不能为空"`
+	UserId    int            `orm:"user_id"    json:"userId"      v:"required|min:1#用户ID不能为空|用户ID不能为空"` // 用户ID
+	UserName  string         `orm:"user_name"  json:"userName"    v:"required#用户姓名不能为空"`                // 用户姓名
+	UserPost  string         `orm:"user_post"  json:"userPost"`                                         // 岗位
+	UserPhone string         `orm:"user_phone" json:"userPhone"`                                        // 电话
+	Lines     []*ProductLine `json:"lines"     v:"required#产品线不能为空"`
 }
 
 // ProductLine 产品线
 type ProductLine struct {
 	ProductCode string `orm:"product_code" json:"productCode" v:"required#产品线编码不能为空"` // 产品线编码
 	ProductName string `orm:"product_name" json:"productName" v:"required#产品线名称不能为空"` // 产品线名称
-	Remark      string `orm:"remark"       json:"remark"`                                      // 备注
+	Remark      string `orm:"remark"       json:"remark"`                             // 备注
 }

+ 63 - 0
opms_admin/app/model/base_region_auth.go

@@ -0,0 +1,63 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package model
+
+import (
+	"dashoo.cn/micro/app/model/internal"
+)
+
+// BaseRegionAuth is the golang structure for table base_region_auth.
+type BaseRegionAuth internal.BaseRegionAuth
+
+// Fill with you ideas below.
+
+// ReturnBaseRegionAuth 返回前端的数据
+type ReturnBaseRegionAuth struct {
+	UserId         int    `orm:"user_id"          json:"userId"`         // 用户ID
+	UserName       string `orm:"user_name"        json:"userName"`       // 姓名
+	UserPost       string `orm:"user_post"        json:"userPost"`       // 岗位
+	UserPhone      string `orm:"user_phone"       json:"userPhone"`      // 电话
+	SaleRegionId   string `orm:"sale_region_id"   json:"saleRegionId"`   // 销售区域ID
+	SaleRegionName string `orm:"sale_region_name" json:"saleRegionName"` // 销售区域名称
+	ProvinceId     string `orm:"province_id"      json:"provinceId"`     // 省ID
+	ProvinceName   string `orm:"province_name"    json:"provinceName"`   // 省名称
+	CityId         string `orm:"city_id"          json:"cityId"`         // 市ID
+	CityName       string `orm:"city_name"        json:"cityName"`       // 市名称
+	RegionInfo     string `json:"regionInfo"`                            // 显示区域信息
+}
+
+// BaseRegionAuthSearchReq 销售区域授权查询
+type BaseRegionAuthSearchReq struct {
+	UserId         int    `orm:"user_id"          json:"userId"`         // 用户ID
+	UserName       string `orm:"user_name"        json:"userName"`       // 用户姓名
+	UserPost       string `orm:"user_post"        json:"userPost"`       // 岗位
+	UserPhone      string `orm:"user_phone"       json:"userPhone"`      // 电话
+	SaleRegionId   int    `orm:"sale_region_id"   json:"saleRegionId"`   // 销售区域ID
+	SaleRegionName string `orm:"sale_region_name" json:"saleRegionName"` // 销售区域名称
+	ProvinceId     int    `orm:"province_id"      json:"provinceId"`     // 省ID
+	ProvinceName   string `orm:"province_name"    json:"provinceName"`   // 省名称
+	CityId         int    `orm:"city_id"          json:"cityId"`         // 市ID
+	CityName       string `orm:"city_name"        json:"cityName"`       // 市名称
+}
+
+// SaveBaseRegionAuthReq 销售区域线更新
+type SaveBaseRegionAuthReq struct {
+	SaleRegionId   int       `orm:"sale_region_id"   json:"saleRegionId"   v:"required|min:1#销售区域ID不能为空|销售区域ID不能为空"` // 销售区域ID
+	SaleRegionName string    `orm:"sale_region_name" json:"saleRegionName" v:"required#销售区域名称不能为空"`                  // 销售区域名称
+	UserId         int       `orm:"user_id"          json:"userId"         v:"required|min:1#用户ID不能为空|用户ID不能为空"`     // 用户ID
+	UserName       string    `orm:"user_name"        json:"userName"       v:"required#用户姓名不能为空"`                    // 用户姓名
+	UserPost       string    `orm:"user_post"        json:"userPost"`                                                // 岗位
+	UserPhone      string    `orm:"user_phone"       json:"userPhone"`                                               // 电话
+	Regions        []*Region `json:"regions"`
+}
+
+// Region 销售区域
+type Region struct {
+	ProvinceId   int    `orm:"province_id"      json:"provinceId" v:"required|min:1#省ID不能为空|省ID不能为空"` // 省ID
+	ProvinceName string `orm:"province_name"    json:"provinceName" v:"required#省名称不能为空"`             // 省名称
+	CityId       int    `orm:"city_id"          json:"cityId" v:"required|min:1#市ID不能为空|市ID不能为空"`     // 市ID
+	CityName     string `orm:"city_name"        json:"cityName" v:"required#市名称不能为空"`                 // 市名称
+	Remark       string `orm:"remark"           json:"remark"`                                        // 备注
+}

+ 32 - 0
opms_admin/app/model/internal/base_region_auth.go

@@ -0,0 +1,32 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// BaseRegionAuth is the golang structure for table base_region_auth.
+type BaseRegionAuth struct {
+	Id             int         `orm:"id,primary"       json:"id"`             // 主键
+	UserId         int         `orm:"user_id"          json:"userId"`         // 用户ID
+	UserName       string      `orm:"user_name"        json:"userName"`       // 姓名
+	UserPost       string      `orm:"user_post"        json:"userPost"`       // 岗位
+	UserPhone      string      `orm:"user_phone"       json:"userPhone"`      // 电话
+	SaleRegionId   int         `orm:"sale_region_id"   json:"saleRegionId"`   // 销售区域ID
+	SaleRegionName string      `orm:"sale_region_name" json:"saleRegionName"` // 销售区域名称
+	ProvinceId     int         `orm:"province_id"      json:"provinceId"`     // 省ID
+	ProvinceName   string      `orm:"province_name"    json:"provinceName"`   // 省名称
+	CityId         int         `orm:"city_id"          json:"cityId"`         // 市ID
+	CityName       string      `orm:"city_name"        json:"cityName"`       // 市名称
+	Remark         string      `orm:"remark"           json:"remark"`         // 备注
+	CreatedBy      int         `orm:"created_by"       json:"createdBy"`      // 创建者
+	CreatedName    string      `orm:"created_name"     json:"createdName"`    // 创建人
+	CreatedTime    *gtime.Time `orm:"created_time"     json:"createdTime"`    // 创建时间
+	UpdatedBy      int         `orm:"updated_by"       json:"updatedBy"`      // 更新者
+	UpdatedName    string      `orm:"updated_name"     json:"updatedName"`    // 更新人
+	UpdatedTime    *gtime.Time `orm:"updated_time"     json:"updatedTime"`    // 更新时间
+	DeletedTime    *gtime.Time `orm:"deleted_time"     json:"deletedTime"`    // 删除时间
+}

+ 3 - 9
opms_admin/app/service/base_product_auth.go

@@ -28,7 +28,7 @@ func NewLineService(ctx context.Context) (svc *lineService, err error) {
 }
 
 // GetList 用户产品线列表
-func (s *lineService) GetList(req *model.BaseProductAuthSearchReq) (total int, lines []*model.BaseProductAuth, err error) {
+func (s *lineService) GetList(req *model.BaseProductAuthSearchReq) (lines []*model.BaseProductAuth, err error) {
 	lineModel := s.Dao.M
 	if req.UserId != 0 {
 		lineModel = lineModel.Where("user_id", req.UserId)
@@ -49,12 +49,6 @@ func (s *lineService) GetList(req *model.BaseProductAuthSearchReq) (total int, l
 		lineModel = lineModel.Where("product_name", req.ProductName)
 	}
 
-	total, err = lineModel.Count()
-	if err != nil {
-		g.Log().Error(err)
-		err = gerror.New("获取总行数失败")
-	}
-
 	err = lineModel.Order("id ASC").Scan(&lines)
 	if err != nil {
 		g.Log().Error(err)
@@ -96,7 +90,7 @@ func (s *lineService) Save(req *model.SaveBaseProductAuthReq) (err error) {
 	return
 }
 
-func (s *lineService) GetProductLineUsers(req *model.SysUserSearchReq) (total int, lines []*model.BaseProductAuth, err error) {
+func (s *lineService) GetProductLineUsers(req *model.SysUserSearchReq) (total int, lines []*model.ReturnBaseProductAuth, err error) {
 	userService, err := NewUserService(s.Ctx)
 	if err != nil {
 		return 0, nil, err
@@ -117,7 +111,7 @@ func (s *lineService) GetProductLineUsers(req *model.SysUserSearchReq) (total in
 		return 0, nil, err
 	}
 	for _, user := range users {
-		var data model.BaseProductAuth
+		var data model.ReturnBaseProductAuth
 		data.UserId = user.Id
 		data.UserName = user.NickName
 		data.UserPost = "" // TODO 暂时为空

+ 187 - 0
opms_admin/app/service/base_region_auth.go

@@ -0,0 +1,187 @@
+package service
+
+import (
+	"context"
+	"dashoo.cn/micro/app/dao"
+	"dashoo.cn/micro/app/model"
+	"database/sql"
+	"fmt"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gconv"
+)
+
+type regionService struct {
+	*contextService
+
+	Dao *dao.BaseRegionAuthDao
+}
+
+func NewRegionService(ctx context.Context) (svc *regionService, err error) {
+	svc = new(regionService)
+	if svc.contextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = dao.NewBaseRegionAuthDao(svc.Tenant)
+	svc.Table = svc.Dao.Table
+	return svc, nil
+}
+
+// GetList 用户产品线列表
+func (s *regionService) GetList(req *model.BaseRegionAuthSearchReq) (regions []*model.BaseRegionAuth, err error) {
+	regionModel := s.Dao.M
+	if req.UserId != 0 {
+		regionModel = regionModel.Where("user_id", req.UserId)
+	}
+	if req.UserName != "" {
+		regionModel = regionModel.Where("user_name", req.UserName)
+	}
+	if req.UserPost != "" {
+		regionModel = regionModel.Where("user_post", req.UserPost)
+	}
+	if req.UserPhone != "" {
+		regionModel = regionModel.Where("user_phone", req.UserPhone)
+	}
+	if req.SaleRegionId != 0 {
+		regionModel = regionModel.Where("sale_region_id", req.SaleRegionId)
+	}
+	if req.SaleRegionName != "" {
+		regionModel = regionModel.Where("sale_region_name", req.SaleRegionName)
+	}
+	if req.ProvinceId != 0 {
+		regionModel = regionModel.Where("province_id", req.ProvinceId)
+	}
+	if req.ProvinceName != "" {
+		regionModel = regionModel.Where("province_name", req.ProvinceName)
+	}
+	if req.CityId != 0 {
+		regionModel = regionModel.Where("city_id", req.CityId)
+	}
+	if req.CityName != "" {
+		regionModel = regionModel.Where("city_name", req.CityName)
+	}
+
+	err = regionModel.Order("id ASC").Scan(&regions)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取数据失败")
+	}
+	return
+}
+
+// Save 创建或更新数据
+func (s *regionService) Save(req *model.SaveBaseRegionAuthReq) (err error) {
+	var newRegions []*model.BaseRegionAuth
+
+	// 标记删除旧数据
+	oldRegions, err := s.Dao.Where(fmt.Sprintf("user_id='%v' AND sale_region_id='%v'", req.UserId, req.SaleRegionId)).FindAll()
+	if err != nil {
+		return err
+	}
+
+	// 填入新数据
+	for _, region := range req.Regions {
+		isNew := true
+		for _, old := range oldRegions {
+			if region.ProvinceId == old.ProvinceId && region.CityId == old.CityId {
+				isNew = false
+				break
+			}
+		}
+		if isNew {
+			data := &model.BaseRegionAuth{
+				UserId:         req.UserId,
+				UserName:       req.UserName,
+				UserPhone:      req.UserPhone,
+				UserPost:       req.UserPost,
+				SaleRegionId:   req.SaleRegionId,
+				SaleRegionName: req.SaleRegionName,
+				ProvinceId:     region.ProvinceId,
+				ProvinceName:   region.ProvinceName,
+				CityId:         region.CityId,
+				CityName:       region.CityName,
+				Remark:         region.Remark,
+			}
+			SetCreatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
+			SetUpdatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
+
+			newRegions = append(newRegions, data)
+		}
+	}
+	// 标记删除旧数据
+	for index, old := range oldRegions {
+		isDelete := true
+		for _, region := range req.Regions {
+			if region.ProvinceId == old.ProvinceId && region.CityId == old.CityId {
+				isDelete = false
+				break
+			}
+		}
+		if isDelete {
+			// 标记删除
+			oldRegions[index].DeletedTime = gtime.Now()
+			// 将删除数据存入切片中
+			newRegions = append(newRegions, oldRegions[index])
+		}
+	}
+	if len(newRegions) > 0 {
+		_, err = s.Dao.Save(newRegions)
+	}
+
+	return
+}
+
+func (s *regionService) GetRegionUsers(req *model.SysUserSearchReq) (total int, regions []*model.ReturnBaseRegionAuth, err error) {
+	userService, err := NewUserService(s.Ctx)
+	if err != nil {
+		return 0, nil, err
+	}
+
+	total, users, err := userService.GetUsersByDeptEx(req)
+	if err != nil {
+		return 0, nil, err
+	}
+
+	var userIds []int
+	for _, user := range users {
+		userIds = append(userIds, user.Id)
+	}
+
+	allRegions, err := s.Dao.Where("user_id IN (?)", userIds).Order("user_id ASC, id ASC").FindAll()
+	if err != nil && err != sql.ErrNoRows {
+		return 0, nil, err
+	}
+	for _, user := range users {
+		var data model.ReturnBaseRegionAuth
+		data.UserId = user.Id
+		data.UserName = user.NickName
+		data.UserPost = "" // TODO 暂时为空
+		data.UserPhone = user.Phone
+		for _, region := range allRegions {
+			if user.Id == region.UserId {
+				if data.RegionInfo == "" {
+					data.SaleRegionId = gconv.String(region.SaleRegionId)
+					data.SaleRegionName = region.SaleRegionName
+					data.ProvinceId = gconv.String(region.ProvinceId)
+					data.ProvinceName = region.ProvinceName
+					data.CityId = gconv.String(region.CityId)
+					data.CityName = region.CityName
+					data.RegionInfo = region.SaleRegionName + "-" + region.ProvinceName + "-" + region.CityName
+				} else {
+					data.SaleRegionId += "," + gconv.String(region.SaleRegionId)
+					data.SaleRegionName += "," + region.SaleRegionName
+					data.ProvinceId += "," + gconv.String(region.ProvinceId)
+					data.ProvinceName += "," + region.ProvinceName
+					data.CityId += "," + gconv.String(region.CityId)
+					data.CityName += "," + region.CityName
+					data.RegionInfo += region.SaleRegionName + "-" + region.ProvinceName + "-" + region.CityName
+				}
+			}
+		}
+
+		regions = append(regions, &data)
+	}
+
+	return
+}

+ 1 - 0
opms_admin/main.go

@@ -26,6 +26,7 @@ func main() {
 	s.RegisterName("LoginLog", new(handler.LoginLogHandler), "")
 	s.RegisterName("Config", new(handler.ConfigHandler), "")
 	s.RegisterName("BaseProductAuth", new(handler.BaseProductAuthHandler), "")
+	s.RegisterName("BaseRegionAuth", new(handler.BaseRegionAuthHandler), "")
 
 	// 注册文件处理Service对象
 	//dynamic.BeanFactory.BeanRegister(service.NewRoleService())

+ 42 - 36
opms_parent/app/dao/base/internal/base_sales_region_detail.go

@@ -27,18 +27,20 @@ type BaseSalesRegionDetailDao struct {
 
 // BaseSalesRegionDetailColumns defines and stores column names for table base_sales_region_detail.
 type baseSalesRegionDetailColumns struct {
-	Id          string // 主键
-	RegionId    string // 关联销售区域
-	DistId      string // 行政区县ID
-	DistName    string // 行政区县名称
-	Remark      string // 备注
-	CreatedBy   string // 创建者
-	CreatedName string // 创建人
-	CreatedTime string // 创建时间
-	UpdatedBy   string // 更新者
-	UpdatedName string // 更新人
-	UpdatedTime string // 更新时间
-	DeletedTime string // 删除时间
+	Id             string // 主键
+	RegionId       string // 关联销售区域
+	CustProvinceId string // 所在省ID
+	CustProvince   string // 所在省
+	CustCityId     string // 所在市ID
+	CustCity       string // 所在市
+	Remark         string // 备注
+	CreatedBy      string // 创建者
+	CreatedName    string // 创建人
+	CreatedTime    string // 创建时间
+	UpdatedBy      string // 更新者
+	UpdatedName    string // 更新人
+	UpdatedTime    string // 更新时间
+	DeletedTime    string // 删除时间
 }
 
 var (
@@ -48,18 +50,20 @@ var (
 		DB:    g.DB("default"),
 		Table: "base_sales_region_detail",
 		Columns: baseSalesRegionDetailColumns{
-			Id:          "id",
-			RegionId:    "region_id",
-			DistId:      "dist_id",
-			DistName:    "dist_name",
-			Remark:      "remark",
-			CreatedBy:   "created_by",
-			CreatedName: "created_name",
-			CreatedTime: "created_time",
-			UpdatedBy:   "updated_by",
-			UpdatedName: "updated_name",
-			UpdatedTime: "updated_time",
-			DeletedTime: "deleted_time",
+			Id:             "id",
+			RegionId:       "region_id",
+			CustProvinceId: "cust_province_id",
+			CustProvince:   "cust_province",
+			CustCityId:     "cust_city_id",
+			CustCity:       "cust_city",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
 		},
 	}
 )
@@ -71,18 +75,20 @@ func NewBaseSalesRegionDetailDao(tenant string) BaseSalesRegionDetailDao {
 		DB:    g.DB(tenant),
 		Table: "base_sales_region_detail",
 		Columns: baseSalesRegionDetailColumns{
-			Id:          "id",
-			RegionId:    "region_id",
-			DistId:      "dist_id",
-			DistName:    "dist_name",
-			Remark:      "remark",
-			CreatedBy:   "created_by",
-			CreatedName: "created_name",
-			CreatedTime: "created_time",
-			UpdatedBy:   "updated_by",
-			UpdatedName: "updated_name",
-			UpdatedTime: "updated_time",
-			DeletedTime: "deleted_time",
+			Id:             "id",
+			RegionId:       "region_id",
+			CustProvinceId: "cust_province_id",
+			CustProvince:   "cust_province",
+			CustCityId:     "cust_city_id",
+			CustCity:       "cust_city",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
 		},
 	}
 	return dao

+ 20 - 17
opms_parent/app/model/base/base_sales_region_detail.go

@@ -15,7 +15,7 @@ type BaseSalesRegionDetail internal.BaseSalesRegionDetail
 
 // Fill with you ideas below.
 
-// 条件搜索
+// SecBaseRegionDetailReq 条件搜索
 type SecBaseRegionDetailReq struct {
 	RegionId     int    `p:"regionId"    json:"regionId"`
 	CustCode     string `p:"custCode"    json:"custCode"`
@@ -24,28 +24,31 @@ type SecBaseRegionDetailReq struct {
 	request.PageReq
 }
 
-// 创建区域
+// AddBaseRegionDetailReq 创建区域
 type AddBaseRegionDetailReq struct {
-	RegionId int    `p:"regionId"        json:"regionId"   v:"required#关联销售区域"`
-	DistId   int    `json:"distId"  v:"required#区域编码不能为空"`   // 行政区县ID
-	DistName string `json:"distName"  v:"required#区域名称不能为空"` // 行政区县名称
-	Remark   string
+	RegionId       int    `p:"regionId"        json:"regionId"   v:"required|min:1#关联销售区域不能为空|关联销售区域不能为空"`
+	CustProvinceId int    `json:"custProvinceId"  v:"required|min:1#所在省ID不能为空|所在省ID不能为空"` // 所在省ID
+	CustProvince   string `json:"custProvince"  v:"required#所在省不能为空"`                     // 所在省
+	CustCityId     int    `json:"custCityId"  v:"required|min:1#所在市ID不能为空|所在市ID不能为空"`     // 所在市ID
+	CustCity       string `json:"custCity"  v:"required#所在市不能为空"`                         // 所在市
+	Remark         string
 }
 
-// 列表字段
+// BaseRegionDetailRep 列表字段
 type BaseRegionDetailRep struct {
-	Id          int        `p:"id"         json:"id"   `
-	RegionId    int        `p:"regionId"         json:"regionId"   `
-	DistId      int        `p:"distId"    json:"distId" `
-	DistName    string     `p:"distName"    json:"distName" `
-	Count       int        `p:"count"    json:"count" `
-	Remark      string     `p:"remark"    json:"remark" `
-	CreatedName string     `p:"createdName"    json:"createdName" `
-	CreatedTime gtime.Time `p:"createdTime"    json:"createdTime" `
+	Id             int        `p:"id"         json:"id"   `
+	RegionId       int        `p:"regionId"         json:"regionId"   `
+	CustProvinceId int        `p:"custProvinceId"    json:"custProvinceId" `
+	CustProvince   string     `p:"custProvince"    json:"custProvince" `
+	CustCityId     int        `p:"custCityId"    json:"custCityId" `
+	CustCity       string     `p:"custCity"    json:"custCity" `
+	Count          int        `p:"count"    json:"count" `
+	Remark         string     `p:"remark"    json:"remark" `
+	CreatedName    string     `p:"createdName"    json:"createdName" `
+	CreatedTime    gtime.Time `p:"createdTime"    json:"createdTime" `
 }
 
-//更新
-
+// UpdateBaseRegionDetailReq 更新
 type UpdateBaseRegionDetailReq struct {
 	*BaseSalesRegionDetail
 	Id int `p:"id"  json:"id" v:"required# id不能为空"`

+ 14 - 12
opms_parent/app/model/base/internal/base_sales_region_detail.go

@@ -10,16 +10,18 @@ import (
 
 // BaseSalesRegionDetail is the golang structure for table base_sales_region_detail.
 type BaseSalesRegionDetail struct {
-	Id          int         `orm:"id,primary"   json:"id"`          // 主键
-	RegionId    int         `orm:"region_id"    json:"regionId"`    // 关联销售区域
-	DistId      int         `orm:"dist_id"      json:"distId"`      // 行政区县ID
-	DistName    string      `orm:"dist_name"    json:"distName"`    // 行政区县名称
-	Remark      string      `orm:"remark"       json:"remark"`      // 备注
-	CreatedBy   int         `orm:"created_by"   json:"createdBy"`   // 创建者
-	CreatedName string      `orm:"created_name" json:"createdName"` // 创建人
-	CreatedTime *gtime.Time `orm:"created_time" json:"createdTime"` // 创建时间
-	UpdatedBy   int         `orm:"updated_by"   json:"updatedBy"`   // 更新者
-	UpdatedName string      `orm:"updated_name" json:"updatedName"` // 更新人
-	UpdatedTime *gtime.Time `orm:"updated_time" json:"updatedTime"` // 更新时间
-	DeletedTime *gtime.Time `orm:"deleted_time" json:"deletedTime"` // 删除时间
+	Id             int         `orm:"id,primary"       json:"id"`             // 主键
+	RegionId       int         `orm:"region_id"        json:"regionId"`       // 关联销售区域
+	CustProvinceId int         `orm:"cust_province_id" json:"custProvinceId"` // 所在省ID
+	CustProvince   string      `orm:"cust_province"    json:"custProvince"`   // 所在省
+	CustCityId     int         `orm:"cust_city_id"     json:"custCityId"`     // 所在市ID
+	CustCity       string      `orm:"cust_city"        json:"custCity"`       // 所在市
+	Remark         string      `orm:"remark"           json:"remark"`         // 备注
+	CreatedBy      int         `orm:"created_by"       json:"createdBy"`      // 创建者
+	CreatedName    string      `orm:"created_name"     json:"createdName"`    // 创建人
+	CreatedTime    *gtime.Time `orm:"created_time"     json:"createdTime"`    // 创建时间
+	UpdatedBy      int         `orm:"updated_by"       json:"updatedBy"`      // 更新者
+	UpdatedName    string      `orm:"updated_name"     json:"updatedName"`    // 更新人
+	UpdatedTime    *gtime.Time `orm:"updated_time"     json:"updatedTime"`    // 更新时间
+	DeletedTime    *gtime.Time `orm:"deleted_time"     json:"deletedTime"`    // 删除时间
 }

+ 1 - 1
opms_parent/app/service/base/base_sales_region.go

@@ -66,7 +66,7 @@ func (s *salesRegionService) GetRegionTree() (regionList []*model.Region, err er
 	}
 	detailDao := base.NewBaseSalesRegionDetailDao(s.Tenant)
 	regionDetailsList := ([]*model.District)(nil)
-	err = detailDao.Fields("region_id, dist_id as regionCode, dist_name as regionDesc").
+	err = detailDao.Fields("region_id, cust_province_id as regionCode, cust_province as regionDesc").Group("cust_province_id").
 		OrderAsc(detailDao.Columns.RegionId).Scan(&regionDetailsList)
 	if err != nil {
 		return

+ 2 - 2
opms_parent/app/service/base/base_sales_region_detail.go

@@ -44,7 +44,7 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 	}
 	var districtList []int
 	for _, v := range RegionList {
-		districtList = append(districtList, v.DistId)
+		districtList = append(districtList, v.CustProvinceId)
 	}
 	//CustModel := p.CustomerDao.M
 	CustModel := s.CustomerDao.M.Fields("count(*) as count,cust_dist_code").Where("cust_dist_code in (?)", districtList)
@@ -62,7 +62,7 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 
 	for _, v := range RegionList {
 		for _, v3 := range custDist {
-			if v.DistId == gconv.Int(v3["cust_dist_code"]) {
+			if v.CustProvinceId == gconv.Int(v3["cust_dist_code"]) {
 				v.Count = gconv.Int(v3["count"])
 			}
 		}