123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package provincial_department
- import (
- "context"
- "encoding/json"
- "fmt"
- "github.com/tidwall/gjson"
- "go.uber.org/zap"
- "smart-provincial/errors"
- "smart-provincial/pb/v1"
- "smart-provincial/thirdparty"
- "strings"
- "smart-provincial/parser"
- "github.com/jaryhe/gopkgs/logger"
- )
- func ProvincialPostTeam(ctx context.Context, req *v1.ProvincialPostTeamRequest)(reply *v1.ProvincialPostTeamReply, err error) {
- token, err := Login()
- if err != nil {
- return nil, err
- }
- data := map[string]interface{}{
- "Code":req.Code,
- "TeamSysNo":req.TeamSysNo,
- "TeamName":req.TeamName,
- "CorpCode":req.CorpCode,
- "CorpName":req.CorpName,
- "TeamLeaderName":req.TeamLeaderName,
- "TeamLeaderPhone":req.TeamLeaderPhone,
- }
- datas := []map[string]interface{}{}
- datas = append(datas, data)
- param := map[string]interface{}{
- "type":"项目班组信息",
- "datas":datas,
- }
- bytes, err := thirdparty.ProvincialPost(parser.Conf.ThirdParty.Provincial.ProjectUploadApi, token, param)
- fmt.Printf("provincial add team %s,%v\n", bytes, err)
- if err != nil {
- s, _ := json.Marshal(param)
- logger.Error("thirdpary provincial add team",
- zap.String("call", parser.Conf.ThirdParty.Provincial.ProjectUploadApi),
- zap.String("param", string(s)),
- zap.String("error", err.Error()))
- return nil, errors.ProvincialProjectUploadError
- }
- ack := gjson.GetBytes(bytes, "ack_code").String()
- if strings.ToUpper(ack) != "SUCCESS" {
- s, _ := json.Marshal(param)
- logger.Error("thirdpary provincial add team",
- zap.String("call", parser.Conf.ThirdParty.Provincial.ProjectUploadApi),
- zap.String("param", string(s)),
- zap.String("error",string(bytes)))
- return nil, errors.ProvincialProjectUploadError
- }
- id := gjson.GetBytes(bytes, "ID").String()
- reply.Id = id
- reply = &v1.ProvincialPostTeamReply{}
- return reply, nil
- }
|