作者 唐旭辉

..

@@ -385,6 +385,26 @@ func (c *CompanyController) InitCompany() { @@ -385,6 +385,26 @@ func (c *CompanyController) InitCompany() {
385 msg = protocol.BadRequestParam("1") 385 msg = protocol.BadRequestParam("1")
386 return 386 return
387 } 387 }
  388 + if param.CompanyId <= 0 {
  389 + log.Error("公司id为0")
  390 + msg = protocol.BadRequestParam("1")
  391 + return
  392 + }
  393 + if len(param.CompanyName) == 0 {
  394 + log.Error("公司名称空")
  395 + msg = protocol.BadRequestParam("1")
  396 + return
  397 + }
  398 + if len(param.AdminAccount) == 0 {
  399 + log.Error("人员账号空")
  400 + msg = protocol.BadRequestParam("1")
  401 + return
  402 + }
  403 + if len(param.AdminName) == 0 {
  404 + log.Error("人员名称空")
  405 + msg = protocol.BadRequestParam("1")
  406 + return
  407 + }
388 var ( 408 var (
389 err error 409 err error
390 ) 410 )
@@ -2,7 +2,7 @@ package protocol @@ -2,7 +2,7 @@ package protocol
2 2
3 var errmessge ErrorMap = map[string]string{ 3 var errmessge ErrorMap = map[string]string{
4 //操作 4 //操作
5 - "0": "成功", 5 + "0": "ok",
6 "1": "网络连接无响应", 6 "1": "网络连接无响应",
7 //角色相关 7 //角色相关
8 "10001": "请先删除该分组下的其他角色", 8 "10001": "请先删除该分组下的其他角色",
@@ -30,3 +30,30 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { @@ -30,3 +30,30 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
30 } 30 }
31 return uclientReturn, nil 31 return uclientReturn, nil
32 } 32 }
  33 +
  34 +func RequestUCenterAddUser(phone string, nickname string, avatar string) (*ResponseAddUser, error) {
  35 + var ucenterReturn *ResponseAddUser
  36 + param := RequestAddUser{
  37 + Phone: phone,
  38 + Nickname: nickname,
  39 + Avatar: avatar,
  40 + Password: "9d1f5048afd96b39a3dae71a99f2c77a30112d29", //默认密码:fmt.Sprintf("%x", sha1.Sum([]byte("mmm1234554321")))
  41 + RegIm: 1,
  42 + }
  43 + uclient := NewUCenterClient()
  44 + btBody, err := uclient.Call(param)
  45 + if err != nil {
  46 + log.Error("统一用户中心请求失败 err:%s", err)
  47 + return nil, protocol.NewErrWithMessage("1")
  48 + }
  49 + err = json.Unmarshal(btBody, &ucenterReturn)
  50 + if err != nil {
  51 + log.Error("解析统一用户中心响应失败 err:%s", err)
  52 + return nil, protocol.NewErrWithMessage("1")
  53 + }
  54 + if !(ucenterReturn.Code == ResponseCode0 &&
  55 + ucenterReturn.Msg == ResponseMsgOk) {
  56 + return nil, protocol.NewErrWithMessage("10021")
  57 + }
  58 + return ucenterReturn, nil
  59 +}
@@ -57,7 +57,7 @@ type ResponseLogin struct { @@ -57,7 +57,7 @@ type ResponseLogin struct {
57 57
58 type RequestAddUser struct { 58 type RequestAddUser struct {
59 Phone string `json:"phone"` 59 Phone string `json:"phone"`
60 - RegIm bool `json:"regIm"` 60 + RegIm int8 `json:"regIm"`
61 Nickname string `json:"nickname"` 61 Nickname string `json:"nickname"`
62 Avatar string `json:"avatar"` 62 Avatar string `json:"avatar"`
63 Password string `json:"password"` 63 Password string `json:"password"`
@@ -86,6 +86,19 @@ func (r RequestAddUser) Valid() error { @@ -86,6 +86,19 @@ func (r RequestAddUser) Valid() error {
86 return nil 86 return nil
87 } 87 }
88 88
  89 +type ResponseAddUser struct {
  90 + CommResponse
  91 + Data struct {
  92 + Id int64 `json:"id"`
  93 + Phone string `json:"phone"`
  94 + Nickname string `json:"nickname"`
  95 + Avatar string `json:"avatar"`
  96 + Token string `json:"token"`
  97 + Accid int64 `json:"accid"`
  98 + CustomerAccount int64 `json:"customerAccount"`
  99 + } `json:"data"`
  100 +}
  101 +
89 type RequestCheckCompany struct { 102 type RequestCheckCompany struct {
90 CompanyId int64 `json:"company_id"` 103 CompanyId int64 `json:"company_id"`
91 } 104 }