|
@@ -17,10 +17,14 @@ type CompletionUserInfo struct {
|
|
|
EntId int `json:"entId"`
|
|
|
}
|
|
|
type Resp struct {
|
|
|
- Fool bool `json:"fool"`
|
|
|
+ Fool bool `json:"fool"`
|
|
|
+ EntPositionId int64 `json:"entPositionId"`
|
|
|
+ UserPositionId int64 `json:"userpositionId"`
|
|
|
}
|
|
|
|
|
|
func (rpc *JyUser) AddUserInfo(info *CompletionUserInfo, res *Resp) error {
|
|
|
+ userPositionId := int64(0)
|
|
|
+ entPositionId := int64(0)
|
|
|
fool := BaseMysql.ExecTx("", func(tx *sql.Tx) bool {
|
|
|
userData := BaseMysql.FindOne(UserTable, map[string]interface{}{
|
|
|
"phone": info.Phone,
|
|
@@ -46,7 +50,8 @@ func (rpc *JyUser) AddUserInfo(info *CompletionUserInfo, res *Resp) error {
|
|
|
}
|
|
|
personId := int64(0)
|
|
|
userId := int64(0)
|
|
|
- accountId := int64(0)
|
|
|
+ userAccountId := int64(0)
|
|
|
+ entAccountId := int64(0)
|
|
|
personName := ""
|
|
|
accountName := ""
|
|
|
if userData == nil || len(*userData) == 0 {
|
|
@@ -69,8 +74,18 @@ func (rpc *JyUser) AddUserInfo(info *CompletionUserInfo, res *Resp) error {
|
|
|
"type": 1,
|
|
|
"person_id": personId,
|
|
|
}
|
|
|
- accountId = BaseMysql.Insert(BaseAccount, entMap)
|
|
|
- if accountId == 0 {
|
|
|
+ entAccountId = BaseMysql.Insert(BaseAccount, entMap)
|
|
|
+ if entAccountId == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ entUserMap := map[string]interface{}{
|
|
|
+ "ent_id": 0,
|
|
|
+ "name": "",
|
|
|
+ "type": 0,
|
|
|
+ "person_id": personId,
|
|
|
+ }
|
|
|
+ userAccountId = BaseMysql.Insert(BaseAccount, entUserMap)
|
|
|
+ if userAccountId == 0 {
|
|
|
return false
|
|
|
}
|
|
|
//用户表添加
|
|
@@ -106,10 +121,38 @@ func (rpc *JyUser) AddUserInfo(info *CompletionUserInfo, res *Resp) error {
|
|
|
"base_user_id": userId,
|
|
|
}
|
|
|
Mgo.Save("user", data)
|
|
|
+ //个人职位
|
|
|
+ //职位表添加
|
|
|
+ userPositionMap := map[string]interface{}{
|
|
|
+ "ent_id": info.EntId,
|
|
|
+ "user_id": userId,
|
|
|
+ "account_id": userAccountId,
|
|
|
+ "person_name": personName,
|
|
|
+ "account_name": accountName,
|
|
|
+ "type": 0,
|
|
|
+ }
|
|
|
+ userPositionId = BaseMysql.Insert(BasePosition, userPositionMap)
|
|
|
+ if userPositionId == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //企业职位
|
|
|
+ //职位表添加
|
|
|
+ entPositionMap := map[string]interface{}{
|
|
|
+ "ent_id": info.EntId,
|
|
|
+ "user_id": userId,
|
|
|
+ "account_id": entAccountId,
|
|
|
+ "person_name": personName,
|
|
|
+ "account_name": accountName,
|
|
|
+ "type": 1,
|
|
|
+ }
|
|
|
+ entPositionId = BaseMysql.Insert(BasePosition, entPositionMap)
|
|
|
+ if entPositionId == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
} else {
|
|
|
personId = common.Int64All((*userData)["person_id"])
|
|
|
userId = common.Int64All((*userData)["id"])
|
|
|
- //账号信息查询
|
|
|
+ //企业账号信息查询
|
|
|
accountData := BaseMysql.FindOne(BaseAccount, map[string]interface{}{
|
|
|
"person_id": personId,
|
|
|
"ent_id": info.EntId,
|
|
@@ -117,9 +160,33 @@ func (rpc *JyUser) AddUserInfo(info *CompletionUserInfo, res *Resp) error {
|
|
|
}, "name,id", "")
|
|
|
if accountData == nil || len(*accountData) == 0 {
|
|
|
return false
|
|
|
+ //添加企业账号
|
|
|
+ entMap := map[string]interface{}{
|
|
|
+ "ent_id": info.EntId,
|
|
|
+ "name": info.EntName,
|
|
|
+ "type": 1,
|
|
|
+ "person_id": personId,
|
|
|
+ }
|
|
|
+ entAccountId = BaseMysql.Insert(BaseAccount, entMap)
|
|
|
+ if entAccountId == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ accountName = info.EntName
|
|
|
+ } else {
|
|
|
+ accountName = common.InterfaceToStr((*accountData)["name"])
|
|
|
+ entAccountId = common.Int64All((*accountData)["id"])
|
|
|
+ }
|
|
|
+ //个人账号信息查询
|
|
|
+ userAccountData := BaseMysql.FindOne(BaseAccount, map[string]interface{}{
|
|
|
+ "person_id": personId,
|
|
|
+ "ent_id": info.EntId,
|
|
|
+ "type": 0,
|
|
|
+ }, "name,id", "")
|
|
|
+ if userAccountData == nil || len(*userAccountData) == 0 {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ userAccountId = common.Int64All((*accountData)["id"])
|
|
|
}
|
|
|
- accountName = common.InterfaceToStr((*accountData)["name"])
|
|
|
- accountId = common.Int64All((*accountData)["name"])
|
|
|
//自然人信息查询
|
|
|
personData := BaseMysql.FindOne(BasePerson, map[string]interface{}{
|
|
|
"id": personId,
|
|
@@ -128,22 +195,36 @@ func (rpc *JyUser) AddUserInfo(info *CompletionUserInfo, res *Resp) error {
|
|
|
return false
|
|
|
}
|
|
|
personName = common.InterfaceToStr((*personData)["name"])
|
|
|
- }
|
|
|
- //职位表添加
|
|
|
- positionMap := map[string]interface{}{
|
|
|
- "ent_id": info.EntId,
|
|
|
- "user_id": userId,
|
|
|
- "account_id": accountId,
|
|
|
- "person_name": personName,
|
|
|
- "account_name": accountName,
|
|
|
- "type": 1,
|
|
|
- }
|
|
|
- positionId := BaseMysql.Insert(BasePosition, positionMap)
|
|
|
- if positionId == 0 {
|
|
|
- return false
|
|
|
+ //职位表添加
|
|
|
+ positionMap := map[string]interface{}{
|
|
|
+ "ent_id": info.EntId,
|
|
|
+ "user_id": userId,
|
|
|
+ "account_id": entAccountId,
|
|
|
+ "person_name": personName,
|
|
|
+ "account_name": accountName,
|
|
|
+ "type": 1,
|
|
|
+ }
|
|
|
+ entPositionId = BaseMysql.Insert(BasePosition, positionMap)
|
|
|
+ if entPositionId == 0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //个人职位信息查询
|
|
|
+ userPositionData := BaseMysql.FindOne(BasePosition, map[string]interface{}{
|
|
|
+ "ent_id": info.EntId,
|
|
|
+ "user_id": userId,
|
|
|
+ "account_id": userAccountId,
|
|
|
+ "type": 0,
|
|
|
+ }, "id", "")
|
|
|
+ if userPositionData == nil || len(*userPositionData) == 0 {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ userPositionId = common.Int64All((*userPositionData)["id"])
|
|
|
+ }
|
|
|
}
|
|
|
return true
|
|
|
})
|
|
|
res.Fool = fool
|
|
|
+ res.EntPositionId = entPositionId
|
|
|
+ res.UserPositionId = userPositionId
|
|
|
return nil
|
|
|
}
|