@@ -0,0 +1,52 @@ | |||||
package hdl | |||||
import ( | |||||
"applet/app/e" | |||||
"applet/app/lib/validate" | |||||
"applet/app/md" | |||||
"applet/app/svc" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
// AccountBase | |||||
// @Summary 账号信息 | |||||
// @Tags 账号中心------嘉俊 | |||||
// @Description 账号信息 | |||||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Success 200 {object} md.AccountBase "具体看返回内容" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/account/base [GET] | |||||
func AccountBase(c *gin.Context) { | |||||
svc.AccountBase(c) | |||||
} | |||||
// AccountUpdatePassword | |||||
// @Summary 企业认证保存 | |||||
// @Tags 账号中心------嘉俊 | |||||
// @Description 资质认证-企业认证保存 | |||||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Param args body md.AccountUpdatePasswordReq true "请求参数" | |||||
// @Success 200 {string} "具体看返回内容" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/account/update/password [POST] | |||||
func AccountUpdatePassword(c *gin.Context) { | |||||
var req md.AccountUpdatePasswordReq | |||||
err := c.ShouldBindJSON(&req) | |||||
if err != nil { | |||||
err = validate.HandleValidateErr(err) | |||||
err1 := err.(e.E) | |||||
e.OutErr(c, err1.Code, err1.Error()) | |||||
return | |||||
} | |||||
err = svc.AccountUpdatePassword(c, req) | |||||
if err != nil { | |||||
e.OutErr(c, 400, err) | |||||
return | |||||
} | |||||
e.OutSuc(c, "success", nil) | |||||
return | |||||
} |
@@ -8,8 +8,12 @@ import ( | |||||
"applet/app/utils" | "applet/app/utils" | ||||
db "code.fnuoos.com/zhimeng/model.git/src" | db "code.fnuoos.com/zhimeng/model.git/src" | ||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | "code.fnuoos.com/zhimeng/model.git/src/implement" | ||||
model2 "code.fnuoos.com/zhimeng/model.git/src/model" | |||||
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement" | |||||
"code.fnuoos.com/zhimeng/model.git/src/super/model" | |||||
"fmt" | "fmt" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"time" | |||||
) | ) | ||||
// Login 登陆 | // Login 登陆 | ||||
@@ -58,3 +62,158 @@ func Login(c *gin.Context) { | |||||
}, nil) | }, nil) | ||||
return | return | ||||
} | } | ||||
// LoginPhone 手机号登陆 | |||||
// @Summary 手机号登陆 | |||||
// @Tags ADMIN | |||||
// @Description 手机号登入 | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Param req body md.LoginPhoneReq true "用户名、验证码" | |||||
// @Success 200 {object} md.LoginResponse "token" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/login [post] | |||||
func LoginPhone(c *gin.Context) { | |||||
var req md.LoginPhoneReq | |||||
err := c.ShouldBindJSON(&req) | |||||
if err != nil { | |||||
err = validate.HandleValidateErr(err) | |||||
err1 := err.(e.E) | |||||
e.OutErr(c, err1.Code, err1.Error()) | |||||
return | |||||
} | |||||
engine := db.DBs[svc.GetMasterId(c)] | |||||
check, err := svc.SmsCheck(c, req.UserName, req.Captcha) | |||||
if check == false { | |||||
e.OutErr(c, 400, e.NewErr(400, err.Error())) | |||||
return | |||||
} | |||||
adminDb := implement.NewAgentDb(engine) | |||||
admin, err := adminDb.GetAgentByUsername(req.UserName) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err) | |||||
return | |||||
} | |||||
if admin == nil { | |||||
e.OutErr(c, e.ERR_NO_DATA, "账号不存在!") | |||||
return | |||||
} | |||||
ip := utils.GetIP(c.Request) | |||||
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(admin.Id)) | |||||
token, err := svc.HandleLoginToken(key, admin) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR, err.Error()) | |||||
return | |||||
} | |||||
e.OutSuc(c, md.LoginResponse{ | |||||
Token: token, | |||||
}, nil) | |||||
return | |||||
} | |||||
// Register 手机号注册 | |||||
// @Summary 手机号注册 | |||||
// @Tags ADMIN | |||||
// @Description 手机号注册 | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Param req body md.LoginReq true "用户名、验证码" | |||||
// @Success 200 {object} md.LoginResponse "token" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/login [post] | |||||
func Register(c *gin.Context) { | |||||
var req md.RegisterReq | |||||
err := c.ShouldBindJSON(&req) | |||||
if err != nil { | |||||
err = validate.HandleValidateErr(err) | |||||
err1 := err.(e.E) | |||||
e.OutErr(c, err1.Code, err1.Error()) | |||||
return | |||||
} | |||||
masterId := svc.GetMasterId(c) | |||||
engine := db.DBs[svc.GetMasterId(c)] | |||||
check, err := svc.SmsCheck(c, req.UserName, req.Captcha) | |||||
if check == false { | |||||
e.OutErr(c, 400, e.NewErr(400, err.Error())) | |||||
return | |||||
} | |||||
now := time.Now() | |||||
//1、判断当前账号是否已存在 | |||||
agentDb := implement.NewAgentDb(engine) | |||||
agent, err := agentDb.GetAgentByUsername(req.UserName) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err) | |||||
return | |||||
} | |||||
if agent != nil { | |||||
e.OutErr(c, e.ERR_NO_DATA, "账号已存在!") | |||||
return | |||||
} | |||||
//2、生成 agent_list 记录 | |||||
agentListDb := implement2.NewAgentListDb(db.Db) | |||||
agentId := utils.GenerateUniqueRandomNumbers(8) | |||||
agentList := model.AgentList{ | |||||
Uuid: utils.StrToInt(masterId), | |||||
AgentId: utils.StrToInt(agentId), | |||||
Kind: 1, | |||||
CompanyName: "", | |||||
CompanyAbbreviation: "", | |||||
UnifiedSocialCreditCode: "", | |||||
CertificateType: 1, | |||||
BusinessLicenseImgUrl: "", | |||||
LegalRepresentative: "", | |||||
CountryRegionId: 1, | |||||
CountryRegion: "", | |||||
RegisteredAddressProvinceId: 0, | |||||
RegisteredAddressCityId: 0, | |||||
RegisteredAddressCountyId: 0, | |||||
RegisteredAddress: "", | |||||
BusinessLicenseAddress: "", | |||||
CertificateValidity: "", | |||||
State: 0, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
} | |||||
insertAffected, err := agentListDb.AgentListInsert(&agentList) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
if insertAffected <= 0 { | |||||
e.OutErr(c, e.ERR_DB_ORM, "生成 记录失败") | |||||
return | |||||
} | |||||
//3、新增 agent 记录 | |||||
agentModel := model2.Agent{ | |||||
AgentId: utils.StrToInt(agentId), | |||||
Username: req.UserName, | |||||
Password: utils.Md5(req.PassWord), | |||||
State: 1, | |||||
IsSuperAdministrator: 1, | |||||
Memo: "", | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
} | |||||
insertAffected, err = agentDb.AgentInsert(&agentModel) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
if insertAffected <= 0 { | |||||
e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败") | |||||
return | |||||
} | |||||
ip := utils.GetIP(c.Request) | |||||
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(agentModel.Id)) | |||||
token, err := svc.HandleLoginToken(key, &agentModel) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR, err.Error()) | |||||
return | |||||
} | |||||
e.OutSuc(c, md.LoginResponse{ | |||||
Token: token, | |||||
}, nil) | |||||
return | |||||
} |
@@ -0,0 +1,20 @@ | |||||
package hdl | |||||
import ( | |||||
"applet/app/svc" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
// MediumList | |||||
// @Summary 媒体列表 | |||||
// @Tags 媒体中心------嘉俊 | |||||
// @Description 媒体中心-媒体列表 | |||||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Success 200 {object} md.MediumListRes "具体看返回内容 data里面的数据" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/medium/list [POST] | |||||
func MediumList(c *gin.Context) { | |||||
svc.MediumList(c) | |||||
} |
@@ -0,0 +1,112 @@ | |||||
package hdl | |||||
import ( | |||||
"applet/app/db/implement" | |||||
"applet/app/e" | |||||
"applet/app/lib/validate" | |||||
"applet/app/md" | |||||
"applet/app/svc" | |||||
"applet/app/utils" | |||||
"applet/app/utils/logx" | |||||
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | |||||
qiniu "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/qiniuyun" | |||||
"fmt" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
// ImgReqUpload | |||||
// @Summary 七牛云上传 | |||||
// @Tags 七牛云 | |||||
// @Description 七牛云-七牛云上传 | |||||
// @param Authorization header string false "验证参数Bearer和token空格拼接" | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Param args body md.ImgReqUpload true "请求参数" | |||||
// @Success 200 {string} "success" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/qiniuyun/upload [POST] | |||||
func ImgReqUpload(c *gin.Context) { | |||||
var args md.ImgReqUpload | |||||
err := c.ShouldBindJSON(&args) | |||||
if err != nil { | |||||
err = validate.HandleValidateErr(err) | |||||
err1 := err.(e.E) | |||||
e.OutErr(c, err1.Code, err1.Error()) | |||||
return | |||||
} | |||||
// 文件名名称 | |||||
if args.FileSize < 1 || args.FileName == "" { | |||||
logx.Warn(err) | |||||
e.OutErr(c, e.ERR_INVALID_ARGS) | |||||
return | |||||
} | |||||
scheme := "http" | |||||
if c.Request.TLS != nil { | |||||
scheme = "https" | |||||
} | |||||
// 拼装回调地址 | |||||
callbackUrl := scheme + "://" + c.Request.Host + "/api/qiniuyun/callback?master_id=" + c.GetString("mid") | |||||
NewSysCfgDb := implement.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid")) | |||||
stgInfo := NewSysCfgDb.SysCfgFindWithDb( | |||||
md2.KEY_CFG_FILE_BUCKET, | |||||
md2.KEY_CFG_FILE_HOST, | |||||
md2.KEY_CFG_FILE_AK, | |||||
md2.KEY_CFG_FILE_SK, | |||||
md2.KEY_CFG_FILE_PVD, | |||||
md2.KEY_CFG_FILE_REGION, | |||||
md2.KEY_CFG_FILE_MAX_SIZE, | |||||
md2.KEY_CFG_FILE_EXT, | |||||
md2.KEY_CFG_FILE_SCHEME, | |||||
md2.KEY_CFG_FILE_AVATAR_THUMBNAIL, | |||||
) | |||||
if stgInfo == nil { | |||||
e.OutErr(c, 400, e.NewErr(400, "配置未设置")) | |||||
return | |||||
} | |||||
res, err := qiniu.ImgReqUpload(stgInfo, "", args.Dir, args.FileName, callbackUrl, args.FileSize) | |||||
if err != nil { | |||||
e.OutErr(c, 400, err.Error()) | |||||
return | |||||
} | |||||
my := utils.SerializeStr(res) | |||||
var my1 map[string]interface{} | |||||
utils.Unserialize([]byte(my), &my1) | |||||
e.OutSuc(c, my1, nil) | |||||
return | |||||
} | |||||
func FileImgCallback(c *gin.Context) { | |||||
masterID := c.Query("master_id") | |||||
c.Set("mid", masterID) | |||||
var args md2.FileCallback | |||||
err := c.ShouldBindJSON(&args) | |||||
if err != nil { | |||||
fmt.Println("七牛云上传回调参数错误:>>>>>>>>>>", err) | |||||
e.OutErr(c, 200, e.ERR_INVALID_ARGS) | |||||
return | |||||
} | |||||
res := map[string]interface{}{ | |||||
"name": args.FileName, | |||||
"fname": getFileNameURL(c, args.FileName), | |||||
"fsize": args.FileSize, | |||||
"provider": args.Provider, | |||||
"uid": args.Uid, | |||||
"dir_id": args.DirId, | |||||
"w": args.Width, | |||||
"h": args.Height, | |||||
} | |||||
e.OutSuc(c, &res, nil) | |||||
} | |||||
func getFileNameURL(c *gin.Context, filename string) string { | |||||
NewSysCfgDb := implement.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid")) | |||||
protocol := NewSysCfgDb.SysCfgGetWithDb("file_bucket_scheme") | |||||
domain := NewSysCfgDb.SysCfgGetWithDb("file_bucket_host") | |||||
imgformat := NewSysCfgDb.SysCfgGetWithDb("file_avatar_thumbnail") | |||||
if protocol != "" && domain != "" && imgformat != "" { | |||||
return protocol + "://" + domain + "/" + filename | |||||
} | |||||
return filename | |||||
} |
@@ -17,7 +17,7 @@ import ( | |||||
// @Produce json | // @Produce json | ||||
// @Success 200 {string} "具体看返回内容" | // @Success 200 {string} "具体看返回内容" | ||||
// @Failure 400 {object} md.Response "具体错误" | // @Failure 400 {object} md.Response "具体错误" | ||||
// @Router /api/qualification/info [GET] | |||||
// @Router /api/account/qualification/info [GET] | |||||
func QualificationInfo(c *gin.Context) { | func QualificationInfo(c *gin.Context) { | ||||
svc.QualificationInfo(c) | svc.QualificationInfo(c) | ||||
} | } | ||||
@@ -31,7 +31,7 @@ func QualificationInfo(c *gin.Context) { | |||||
// @Produce json | // @Produce json | ||||
// @Success 200 {string} "具体看返回内容" | // @Success 200 {string} "具体看返回内容" | ||||
// @Failure 400 {object} md.Response "具体错误" | // @Failure 400 {object} md.Response "具体错误" | ||||
// @Router /api/qualification/select/base [GET] | |||||
// @Router /api/account/qualification/select/base [GET] | |||||
func QualificationSelectBase(c *gin.Context) { | func QualificationSelectBase(c *gin.Context) { | ||||
svc.QualificationSelectBase(c) | svc.QualificationSelectBase(c) | ||||
} | } | ||||
@@ -46,7 +46,7 @@ func QualificationSelectBase(c *gin.Context) { | |||||
// @Param args body md.AgentList true "请求参数" | // @Param args body md.AgentList true "请求参数" | ||||
// @Success 200 {string} "具体看返回内容" | // @Success 200 {string} "具体看返回内容" | ||||
// @Failure 400 {object} md.Response "具体错误" | // @Failure 400 {object} md.Response "具体错误" | ||||
// @Router /api/qualification/enterprise/save [POST] | |||||
// @Router /api/account/qualification/enterprise/save [POST] | |||||
func QualificationEnterpriseSave(c *gin.Context) { | func QualificationEnterpriseSave(c *gin.Context) { | ||||
var req md.AgentList | var req md.AgentList | ||||
err := c.ShouldBindJSON(&req) | err := c.ShouldBindJSON(&req) | ||||
@@ -75,7 +75,7 @@ func QualificationEnterpriseSave(c *gin.Context) { | |||||
// @Param args body md.AgentBankInfo true "请求参数" | // @Param args body md.AgentBankInfo true "请求参数" | ||||
// @Success 200 {string} "具体看返回内容" | // @Success 200 {string} "具体看返回内容" | ||||
// @Failure 400 {object} md.Response "具体错误" | // @Failure 400 {object} md.Response "具体错误" | ||||
// @Router /api/qualification/bank/save [POST] | |||||
// @Router /api/account/qualification/bank/save [POST] | |||||
func QualificationBankSave(c *gin.Context) { | func QualificationBankSave(c *gin.Context) { | ||||
var req md.AgentBankInfo | var req md.AgentBankInfo | ||||
err := c.ShouldBindJSON(&req) | err := c.ShouldBindJSON(&req) | ||||
@@ -104,7 +104,7 @@ func QualificationBankSave(c *gin.Context) { | |||||
// @Param args body md.AgentContactInfo true "请求参数" | // @Param args body md.AgentContactInfo true "请求参数" | ||||
// @Success 200 {string} "具体看返回内容" | // @Success 200 {string} "具体看返回内容" | ||||
// @Failure 400 {object} md.Response "具体错误" | // @Failure 400 {object} md.Response "具体错误" | ||||
// @Router /api/qualification/contact/save [POST] | |||||
// @Router /api/account/qualification/contact/save [POST] | |||||
func QualificationContactSave(c *gin.Context) { | func QualificationContactSave(c *gin.Context) { | ||||
var req md.AgentContactInfo | var req md.AgentContactInfo | ||||
err := c.ShouldBindJSON(&req) | err := c.ShouldBindJSON(&req) | ||||
@@ -0,0 +1,83 @@ | |||||
package hdl | |||||
import ( | |||||
implement2 "applet/app/db/implement" | |||||
"applet/app/e" | |||||
"applet/app/lib/validate" | |||||
"applet/app/md" | |||||
"applet/app/svc" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/sms" | |||||
"code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"github.com/gin-gonic/gin" | |||||
"github.com/tidwall/gjson" | |||||
) | |||||
// Sms | |||||
// @Summary 短信发送 | |||||
// @Tags 短信 | |||||
// @Description 短信-短信发送 | |||||
// @param Authorization header string false "验证参数Bearer和token空格拼接" | |||||
// @Accept json | |||||
// @Produce json | |||||
// @Param args body md.SmsReq true "请求参数" | |||||
// @Success 200 {string} "success" | |||||
// @Failure 400 {object} md.Response "具体错误" | |||||
// @Router /api/sms [POST] | |||||
func Sms(c *gin.Context) { | |||||
var args md.SmsReq | |||||
err := c.ShouldBindJSON(&args) | |||||
if err != nil { | |||||
err = validate.HandleValidateErr(err) | |||||
err1 := err.(e.E) | |||||
e.OutErr(c, err1.Code, err1.Error()) | |||||
return | |||||
} | |||||
if args.Type == "fast_login" { | |||||
NewAdminDb := implement.NewAdminDb(svc.MasterDb(c)) | |||||
admin, _ := NewAdminDb.GetAdminByUserName(args.Phone) | |||||
if admin == nil { | |||||
e.OutErr(c, 400, e.NewErr(400, "账号未注册")) | |||||
return | |||||
} | |||||
} | |||||
if args.Type == "update_password" { | |||||
admin, _ := svc.CheckUser(c) | |||||
if admin == nil { | |||||
e.OutErr(c, 400, e.NewErr(400, "账号未注册")) | |||||
return | |||||
} | |||||
args.Phone = admin.Username | |||||
} | |||||
NewSysCfgDb := implement2.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid")) | |||||
key := NewSysCfgDb.SysCfgGetWithDb("mob_app_key") | |||||
if key == "" { | |||||
e.OutErr(c, 400, e.NewErr(400, "appkey不存在")) | |||||
return | |||||
} | |||||
where := map[string]interface{}{ | |||||
"appkey": key, | |||||
"zone": "86", | |||||
"phone": args.Phone, | |||||
} | |||||
send, err := sms.SmsMobApiSend(where) | |||||
if err != nil { | |||||
e.OutErr(c, 400, err.Error()) | |||||
return | |||||
} | |||||
status := gjson.Get(send, "status").Int() | |||||
msg := gjson.Get(send, "error").String() | |||||
if status == 471 { | |||||
e.OutErr(c, 400, e.NewErr(400, "发送的ip不在白名单中")) | |||||
return | |||||
} | |||||
if status == 406 { | |||||
e.OutErr(c, 400, e.NewErr(400, "appkey不存在")) | |||||
return | |||||
} | |||||
if status != 200 { | |||||
e.OutErr(c, 400, e.NewErr(400, msg)) | |||||
return | |||||
} | |||||
e.OutSuc(c, "success", nil) | |||||
return | |||||
} |
@@ -0,0 +1,6 @@ | |||||
package md | |||||
type SelectData struct { | |||||
Name string `json:"name" example:"名称"` | |||||
Value string `json:"value" example:"值"` | |||||
} |
@@ -0,0 +1,19 @@ | |||||
package md | |||||
type AccountBase struct { | |||||
AdminPhone string `json:"admin_phone" example:"管理员手机号"` | |||||
Nickname string `json:"nickname" example:"昵称"` | |||||
CompanyName string `json:"company_name" example:"公司名称"` | |||||
CompanyAbbreviation string `json:"company_abbreviation" example:"公司简称"` | |||||
AgentId string `json:"agent_id" example:"账户ID"` | |||||
ContactName string `json:"contact_name" example:"联系人"` | |||||
ContactEmail string `json:"contact_email" example:"邮箱"` | |||||
ContactPhone string `json:"contact_phone" example:"联系电话"` | |||||
ContactAddress string `json:"contact_address" example:"联系地址"` | |||||
CurrencyConf string `json:"currency_conf" example:"结算币种"` | |||||
CountryRegion string `json:"country_region" example:"国家地区"` | |||||
} | |||||
type AccountUpdatePasswordReq struct { | |||||
PassWord string `json:"password" example:"登录密码"` | |||||
Captcha string `json:"captcha" example:"验证码"` | |||||
} |
@@ -9,3 +9,12 @@ type LoginReq struct { | |||||
type LoginResponse struct { | type LoginResponse struct { | ||||
Token string `json:"token"` | Token string `json:"token"` | ||||
} | } | ||||
type LoginPhoneReq struct { | |||||
UserName string `json:"username" binding:"required" example:"登录账号"` | |||||
Captcha string `json:"captcha" binding:"required" example:"验证码"` | |||||
} | |||||
type RegisterReq struct { | |||||
UserName string `json:"username" binding:"required" example:"登录账号"` | |||||
Captcha string `json:"captcha" binding:"required" example:"验证码"` | |||||
PassWord string `json:"password" binding:"required" example:"登录密码"` | |||||
} |
@@ -0,0 +1,12 @@ | |||||
package md | |||||
var Country = []map[string]string{ | |||||
{ | |||||
"value": "1", "name": "中国/国内", | |||||
}, | |||||
} | |||||
var CurrencyConf = []map[string]string{ | |||||
{ | |||||
"value": "0", "name": "人民币", | |||||
}, | |||||
} |
@@ -0,0 +1,24 @@ | |||||
package md | |||||
type MediumListReq struct { | |||||
Limit string `json:"limit"` | |||||
Page string `json:"page" ` | |||||
Name string `json:"name"` | |||||
State string `json:"state"` | |||||
} | |||||
type MediumListRes struct { | |||||
State []SelectData `json:"state" ` | |||||
List []MediumListData `json:"list"` | |||||
Total int64 `json:"total"` | |||||
} | |||||
type MediumListData struct { | |||||
MediumId string `json:"medium_id" example:"媒体id"` | |||||
CompanyName string `json:"company_name" example:"公司名称"` | |||||
Id string `json:"id" example:"id"` | |||||
Memo string `json:"memo" example:"备注 审核时填写的"` | |||||
State string `json:"state" example:"状态(0:待提交 1:待审核 2:审核通过 3:审核拒绝)"` | |||||
UnifiedSocialCreditCode string `json:"unified_social_credit_code" example:"统一社会信用代码"` | |||||
LegalRepresentative string `json:"legal_representative" example:"法定代表人"` | |||||
Account string `json:"account" example:"媒体账号"` | |||||
BusinessLicenseAddress string `json:"business_license_address" example:"营业执照地址"` | |||||
} |
@@ -0,0 +1,7 @@ | |||||
package md | |||||
type ImgReqUpload struct { | |||||
Dir string `json:"dir"` | |||||
FileName string `json:"file_name"` | |||||
FileSize int64 `json:"file_size"` // 文件大小, 单位byte | |||||
} |
@@ -0,0 +1,6 @@ | |||||
package md | |||||
type SmsReq struct { | |||||
Phone string `json:"phone"` | |||||
Type string `json:"type" example:"手机号登陆:fast_login 注册:register 修改密码:update_password"` | |||||
} |
@@ -51,17 +51,23 @@ func Init() *gin.Engine { | |||||
func route(r *gin.RouterGroup) { | func route(r *gin.RouterGroup) { | ||||
r.GET("/test", hdl.Demo) | r.GET("/test", hdl.Demo) | ||||
r.Use(mw.DB) // 以下接口需要用到数据库 | |||||
r.POST("/qiniuyun/callback", hdl.FileImgCallback) //七牛云回调 | |||||
r.Use(mw.DB) // 以下接口需要用到数据库 | |||||
{ | { | ||||
r.POST("/login", hdl.Login) | r.POST("/login", hdl.Login) | ||||
r.POST("/login/phone", hdl.LoginPhone) | |||||
r.POST("/register", hdl.Register) | |||||
} | } | ||||
r.Use(mw.CheckBody) //body参数转换 | r.Use(mw.CheckBody) //body参数转换 | ||||
r.Use(mw.CheckSign) //签名校验 | r.Use(mw.CheckSign) //签名校验 | ||||
r.Use(mw.Auth) // 以下接口需要JWT验证 | |||||
rRole(r.Group("/role")) //权限管理 | |||||
rQualification(r.Group("/qualification")) //资质 | |||||
{ | |||||
r.POST("/qiniuyun/upload", hdl.ImgReqUpload) //七牛云上传 | |||||
r.POST("/sms", hdl.Sms) //短信发送 | |||||
} | |||||
r.Use(mw.Auth) // 以下接口需要JWT验证 | |||||
rRole(r.Group("/role")) //权限管理 | |||||
rMedium(r.Group("/medium")) //媒体中心 | |||||
rAccount(r.Group("/account")) //账号中心 | |||||
} | } | ||||
@@ -81,10 +87,15 @@ func rRole(r *gin.RouterGroup) { | |||||
r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息 | r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息 | ||||
r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色 | r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色 | ||||
} | } | ||||
func rQualification(r *gin.RouterGroup) { | |||||
r.GET("/info", hdl.QualificationInfo) //资质认证-基本信息 | |||||
r.GET("/select/base", hdl.QualificationSelectBase) //资质认证-认证选择内容 | |||||
r.POST("/enterprise/save", hdl.QualificationEnterpriseSave) //资质认证-企业认证保存 | |||||
r.POST("/bank/save", hdl.QualificationBankSave) //资质认证-银行资质保存 | |||||
r.POST("/contact/save", hdl.QualificationContactSave) //资质认证-联系方式保存 | |||||
func rMedium(r *gin.RouterGroup) { | |||||
r.POST("/list", hdl.MediumList) //媒体列表 | |||||
} | |||||
func rAccount(r *gin.RouterGroup) { | |||||
r.GET("/base", hdl.AccountBase) //账号信息 | |||||
r.POST("/update/password", hdl.AccountUpdatePassword) //账号信息-修改密码 | |||||
r.GET("/qualification/info", hdl.QualificationInfo) //资质认证-基本信息 | |||||
r.GET("/qualification/select/base", hdl.QualificationSelectBase) //资质认证-认证选择内容 | |||||
r.POST("/qualification/enterprise/save", hdl.QualificationEnterpriseSave) //资质认证-企业认证保存 | |||||
r.POST("/qualification/bank/save", hdl.QualificationBankSave) //资质认证-银行资质保存 | |||||
r.POST("/qualification/contact/save", hdl.QualificationContactSave) //资质认证-联系方式保存 | |||||
} | } |
@@ -0,0 +1,69 @@ | |||||
package svc | |||||
import ( | |||||
"applet/app/e" | |||||
"applet/app/md" | |||||
"applet/app/utils" | |||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"code.fnuoos.com/zhimeng/model.git/src/super/implement" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
func AccountBase(c *gin.Context) { | |||||
user := GetUser(c) | |||||
res := md.AccountBase{ | |||||
Nickname: user.Username, | |||||
AdminPhone: user.Username, | |||||
CompanyName: "", | |||||
CompanyAbbreviation: "", | |||||
AgentId: utils.IntToStr(user.AgentId), | |||||
ContactName: "", | |||||
ContactEmail: "", | |||||
ContactPhone: user.Username, | |||||
ContactAddress: "", | |||||
CurrencyConf: "", | |||||
CountryRegion: "", | |||||
} | |||||
NewAgentListDb := implement.NewAgentListDb(db.Db) | |||||
agent, _ := NewAgentListDb.GetAgentList(user.AgentId) | |||||
if agent != nil { | |||||
Country := md.Country | |||||
res.CompanyAbbreviation = agent.CompanyAbbreviation | |||||
res.Nickname = agent.CompanyAbbreviation | |||||
res.CompanyName = agent.CompanyName | |||||
for _, v := range Country { | |||||
if utils.StrToInt(v["value"]) == agent.CountryRegionId { | |||||
res.CountryRegion = v["name"] | |||||
} | |||||
} | |||||
} | |||||
NewAgentBankInfoDb := implement.NewAgentBankInfoDb(db.Db) | |||||
bank, _ := NewAgentBankInfoDb.GetAgentBankInfoList(user.AgentId) | |||||
if bank != nil { | |||||
for _, v := range md.CurrencyConf { | |||||
if utils.StrToInt(v["value"]) == bank.CurrencyConf { | |||||
res.CurrencyConf = v["name"] | |||||
} | |||||
} | |||||
} | |||||
NewAgentContactInfoDb := implement.NewAgentContactInfoDb(db.Db) | |||||
contact, _ := NewAgentContactInfoDb.GetAgentContactInfoList(user.AgentId) | |||||
if contact != nil { | |||||
res.ContactName = contact.Name | |||||
res.ContactAddress = contact.Address | |||||
res.ContactEmail = contact.Email | |||||
res.ContactPhone = contact.Phone | |||||
} | |||||
e.OutSuc(c, res, nil) | |||||
return | |||||
} | |||||
func AccountUpdatePassword(c *gin.Context, req md.AccountUpdatePasswordReq) error { | |||||
user := GetUser(c) | |||||
check, err := SmsCheck(c, user.Username, req.Captcha) | |||||
if check == false { | |||||
return err | |||||
} | |||||
user.Password = utils.Md5(req.PassWord) | |||||
MasterDb(c).Where("id=?", user.Id).Cols("password").Update(user) | |||||
return nil | |||||
} |
@@ -21,7 +21,7 @@ func GetMasterId(c *gin.Context) (masterId string) { | |||||
//TODO::通过域名查找masterId | //TODO::通过域名查找masterId | ||||
host := c.Request.Host | host := c.Request.Host | ||||
userAppDomainDb := implement.NewUserAppDomainDb(db.Db) | userAppDomainDb := implement.NewUserAppDomainDb(db.Db) | ||||
userAppDomain, err := userAppDomainDb.GetMediumAppDomainByHost(host) | |||||
userAppDomain, err := userAppDomainDb.GetAppDomainByHost(host) | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err) | e.OutErr(c, e.ERR_DB_ORM, err) | ||||
return | return | ||||
@@ -0,0 +1,62 @@ | |||||
package svc | |||||
import ( | |||||
"applet/app/e" | |||||
"applet/app/lib/validate" | |||||
"applet/app/md" | |||||
"applet/app/utils" | |||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
implement2 "code.fnuoos.com/zhimeng/model.git/src/implement" | |||||
"code.fnuoos.com/zhimeng/model.git/src/super/implement" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
func MediumList(c *gin.Context) { | |||||
var req md.MediumListReq | |||||
err := c.ShouldBindJSON(&req) | |||||
if err != nil { | |||||
err = validate.HandleValidateErr(err) | |||||
err1 := err.(e.E) | |||||
e.OutErr(c, err1.Code, err1.Error()) | |||||
return | |||||
} | |||||
user := GetUser(c) | |||||
engine := db.Db | |||||
agentWithMediumDb := implement.NewAgentWithMediumDb(engine) | |||||
data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, user.AgentId, 0, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) | |||||
list := make([]md.MediumListData, 0) | |||||
NewMediumDb := implement2.NewMediumDb(MasterDb(c)) | |||||
if data != nil { | |||||
for _, v := range data { | |||||
tmp := md.MediumListData{ | |||||
Id: utils.IntToStr(v.AgentWithMedium.Id), | |||||
MediumId: utils.IntToStr(v.AgentWithMedium.MediumId), | |||||
CompanyName: v.MediumList.CompanyName, | |||||
UnifiedSocialCreditCode: v.MediumList.UnifiedSocialCreditCode, | |||||
State: utils.IntToStr(v.MediumList.State), | |||||
Memo: v.MediumList.Memo, | |||||
LegalRepresentative: v.MediumList.LegalRepresentative, | |||||
BusinessLicenseAddress: v.MediumList.BusinessLicenseAddress, | |||||
} | |||||
medium := NewMediumDb.GetSuperAdmin(v.AgentWithMedium.MediumId) | |||||
if medium != nil { | |||||
tmp.Account = medium.Username | |||||
} | |||||
list = append(list, tmp) | |||||
} | |||||
} | |||||
res := md.MediumListRes{ | |||||
List: list, | |||||
Total: total, | |||||
State: []md.SelectData{ | |||||
{Name: "待提交", Value: "0"}, | |||||
{Name: "待审核", Value: "1"}, | |||||
{Name: "审核通过", Value: "2"}, | |||||
{Name: "审核拒绝", Value: "3"}, | |||||
}, | |||||
} | |||||
e.OutSuc(c, res, nil) | |||||
return | |||||
} |
@@ -0,0 +1,19 @@ | |||||
package svc | |||||
import ( | |||||
"applet/app/db/implement" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/sms" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
func SmsCheck(c *gin.Context, phone, captcha string) (bool, error) { | |||||
send := map[string]interface{}{ | |||||
"phone": phone, | |||||
"zone": "86", | |||||
"code": captcha, | |||||
} | |||||
NewSysCfgDb := implement.NewSysCfgDb(MasterDb(c), c.GetString("mid")) | |||||
key := NewSysCfgDb.SysCfgGetWithDb("mob_app_key") | |||||
send["appkey"] = key | |||||
return sms.SMSMobCheck(send) | |||||
} |
@@ -1,78 +0,0 @@ | |||||
package svc | |||||
import ( | |||||
"applet/app/db/implement" | |||||
db "code.fnuoos.com/zhimeng/model.git/src" | |||||
"github.com/gin-gonic/gin" | |||||
"xorm.io/xorm" | |||||
"applet/app/md" | |||||
"applet/app/utils/cache" | |||||
) | |||||
// 单挑记录获取 | |||||
func SysCfgGet(c *gin.Context, key string) string { | |||||
masterId := GetMasterId(c) | |||||
eg := db.DBs[masterId] | |||||
sysCfgDb := implement.NewSysCfgDb(eg, masterId) | |||||
return sysCfgDb.SysCfgGetWithDb(key) | |||||
} | |||||
// 多条记录获取 | |||||
func SysCfgFind(c *gin.Context, keys ...string) map[string]string { | |||||
var masterId string | |||||
if c == nil { | |||||
masterId = "" | |||||
} else { | |||||
masterId = GetMasterId(c) | |||||
} | |||||
tmp := SysCfgFindComm(masterId, keys...) | |||||
return tmp | |||||
} | |||||
func SysCfgFindComm(masterId string, keys ...string) map[string]string { | |||||
var eg *xorm.Engine | |||||
if masterId == "" { | |||||
eg = db.Db | |||||
} else { | |||||
eg = db.DBs[masterId] | |||||
} | |||||
res := map[string]string{} | |||||
//TODO::判断keys长度(大于10个直接查数据库) | |||||
sysCfgDb := implement.NewSysCfgDb(eg, masterId) | |||||
if len(keys) > 10 { | |||||
cfgList, _ := sysCfgDb.SysCfgGetAll() | |||||
if cfgList == nil { | |||||
return nil | |||||
} | |||||
for _, v := range *cfgList { | |||||
res[v.K] = v.V | |||||
} | |||||
} else { | |||||
for _, key := range keys { | |||||
res[key] = sysCfgDb.SysCfgGetWithDb(key) | |||||
} | |||||
} | |||||
return res | |||||
} | |||||
// 清理系统配置信息 | |||||
func SysCfgCleanCache() { | |||||
cache.Del(md.KEY_SYS_CFG_CACHE) | |||||
} | |||||
// 写入系统设置 | |||||
func SysCfgSet(c *gin.Context, key, val, memo string) bool { | |||||
masterId := GetMasterId(c) | |||||
eg := db.DBs[masterId] | |||||
sysCfgDb := implement.NewSysCfgDb(eg, masterId) | |||||
cfg, err := sysCfgDb.SysCfgGetOne(key) | |||||
if err != nil || cfg == nil { | |||||
return sysCfgDb.SysCfgInsert(key, val, memo) | |||||
} | |||||
if memo != "" && cfg.Memo != memo { | |||||
cfg.Memo = memo | |||||
} | |||||
SysCfgCleanCache() | |||||
return sysCfgDb.SysCfgUpdate(key, val) | |||||
} |
@@ -5,6 +5,7 @@ import ( | |||||
"fmt" | "fmt" | ||||
"math/big" | "math/big" | ||||
"math/rand" | "math/rand" | ||||
"strconv" | |||||
"time" | "time" | ||||
) | ) | ||||
@@ -29,3 +30,29 @@ func RandNum() string { | |||||
seed := time.Now().UnixNano() + rand.Int63() | seed := time.Now().UnixNano() + rand.Int63() | ||||
return fmt.Sprintf("%05v", rand.New(rand.NewSource(seed)).Int31n(1000000)) | return fmt.Sprintf("%05v", rand.New(rand.NewSource(seed)).Int31n(1000000)) | ||||
} | } | ||||
func GenerateUniqueRandomNumbers(n int) string { | |||||
rand.Seed(time.Now().UnixNano()) // 初始化随机种子 | |||||
numbers := make([]int, n) // 创建一个切片来保存随机数 | |||||
for i := range numbers { | |||||
j := 0 | |||||
for { | |||||
b := rand.Intn(10) // 生成0-9之间的随机数 | |||||
numbers[i] = b | |||||
for _, num := range numbers[:i] { | |||||
if num == b { | |||||
j++ | |||||
break | |||||
} | |||||
} | |||||
if j == 0 { | |||||
break | |||||
} | |||||
} | |||||
} | |||||
var numbersStr string | |||||
for _, v := range numbers { | |||||
numbersStr += strconv.Itoa(v) | |||||
} | |||||
return numbersStr | |||||
} |
@@ -5,7 +5,8 @@ go 1.18 | |||||
//replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models | //replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models | ||||
require ( | require ( | ||||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240821082038-bfd73b32452e | |||||
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240821062104-50d608c7fd6a | |||||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240823034048-34202e969e8d | |||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 | github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 | ||||
github.com/boombuler/barcode v1.0.1 | github.com/boombuler/barcode v1.0.1 | ||||
github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 | github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 | ||||
@@ -29,11 +30,11 @@ require ( | |||||
github.com/swaggo/gin-swagger v1.6.0 | github.com/swaggo/gin-swagger v1.6.0 | ||||
github.com/swaggo/swag v1.8.12 | github.com/swaggo/swag v1.8.12 | ||||
github.com/syyongx/php2go v0.9.8 | github.com/syyongx/php2go v0.9.8 | ||||
github.com/tidwall/gjson v1.7.4 | |||||
github.com/tidwall/gjson v1.14.1 | |||||
go.uber.org/zap v1.16.0 | go.uber.org/zap v1.16.0 | ||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 | gopkg.in/natefinch/lumberjack.v2 v2.2.1 | ||||
gopkg.in/yaml.v2 v2.4.0 | gopkg.in/yaml.v2 v2.4.0 | ||||
xorm.io/xorm v1.3.1 | |||||
xorm.io/xorm v1.3.2 | |||||
) | ) | ||||
require ( | require ( | ||||
@@ -57,7 +58,7 @@ require ( | |||||
github.com/gobwas/glob v0.2.3 // indirect | github.com/gobwas/glob v0.2.3 // indirect | ||||
github.com/goccy/go-json v0.10.2 // indirect | github.com/goccy/go-json v0.10.2 // indirect | ||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||||
github.com/golang/protobuf v1.5.2 // indirect | |||||
github.com/golang/protobuf v1.5.3 // indirect | |||||
github.com/golang/snappy v0.0.4 // indirect | github.com/golang/snappy v0.0.4 // indirect | ||||
github.com/gookit/color v1.3.8 // indirect | github.com/gookit/color v1.3.8 // indirect | ||||
github.com/gorilla/context v1.1.1 // indirect | github.com/gorilla/context v1.1.1 // indirect | ||||
@@ -72,15 +73,13 @@ require ( | |||||
github.com/mattn/go-isatty v0.0.19 // indirect | github.com/mattn/go-isatty v0.0.19 // indirect | ||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||||
github.com/modern-go/reflect2 v1.0.2 // indirect | github.com/modern-go/reflect2 v1.0.2 // indirect | ||||
github.com/onsi/ginkgo v1.15.0 // indirect | |||||
github.com/onsi/gomega v1.10.5 // indirect | |||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect | github.com/pelletier/go-toml/v2 v2.0.6 // indirect | ||||
github.com/pkg/errors v0.9.1 // indirect | github.com/pkg/errors v0.9.1 // indirect | ||||
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect | github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect | ||||
github.com/syndtr/goleveldb v1.0.0 // indirect | github.com/syndtr/goleveldb v1.0.0 // indirect | ||||
github.com/temoto/robotstxt v1.1.2 // indirect | github.com/temoto/robotstxt v1.1.2 // indirect | ||||
github.com/tidwall/match v1.0.3 // indirect | |||||
github.com/tidwall/pretty v1.1.0 // indirect | |||||
github.com/tidwall/match v1.1.1 // indirect | |||||
github.com/tidwall/pretty v1.2.0 // indirect | |||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | ||||
github.com/ugorji/go/codec v1.2.9 // indirect | github.com/ugorji/go/codec v1.2.9 // indirect | ||||
go.uber.org/atomic v1.7.0 // indirect | go.uber.org/atomic v1.7.0 // indirect | ||||