# Conflicts: # app/hdl/hdl_login.gomaster
@@ -117,7 +117,7 @@ func LoginPhone(c *gin.Context) { | |||||
// @Description 手机号注册 | // @Description 手机号注册 | ||||
// @Accept json | // @Accept json | ||||
// @Produce json | // @Produce json | ||||
// @Param req body md.LoginReq true "用户名、验证码" | |||||
// @Param req body md.RegisterReq true "用户名、验证码" | |||||
// @Success 200 {object} md.LoginResponse "token" | // @Success 200 {object} md.LoginResponse "token" | ||||
// @Failure 400 {object} md.Response "具体错误" | // @Failure 400 {object} md.Response "具体错误" | ||||
// @Router /api/register [post] | // @Router /api/register [post] | ||||
@@ -210,26 +210,40 @@ func Register(c *gin.Context) { | |||||
} | } | ||||
insertAffected, err = db.Db.Insert(&MediumDivisionStrategyModel) | insertAffected, err = db.Db.Insert(&MediumDivisionStrategyModel) | ||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | return | ||||
} | } | ||||
if insertAffected <= 0 { | if insertAffected <= 0 { | ||||
e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败") | e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败") | ||||
return | return | ||||
} | } | ||||
if utils.StrToInt(req.AgentId) > 0 { | |||||
NewAgentWithMediumDb := implement2.NewAgentWithMediumDb(db.Db) | |||||
data := NewAgentWithMediumDb.GetAgentWithMediumByMediumIdAndAgentId(utils.StrToInt(mediumId), utils.StrToInt(req.AgentId)) | |||||
if data != nil { | |||||
e.OutErr(c, 400, e.NewErr(400, "已绑定过该渠道代理")) | |||||
//5、判断是否为渠道代理邀请 | |||||
if req.AgentId != "" { | |||||
agentDb := implement.NewAgentDb(engine) | |||||
agent, err1 := agentDb.GetAgent(utils.StrToInt(req.AgentId)) | |||||
if err1 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||||
return | return | ||||
} | } | ||||
var tmp = model.AgentWithMedium{ | |||||
AgentId: utils.StrToInt(req.AgentId), | |||||
MediumId: utils.StrToInt(mediumId), | |||||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||||
if agent != nil { | |||||
//5.1 新增agent_with_medium记录 | |||||
agentWithMediumDb := implement2.NewAgentWithMediumDb(engine) | |||||
insertAffected, err = agentWithMediumDb.AgentWithMediumInsert(&model.AgentWithMedium{ | |||||
AgentId: utils.StrToInt(req.AgentId), | |||||
MediumId: utils.StrToInt(mediumId), | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
if insertAffected <= 0 { | |||||
e.OutErr(c, e.ERR_DB_ORM, "新增 agent_with_medium 记录失败") | |||||
return | |||||
} | |||||
} | } | ||||
db.Db.InsertOne(&tmp) | |||||
} | } | ||||
ip := utils.GetIP(c.Request) | ip := utils.GetIP(c.Request) | ||||
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(mediumModel.Id)) | key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(mediumModel.Id)) | ||||
@@ -16,6 +16,7 @@ type LoginPhoneReq struct { | |||||
} | } | ||||
type RegisterReq struct { | type RegisterReq struct { | ||||
UserName string `json:"username" binding:"required" example:"登录账号"` | UserName string `json:"username" binding:"required" example:"登录账号"` | ||||
AgentId string `json:"agent_id" example:"代理id"` | |||||
Captcha string `json:"captcha" binding:"required" example:"验证码"` | Captcha string `json:"captcha" binding:"required" example:"验证码"` | ||||
PassWord string `json:"password" binding:"required" example:"登录密码"` | PassWord string `json:"password" binding:"required" example:"登录密码"` | ||||
AgentId string `json:"agent_id" example:"代理id"` | AgentId string `json:"agent_id" example:"代理id"` | ||||
@@ -1198,7 +1198,7 @@ const docTemplate = `{ | |||||
"in": "body", | "in": "body", | ||||
"required": true, | "required": true, | ||||
"schema": { | "schema": { | ||||
"$ref": "#/definitions/md.LoginReq" | |||||
"$ref": "#/definitions/md.RegisterReq" | |||||
} | } | ||||
} | } | ||||
], | ], | ||||
@@ -3193,6 +3193,32 @@ const docTemplate = `{ | |||||
} | } | ||||
} | } | ||||
}, | }, | ||||
"md.RegisterReq": { | |||||
"type": "object", | |||||
"required": [ | |||||
"captcha", | |||||
"password", | |||||
"username" | |||||
], | |||||
"properties": { | |||||
"agent_id": { | |||||
"type": "string", | |||||
"example": "代理id" | |||||
}, | |||||
"captcha": { | |||||
"type": "string", | |||||
"example": "验证码" | |||||
}, | |||||
"password": { | |||||
"type": "string", | |||||
"example": "登录密码" | |||||
}, | |||||
"username": { | |||||
"type": "string", | |||||
"example": "登录账号" | |||||
} | |||||
} | |||||
}, | |||||
"md.Response": { | "md.Response": { | ||||
"type": "object", | "type": "object", | ||||
"properties": { | "properties": { | ||||
@@ -1190,7 +1190,7 @@ | |||||
"in": "body", | "in": "body", | ||||
"required": true, | "required": true, | ||||
"schema": { | "schema": { | ||||
"$ref": "#/definitions/md.LoginReq" | |||||
"$ref": "#/definitions/md.RegisterReq" | |||||
} | } | ||||
} | } | ||||
], | ], | ||||
@@ -3185,6 +3185,32 @@ | |||||
} | } | ||||
} | } | ||||
}, | }, | ||||
"md.RegisterReq": { | |||||
"type": "object", | |||||
"required": [ | |||||
"captcha", | |||||
"password", | |||||
"username" | |||||
], | |||||
"properties": { | |||||
"agent_id": { | |||||
"type": "string", | |||||
"example": "代理id" | |||||
}, | |||||
"captcha": { | |||||
"type": "string", | |||||
"example": "验证码" | |||||
}, | |||||
"password": { | |||||
"type": "string", | |||||
"example": "登录密码" | |||||
}, | |||||
"username": { | |||||
"type": "string", | |||||
"example": "登录账号" | |||||
} | |||||
} | |||||
}, | |||||
"md.Response": { | "md.Response": { | ||||
"type": "object", | "type": "object", | ||||
"properties": { | "properties": { | ||||
@@ -755,6 +755,25 @@ definitions: | |||||
uuid: | uuid: | ||||
type: string | type: string | ||||
type: object | type: object | ||||
md.RegisterReq: | |||||
properties: | |||||
agent_id: | |||||
example: 代理id | |||||
type: string | |||||
captcha: | |||||
example: 验证码 | |||||
type: string | |||||
password: | |||||
example: 登录密码 | |||||
type: string | |||||
username: | |||||
example: 登录账号 | |||||
type: string | |||||
required: | |||||
- captcha | |||||
- password | |||||
- username | |||||
type: object | |||||
md.Response: | md.Response: | ||||
properties: | properties: | ||||
code: | code: | ||||
@@ -1764,7 +1783,7 @@ paths: | |||||
name: req | name: req | ||||
required: true | required: true | ||||
schema: | schema: | ||||
$ref: '#/definitions/md.LoginReq' | |||||
$ref: '#/definitions/md.RegisterReq' | |||||
produces: | produces: | ||||
- application/json | - application/json | ||||
responses: | responses: | ||||
@@ -6,7 +6,7 @@ go 1.18 | |||||
// | // | ||||
require ( | require ( | ||||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240913063657-cd3094cf9822 | |||||
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240918130541-2345c97fc95a | |||||
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 | ||||
@@ -1,49 +1,90 @@ | |||||
apiVersion: apps/v1 | |||||
kind: Deployment | kind: Deployment | ||||
apiVersion: apps/v1 | |||||
# 元数据 | |||||
metadata: | metadata: | ||||
namespace: zhios | |||||
name: zhios-mall | |||||
name: advertisement-medium | |||||
namespace: advertisement | |||||
labels: | labels: | ||||
app: zhios-mall | |||||
app: advertisement-medium | |||||
annotations: | |||||
kubesphere.io/creator: dengbiao | |||||
kubesphere.io/description: advertisement-medium | |||||
# deployment主要部分 | |||||
spec: | spec: | ||||
replicas: 1 | replicas: 1 | ||||
selector: | |||||
matchLabels: | |||||
# 名称与上面的labels对应 | |||||
app: advertisement-medium | |||||
template: | template: | ||||
metadata: | metadata: | ||||
name: zhios-mall | |||||
labels: | labels: | ||||
app: zhios-mall | |||||
# 名称与上面的matchLabels对应 | |||||
app: advertisement-medium | |||||
spec: | spec: | ||||
containers: | |||||
- name: zhios-mall-container | |||||
image: registry-vpc.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-mall:0.1 | |||||
ports: | |||||
- containerPort: 5002 | |||||
name: 5002tcp | |||||
protocol: TCP | |||||
resources: | |||||
limits: | |||||
cpu: "1" | |||||
memory: 256Mi | |||||
requests: | |||||
cpu: 200m | |||||
memory: 128Mi | |||||
imagePullPolicy: IfNotPresent | |||||
restartPolicy: Always | |||||
# 声明挂载卷(将外部已存在的pvc、config等挂载进来) | |||||
volumes: | volumes: | ||||
# 用于时区校正 | |||||
- name: host-time | - name: host-time | ||||
hostPath: | hostPath: | ||||
path: /etc/localtime | path: /etc/localtime | ||||
type: '' | type: '' | ||||
- name: mall-cfg | |||||
# 将前面创建的configMap也挂载进来 | |||||
- name: advertisement-medium-cfg | |||||
configMap: | configMap: | ||||
name: zhios-mall-cfg | |||||
# 这里的名字就是前面创建的configMap的名字 | |||||
name: advertisement-medium-cfg | |||||
defaultMode: 420 | defaultMode: 420 | ||||
selector: | |||||
matchLabels: | |||||
app: zhios-mall | |||||
strategy: | |||||
type: RollingUpdate | |||||
rollingUpdate: | |||||
maxUnavailable: 25% | |||||
maxSurge: 25% | |||||
# pvc | |||||
- name: advertisement-medium-pvc # 在该部署中的名称,后面使用改名称挂载 | |||||
persistentVolumeClaim: | |||||
claimName: advertisement-medium-pvc # pvc的名称 | |||||
# Nginx配置 | |||||
- name: advertisement-medium-nginx | |||||
configMap: | |||||
name: advertisement-medium-nginx # 外部configMap的名称 | |||||
items: | |||||
- key: go.conf | |||||
path: default.conf | |||||
containers: | |||||
# 主容器 | |||||
- name: advertisement-medium-container | |||||
# 镜像地址(提前打包好并推送的镜像仓库) | |||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/advertisement-medium:0.0.1' | |||||
ports: | |||||
- name: ad-medium-1004 | |||||
# 容器端口号(注意与golang web server启动的端口一致) | |||||
containerPort: 1004 | |||||
protocol: TCP | |||||
# 将前面volume声明的需要用到的pvc、config挂载上来 | |||||
volumeMounts: | |||||
- name: host-time | |||||
readOnly: true | |||||
mountPath: /etc/localtime | |||||
- name: advertisement-medium-cfg # 该名字对应前面volumes声明的名字 | |||||
readOnly: true | |||||
# 挂载到容器的哪个路径 | |||||
mountPath: /var/zyos | |||||
imagePullPolicy: Always | |||||
# Nginx 容器 | |||||
- name: nginx | |||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/nginx:latest' | |||||
ports: | |||||
- name: http-80 | |||||
containerPort: 80 | |||||
protocol: TCP | |||||
volumeMounts: | |||||
# 时区校正 | |||||
- name: host-time | |||||
readOnly: true | |||||
mountPath: /etc/localtime | |||||
# 存储卷 用于存放前端代码 | |||||
- name: advertisement-medium-pvc # 前面volumes声明的名称 | |||||
mountPath: /usr/share/nginx/html | |||||
- name: advertisement-medium-nginx # Nginx 配置 | |||||
readOnly: true | |||||
mountPath: /etc/nginx/conf.d/default.conf | |||||
subPath: default.conf | |||||
restartPolicy: Always | |||||
terminationGracePeriodSeconds: 30 | |||||
dnsPolicy: ClusterFirst |
@@ -0,0 +1,20 @@ | |||||
apiVersion: networking.k8s.io/v1 | |||||
kind: Ingress | |||||
metadata: | |||||
annotations: | |||||
cert-manager.io/cluster-issuer: letsencrypt-prod | |||||
kubesphere.io/creator: dengbiao | |||||
name: advertisement-medium | |||||
namespace: advertisement | |||||
spec: | |||||
rules: | |||||
- host: '*.admt.zhiyingos.cn' | |||||
http: | |||||
paths: | |||||
- backend: | |||||
service: | |||||
name: advertisement-medium | |||||
port: | |||||
number: 80 | |||||
path: / | |||||
pathType: ImplementationSpecific |