作者 唐旭辉

数据输出格式修改

... ... @@ -142,12 +142,18 @@ func (c *CommonController) DefaultImage() {
case 1:
//返回机会分类的图标
imageNames = []string{
imgehost + "/图1.jpg",
imgehost + "/sort/chance_one_channel@2x.png",
imgehost + "/sort/chance_one_area@2x.png",
imgehost + "/sort/chance_one_client@2x.png",
imgehost + "/sort/chance_one_product@2x.png",
}
case 2:
//返回机会模板的图标
imageNames = []string{
imgehost + "/图1.jpg",
imgehost + "/template/chance_two_application@x2.png",
imgehost + "/template/chance_two_follow@x2.png",
imgehost + "/template/chance_two_improve@x2.png",
imgehost + "/template/chance_two_original@x2.png",
}
}
data := map[string][]string{
... ...
... ... @@ -40,7 +40,7 @@ type ResponseDepartmentInfo struct {
ID int64 `json:"id"`
CompanyID int64 `json:"company_id"` //公司
Name string `json:"name"` //部门名字
ParantID int64 `json:"parent_id"` //父级部门Id
ParantID int64 `json:"parentId"` //父级部门Id
Manages []DepartmentManager `json:"manages"` //部门管理员
Members []DepartmentMember `json:"members"` //部门成员
Member int64 `json:"member"` //成员数
... ...
... ... @@ -14,14 +14,6 @@ import (
//InitCompanyInfo 初始化公司
func InitCompanyInfo(centerCompany protocol.CenterCompanyInfo) error {
// var (
// centerCompany CenterCompanyInfo
// err error
// )
// centerCompany, err = GetCenterCompanyInfo(uCompanyid)
// if err != nil {
// return protocol.NewErrWithMessage("10051")
// }
var (
newDeparment *models.Department
newRoleGroup *models.Role
... ... @@ -157,7 +149,11 @@ func initAdminUser(centerCompany protocol.CenterCompanyInfo, o orm.Ormer) (*mode
return nil, err
}
} else if err == orm.ErrNoRows {
ucenterUser, err := ucenter.RequestUCenterAddUser(centerCompany.AdminAccount, centerCompany.AdminName, "")
var (
ucenterUser = &ucenter.ResponseAddUser{}
err error
)
ucenterUser, err = ucenter.RequestUCenterAddUser(centerCompany.AdminAccount, centerCompany.AdminName, "")
if err != nil {
log.Error("获取统一用户中心数据失败 :%s", err)
return nil, err
... ...
... ... @@ -353,16 +353,16 @@ func editUserRole(usercompanyid int64, userid int64, companyid int64, roleids []
return nil
}
func editUserCompany(userCompanyid int64, userid int64, nickname string, o orm.Ormer) error {
m := &models.UserCompany{
Id: userCompanyid,
NickName: nickname,
UserId: userid,
}
// func editUserCompany(userCompanyid int64, userid int64, nickname string, o orm.Ormer) error {
// m := &models.UserCompany{
// Id: userCompanyid,
// NickName: nickname,
// UserId: userid,
// }
err := models.UpdateUserCompanyById(m, []string{"NickName", "UserId"}, o)
return err
}
// err := models.UpdateUserCompanyById(m, []string{"NickName", "UserId"}, o)
// return err
// }
//校验user和公司的关系是否正确
func validUserCompany(userCompanyid int64, companyid int64) (*models.UserCompany, error) {
... ... @@ -406,34 +406,34 @@ func UserEdit(param protocol.RequestUserEdit) error {
log.Error(err.Error())
return err
}
//检查用户手机号是否生变更
var (
usrData *models.User
)
usrData, err = models.GetUserById(ucompany.UserId)
_, err = models.GetUserById(ucompany.UserId)
if err != nil {
log.Error("获取用户数据失败:%s", err)
return protocol.NewErrWithMessage("1")
}
o := orm.NewOrm()
o.Begin()
if usrData.Phone != param.Phone {
//手机号变更
uid, err := addNewUser(param.Name, param.Phone, o)
if err != nil {
o.Rollback()
log.Error("手机号变更,新增用户失败;%s", err)
return protocol.NewErrWithMessage("1")
}
ucompany.UserId = uid
}
//检查用户手机号是否生变更
// var (
// usrData *models.User
// )
// if usrData.Phone != param.Phone {
// //手机号变更
// uid, err := addNewUser(param.Name, param.Phone, o)
// if err != nil {
// o.Rollback()
// log.Error("手机号变更,新增用户失败;%s", err)
// return protocol.NewErrWithMessage("1")
// }
// ucompany.UserId = uid
// }
//用户数据更新
err = editUserCompany(param.UserCompanyID, ucompany.UserId, param.Name, o)
if err != nil {
o.Rollback()
log.Error("editUserCompany err:%s", err)
return protocol.NewErrWithMessage("1")
}
// err = editUserCompany(param.UserCompanyID, ucompany.UserId, param.Name, o)
// if err != nil {
// o.Rollback()
// log.Error("editUserCompany err:%s", err)
// return protocol.NewErrWithMessage("1")
// }
//添加角色
err = editUserRole(param.UserCompanyID, ucompany.UserId, param.CompanyId, param.Roles, o)
if err != nil {
... ...