作者 唐旭辉

..

... ... @@ -385,6 +385,26 @@ func (c *CompanyController) InitCompany() {
msg = protocol.BadRequestParam("1")
return
}
if param.CompanyId <= 0 {
log.Error("公司id为0")
msg = protocol.BadRequestParam("1")
return
}
if len(param.CompanyName) == 0 {
log.Error("公司名称空")
msg = protocol.BadRequestParam("1")
return
}
if len(param.AdminAccount) == 0 {
log.Error("人员账号空")
msg = protocol.BadRequestParam("1")
return
}
if len(param.AdminName) == 0 {
log.Error("人员名称空")
msg = protocol.BadRequestParam("1")
return
}
var (
err error
)
... ...
... ... @@ -2,7 +2,7 @@ package protocol
var errmessge ErrorMap = map[string]string{
//操作
"0": "成功",
"0": "ok",
"1": "网络连接无响应",
//角色相关
"10001": "请先删除该分组下的其他角色",
... ...
... ... @@ -30,3 +30,30 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
}
return uclientReturn, nil
}
func RequestUCenterAddUser(phone string, nickname string, avatar string) (*ResponseAddUser, error) {
var ucenterReturn *ResponseAddUser
param := RequestAddUser{
Phone: phone,
Nickname: nickname,
Avatar: avatar,
Password: "9d1f5048afd96b39a3dae71a99f2c77a30112d29", //默认密码:fmt.Sprintf("%x", sha1.Sum([]byte("mmm1234554321")))
RegIm: 1,
}
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
err = json.Unmarshal(btBody, &ucenterReturn)
if err != nil {
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0 &&
ucenterReturn.Msg == ResponseMsgOk) {
return nil, protocol.NewErrWithMessage("10021")
}
return ucenterReturn, nil
}
... ...
... ... @@ -57,7 +57,7 @@ type ResponseLogin struct {
type RequestAddUser struct {
Phone string `json:"phone"`
RegIm bool `json:"regIm"`
RegIm int8 `json:"regIm"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Password string `json:"password"`
... ... @@ -86,6 +86,19 @@ func (r RequestAddUser) Valid() error {
return nil
}
type ResponseAddUser struct {
CommResponse
Data struct {
Id int64 `json:"id"`
Phone string `json:"phone"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Token string `json:"token"`
Accid int64 `json:"accid"`
CustomerAccount int64 `json:"customerAccount"`
} `json:"data"`
}
type RequestCheckCompany struct {
CompanyId int64 `json:"company_id"`
}
... ...