正在显示
16 个修改的文件
包含
417 行增加
和
0 行删除
pkg/application/company/company.go
0 → 100644
| 1 | +package company | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/tiptok/gocomm/pkg/log" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | ||
| 9 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company" | ||
| 10 | + "strings" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest) (rsp *protocolx.PropertyResponse, err error) { | ||
| 14 | + var ( | ||
| 15 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 16 | + ) | ||
| 17 | + rsp = &protocolx.PropertyResponse{} | ||
| 18 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 19 | + log.Error(err) | ||
| 20 | + return nil, err | ||
| 21 | + } | ||
| 22 | + defer func() { | ||
| 23 | + transactionContext.RollbackTransaction() | ||
| 24 | + }() | ||
| 25 | + | ||
| 26 | + //用户查询区域 | ||
| 27 | + if (request.Action & 0x01) > 0 { | ||
| 28 | + rsp.Districts, _ = getDistricts(header.UserId, transactionContext) | ||
| 29 | + } | ||
| 30 | + //查询合伙人类型 | ||
| 31 | + if (request.Action & 0x02) > 0 { | ||
| 32 | + rsp.JoinWays, _ = getJoinWays(transactionContext) | ||
| 33 | + } | ||
| 34 | + err = transactionContext.CommitTransaction() | ||
| 35 | + return | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +func Partners(header *protocol.RequestHeader, request *protocolx.PartnersRequest) (rsp *protocolx.PartnersResponse, err error) { | ||
| 39 | + var ( | ||
| 40 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 41 | + ) | ||
| 42 | + rsp = &protocolx.PartnersResponse{} | ||
| 43 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 44 | + log.Error(err) | ||
| 45 | + return nil, err | ||
| 46 | + } | ||
| 47 | + defer func() { | ||
| 48 | + transactionContext.RollbackTransaction() | ||
| 49 | + }() | ||
| 50 | + | ||
| 51 | + err = transactionContext.CommitTransaction() | ||
| 52 | + return | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +func Statistics(header *protocol.RequestHeader, request *protocolx.StatisticsRequest) (rsp *protocolx.StatisticsResponse, err error) { | ||
| 56 | + var ( | ||
| 57 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 58 | + ) | ||
| 59 | + rsp = &protocolx.StatisticsResponse{} | ||
| 60 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 61 | + log.Error(err) | ||
| 62 | + return nil, err | ||
| 63 | + } | ||
| 64 | + defer func() { | ||
| 65 | + transactionContext.RollbackTransaction() | ||
| 66 | + }() | ||
| 67 | + | ||
| 68 | + err = transactionContext.CommitTransaction() | ||
| 69 | + return | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +// 获取区域列表 | ||
| 73 | +func getDistricts(userId int64, transactionContext *transaction.TransactionContext) (districts []protocolx.Districts, err error) { | ||
| 74 | + var ( | ||
| 75 | + user *domain.Users | ||
| 76 | + partnerInfos []*domain.PartnerInfo | ||
| 77 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
| 78 | + PartnerInfoRepository, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | ||
| 79 | + ) | ||
| 80 | + if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil { | ||
| 81 | + log.Error(err) | ||
| 82 | + return | ||
| 83 | + } | ||
| 84 | + if user == nil || len(user.AccessPartners) == 0 { | ||
| 85 | + return | ||
| 86 | + } | ||
| 87 | + if _, partnerInfos, err = PartnerInfoRepository.Find(map[string]interface{}{ | ||
| 88 | + "inPartnerIds": user.AccessPartnerIds(), | ||
| 89 | + "sortByCreateTime": domain.ASC}, | ||
| 90 | + ); err != nil { | ||
| 91 | + return | ||
| 92 | + } | ||
| 93 | + for i := range partnerInfos { | ||
| 94 | + partner := partnerInfos[i] | ||
| 95 | + include := false | ||
| 96 | + if partner.RegionInfo == nil { | ||
| 97 | + continue | ||
| 98 | + } | ||
| 99 | + for j := range districts { | ||
| 100 | + if strings.TrimSpace(districts[j].Name) == strings.TrimSpace(partner.RegionInfo.RegionName) { | ||
| 101 | + include = true | ||
| 102 | + break | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + if !include { | ||
| 106 | + districts = append(districts, protocolx.Districts{ | ||
| 107 | + Id: partner.RegionInfo.RegionId, | ||
| 108 | + Name: partner.RegionInfo.RegionName, | ||
| 109 | + }) | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + return | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +// 获取合伙人类型列表 | ||
| 116 | +func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays []protocolx.JoinWays, err error) { | ||
| 117 | + var ( | ||
| 118 | + CategoryInfoRepository, _ = factory.CreatePartnerCategoryInfoRepository(transactionContext) | ||
| 119 | + categories []*domain.PartnerCategoryInfo | ||
| 120 | + ) | ||
| 121 | + if _, categories, err = CategoryInfoRepository.Find(nil); err != nil && len(categories) == 0 { | ||
| 122 | + return | ||
| 123 | + } | ||
| 124 | + for i := range categories { | ||
| 125 | + c := categories[i] | ||
| 126 | + joinWays = append(joinWays, protocolx.JoinWays{Type: c.Id, Name: c.Name}) | ||
| 127 | + } | ||
| 128 | + return | ||
| 129 | +} |
| @@ -8,9 +8,14 @@ var LOG_LEVEL = "debug" | @@ -8,9 +8,14 @@ var LOG_LEVEL = "debug" | ||
| 8 | var LOG_File = "app.log" | 8 | var LOG_File = "app.log" |
| 9 | 9 | ||
| 10 | var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897" | 10 | var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897" |
| 11 | +var UCENTER_SERVICE_HOST = "https://suplus-ucenter-dev.fjmaimaimai.com" | ||
| 12 | +var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52" | ||
| 11 | 13 | ||
| 12 | func init() { | 14 | func init() { |
| 13 | if os.Getenv("LOG_LEVEL") != "" { | 15 | if os.Getenv("LOG_LEVEL") != "" { |
| 14 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 16 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
| 15 | } | 17 | } |
| 18 | + if os.Getenv("UCENTER_SERVICE_HOST") != "" { | ||
| 19 | + UCENTER_SERVICE_HOST = os.Getenv("UCENTER_SERVICE_HOST") | ||
| 20 | + } | ||
| 16 | } | 21 | } |
| @@ -46,6 +46,17 @@ type Users struct { | @@ -46,6 +46,17 @@ type Users struct { | ||
| 46 | AccessPartners []*PartnerInfo | 46 | AccessPartners []*PartnerInfo |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | +func (Users *Users) AccessPartnerIds() []int64 { | ||
| 50 | + var partnerIds []int64 | ||
| 51 | + if Users == nil { | ||
| 52 | + return partnerIds | ||
| 53 | + } | ||
| 54 | + for i := range Users.AccessPartners { | ||
| 55 | + partnerIds = append(partnerIds, Users.AccessPartners[i].Id) | ||
| 56 | + } | ||
| 57 | + return partnerIds | ||
| 58 | +} | ||
| 59 | + | ||
| 49 | type UsersRepository interface { | 60 | type UsersRepository interface { |
| 50 | Save(dm *Users) (*Users, error) | 61 | Save(dm *Users) (*Users, error) |
| 51 | Remove(dm *Users) (*Users, error) | 62 | Remove(dm *Users) (*Users, error) |
pkg/infrastructure/dao/pg_users_dao.go
0 → 100644
| 1 | +package dao | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "github.com/go-pg/pg/v10" | ||
| 6 | + "github.com/go-pg/pg/v10/orm" | ||
| 7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | ||
| 9 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | ||
| 10 | + . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type UsersDao struct { | ||
| 14 | + transactionContext *transaction.TransactionContext | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +func (dao *UsersDao) UserAccessPartners(queryOptions map[string]interface{}) ([]*domain.Users, error) { | ||
| 18 | + tx := dao.transactionContext.PgTx | ||
| 19 | + m := new(models.Users) | ||
| 20 | + var users *domain.Users | ||
| 21 | + query := NewQuery(tx.Model(m), queryOptions) | ||
| 22 | + if inParterIds, ok := queryOptions["inParterIds"]; ok { | ||
| 23 | + query.Relation("PartnerInfo", func(q *orm.Query) (*orm.Query, error) { | ||
| 24 | + return q.Where("id in (?)", pg.In(inParterIds.([]int64))), nil | ||
| 25 | + }) | ||
| 26 | + } | ||
| 27 | + err := query.Select(&users) | ||
| 28 | + return nil, err | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func NewUsersDao(transactionContext *transaction.TransactionContext) (*UsersDao, error) { | ||
| 32 | + if transactionContext == nil { | ||
| 33 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
| 34 | + } else { | ||
| 35 | + return &UsersDao{ | ||
| 36 | + transactionContext: transactionContext, | ||
| 37 | + }, nil | ||
| 38 | + } | ||
| 39 | +} |
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao" |
| 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository" |
| 9 | + http_gateway "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr" | ||
| 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 11 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
| 11 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 12 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
| @@ -53,6 +54,8 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro | @@ -53,6 +54,8 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro | ||
| 53 | err = protocol.NewErrWithMessage(502, err) //账号不存在 | 54 | err = protocol.NewErrWithMessage(502, err) //账号不存在 |
| 54 | return | 55 | return |
| 55 | } | 56 | } |
| 57 | + ucenerSvr := http_gateway.NewHttplibUCenterApiServiceGateway() | ||
| 58 | + _, err = ucenerSvr.ServerLogin(phone, password, 1) | ||
| 56 | return | 59 | return |
| 57 | } | 60 | } |
| 58 | 61 |
| 1 | package repository | 1 | package repository |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "github.com/go-pg/pg/v10" | ||
| 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
| @@ -55,6 +56,11 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions map[string]interfa | @@ -55,6 +56,11 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions map[string]interfa | ||
| 55 | query.SetWhere("partner_info.account = ?", "account") | 56 | query.SetWhere("partner_info.account = ?", "account") |
| 56 | query.SetWhere("partner_info.status = ?", "status") | 57 | query.SetWhere("partner_info.status = ?", "status") |
| 57 | query.SetWhere("partner_info.company_id = ?", "companyId") | 58 | query.SetWhere("partner_info.company_id = ?", "companyId") |
| 59 | + //if inParterIds,ok :=queryOptions["inParterIds"];ok{ | ||
| 60 | + // query.Relation("PartnerInfo", func(q *orm.Query) (*orm.Query, error) { | ||
| 61 | + // return q.Where("id in (?)",pg.In(inParterIds.([]int64))),nil | ||
| 62 | + // }) | ||
| 63 | + //} | ||
| 58 | if err := query.First(); err != nil { | 64 | if err := query.First(); err != nil { |
| 59 | return nil, query.HandleError(err, "没有此合伙人") | 65 | return nil, query.HandleError(err, "没有此合伙人") |
| 60 | } | 66 | } |
| @@ -76,6 +82,10 @@ func (repository *PartnerInfoRepository) Find(queryOptions map[string]interface{ | @@ -76,6 +82,10 @@ func (repository *PartnerInfoRepository) Find(queryOptions map[string]interface{ | ||
| 76 | SetLimit(). | 82 | SetLimit(). |
| 77 | SetOrder("partner_info.create_at", "sortByCreateTime"). | 83 | SetOrder("partner_info.create_at", "sortByCreateTime"). |
| 78 | SetOrder("partner_info.update_at", "sortByUpdateTime") | 84 | SetOrder("partner_info.update_at", "sortByUpdateTime") |
| 85 | + | ||
| 86 | + if inPartnerIds, ok := queryOptions["inPartnerIds"]; ok { | ||
| 87 | + query.Where("id in (?)", pg.In(inPartnerIds.([]int64))) | ||
| 88 | + } | ||
| 79 | var err error | 89 | var err error |
| 80 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 90 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
| 81 | return 0, PartnerInfos, err | 91 | return 0, PartnerInfos, err |
| @@ -66,6 +66,7 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in | @@ -66,6 +66,7 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in | ||
| 66 | var UsersModels []*models.Users | 66 | var UsersModels []*models.Users |
| 67 | Userss := make([]*domain.Users, 0) | 67 | Userss := make([]*domain.Users, 0) |
| 68 | query := NewQuery(tx.Model(&UsersModels), queryOptions). | 68 | query := NewQuery(tx.Model(&UsersModels), queryOptions). |
| 69 | + SetWhere("id = ?", "id"). | ||
| 69 | SetWhere("phone = ?", "phone"). | 70 | SetWhere("phone = ?", "phone"). |
| 70 | SetWhere("company_id = ?", "companyId"). | 71 | SetWhere("company_id = ?", "companyId"). |
| 71 | SetWhere(`status = ?`, "status"). | 72 | SetWhere(`status = ?`, "status"). |
| 1 | +package svr | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | ||
| 7 | + "strconv" | ||
| 8 | + "strings" | ||
| 9 | + "time" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type HttplibUCenterApiServiceGateway struct { | ||
| 13 | + httplibBaseServiceGateway | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +// 服务登录 | ||
| 17 | +func (serviceGateway *HttplibUCenterApiServiceGateway) ServerLogin(phone, password string, loginType int) (int, error) { | ||
| 18 | + url := strings.Join([]string{serviceGateway.baseURL, "auth", "serverLogin"}, "/") | ||
| 19 | + request := serviceGateway.createRequest(url, "post") | ||
| 20 | + request.Header("appKey", constant.UCENTER_APP_KEY) | ||
| 21 | + options := make(map[string]interface{}) | ||
| 22 | + options["phone"] = strings.TrimSpace(phone) | ||
| 23 | + options["password"] = strings.TrimSpace(password) | ||
| 24 | + options["type"] = loginType | ||
| 25 | + request.JSONBody(options) | ||
| 26 | + response := make(map[string]interface{}) | ||
| 27 | + //data,_:=request.Bytes() | ||
| 28 | + //fmt.Println(string(data)) | ||
| 29 | + err := request.ToJSON(&response) | ||
| 30 | + if err != nil { | ||
| 31 | + log.Error("Service Gateway Fail:", err) | ||
| 32 | + return 0, err | ||
| 33 | + } | ||
| 34 | + return serviceGateway.handlerError(response) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// 修改密码 | ||
| 38 | +func (serviceGateway *HttplibUCenterApiServiceGateway) UpdateUserPassword(uid int64, phone, password string) (int, error) { | ||
| 39 | + url := strings.Join([]string{serviceGateway.baseURL, "users", fmt.Sprintf("%v", uid)}, "/") | ||
| 40 | + request := serviceGateway.createRequest(url, "put") | ||
| 41 | + request.Header("appKey", constant.UCENTER_APP_KEY) | ||
| 42 | + options := make(map[string]interface{}) | ||
| 43 | + options["phone"] = strings.TrimSpace(phone) | ||
| 44 | + options["password"] = strings.TrimSpace(password) | ||
| 45 | + request.JSONBody(options) | ||
| 46 | + response := make(map[string]interface{}) | ||
| 47 | + //data,_:=request.Bytes() | ||
| 48 | + //fmt.Println(string(data)) | ||
| 49 | + err := request.ToJSON(&response) | ||
| 50 | + if err != nil { | ||
| 51 | + log.Error("Service Gateway Fail:", err) | ||
| 52 | + return 0, err | ||
| 53 | + } | ||
| 54 | + return serviceGateway.handlerError(response) | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +func (serviceGateway *HttplibUCenterApiServiceGateway) handlerError(in map[string]interface{}) (int, error) { | ||
| 58 | + var rspCode int | ||
| 59 | + var err error | ||
| 60 | + if code, ok := in["code"]; ok { | ||
| 61 | + rspCode, _ = strconv.Atoi(fmt.Sprintf("%v", code)) | ||
| 62 | + } else { | ||
| 63 | + err = fmt.Errorf("网关解析错误") | ||
| 64 | + } | ||
| 65 | + if msg, ok := in["msg"]; ok { | ||
| 66 | + msg := msg.(string) | ||
| 67 | + if rspCode != 0 && len(msg) > 0 { | ||
| 68 | + err = fmt.Errorf(msg) | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + return rspCode, err | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +func NewHttplibUCenterApiServiceGateway() *HttplibUCenterApiServiceGateway { | ||
| 75 | + return &HttplibUCenterApiServiceGateway{ | ||
| 76 | + httplibBaseServiceGateway: httplibBaseServiceGateway{ | ||
| 77 | + baseURL: constant.UCENTER_SERVICE_HOST, | ||
| 78 | + connectTimeout: 100 * time.Second, | ||
| 79 | + readWriteTimeout: 30 * time.Second, | ||
| 80 | + }, | ||
| 81 | + } | ||
| 82 | +} |
pkg/port/appsvr/controllers/company.go
0 → 100644
| 1 | +package controllers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/tiptok/gocomm/pkg/log" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/company" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | ||
| 7 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type CompanyController struct { | ||
| 11 | + BaseController | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +// Property | ||
| 15 | +// 测试 | ||
| 16 | +func (this *CompanyController) Property() { | ||
| 17 | + var msg *protocol.ResponseMessage | ||
| 18 | + defer func() { | ||
| 19 | + this.Resp(msg) | ||
| 20 | + }() | ||
| 21 | + var request *protocolx.PropertyRequest | ||
| 22 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
| 23 | + msg = protocol.BadRequestParam(1) | ||
| 24 | + return | ||
| 25 | + } | ||
| 26 | + if b, m := this.Valid(request); !b { | ||
| 27 | + msg = m | ||
| 28 | + return | ||
| 29 | + } | ||
| 30 | + header := this.GetRequestHeader(this.Ctx) | ||
| 31 | + data, err := company.Property(header, request) | ||
| 32 | + if err != nil { | ||
| 33 | + log.Error(err) | ||
| 34 | + } | ||
| 35 | + msg = protocol.NewReturnResponse(data, err) | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +// Partners | ||
| 39 | +// 测试 | ||
| 40 | +func (this *CompanyController) Partners() { | ||
| 41 | + var msg *protocol.ResponseMessage | ||
| 42 | + defer func() { | ||
| 43 | + this.Resp(msg) | ||
| 44 | + }() | ||
| 45 | + var request *protocolx.PartnersRequest | ||
| 46 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
| 47 | + msg = protocol.BadRequestParam(1) | ||
| 48 | + return | ||
| 49 | + } | ||
| 50 | + if b, m := this.Valid(request); !b { | ||
| 51 | + msg = m | ||
| 52 | + return | ||
| 53 | + } | ||
| 54 | + header := this.GetRequestHeader(this.Ctx) | ||
| 55 | + data, err := company.Partners(header, request) | ||
| 56 | + if err != nil { | ||
| 57 | + log.Error(err) | ||
| 58 | + } | ||
| 59 | + msg = protocol.NewReturnResponse(data, err) | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +// Statistics | ||
| 63 | +// 测试 | ||
| 64 | +func (this *CompanyController) Statistics() { | ||
| 65 | + var msg *protocol.ResponseMessage | ||
| 66 | + defer func() { | ||
| 67 | + this.Resp(msg) | ||
| 68 | + }() | ||
| 69 | + var request *protocolx.StatisticsRequest | ||
| 70 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
| 71 | + msg = protocol.BadRequestParam(1) | ||
| 72 | + return | ||
| 73 | + } | ||
| 74 | + if b, m := this.Valid(request); !b { | ||
| 75 | + msg = m | ||
| 76 | + return | ||
| 77 | + } | ||
| 78 | + header := this.GetRequestHeader(this.Ctx) | ||
| 79 | + data, err := company.Statistics(header, request) | ||
| 80 | + if err != nil { | ||
| 81 | + log.Error(err) | ||
| 82 | + } | ||
| 83 | + msg = protocol.NewReturnResponse(data, err) | ||
| 84 | +} |
| @@ -31,6 +31,10 @@ func init() { | @@ -31,6 +31,10 @@ func init() { | ||
| 31 | 31 | ||
| 32 | nsV1.Router("/dividend/statistics", &controllers.DividendController{}, "Post:DividendStatistics") | 32 | nsV1.Router("/dividend/statistics", &controllers.DividendController{}, "Post:DividendStatistics") |
| 33 | nsV1.Router("/dividend/orders", &controllers.DividendController{}, "Post:DividendOrders") | 33 | nsV1.Router("/dividend/orders", &controllers.DividendController{}, "Post:DividendOrders") |
| 34 | + | ||
| 35 | + nsV1.Router("/company/property", &controllers.CompanyController{}, "post:Property") | ||
| 36 | + nsV1.Router("/company/partners", &controllers.CompanyController{}, "post:Partners") | ||
| 37 | + nsV1.Router("/company/statistics", &controllers.CompanyController{}, "post:Statistics") | ||
| 34 | beego.AddNamespace(nsV1) | 38 | beego.AddNamespace(nsV1) |
| 35 | 39 | ||
| 36 | InitV2() | 40 | InitV2() |
pkg/protocol/company/partners_request.go
0 → 100644
pkg/protocol/company/partners_response.go
0 → 100644
pkg/protocol/company/property_request.go
0 → 100644
pkg/protocol/company/property_response.go
0 → 100644
| 1 | +package company | ||
| 2 | + | ||
| 3 | +type PropertyResponse struct { | ||
| 4 | + // 唯一标识 | ||
| 5 | + Districts []Districts `json:"districts"` | ||
| 6 | + JoinWays []JoinWays `json:"joinWays"` | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +// 区域 | ||
| 10 | +type Districts struct { | ||
| 11 | + Id int `json:"id"` | ||
| 12 | + Name string `json:"name"` | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// 合作类型 | ||
| 16 | +type JoinWays struct { | ||
| 17 | + Type int64 `json:"type"` | ||
| 18 | + Name string `json:"name"` | ||
| 19 | +} |
pkg/protocol/company/statistics_request.go
0 → 100644
-
请 注册 或 登录 后发表评论