作者 yangfu

修改

... ... @@ -67,6 +67,16 @@ var errmessge ErrorMap = map[int]string{
//评论相关
5601: "评论不存在",
//企业平台
10001: "用户不存在",
10002: "登录凭证已过期,请重新登录",
10003: "验证码不能为空",
10004: "登录凭证不能为空",
10005: "密码不能为空",
10006: "用户不存在",
10007: "用户已被禁用",
10008: "用户无模块权限",
}
const (
... ...
... ... @@ -328,21 +328,21 @@ func Authorize(header *protocol.RequestHeader, request *protocol.AuthorizeReques
//权限验证 判断用户公司是否存在
if userCompany, err = models.GetUserCompanyById(request.Muid); err != nil {
log.Error(err, request.Muid)
err = protocol.NewErrWithMessage(2002, err) //TODO:用户不存在
err = protocol.NewErrWithMessage(10008, err) //用户无模块权限
return
}
if userCompany.Enable != 1 {
err = protocol.NewErrWithMessage(2002, err) //TODO:用户无权限
err = protocol.NewErrWithMessage(10006, err) //用户已禁用
log.Error(err)
return
}
if company, err = models.GetCompanyById(request.Cid); err != nil || company.Enable != 1 {
if company, err = models.GetCompanyById(request.Cid); err != nil {
log.Error(err, request.Cid)
err = protocol.NewErrWithMessage(2002, err) //TODO:公司模块不存在
err = protocol.NewErrWithMessage(10007, err) //企业已禁用
return
}
if company.Enable != 1 {
err = protocol.NewErrWithMessage(2002, err) //TODO:公司模块被禁用
err = protocol.NewErrWithMessage(10007, err) ///企业已禁用
log.Error(err)
return
}
... ...
... ... @@ -69,3 +69,25 @@ func Test_FixPath(t *testing.T) {
}
}
}
func Test_UploadImage(t *testing.T) {
input := "https://upfile.asqql.com/2009pasdfasdfic2009s305985-ts/2019-12/2019123019514565723.gif"
var (
err error
auth *aliyun.CreateUploadImageResponse
vodc *vod.Client
)
vodc, err = aliyun.DefaultVodClient()
if err != nil {
t.Fatal(err)
}
auth, err = aliyun.CreateUploadImage(vodc, &aliyun.CreateUploadImageRequest{FileName: fixPath("https://mmm-opp-prd.fjmaimaimai.com/file/opp/image/20200325/1585134451_FrdwfRHEMc33JwX7FtJAY4baMyD7J6pP.jpg")})
if err != nil {
t.Fatal(err)
}
err = upload(fixPath(input), auth.UploadAddress, auth.UploadAuth)
if err != nil {
t.Fatal(err)
}
t.Log(fmt.Sprintf("%v -> %v", input, auth.ImageURL), UploadSuccess)
}
... ...