1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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 ProvincialPostStaff(ctx context.Context, req *v1.ProvincialPostStaffRequest)(reply *v1.ProvincialPostStaffReply, 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,
- "WorkerName":req.WorkerName,
- "IsTeamLeader":req.IsTeamLeader,
- "IDCardType":req.IdCardType,
- "IDCardNumber":req.IdCardNumber,
- "Age":req.Age,
- "Gender":req.Gender,
- "Nation":req.Nation,
- "Address":req.Address,
- "headImage":req.HeadImage,
- "PoliticsType":req.PoliticsType,
- "CultureLevelType":req.CultureLevelType,
- "GrantOrg":req.GrantOrg,
- "WorkType":req.WorkType,
- "NativePlace":req.NativePlace,
- "Mobile":req.Mobile,
- "HasContract":req.HasContract,
- }
- 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 staff: %s,%v\n", bytes, err)
- if err != nil {
- s, _ := json.Marshal(param)
- logger.Error("thirdpary provincial add staff",
- 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 staff",
- 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.ProvincialPostStaffReply{}
- return reply, nil
- }
|