作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -23,6 +23,7 @@ type MyConfig struct {
FileSavePath string
FileHost string
FileHostPath string
BusinessAdminUrl string
}
//MConfig
... ... @@ -54,6 +55,7 @@ func RestMyConfig() *MyConfig {
FileSavePath: beego.AppConfig.String("file_save_path"),
FileHost: beego.AppConfig.String("file_host"),
FileHostPath: beego.AppConfig.String("file_host_path"),
BusinessAdminUrl: beego.AppConfig.String("business_admin_url"),
}
return MConfig
}
... ...
... ... @@ -32,6 +32,9 @@ ucenter_base_url = "http://suplus-ucenter-dev.fjmaimaimai.com"
ucenter_app_key = "39aefef9e22744a3b2d2d3791824ae7b"
ucenter_secret = "cykbjnfqgctn"
##企业平台相关配置
business_admin_url = "http://suplus-business-admin-dev.fjmaimaimai.com"
# 上传文件保存路径
file_save_path = "/var/www/oppmg/file/opportunity"
file_host = "http://mmm-oppmg-dev.fjmaimaimai.com"
... ...
... ... @@ -32,6 +32,9 @@ ucenter_base_url = "https://public-interface.fjmaimaimai.com/ucenter"
ucenter_app_key = "39aefef9e22744a3b2d2d3791824ae7b"
ucenter_secret = "cykbjnfqgctn"
##企业平台相关配置
business_admin_url = "http://suplus-business-admin-prd.fjmaimaimai.com"
# 上传文件保存路径
file_save_path = "/var/www/oppmg/file/opportunity"
file_host = "https://public-interface.fjmaimaimai.com/opportunitymg"
... ...
... ... @@ -32,6 +32,9 @@ ucenter_base_url = "http://suplus-ucenter-test.fjmaimaimai.com"
ucenter_app_key = "39aefef9e22744a3b2d2d3791824ae7b"
ucenter_secret = "cykbjnfqgctn"
##企业平台相关配置
business_admin_url = "http://suplus-business-admin-test.fjmaimaimai.com"
# 上传文件保存路径
file_save_path = "/var/www/oppmg/file/opportunity"
file_host = "http://mmm-oppmg-test.fjmaimaimai.com"
... ...
... ... @@ -54,22 +54,22 @@ func (c AchievementController) AddAchievement() {
}
if len(param.ChanceData) == 0 {
log.Error("len(param.ChanceData) == 0 ")
msg = protocol.BadRequestParam("10109")
msg = protocol.BadRequestParam("11102")
return
}
if param.ChanceTypeId == 0 {
log.Error(" param.ChanceTypeId == 0 ")
msg = protocol.BadRequestParam("10108")
msg = protocol.BadRequestParam("11101")
return
}
if param.GraspScore < 0 || param.GraspScore > 100 {
log.Error(" param.GraspScore < 0 || param.GraspScore > 100 ")
msg = protocol.BadRequestParam("10121")
msg = protocol.BadRequestParam("11104")
return
}
if param.UserGraspScore < 0 || param.UserGraspScore > 100 {
log.Error("param.UserGraspScore < 0 || param.UserGraspScore > 100")
msg = protocol.BadRequestParam("10122")
msg = protocol.BadRequestParam("11105")
}
var providerScore float64
for _, v := range param.Provider {
... ... @@ -78,7 +78,7 @@ func (c AchievementController) AddAchievement() {
remainScore := param.GraspScore - param.UserGraspScore - providerScore
if remainScore < 0 {
log.Error("分配的总分不可大于把握分")
msg = protocol.BadRequestParam("10122")
msg = protocol.BadRequestParam("11105")
return
}
... ... @@ -103,22 +103,22 @@ func (c AchievementController) EditAchievement() {
}
if len(param.ChanceData) == 0 {
log.Error("len(param.ChanceData) == 0 ")
msg = protocol.BadRequestParam("10109")
msg = protocol.BadRequestParam("11102")
return
}
if param.ChanceTypeId == 0 {
log.Error(" param.ChanceTypeId == 0 ")
msg = protocol.BadRequestParam("10108")
msg = protocol.BadRequestParam("11101")
return
}
if param.GraspScore < 0 || param.GraspScore > 100 {
log.Error(" param.GraspScore < 0 || param.GraspScore > 100 ")
msg = protocol.BadRequestParam("10121")
msg = protocol.BadRequestParam("11104")
return
}
if param.UserGraspScore < 0 || param.UserGraspScore > 100 {
log.Error("param.UserGraspScore < 0 || param.UserGraspScore > 100")
msg = protocol.BadRequestParam("10122")
msg = protocol.BadRequestParam("11105")
}
var providerScore float64
for _, v := range param.Provider {
... ... @@ -127,7 +127,7 @@ func (c AchievementController) EditAchievement() {
remainScore := param.GraspScore - param.UserGraspScore - providerScore
if remainScore < 0 {
log.Error("分配的总分不可大于把握分")
msg = protocol.BadRequestParam("10122")
msg = protocol.BadRequestParam("11105")
return
}
companyid := c.GetCompanyId()
... ...
... ... @@ -292,11 +292,11 @@ func (c *AuditController) EditReserveType() {
}
nameRune := []rune(param.Name)
if len(nameRune) == 0 {
msg = protocol.BadRequestParam("10133")
msg = protocol.BadRequestParam("11112")
return
}
if len(nameRune) > 20 {
msg = protocol.BadRequestParam("10134")
msg = protocol.BadRequestParam("11113")
return
}
companyId := c.GetCompanyId()
... ...
... ... @@ -61,7 +61,7 @@ func (c *AuthController) Login() {
return
}
if len(param.Account) == 0 || len(param.Password) == 0 {
msg = protocol.BadRequestParam("10021")
msg = protocol.BadRequestParam("10201")
return
}
logintoken, err := serveauth.LoginAuthByUCenter(param.Account, param.Password)
... ... @@ -99,7 +99,7 @@ func (c *AuthController) LoginSms() {
return
}
if len(param.Account) == 0 || len(param.Code) == 0 {
msg = protocol.BadRequestParam("10021")
msg = protocol.BadRequestParam("10201")
return
}
var uclientReturn *ucenter.ResponseLoginSms
... ... @@ -112,7 +112,7 @@ func (c *AuthController) LoginSms() {
Data: protocol.NullData,
}
} else {
msg = protocol.NewMessage("10028")
msg = protocol.NewMessage("10208")
}
return
}
... ... @@ -151,7 +151,7 @@ func (c *AuthController) LoginSecretKey() {
return
}
if len(param.Secret) == 0 {
msg = protocol.BadRequestParam("10080")
msg = protocol.BadRequestParam("10210")
return
}
logintoken, err := serveauth.LoginAuthBySecretKey(param.Secret)
... ...
... ... @@ -36,7 +36,7 @@ func (this *BaseController) Prepare() {
companyid := this.GetCompanyId()
ok := serveauth.ValidUserPermission(p, userid, companyid)
if !ok {
msg := protocol.NewMessage("10080")
msg := protocol.NewMessage("10210")
this.ResposeJson(msg)
return
}
... ...
... ... @@ -42,7 +42,7 @@ func (this *BulletinController) BulletinRelease() {
return
}
if len([]rune(request.Title)) > 30 {
msg = protocol.BadRequestParam("10278")
msg = protocol.BadRequestParam("10618")
return
}
rsp, err := bulletin.BulletinRelease(uid, companyId, request)
... ...
... ... @@ -55,11 +55,11 @@ func (c *CompanyController) DepartmentAdd() {
}
s := []rune(param.Name)
if len(s) == 0 {
msg = protocol.BadRequestParam("10044")
msg = protocol.BadRequestParam("10403")
return
}
if len(s) > 20 {
msg = protocol.BadRequestParam("10043")
msg = protocol.BadRequestParam("10402")
return
}
... ... @@ -90,16 +90,16 @@ func (c *CompanyController) DepartmentUpdate() {
}
s := []rune(param.Name)
if len(s) == 0 {
msg = protocol.BadRequestParam("10044")
msg = protocol.BadRequestParam("10403")
return
}
if len(s) > 20 {
msg = protocol.BadRequestParam("10043")
msg = protocol.BadRequestParam("10402")
return
}
// if param.ParentID <= 0 {
// //部门必定有上级部门 ,至少是公司一级
// msg = protocol.BadRequestParam("10042")
// msg = protocol.BadRequestParam("10401")
// return
// }
param.CompanyID = c.GetCompanyId()
... ... @@ -170,7 +170,7 @@ func (c *CompanyController) PositionAdd() {
}
n := []rune(param.Name)
if len(n) > 10 || len(n) == 0 {
msg = protocol.BadRequestParam("10014")
msg = protocol.BadRequestParam("10104")
return
}
param.CompanyID = c.GetCompanyId()
... ... @@ -194,7 +194,7 @@ func (c *CompanyController) PositionEdit() {
}
n := []rune(param.Name)
if len(n) > 10 || len(n) == 0 {
msg = protocol.BadRequestParam("10014")
msg = protocol.BadRequestParam("10104")
return
}
param.CompanyID = c.GetCompanyId()
... ... @@ -261,24 +261,24 @@ func (c *CompanyController) PositionList() {
// }
// name := []rune(strings.TrimSpace(param.Name))
// if len(name) == 0 {
// msg = protocol.BadRequestParam("10035")
// msg = protocol.BadRequestParam("10305")
// return
// }
// if len(name) > 10 {
// msg = protocol.BadRequestParam("10034")
// msg = protocol.BadRequestParam("10304")
// return
// }
// ok := utils.PhoneMatch.MatchString(param.Phone)
// if !ok {
// msg = protocol.BadRequestParam("10036")
// msg = protocol.BadRequestParam("10306")
// return
// }
// if len(param.Departments) == 0 {
// msg = protocol.BadRequestParam("10037")
// msg = protocol.BadRequestParam("10307")
// return
// }
// if len(param.Roles) == 0 {
// msg = protocol.BadRequestParam("10038")
// msg = protocol.BadRequestParam("10308")
// return
// }
// param.CompanyId = c.GetCompanyId()
... ... @@ -302,20 +302,20 @@ func (c *CompanyController) UserEdit() {
}
// name := []rune(strings.TrimSpace(param.Name))
// if len(name) == 0 {
// msg = protocol.BadRequestParam("10035")
// msg = protocol.BadRequestParam("10305")
// return
// }
// if len(name) > 10 {
// msg = protocol.BadRequestParam("10034")
// msg = protocol.BadRequestParam("10304")
// return
// }
// if len(param.Departments) == 0 {
// msg = protocol.BadRequestParam("10037")
// msg = protocol.BadRequestParam("10307")
// return
// }
if len(param.Roles) == 0 {
msg = protocol.BadRequestParam("10038")
msg = protocol.BadRequestParam("10308")
return
}
param.CompanyId = c.GetCompanyId()
... ...
... ... @@ -48,7 +48,7 @@ func (c RankController) EditRankType() {
param.Name = strings.TrimSpace(param.Name)
n := []rune(param.Name)
if len(n) > 5 || len(n) == 0 {
msg = protocol.BadRequestParam("10103")
msg = protocol.BadRequestParam("11003")
return
}
companyid := c.GetCompanyId()
... ... @@ -132,17 +132,17 @@ func (c RankController) RankSeasonAdd() {
}
param.Name = strings.TrimSpace(param.Name)
if len(param.Name) == 0 {
msg = protocol.BadRequestParam("10104")
msg = protocol.BadRequestParam("11004")
return
}
param.BeginTime = strings.TrimSpace(param.BeginTime)
if len(param.BeginTime) == 0 {
msg = protocol.BadRequestParam("10105")
msg = protocol.BadRequestParam("11005")
return
}
param.EndTime = strings.TrimSpace(param.EndTime)
if len(param.EndTime) == 0 {
msg = protocol.BadRequestParam("10106")
msg = protocol.BadRequestParam("11006")
return
}
var (
... ... @@ -151,13 +151,13 @@ func (c RankController) RankSeasonAdd() {
)
t1, err := time.ParseInLocation("2006-01-02", param.BeginTime, time.Local)
if err != nil {
msg = protocol.BadRequestParam("10105")
msg = protocol.BadRequestParam("11005")
return
}
beginTime = t1.Unix()
t2, err := time.ParseInLocation("2006-01-02", param.EndTime, time.Local)
if err != nil {
msg = protocol.BadRequestParam("10106")
msg = protocol.BadRequestParam("11006")
return
}
endTime = t2.Unix() + 86399 //60*60*24-1
... ... @@ -167,7 +167,7 @@ func (c RankController) RankSeasonAdd() {
}
ok := serverank.RankPeriodCheckTime(param.RankTypeId, beginTime, endTime, 0)
if !ok {
msg = protocol.BadRequestParam("10101")
msg = protocol.BadRequestParam("11001")
return
}
companyid := c.GetCompanyId()
... ... @@ -203,12 +203,12 @@ func (c RankController) RankSeasonEdit() {
}
param.BeginTime = strings.TrimSpace(param.BeginTime)
if len(param.BeginTime) == 0 {
msg = protocol.BadRequestParam("10105")
msg = protocol.BadRequestParam("11005")
return
}
param.EndTime = strings.TrimSpace(param.EndTime)
if len(param.EndTime) == 0 {
msg = protocol.BadRequestParam("10106")
msg = protocol.BadRequestParam("11006")
return
}
var (
... ... @@ -218,14 +218,14 @@ func (c RankController) RankSeasonEdit() {
t1, err := time.ParseInLocation("2006-01-02", param.BeginTime, time.Local)
if err != nil {
log.Error(err.Error())
msg = protocol.BadRequestParam("10105")
msg = protocol.BadRequestParam("11005")
return
}
beginTime = t1.Unix()
t2, err := time.ParseInLocation("2006-01-02", param.EndTime, time.Local)
if err != nil {
log.Error(err.Error())
msg = protocol.BadRequestParam("10106")
msg = protocol.BadRequestParam("11006")
return
}
... ... @@ -236,7 +236,7 @@ func (c RankController) RankSeasonEdit() {
}
ok := serverank.RankPeriodCheckTime(param.RankTypeId, beginTime, endTime, param.Id)
if !ok {
msg = protocol.BadRequestParam("10101")
msg = protocol.BadRequestParam("11001")
return
}
companyid := c.GetCompanyId()
... ... @@ -290,12 +290,12 @@ func (c RankController) RankRangeAdd() {
param.Name = strings.TrimSpace(param.Name)
n := []rune(param.Name)
if len(n) == 0 || len(n) > 5 {
msg = protocol.BadRequestParam("10107")
msg = protocol.BadRequestParam("11007")
return
}
ok := serverank.RankRangeNameOnlyOne(param.RankTypeId, 0, param.Name)
if !ok {
msg = protocol.BadRequestParam("10125")
msg = protocol.BadRequestParam("11009")
return
}
switch param.RangeType {
... ... @@ -339,7 +339,7 @@ func (c RankController) RankRangeEdit() {
param.Name = strings.TrimSpace(param.Name)
n := []rune(param.Name)
if len(n) == 0 || len(n) > 5 {
msg = protocol.BadRequestParam("10107")
msg = protocol.BadRequestParam("11007")
return
}
... ... @@ -488,7 +488,7 @@ func (c RankController) RankItemEdit() {
return
}
if len(param.ItemKey) > 4 {
msg = protocol.BadRequestParam("10123")
msg = protocol.BadRequestParam("11008")
return
}
companyid := c.GetCompanyId()
... ... @@ -517,7 +517,7 @@ func (c RankController) RankRangeMove() {
}
companyid := c.GetCompanyId()
if len(param.RelationId) == 0 {
msg = protocol.BadRequestParam("10126")
msg = protocol.BadRequestParam("11010")
return
}
err := serverank.RankRangeMove(param.FromId, param.ToId, param.RelationId, companyid)
... ...
... ... @@ -40,22 +40,22 @@ func (this *TemplateController) TemplateAdd() {
return
}
if len([]rune(request.Template.Name)) > 30 {
msg = protocol.BadRequestParam("10070")
msg = protocol.BadRequestParam("10610")
return
}
if len([]rune(request.Template.Doc)) > 30 {
msg = protocol.BadRequestParam("10272")
msg = protocol.BadRequestParam("10612")
return
}
{
//审批人配置
v := request.AuditFlowConfig.NoApprover
if !(v == models.NoApproverPass || v == models.NoApproverToAdmin) {
msg = protocol.BadRequestParam("10068")
msg = protocol.BadRequestParam("10608")
return
}
if len(request.AuditFlowConfig.ProcessConfig) == 0 {
msg = protocol.BadRequestParam("10069")
msg = protocol.BadRequestParam("10609")
return
}
}
... ... @@ -116,11 +116,11 @@ func (this *TemplateController) TemplateUpdate() {
return
}
if len([]rune(request.Template.Name)) > 30 {
msg = protocol.BadRequestParam("10070")
msg = protocol.BadRequestParam("10610")
return
}
if len([]rune(request.Template.Doc)) > 30 {
msg = protocol.BadRequestParam("10272")
msg = protocol.BadRequestParam("10612")
return
}
{
... ... @@ -304,7 +304,7 @@ func (this *TemplateController) TemplateOperateCategory() {
return
}
if len([]rune(request.Name)) > 10 {
msg = protocol.BadRequestParam("10070")
msg = protocol.BadRequestParam("10610")
return
}
rsp, err := audit.TemplateOperateCategory(uid, companyId, request)
... ... @@ -448,10 +448,10 @@ func checkSelfCheckData(data []protocol.TemplateSelfCheck) error {
for i, v := range data {
s := []rune(v.Title)
if len(s) == 0 || len(s) > 50 {
return protocol.NewErrWithMessage("10127")
return protocol.NewErrWithMessage("11106")
}
if _, ok := titleMap[v.Title]; ok {
return protocol.NewErrWithMessage("10130")
return protocol.NewErrWithMessage("11109")
} else {
titleMap[v.Title] = 1
}
... ... @@ -460,10 +460,10 @@ func checkSelfCheckData(data []protocol.TemplateSelfCheck) error {
for _, vv := range data[i].Child {
ss := []rune(vv.Title)
if len(ss) == 0 || len(ss) > 50 {
return protocol.NewErrWithMessage("10127")
return protocol.NewErrWithMessage("11106")
}
if _, ok := childTitleMap[vv.Title]; ok {
return protocol.NewErrWithMessage("10130")
return protocol.NewErrWithMessage("11109")
} else {
childTitleMap[vv.Title] = 1
}
... ... @@ -471,7 +471,7 @@ func checkSelfCheckData(data []protocol.TemplateSelfCheck) error {
}
}
if cnt > 30 {
return protocol.NewErrWithMessage("10128")
return protocol.NewErrWithMessage("11107")
}
return nil
}
... ... @@ -482,7 +482,7 @@ func auditFlowMustActionTypeOr(auditflow protocol.AuditFlowConfig) error {
continue
}
if v.AcitonType != models.ActionTypeOr {
return protocol.NewErrWithMessage("10129")
return protocol.NewErrWithMessage("11108")
}
}
return nil
... ...
... ... @@ -59,14 +59,14 @@ var AuthToken = func(ctx *context.Context) {
storetoken, err = redisdata.GetLoginToken(mtoken.UID, mtoken.CompanyID)
if err != nil {
log.Error("redisdata.GetLoginToken err:%s", err)
msg = protocol.NewMessage("10024")
msg = protocol.NewMessage("10204")
ctx.Output.JSON(msg, false, false)
return
}
if beego.BConfig.RunMode == "prod" {
//校验是否是单客户端操作
if storetoken.AccessToken != accesstoken {
msg = protocol.NewMessage("10025")
msg = protocol.NewMessage("10205")
ctx.Output.JSON(msg, false, false)
return
}
... ... @@ -79,12 +79,12 @@ var AuthToken = func(ctx *context.Context) {
return
}
if ok := serveauth.IsJwtErrorExpired(err); ok {
msg := protocol.NewMessage("10024")
msg := protocol.NewMessage("10204")
ctx.Output.JSON(msg, false, false)
return
}
log.Error("token 校验失败:%s", err)
msg = protocol.NewMessage("10024")
msg = protocol.NewMessage("10204")
ctx.Output.JSON(msg, false, false)
return
}
... ...
... ... @@ -16,12 +16,6 @@ type AchievementChance struct {
Code string `json:"code"`
}
type AchievementImage struct {
Path string `json:"path"`
W int `json:"-"`
H int `json:"-"`
}
//RequestAddAchievement 添加成果
type RequestAddAchievement struct {
ChanceData []AchievementChance `json:"chance_data"`
... ... @@ -33,7 +27,7 @@ type RequestAddAchievement struct {
UserGraspScore float64 `json:"user_grasp_score"` //把握人总得分
Provider []AchievementProvider `json:"provider"` //机会提供者
SourceContent string `json:"source_content"` //成果描述文本
Images []AchievementImage `json:"image"` //图片
Images []ImageJsonData `json:"image"` //图片
}
//RequestAddAchievement 添加成果
... ... @@ -46,7 +40,7 @@ type RequestEditAchievement struct {
UserGraspScore float64 `json:"user_grasp_score"` //把握人总得分
SourceContent string `json:"source_content"` //成果描述文本
Provider []AchievementProvider `json:"provider"` //机会提供者
Images []AchievementImage `json:"image"` //图片
Images []ImageJsonData `json:"image"` //图片
}
// ResponseRankSeasonList 赛季列表
... ... @@ -83,6 +77,6 @@ type ResponseAchievementInfo struct {
UserGraspScore float64 `json:"user_grasp_score"` //把握人总得分
Provider []AchievementProvider `json:"provider"` //机会提供者
SourceContent string `json:"source_content"` //成果描述文本
Images []AchievementImage `json:"image"` //图片
Images []ImageJsonData `json:"image"` //图片
CrreateAt string `json:"create_at"`
}
... ...
... ... @@ -111,3 +111,13 @@ type SelectChanceList struct {
ResponsePageInfo
List []SelectChanceListItem `json:"lists"`
}
type ImageJsonData struct {
Path string `json:"path"`
ImageId string `json:"imageId"`
W int `json:"w"`
H int `json:"h"`
}
type VedioJsonData struct {
}
... ...
... ... @@ -88,7 +88,13 @@ func (e ErrWithMessage) Unwrap() error {
//ParseToMessage 实现CustomErrParse的接口
func (e ErrWithMessage) ParseToMessage() *ResponseMessage {
return NewMessage(e.Errno)
rsp := &ResponseMessage{
Errno: transformCode(e.Errno),
Errmsg: e.Errmsg,
Data: NullData,
OriginErrno: e.Errno,
}
return rsp
}
func SearchErr(code string) ErrorCode {
... ...
... ... @@ -4,7 +4,7 @@ var errmessge ErrorMap = map[string]string{
//操作
"0": "ok",
"1": "网络连接无响应",
//角色相关
//角色相关 100xx
"10001": "请先删除该分组下的其他角色",
"10002": "请先删除该角色下的人员",
"10003": "无效角色",
... ... @@ -18,120 +18,126 @@ var errmessge ErrorMap = map[string]string{
"10082": "管理员组角色不能移出",
"10083": "不能将角色添加进管理员组",
"10084": "角色组已存在",
//职位相关
"10011": "该职位已被使用无法删除",
"10012": "超过10级的职位限制,请重新选择",
"10013": "同一级职位名称不允许重复",
"10014": "职位名称最多10个字符",
"10015": "上级职位不能选择当前职位及其下级职位",
//安全认证相关
"10020": "验证码过期",
"10021": "账号或密码不正确",
"10022": "账号已被禁用",
"10023": "用户无使用权限",
"10024": "登录凭证失效",
"10025": "该账号已在其他地方登录",
"10026": "验证码校验失败",
"10027": "无操作权限",
"10028": "请输入正确的验证码",
"10029": "获取验证码失败",
"10080": "无操作权限",
"10111": "获取公司信息失败",
//用户相关
"10031": "无效角色",
"10032": "无效部门",
"10033": "无效职位",
"10034": "名字限制10个字符以内",
"10035": "名字是必填项",
"10036": "请输入正确的手机格式",
"10037": "用户的部门必填",
"10038": "用户的角色必填",
"10039": "用户已存在",
"10071": "不能删除主管理员",
"10072": "不能禁用主管理员",
"10073": "角色组已存在",
"10074": "删除失败,存在需要用户审批的单子",
"10075": "禁用失败,存在需要用户审批的单子",
//部门相关
"10041": "无效的主管设置",
"10042": "上级部门不能选择当前部门及其子部门",
"10043": "部门名称限制不超过20个字符",
"10044": "部门名称必填",
"10045": "同一级部门名称不允许重复",
"10046": "超过10级的部门限制,请重新选择",
"10047": "只能删除没有成员的部门,需要先删除部门下的员工,再删除该部门",
"10048": "请设置上级部门",
//用户中心相关
"10051": "无法从远端接口获取公司数据",
"10052": "服务调用失败",
//模板相关
"10061": "请先删除该分类下的二级分类",
"10062": "该分类已被使用无法删除",
"10063": "该分类已被使用无法禁用",
"10064": "编码已存在",
"10065": "编码长度最多6个字符",
"10067": "一级分类不存在",
"10068": "审核人为空参数有误",
"10069": "未设置审核人",
"10070": "分类名称输入大于10个字符",
"10271": "模板已存在",
"10272": "说明信息输入大于30个字符",
"10273": "表单列最多20个字符",
"10274": "最多添加10个字段",
"10275": "最多添加1个节点",
"10276": "最多选择1个角色",
"10277": "最多一个小数",
"10278": "公告标题大于30个字符",
"10279": "该子分类名称已存在",
"10280": "请为您选择的特殊人员设置审批流程",
"10281": "请您选择的审批人员",
"10282": "请您选择的审批角色",
"10283": "特殊审批流程被审批人不可重复",
"10284": "表单字段已经重复",
"10285": "未设置基础内容",
"10286": "未设置特殊审批人",
//职位相关 101xx
"10101": "该职位已被使用无法删除",
"10102": "超过10级的职位限制,请重新选择",
"10103": "同一级职位名称不允许重复",
"10104": "职位名称最多10个字符",
"10105": "上级职位不能选择当前职位及其下级职位",
"10170": "请选择指定成员",
"10171": "请选择审批人类别",
"10172": "请选择审批方式",
"10173": "请选择指定角色",
"10174": "人数不能超过10个",
"10175": "请选择一个角色",
"10176": "至多添加一个审批人",
//公司相关
"12001": "未找到公司信息",
//安全认证相关 102xx
"10200": "验证码过期",
"10201": "账号或密码不正确",
"10202": "账号已被禁用",
"10203": "用户无使用权限",
"10204": "登录凭证失效",
"10205": "该账号已在其他地方登录",
"10206": "验证码校验失败",
"10207": "无操作权限",
"10208": "请输入正确的验证码",
"10209": "获取验证码失败",
"10210": "无操作权限",
"10211": "获取公司信息失败",
"10212": "公司未启用该模块",
//评分配置相关
"12101": "分值范围不符合要求",
"12102": "评分规则不符合要求",
//权限配置相关
"10091": "至少选择一个特定部门",
//用户相关 103xx
"10301": "无效角色",
"10302": "无效部门",
"10303": "无效职位",
"10304": "名字限制10个字符以内",
"10305": "名字是必填项",
"10306": "请输入正确的手机格式",
"10307": "用户的部门必填",
"10308": "用户的角色必填",
"10309": "用户已存在",
"10310": "不能删除主管理员",
"10311": "不能禁用主管理员",
"10312": "角色组已存在",
"10313": "删除失败,存在需要用户审批的单子",
"10314": "禁用失败,存在需要用户审批的单子",
//部门相关 104xx
"10400": "无效的主管设置",
"10401": "上级部门不能选择当前部门及其子部门",
"10402": "部门名称限制不超过20个字符",
"10403": "部门名称必填",
"10404": "同一级部门名称不允许重复",
"10405": "超过10级的部门限制,请重新选择",
"10406": "只能删除没有成员的部门,需要先删除部门下的员工,再删除该部门",
"10407": "请设置上级部门",
"10101": "赛季周期设置与其他赛季重叠",
"10102": "参与人类型不一致",
"10103": "排行榜名称最多5个字符",
"10104": "赛季名称最多输入20个字符",
"10105": "赛季开始时间必填",
"10106": "赛季结束时间必填",
"10107": "参与范围名称最多输入5个字符",
"10108": "成果一级分类必填",
"10109": "成果来源必填",
"10110": "把握人得分不可大于把握得分",
"10121": "把握得分必填,0.1-100",
"10122": "分配的总分不可大于把握分",
"10123": "排行榜评比项最多4项",
"10124": "公司未启用该模块",
"10125": "参与范围名称不能重复",
"10126": "被转移人员不能为空",
"10127": "自查内容维度名称最多输入50个字符",
"10128": "自查内容维度最多输入30个字段",
"10129": "存在自查内容时只能进行或签设置",
"10130": "同一级的自查内容不能重复",
"10131": "储备池分类名称已存在",
"10132": "无法删除已使用的储备池分类",
"10133": "储备池分类名称必填",
"10134": "储备池分类名称最多20个字",
// 请求统一用户中心相关 105xx
"10501": "无法从远端接口获取公司数据",
"10502": "服务调用失败",
//模板相关 106xx
"10601": "请先删除该分类下的二级分类",
"10602": "该分类已被使用无法删除",
"10603": "该分类已被使用无法禁用",
"10604": "编码已存在",
"10605": "编码长度最多6个字符",
"10607": "一级分类不存在",
"10608": "审核人为空参数有误",
"10609": "未设置审核人",
"10610": "分类名称输入大于10个字符",
"10611": "模板已存在",
"10612": "说明信息输入大于30个字符",
"10613": "表单列最多20个字符",
"10614": "最多添加10个字段",
"10615": "最多添加1个节点",
"10616": "最多选择1个角色",
"10617": "最多一个小数",
"10618": "公告标题大于30个字符",
"10619": "该子分类名称已存在",
"10620": "请为您选择的特殊人员设置审批流程",
"10621": "请您选择的审批人员",
"10622": "请您选择的审批角色",
"10623": "特殊审批流程被审批人不可重复",
"10624": "表单字段已经重复",
"10625": "未设置基础内容",
"10626": "未设置特殊审批人",
"10627": "请选择指定成员",
"10628": "请选择审批人类别",
"10629": "请选择审批方式",
"10630": "请选择指定角色",
"10631": "人数不能超过10个",
"10632": "请选择一个角色",
"10633": "至多添加一个审批人",
//公司相关 107xx
"10701": "未找到公司信息",
//评分配置相关 108xx
"10801": "分值范围不符合要求",
"10802": "评分规则不符合要求",
//权限配置相关 109xx
"10901": "至少选择一个特定部门",
//赛季配置相关 110xx
"11001": "赛季周期设置与其他赛季重叠",
"11002": "参与人类型不一致",
"11003": "排行榜名称最多5个字符",
"11004": "赛季名称最多输入20个字符",
"11005": "赛季开始时间必填",
"11006": "赛季结束时间必填",
"11007": "参与范围名称最多输入5个字符",
"11008": "排行榜评比项最多4项",
"11009": "参与范围名称不能重复",
"11010": "被转移人员不能为空",
//成果相关 111xx
"11101": "成果一级分类必填",
"11102": "成果来源必填",
"11103": "把握人得分不可大于把握得分",
"11104": "把握得分必填,0.1-100",
"11105": "分配的总分不可大于把握分",
"11106": "自查内容维度名称最多输入50个字符",
"11107": "自查内容维度最多输入30个字段",
"11108": "存在自查内容时只能进行或签设置",
"11109": "同一级的自查内容不能重复",
"11110": "储备池分类名称已存在",
"11111": "无法删除已使用的储备池分类",
"11112": "储备池分类名称必填",
"11113": "储备池分类名称最多20个字",
}
//错误码转换 ,兼容需要
... ... @@ -139,7 +145,7 @@ func transformCode(code string) int {
switch code {
case "0":
return 0 //登录成功
case "10026", "10024":
case "10206", "10204":
return 2 //token过期
}
return -1 //请求成功,但业务检查不通过
... ...
... ... @@ -310,7 +310,7 @@ func GetAchievementList(pageIndex int, pageSize int, companyId int64, status int
func GetAchievementInfo(id int64, companyId int64) *protocol.ResponseAchievementInfo {
rspData := &protocol.ResponseAchievementInfo{
Images: make([]protocol.AchievementImage, 0),
Images: make([]protocol.ImageJsonData, 0),
Provider: make([]protocol.AchievementProvider, 0),
ChanceData: make([]protocol.AchievementChance, 0),
}
... ... @@ -326,7 +326,7 @@ func GetAchievementInfo(id int64, companyId int64) *protocol.ResponseAchievement
rspData.ChanceTypeId = achievementData.ChanceTypeId
rspData.DepartmentId = achievementData.DepartmentId
rspData.SourceContent = achievementData.SourceContent
img := make([]protocol.AchievementImage, 0)
img := make([]protocol.ImageJsonData, 0)
json.Unmarshal([]byte(achievementData.Images), &img)
rspData.Images = img
rspData.GraspScore = achievementData.GraspScore
... ...
... ... @@ -53,7 +53,7 @@ func GetReserveTypeLsit(pageIndex int, pageSize int, companyid int64) protocol.R
func AddReserveType(name string, companyid int64) error {
has := models.HasChanceReserveTypeName(name, companyid, 0)
if has {
return protocol.NewErrWithMessage("10131")
return protocol.NewErrWithMessage("11110")
}
m := &models.ChanceReserveType{
Name: name,
... ... @@ -69,7 +69,7 @@ func AddReserveType(name string, companyid int64) error {
func EditReserveType(id int, name string, companyid int64) error {
has := models.HasChanceReserveTypeName(name, companyid, id)
if has {
return protocol.NewErrWithMessage("10131")
return protocol.NewErrWithMessage("11110")
}
m := &models.ChanceReserveType{}
var err error
... ... @@ -106,7 +106,7 @@ func DeleteReserveType(id int, companyid int64) error {
o := orm.NewOrm()
has := o.QueryTable(&models.Chance{}).Filter("reserve_type_id", id).Exist()
if has {
return protocol.NewErrWithMessage("10132")
return protocol.NewErrWithMessage("11111")
}
err = models.DeleteChanceReserveType(id)
if err != nil {
... ...
... ... @@ -28,15 +28,15 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
return
}
if len([]rune(request.Template.Code)) > 6 {
err = protocol.NewErrWithMessage("10065")
err = protocol.NewErrWithMessage("10605")
return
}
if _, err = models.GetAuditTemplateByCode(companyId, request.Template.Code, request.Template.ChanceTypeId); err == nil {
err = protocol.NewErrWithMessage("10064")
err = protocol.NewErrWithMessage("10604")
return
}
if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name, request.Template.ChanceTypeId); err == nil {
err = protocol.NewErrWithMessage("10279")
err = protocol.NewErrWithMessage("10619")
return
}
orm := orm2.NewOrm()
... ... @@ -390,7 +390,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques
}
if template.Name != request.Template.Name {
if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name, request.Template.ChanceTypeId); err == nil {
err = protocol.NewErrWithMessage("10279")
err = protocol.NewErrWithMessage("10619")
return
}
}
... ... @@ -604,7 +604,7 @@ func TemplateEditVisible(uid, companyId int64, request *protocol.TemplateEditVis
return
}
if template.CompanyId != int(companyId) {
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
log.Error("template_id:%v companyId:%v want:%v not equal.", request.Id, companyId, template.CompanyId)
return
}
... ... @@ -646,7 +646,7 @@ func TemplateEditSort(uid, companyId int64, request *protocol.TemplateEditSortRe
}
if template.CompanyId != int(companyId) {
log.Debug(fmt.Sprintf("template.companyId input:%v want:%v not equal.", companyId, template.CompanyId))
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
return
}
if item.SortNum == template.SortNum {
... ... @@ -751,17 +751,17 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques
return
}
if template.CompanyId != int(companyId) {
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
return
}
//2.判断是否有对应已经发布的机会
if err = utils.ExecuteQueryOne(&num, sql1, request.TemplateId); err == nil && num > 0 {
err = protocol.NewErrWithMessage("10062")
err = protocol.NewErrWithMessage("10602")
return
}
//3.判断是否有对应发布的成果
if err = utils.ExecuteQueryOne(&num, sql2, request.TemplateId); err == nil && num > 0 {
err = protocol.NewErrWithMessage("10062")
err = protocol.NewErrWithMessage("10602")
return
}
... ... @@ -802,13 +802,13 @@ func TemplateEditEnable(uid, companyId int64, request *protocol.TemplateEditEnab
return
}
if template.CompanyId != int(companyId) {
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
return
}
//2.判断是否有对应已经发布的机会
if request.Enabled == 0 {
if err = utils.ExecuteQueryOne(&num, sql1, request.TemplateId); err == nil && num > 0 {
err = protocol.NewErrWithMessage("10063")
err = protocol.NewErrWithMessage("10603")
return
}
}
... ... @@ -832,13 +832,13 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe
return
}
if chanceType.CompanyId != int(companyId) {
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
log.Error("template_id:%v companyId:%v want:%v not equal.", request.Id, companyId, chanceType.CompanyId)
return
}
if chanceType.Name != request.Name {
if _, err = models.GetChanceTypeByName(companyId, request.Name); err == nil {
err = protocol.NewErrWithMessage("10271")
err = protocol.NewErrWithMessage("10611")
return
}
}
... ... @@ -850,7 +850,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe
return
}
if len([]rune(request.Code)) > 6 {
err = protocol.NewErrWithMessage("10065")
err = protocol.NewErrWithMessage("10605")
return
}
chanceType = &models.ChanceType{
... ... @@ -862,11 +862,11 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe
UpdateAt: time.Now(),
}
if _, err = models.GetChanceTypeByCode(companyId, chanceType.Code); err == nil {
err = protocol.NewErrWithMessage("10064")
err = protocol.NewErrWithMessage("10604")
return
}
if _, err = models.GetChanceTypeByName(companyId, chanceType.Name); err == nil {
err = protocol.NewErrWithMessage("10271")
err = protocol.NewErrWithMessage("10611")
return
}
if c, e := models.GetChanceTypeMaxSort(companyId); e == nil {
... ... @@ -894,28 +894,28 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele
if chanceType, err = models.GetChanceTypeById(request.ChanceTypeId); err != nil {
log.Error(err.Error())
if err == orm2.ErrNoRows {
err = protocol.NewErrWithMessage("10067")
err = protocol.NewErrWithMessage("10607")
}
return
}
if chanceType.CompanyId != int(companyId) {
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
return
}
//1.判断分类下面是否有模板
if err = utils.ExecuteQueryOne(&num, sql1, request.ChanceTypeId); err == nil && num > 0 {
err = protocol.NewErrWithMessage("10061")
err = protocol.NewErrWithMessage("10601")
return
}
//2.判断是否有对应已经发布的机会
if err = utils.ExecuteQueryOne(&num, sql2, request.ChanceTypeId); err == nil && num > 0 {
err = protocol.NewErrWithMessage("10062")
err = protocol.NewErrWithMessage("10602")
return
}
//3.判断是否有对应发布的成果
if err = utils.ExecuteQueryOne(&num, sql3, request.ChanceTypeId); err == nil && num > 0 {
err = protocol.NewErrWithMessage("10062")
err = protocol.NewErrWithMessage("10602")
return
}
... ... @@ -941,7 +941,7 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe
}
if template.CompanyId != int(companyId) {
log.Debug(fmt.Sprintf("template.companyId input:%v want:%v not equal.", companyId, template.CompanyId))
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
return
}
if item.SortNum == template.SortNum {
... ... @@ -968,49 +968,49 @@ func ValidAuditFlowConfig(flowConfig protocol.AuditFlowConfig) (msg *protocol.Re
for i := range flowConfig.ProcessConfig {
config := flowConfig.ProcessConfig[i]
if !(config.ApproveType == models.AuditByDepartmentor || config.ApproveType == models.AuditByUser || config.ApproveType == models.AuditByRole) {
msg = protocol.BadRequestParam("10171")
msg = protocol.BadRequestParam("10628")
return
}
if !(config.AcitonType == models.ActionTypeOr || config.AcitonType == models.ActionTypeAnd) {
msg = protocol.BadRequestParam("10172")
msg = protocol.BadRequestParam("10629")
return
}
if config.ApproveType == models.AuditByUser {
if len(config.ToUser) == 0 {
msg = protocol.BadRequestParam("10170")
msg = protocol.BadRequestParam("10627")
return
}
if len(config.ToUser) > 10 {
msg = protocol.BadRequestParam("10174")
msg = protocol.BadRequestParam("10631")
return
}
}
if config.ApproveType == models.AuditByRole {
if len(config.ToRole) == 0 {
msg = protocol.BadRequestParam("10173")
msg = protocol.BadRequestParam("10630")
return
}
if len(config.ToRole) > 1 {
msg = protocol.BadRequestParam("10175")
msg = protocol.BadRequestParam("10632")
return
}
}
if config.ProcessType == models.FlowTypeNormal {
count++
if count > 1 {
msg = protocol.BadRequestParam("10176")
msg = protocol.BadRequestParam("10633")
return
}
}
if config.ProcessType == models.FlowTypeSpecail {
if len(config.FromSpecialUser) == 0 { //特殊人为空
msg = protocol.BadRequestParam("10286")
msg = protocol.BadRequestParam("10626")
return
}
for i := range config.FromSpecialUser {
u := config.FromSpecialUser[i]
if _, ok := specailUser[u.Id]; ok {
msg = protocol.BadRequestParam("10283")
msg = protocol.BadRequestParam("10623")
return
} else {
specailUser[u.Id] = u.Id
... ... @@ -1029,13 +1029,13 @@ func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseM
break
case models.AuditByUser:
if len(config.ToUser) == 0 {
msg = protocol.BadRequestParam("10281")
msg = protocol.BadRequestParam("10621")
return
}
break
case models.AuditByRole:
if len(config.ToRole) == 0 {
msg = protocol.BadRequestParam("10282")
msg = protocol.BadRequestParam("10622")
return
}
break
... ... @@ -1056,12 +1056,12 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa
for i := range inputs {
input := inputs[i]
if len([]rune(input.Label)) > 50 {
msg = protocol.BadRequestParam("10273")
msg = protocol.BadRequestParam("10613")
return
}
key := fmt.Sprintf("%v-%v", input.SectionType, input.Label)
if _, ok := mapCheckRe[key]; ok {
msg = protocol.BadRequestParam("10284")
msg = protocol.BadRequestParam("10624")
return
} else {
mapCheckRe[key] = key
... ... @@ -1077,11 +1077,11 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa
}
}
if countBasic == 0 {
msg = protocol.BadRequestParam("10285")
msg = protocol.BadRequestParam("10625")
return
}
if countBasic > 10 || countExtral > 10 {
msg = protocol.BadRequestParam("10274")
msg = protocol.BadRequestParam("10614")
return
}
return
... ...
... ... @@ -8,6 +8,7 @@ import (
"oppmg/common/log"
"oppmg/models"
"oppmg/protocol"
serverplatform "oppmg/services/platform"
serverbac "oppmg/services/rbac"
"oppmg/services/ucenter"
"oppmg/storage/redisdata"
... ... @@ -120,11 +121,11 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error)
}
if ok := usercompany.IsEnable(); !ok {
log.Debug("公司禁用此用户")
return logintoken, protocol.NewErrWithMessage("10027")
return logintoken, protocol.NewErrWithMessage("10207")
}
if ok := usercompany.IsDelete(); ok {
log.Debug("公司删除此用户")
return logintoken, protocol.NewErrWithMessage("10027")
return logintoken, protocol.NewErrWithMessage("10207")
}
companydata, err = models.GetCompanyById(usercompany.CompanyId)
if err != nil {
... ... @@ -133,7 +134,7 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error)
}
if ok := companydata.IsEnable(); !ok {
log.Debug("无效公司")
return logintoken, protocol.NewErrWithMessage("10027")
return logintoken, protocol.NewErrWithMessage("10207")
}
logintoken, err = GenerateAuthToken(userid, companydata.Id, usercompany.Id)
if err != nil {
... ... @@ -156,28 +157,28 @@ func LoginAuthByUCenter(account, password string) (
var uclientReturn *ucenter.ResponseLogin
uclientReturn, err = ucenter.RequestUCenterLogin(account, password)
if err != nil {
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
userdata, err = models.GetUserByUCenter(uclientReturn.Data.Id)
if err != nil {
log.Debug("GetUserByUCenter(%d) err:%s", uclientReturn.Data.Id, err)
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
if ok := userdata.IsDelete(); ok {
log.Debug("userdata.IsDelete()==true")
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
if ok := userdata.IsEnable(); !ok {
log.Debug("userdata.IsEnable()==false")
return logintoken, protocol.NewErrWithMessage("10022")
return logintoken, protocol.NewErrWithMessage("10202")
}
if companys, err = getUserCompanyReal(userdata.Id); err != nil {
log.Error("getUserCompanyReal err:%s", err)
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
if len(companys) == 0 {
log.Debug("no company")
return logintoken, protocol.NewErrWithMessage("10022")
return logintoken, protocol.NewErrWithMessage("10202")
}
//获取上一次登录的公司
uAuth, err := models.GetUserAuthByUser(userdata.Id)
... ... @@ -200,7 +201,7 @@ func LoginAuthByUCenter(account, password string) (
ucompany, err := models.GetUserCompanyBy(userdata.Id, companyid)
if err != nil {
log.Error("获取user_company失败;%s", err)
return logintoken, protocol.NewErrWithMessage("10022")
return logintoken, protocol.NewErrWithMessage("10202")
}
usercompanyid = ucompany.Id
logintoken, _ = GenerateAuthToken(userdata.Id, companyid, usercompanyid)
... ... @@ -293,16 +294,19 @@ func UserBaseInfo(userid, companyid int64) (protocol.ResponseMeInfo, error) {
func UserHasCompanys(userid int64) ([]protocol.MeCompany, error) {
var (
companylist []companybase
userData *models.User
err error
mecompanys []protocol.MeCompany
)
companylist, err = getUserCompanyReal(userid)
userData, err = models.GetUserById(userid)
if err != nil {
log.Error("getUserCompanyReal(%d) err:%s", userid, err)
return nil, protocol.NewErrWithMessage("1", err)
return mecompanys, fmt.Errorf("获取用户数据失败")
}
for _, v := range companylist {
resp, err := serverplatform.GetUserCompanyDo(userData.Phone)
if err != nil {
return mecompanys, fmt.Errorf("获取数据失败:%s", err)
}
for _, v := range resp.Data.Company {
t := protocol.MeCompany{
Id: v.Id,
Name: v.Name,
... ... @@ -440,23 +444,23 @@ func LoginAuthBySmsCode(uclientReturn *ucenter.ResponseLoginSms) (
userdata, err = models.GetUserByUCenter(uclientReturn.Data.Cuid)
if err != nil {
log.Debug("GetUserByUCenter(%s) err:%s", uclientReturn.Data.Cuid, err)
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
if ok := userdata.IsDelete(); ok {
log.Debug("userdata.IsDelete()==true")
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
if ok := userdata.IsEnable(); !ok {
log.Debug("userdata.IsEnable()==false")
return logintoken, protocol.NewErrWithMessage("10022")
return logintoken, protocol.NewErrWithMessage("10202")
}
if companys, err = getUserCompanyReal(userdata.Id); err != nil {
log.Error("getUserCompanyReal err:%s", err)
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
if len(companys) == 0 {
log.Debug("no company")
return logintoken, protocol.NewErrWithMessage("10022")
return logintoken, protocol.NewErrWithMessage("10202")
}
//获取上一次登录的公司
uAuth, err := models.GetUserAuthByUser(userdata.Id)
... ... @@ -503,11 +507,11 @@ func SmsCodeSend(phone string) error {
_, err = models.GetUserByPhone(phone)
if err != nil {
log.Error("GetUserByPhone(%s) err:%s", phone, err)
return protocol.NewErrWithMessage("10027")
return protocol.NewErrWithMessage("10207")
}
err = ucenter.RequestUCenterSmsCode(phone)
if err != nil {
return protocol.NewErrWithMessage("10029")
return protocol.NewErrWithMessage("10209")
}
return nil
}
... ... @@ -515,7 +519,7 @@ func SmsCodeSend(phone string) error {
func SmsCodeCheck(phone string, code string) error {
resp, err := ucenter.RequestUCenterSmsCodeCheck(phone, code)
if err != nil {
return protocol.NewErrWithMessage("10026")
return protocol.NewErrWithMessage("10206")
}
//redis 缓存设置
redisdata.SetCaptchAuth(phone, resp.Data.CaptchaCertificate)
... ... @@ -593,26 +597,44 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) {
},
}
}
userdata, err = models.GetUserByPhone(uclientReturn.Data.Phone)
if err != nil {
log.Debug("GetUserByPhone(%d) err:%s", uclientReturn.Data.Phone, err)
return logintoken, protocol.NewErrWithMessage("10021")
return logintoken, protocol.NewErrWithMessage("10201")
}
companyData, err = models.GetCompanyByUCenter(uclientReturn.Data.CompanyId)
if err != nil {
log.Error("获取company数据失败:%s", err)
return logintoken, protocol.NewErrWithMessage("10111")
return logintoken, protocol.NewErrWithMessage("10211")
}
if companyData.Enable == models.COMPANY_ENABLE_NO {
log.Error("公司未启用机会模块")
return logintoken, protocol.NewErrWithMessage("10124")
return logintoken, protocol.NewErrWithMessage("10212")
}
ucompany, err := models.GetUserCompanyBy(userdata.Id, companyData.Id)
if err != nil {
log.Error("获取user_company失败;%s", err)
return logintoken, protocol.NewErrWithMessage("10022")
return logintoken, protocol.NewErrWithMessage("10202")
}
businessAdminResp, err := serverplatform.GetuserAuthDo(ucompany.Id)
if err != nil {
log.Error("向企业平台获取鉴权结果失败,err:%s", err)
return logintoken, protocol.NewErrWithMessage("1")
}
if ok := businessAdminResp.IsOK(); !ok {
return logintoken, protocol.ErrWithMessage{
ErrorCode: protocol.ErrorCode{
Errno: "-1",
Errmsg: businessAdminResp.Msg,
},
}
}
if !businessAdminResp.Data.UserAuth {
log.Error("用户没有权限进行操作")
return logintoken, protocol.NewErrWithMessage("10210")
}
logintoken, _ = GenerateAuthToken(userdata.Id, companyData.Id, ucompany.Id)
//更新用户数据
userdata.Accid = uclientReturn.Data.Accid
... ...
... ... @@ -460,7 +460,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest)
return
}
if bulletin.CompanyId != companyId {
err = protocol.NewErrWithMessage("10027")
err = protocol.NewErrWithMessage("10207")
log.Error("company_id:%v want:%v", companyId, bulletin.CompanyId)
return
}
... ...
... ... @@ -527,7 +527,7 @@ func ForbidCompany(ucenterCompany int64) error {
companyData, err = models.GetCompanyByUCenter(ucenterCompany)
if err == orm.ErrNoRows {
log.Warn("未查找到公司数据")
return protocol.NewErrWithMessage("12001")
return protocol.NewErrWithMessage("10701")
}
if err != nil && err != orm.ErrNoRows {
log.Error(err.Error())
... ... @@ -553,7 +553,7 @@ func AllowCompany(ucenterCompany int64) error {
companyData, err = models.GetCompanyByUCenter(ucenterCompany)
if err == orm.ErrNoRows {
log.Warn("未查找到公司数据")
return protocol.NewErrWithMessage("12001")
return protocol.NewErrWithMessage("10701")
}
if err != nil && err != orm.ErrNoRows {
log.Error(err.Error())
... ...
... ... @@ -21,7 +21,7 @@ func DepartmentAdd(param protocol.RequestDepartmentAdd) (protocol.ResponseDepart
ok := models.ExistDepartmentName(param.ParentID, param.Name)
if ok {
return returndata, protocol.NewErrWithMessage("10045")
return returndata, protocol.NewErrWithMessage("10404")
}
if param.ParentID > 0 {
parentDepart, err = models.GetDepartmentById(param.ParentID)
... ... @@ -39,7 +39,7 @@ func DepartmentAdd(param protocol.RequestDepartmentAdd) (protocol.ResponseDepart
r := parentDepart.Relation
rs := strings.Split(r, "/")
if len(rs) >= 10 { //层级不能超过10级
return returndata, protocol.NewErrWithMessage("10046")
return returndata, protocol.NewErrWithMessage("10405")
}
}
... ... @@ -107,13 +107,13 @@ func DepartmentEdit(param protocol.RequestDepartmentEdit) error {
param.ParentID = departUpdate.ParentId
} else {
if param.ParentID <= 0 {
return protocol.NewErrWithMessage("10048")
return protocol.NewErrWithMessage("10407")
}
}
if param.Name != departUpdate.Name {
ok := models.ExistDepartmentName(param.ParentID, param.Name)
if ok {
return protocol.NewErrWithMessage("10045")
return protocol.NewErrWithMessage("10404")
}
}
//确认部门主管变更情况
... ... @@ -126,19 +126,19 @@ func DepartmentEdit(param protocol.RequestDepartmentEdit) error {
if err != nil {
e := fmt.Errorf("GetUserCompanyReal err:%s", err)
log.Error(e.Error())
return protocol.NewErrWithMessage("10041")
return protocol.NewErrWithMessage("10400")
}
for i := range uc {
if uc[i].CompanyId != param.CompanyID {
e := fmt.Errorf("managers err")
log.Error(e.Error())
return protocol.NewErrWithMessage("10041")
return protocol.NewErrWithMessage("10400")
}
//检查设置的主管是否是部门下的人员
ok := models.ExistUserDepart(param.ID, uc[i].Id)
if !ok {
log.Error("false=aExistUserDepart(departid,usercompanyid) [%d,%d]", param.ID, uc[i].Id)
return protocol.NewErrWithMessage("10041")
return protocol.NewErrWithMessage("10400")
}
newManage = append(newManage, uc[i].Id)
}
... ... @@ -231,7 +231,7 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models
o.Rollback()
e := fmt.Errorf("departSubset[i].Id == newparent.Id")
log.Error(e.Error())
return protocol.NewErrWithMessage("10042")
return protocol.NewErrWithMessage("10401")
}
s := strings.TrimPrefix(departSubset[i].Relation, oldRelation)
//重建关系树
... ... @@ -240,7 +240,7 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models
n := strings.Split(departSubset[i].Relation, "/")
if len(n) > 10 {
o.Rollback()
return protocol.NewErrWithMessage("10046")
return protocol.NewErrWithMessage("10405")
}
err = utils.ExecuteSQLWithOrmer(o, dataSql2, departSubset[i].Relation, departSubset[i].Id)
if err != nil {
... ... @@ -306,7 +306,7 @@ func DepartmentDelete(param protocol.RequestDepartmentDelete) error {
if cnt > 0 {
e := fmt.Errorf("user in department,relation:%s", subset.Relation)
log.Error(e.Error())
return protocol.NewErrWithMessage("10047", e)
return protocol.NewErrWithMessage("10406", e)
}
if _, ok := toDelete[subset.Id]; ok && subset.Id != pos.Id {
delete(toDelete, subset.Id)
... ...
... ... @@ -30,7 +30,7 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI
}
ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name)
if ok {
return nil, protocol.NewErrWithMessage("10013")
return nil, protocol.NewErrWithMessage("10103")
}
//检查上级
if param.ParentID > 0 {
... ... @@ -48,7 +48,7 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI
r := parentPosition.Relation
rs := strings.Split(r, "/")
if len(rs) >= 10 { //层级不能超过10级
return nil, protocol.NewErrWithMessage("10012")
return nil, protocol.NewErrWithMessage("10102")
}
}
... ... @@ -109,7 +109,7 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio
if positionUpdate.Name != param.Name {
ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name)
if ok {
return nil, protocol.NewErrWithMessage("10013")
return nil, protocol.NewErrWithMessage("10103")
}
positionUpdate.Name = param.Name
}
... ... @@ -136,14 +136,14 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio
r := parentPosition.Relation
rs := strings.Split(r, "/")
if len(rs) >= 10 { //层级不能超过10级
return nil, protocol.NewErrWithMessage("10012")
return nil, protocol.NewErrWithMessage("10102")
}
}
//更新部门关系数据
if positionUpdate.ParentId != param.ParentID {
ok := models.ExistPositiontName(param.CompanyID, param.ParentID, param.Name)
if ok {
return nil, protocol.NewErrWithMessage("10013")
return nil, protocol.NewErrWithMessage("10103")
}
err = positionRelationUpdate(positionUpdate, parentPosition)
if err != nil {
... ... @@ -213,7 +213,7 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P
o.Rollback()
e := fmt.Errorf("departSubset[i].Id == newparent.Id")
log.Error(e.Error())
return protocol.NewErrWithMessage("10015", e)
return protocol.NewErrWithMessage("10105", e)
}
//重建关系树
s := strings.TrimPrefix(positionSubset[i].Relation, oldRelation)
... ... @@ -221,7 +221,7 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P
rs := strings.Split(positionSubset[i].Relation, "/")
if len(rs) > 10 { //层级不能超过10级
o.Rollback()
return protocol.NewErrWithMessage("10012")
return protocol.NewErrWithMessage("10102")
}
err = utils.ExecuteSQLWithOrmer(o, dataSql2, positionSubset[i].Relation, positionSubset[i].Id)
if err != nil {
... ... @@ -283,7 +283,7 @@ func PositionDelete(param protocol.RequestPositionDelete) error {
if cnt > 0 {
e := fmt.Errorf("user in position,relation:%s", subset.Relation)
log.Error(e.Error())
return protocol.NewErrWithMessage("10011", e)
return protocol.NewErrWithMessage("10101", e)
}
if _, ok := toDelete[subset.Id]; ok && subset.Id != pos.Id {
delete(toDelete, subset.Id)
... ...
... ... @@ -103,7 +103,7 @@ func validCompanyRole(companyid int64, roleid []int64) error {
if err != nil {
e := fmt.Errorf("ValidCompanyRole err:%s [company:%d,role:%d]", err, companyid, v)
log.Error(e.Error())
return protocol.NewErrWithMessage("10031")
return protocol.NewErrWithMessage("10301")
}
}
return nil
... ... @@ -123,7 +123,7 @@ func validCompanyDepart(companyid int64, departid []int64) error {
if err != nil {
e := fmt.Errorf("ValidCompanyDepart err:%s [company:%d,department:%d]", err, companyid, v)
log.Error(e.Error())
return protocol.NewErrWithMessage("10032")
return protocol.NewErrWithMessage("10302")
}
}
... ... @@ -145,7 +145,7 @@ func validCompanyPosition(companyid int64, positionid []int64) error {
if err != nil {
e := fmt.Errorf("ValidCompanyPosition err:%s [company:%d,department:%d]", err, companyid, v)
log.Error(e.Error())
return protocol.NewErrWithMessage("10033")
return protocol.NewErrWithMessage("10303")
}
}
... ... @@ -164,7 +164,7 @@ func existCompanyUser(companyid int64, phone string) error {
ok := models.ExistUserCompany(userdata.Id, companyid)
if ok {
return protocol.NewErrWithMessage("10039")
return protocol.NewErrWithMessage("10309")
}
return nil
}
... ... @@ -470,14 +470,14 @@ func UserDelete(userCompanyids []int64, companyid int64) error {
Filter("review_status__in", models.AuditFlowProcessReviewWait, models.AuditFlowProcessReviewIng).
Exist()
if exist {
return protocol.NewErrWithMessage("10074")
return protocol.NewErrWithMessage("10313")
}
var (
ids []int64
)
for _, v := range updateIds {
if v.UserId == companyInfo.AdminId {
return protocol.NewErrWithMessage("10071")
return protocol.NewErrWithMessage("10310")
}
ids = append(ids, v.Id)
}
... ... @@ -671,14 +671,14 @@ func UserForbid(userCompanyids []int64, companyid int64) error {
Filter("review_status__in", models.AuditFlowProcessReviewWait, models.AuditFlowProcessReviewIng).
Exist()
if exist {
return protocol.NewErrWithMessage("10075")
return protocol.NewErrWithMessage("10314")
}
var (
ids []int64
)
for _, v := range updateIds {
if v.UserId == companyInfo.AdminId {
return protocol.NewErrWithMessage("10072")
return protocol.NewErrWithMessage("10311")
}
ids = append(ids, v.Id)
}
... ...
... ... @@ -30,7 +30,7 @@ func ConfigScore(uid, companyId int64, request *protocol.ConfigScoreRequest) (rs
return
}
if scoreConfig.CompanyId != int(companyId) {
err = protocol.NewErrWithMessage("10027") //无权限
err = protocol.NewErrWithMessage("10207") //无权限
return
}
goto UPDATE
... ... @@ -38,26 +38,26 @@ func ConfigScore(uid, companyId int64, request *protocol.ConfigScoreRequest) (rs
return
}
if !(checkScoreRange(request.BasicScore) && checkScoreRange(request.ExtraScore) && checkScoreRange(request.ValueScore)) {
err = protocol.NewErrWithMessage("12101")
err = protocol.NewErrWithMessage("10801")
return
}
if request.DiscoveryScore != nil {
c := request.DiscoveryScore
if !(checkFactor(c.BasicFactor) && checkFactor(c.ExtraFactor) && checkFactor(c.ValueFactor)) {
err = protocol.NewErrWithMessage("12102")
err = protocol.NewErrWithMessage("10802")
return
}
} else {
err = protocol.NewErrWithMessage("12102")
err = protocol.NewErrWithMessage("10802")
return
}
if request.SumScore != nil {
if !(checkSumScoreFactor(request.SumScore.DiscoveryFactor) && checkSumScoreFactor(request.SumScore.CatchFactor)) {
err = protocol.NewErrWithMessage("12102")
err = protocol.NewErrWithMessage("10802")
return
}
} else {
err = protocol.NewErrWithMessage("12102")
err = protocol.NewErrWithMessage("10802")
return
}
if scoreConfig, err = models.GetSysConfigByCompanyId(int(companyId), models.KeyScore); err != nil {
... ... @@ -113,7 +113,7 @@ func GetConfigScore(uid, companyId int64, request *protocol.GetConfigScoreReques
//检查分值范围
func checkScoreRange(scoreRange *protocol.ScoreRange) (result bool) {
//err = protocol.NewErrWithMessage("12101")
//err = protocol.NewErrWithMessage("10801")
result = false
if scoreRange.Min < 0 {
return
... ... @@ -135,7 +135,7 @@ func checkScoreRange(scoreRange *protocol.ScoreRange) (result bool) {
//检查发现分计算规则
func checkFactor(factor float64) (result bool) {
result = false
//err = protocol.NewErrWithMessage("12102")
//err = protocol.NewErrWithMessage("10802")
if factor < 0.1 || factor > 1 {
return
}
... ... @@ -147,7 +147,7 @@ func checkFactor(factor float64) (result bool) {
//检查总分计算规则
func checkSumScoreFactor(factor float64) (result bool) {
result = false
//err = protocol.NewErrWithMessage("12102")
//err = protocol.NewErrWithMessage("10802")
if factor < 0.1 || factor > 10 {
return
}
... ...
... ... @@ -2,6 +2,8 @@ package platform
import "errors"
//提供给企业平台调用
type PlatformAction interface {
DoAction(string, []byte) error
}
... ...
package platform
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
mconfig "oppmg/common/config"
"oppmg/common/log"
"time"
)
const (
ResponseOk int = 0
)
//请求企业平台的接口
type IBusinessAdminParam interface {
Format() []byte
GetPath() (string, string) //返回请求路径path,请求方式mathod
}
type BusinessAdminClient struct {
baseUrl string
}
func NewBusinessAdminClient() *BusinessAdminClient {
return &BusinessAdminClient{
baseUrl: mconfig.MConfig.BusinessAdminUrl,
}
}
func (client BusinessAdminClient) buildHeader() http.Header {
var h = http.Header{}
h.Set("Content-Type", "application/json")
h.Set("Accept", "application/json")
return h
}
//httpDo post发送json
func (client BusinessAdminClient) httpDo(path string, mathod string, posts []byte) ([]byte, error) {
httpclient := http.Client{
Timeout: 10 * time.Second, //请求超时时间10秒
}
reqURL := client.baseUrl + path
req, err := http.NewRequest(mathod, reqURL, bytes.NewReader(posts))
if err != nil {
return nil, err
}
req.Header = client.buildHeader()
resp, err := httpclient.Do(req)
log.Info("====>Send To URL:%s", reqURL)
log.Info("====>Send To BusinessAdmin:%s", string(posts))
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
log.Info("<====BusinessAdmin Return:%s", string(body))
return body, nil
}
func (client BusinessAdminClient) Call(param IBusinessAdminParam) ([]byte, error) {
path, mathod := param.GetPath()
return client.httpDo(path, mathod, param.Format())
}
type CommResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
func (resp CommResponse) IsOK() bool {
if resp.Code != ResponseOk {
return false
}
return true
}
//GetuserAuth 企业后台鉴权
//userId 企业后台的用户id ,对应机会系统内的user_company表的字段id
//PlatformId 编号 机会系统固定值18
type RequestGetuserAuth struct {
UserId string `json:"userId"`
platformId string `json:"platformId"`
}
type ResponseGetUserAuth struct {
CommResponse
Data struct {
UserAuth bool `json:"userAuth"`
} `json:"data"`
}
func (r RequestGetuserAuth) Format() []byte {
r.platformId = "3"
var bt []byte
bt, _ = json.Marshal(r)
return bt
}
func (r RequestGetuserAuth) GetPath() (string, string) {
return "/auth/get-user-auth", "POST"
}
func GetuserAuthDo(userid int64) (ResponseGetUserAuth, error) {
param := RequestGetuserAuth{
UserId: fmt.Sprint(userid),
}
var resp ResponseGetUserAuth
uclient := NewBusinessAdminClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("向企业平台发送请求失败 err:%s", err)
return resp, errors.New("向企业平台发送请求失败")
}
err = json.Unmarshal(btBody, &resp)
if err != nil {
log.Error("解析企业平台响应失败 err:%s", err)
return resp, errors.New("解析企业平台响应失败")
}
return resp, nil
}
//RequestGetUserCompany 从企业平台获取用户的公司
type RequestGetUserCompany struct {
Phone string `json:"phone"`
platformId string `json:"platformId"`
}
type ResponseGetUserCompany struct {
CommResponse
Data struct {
Company []struct {
Id int64 `json:"id"`
Name string `json:"name"`
Logo string `json:"logo"`
} `json:"company"`
} `json:"data"`
}
func (r RequestGetUserCompany) Format() []byte {
r.platformId = "3"
var bt []byte
bt, _ = json.Marshal(r)
return bt
}
func (r RequestGetUserCompany) GetPath() (string, string) {
return "/companies/user-company", "POST"
}
func GetUserCompanyDo(phone string) (ResponseGetUserCompany, error) {
param := RequestGetUserCompany{
Phone: phone,
}
var resp ResponseGetUserCompany
uclient := NewBusinessAdminClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("向企业平台发送请求失败 err:%s", err)
return resp, errors.New("向企业平台发送请求失败")
}
err = json.Unmarshal(btBody, &resp)
if err != nil {
log.Error("解析企业平台响应失败 err:%s", err)
return resp, errors.New("解析企业平台响应失败")
}
return resp, nil
}
... ...
... ... @@ -448,7 +448,7 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
}
ok := RankRangeNameOnlyOne(rankRange.RankTypeId, rankRange.Id, name)
if !ok {
return protocol.NewErrWithMessage("10125")
return protocol.NewErrWithMessage("11009")
}
rankRangeDatas, err = models.GetRankRangeDataByRangeId(rankRange.Id)
if err != nil {
... ... @@ -825,7 +825,7 @@ func RankRangeMove(fromId int64, toId int64, relationId []int64, companyid int64
}
if fromTypeFlag != ToTypeFlag {
log.Error("RankRange类型不一致")
return protocol.NewErrWithMessage("10102")
return protocol.NewErrWithMessage("11002")
}
var (
... ...
... ... @@ -221,7 +221,7 @@ func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64
if param.Check == OpportunityCheckLv3 {
if len(param.CheckOption.Departments) == 0 {
return protocol.NewErrWithMessage("10091")
return protocol.NewErrWithMessage("10901")
}
}
... ...
... ... @@ -189,7 +189,7 @@ func RoleGroupEdit(companyid int64, id int64, name string) (*protocol.ResponseRo
if roleinfo.Name != name {
ok := models.ExistRoleName(companyid, name, models.ROLETYPES_GROUP)
if ok {
return nil, protocol.NewErrWithMessage("10073")
return nil, protocol.NewErrWithMessage("10312")
}
roleinfo.Name = name
}
... ...
... ... @@ -8,6 +8,8 @@ import (
"oppmg/protocol"
)
// 请求统一用户中心的接口
//RequestUCenterLogin 调用用户中心进行账号密码登录
func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
var uclientReturn ResponseLogin
... ... @@ -19,7 +21,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
err = json.Unmarshal(btBody, &uclientReturn)
... ... @@ -27,8 +29,8 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(uclientReturn.Code == ResponseCode0) {
return nil, protocol.NewErrWithMessage("10052")
if !(uclientReturn.Code == ResponseCodeOk) {
return nil, protocol.NewErrWithMessage("10502")
}
return &uclientReturn, nil
}
... ... @@ -44,7 +46,7 @@ func RequestUCenterLoginBySecret(secret string) (*ResponseLogin, error) {
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
err = json.Unmarshal(btBody, &uclientReturn)
... ... @@ -52,7 +54,7 @@ func RequestUCenterLoginBySecret(secret string) (*ResponseLogin, error) {
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(uclientReturn.Code == ResponseCode0) {
if !(uclientReturn.Code == ResponseCodeOk) {
return &uclientReturn, protocol.NewErrWithMessage("1")
}
return &uclientReturn, nil
... ... @@ -75,7 +77,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
err = json.Unmarshal(btBody, &ucenterReturn)
... ... @@ -83,8 +85,8 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0) {
return nil, protocol.NewErrWithMessage("10052")
if !(ucenterReturn.Code == ResponseCodeOk) {
return nil, protocol.NewErrWithMessage("10502")
}
return &ucenterReturn, nil
}
... ... @@ -100,7 +102,7 @@ func RequestUCenterSmsCode(phone string) error {
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return protocol.NewErrWithMessage("1")
}
var ucenterReturn CommResponse
... ... @@ -109,8 +111,8 @@ func RequestUCenterSmsCode(phone string) error {
log.Error("解析统一用户中心响应失败 err:%s", err)
return protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0) {
return protocol.NewErrWithMessage("10052")
if !(ucenterReturn.Code == ResponseCodeOk) {
return protocol.NewErrWithMessage("10502")
}
return nil
}
... ... @@ -125,7 +127,7 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
var ucenterReturn ResponseLoginSms
... ... @@ -134,8 +136,8 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0) {
return &ucenterReturn, protocol.NewErrWithMessage("10052")
if !(ucenterReturn.Code == ResponseCodeOk) {
return &ucenterReturn, protocol.NewErrWithMessage("10502")
}
return &ucenterReturn, nil
}
... ... @@ -148,7 +150,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
var ucenterReturn ResponseSmsCodeCheck
... ... @@ -157,8 +159,8 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0) {
return &ucenterReturn, protocol.NewErrWithMessage("10026")
if !(ucenterReturn.Code == ResponseCodeOk) {
return &ucenterReturn, protocol.NewErrWithMessage("10206")
}
return &ucenterReturn, nil
}
... ... @@ -173,7 +175,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e
uclient := NewUCenterClient()
btBody, err := uclient.Call(param)
if err != nil {
log.Error("统一用户中心请求失败 err:%s", err)
log.Error("向统一用户中心发送请求失败 err:%s", err)
return protocol.NewErrWithMessage("1")
}
var ucenterReturn CommResponse
... ... @@ -182,8 +184,8 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e
log.Error("解析统一用户中心响应失败 err:%s", err)
return protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0) {
return protocol.NewErrWithMessage("10052")
if !(ucenterReturn.Code == ResponseCodeOk) {
return protocol.NewErrWithMessage("10502")
}
return nil
... ...
... ... @@ -12,7 +12,7 @@ import (
)
const (
ResponseCode0 int = 0
ResponseCodeOk int = 0
)
type IUCenterParam interface {
... ...
... ... @@ -17,7 +17,7 @@ func ResetPasswordBySms(phone string, newPwd string, confirmPwd string) error {
certificate, err = redisdata.GetCaptchAuth(phone)
if err != nil {
log.Error("从redis获取凭证失败:%s", err)
return protocol.NewErrWithMessage("10020")
return protocol.NewErrWithMessage("10200")
}
err = ucenter.RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate)
if err != nil {
... ...