Преглед на файлове

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/hdl/hdl_login.go
master
huangjiajun преди 3 месеца
родител
ревизия
7998bf7f7e
променени са 8 файла, в които са добавени 196 реда и са изтрити 49 реда
  1. +26
    -12
      app/hdl/hdl_login.go
  2. +1
    -0
      app/md/md_login.go
  3. +27
    -1
      docs/docs.go
  4. +27
    -1
      docs/swagger.json
  5. +20
    -1
      docs/swagger.yaml
  6. +1
    -1
      go.mod
  7. +74
    -33
      k8s/container_prd.yaml
  8. +20
    -0
      k8s/ingress_prd.yaml

+ 26
- 12
app/hdl/hdl_login.go Целия файл

@@ -117,7 +117,7 @@ func LoginPhone(c *gin.Context) {
// @Description 手机号注册
// @Accept json
// @Produce json
// @Param req body md.LoginReq true "用户名、验证码"
// @Param req body md.RegisterReq true "用户名、验证码"
// @Success 200 {object} md.LoginResponse "token"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/register [post]
@@ -210,26 +210,40 @@ func Register(c *gin.Context) {
}
insertAffected, err = db.Db.Insert(&MediumDivisionStrategyModel)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if insertAffected <= 0 {
e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败")
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
}
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)
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(mediumModel.Id))


+ 1
- 0
app/md/md_login.go Целия файл

@@ -16,6 +16,7 @@ type LoginPhoneReq struct {
}
type RegisterReq struct {
UserName string `json:"username" binding:"required" example:"登录账号"`
AgentId string `json:"agent_id" example:"代理id"`
Captcha string `json:"captcha" binding:"required" example:"验证码"`
PassWord string `json:"password" binding:"required" example:"登录密码"`
AgentId string `json:"agent_id" example:"代理id"`


+ 27
- 1
docs/docs.go Целия файл

@@ -1198,7 +1198,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"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": {
"type": "object",
"properties": {


+ 27
- 1
docs/swagger.json Целия файл

@@ -1190,7 +1190,7 @@
"in": "body",
"required": true,
"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": {
"type": "object",
"properties": {


+ 20
- 1
docs/swagger.yaml Целия файл

@@ -755,6 +755,25 @@ definitions:
uuid:
type: string
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:
properties:
code:
@@ -1764,7 +1783,7 @@ paths:
name: req
required: true
schema:
$ref: '#/definitions/md.LoginReq'
$ref: '#/definitions/md.RegisterReq'
produces:
- application/json
responses:


+ 1
- 1
go.mod Целия файл

@@ -6,7 +6,7 @@ go 1.18

//
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/boombuler/barcode v1.0.1
github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5


+ 74
- 33
k8s/container_prd.yaml Целия файл

@@ -1,49 +1,90 @@
apiVersion: apps/v1
kind: Deployment
apiVersion: apps/v1
# 元数据
metadata:
namespace: zhios
name: zhios-mall
name: advertisement-medium
namespace: advertisement
labels:
app: zhios-mall
app: advertisement-medium
annotations:
kubesphere.io/creator: dengbiao
kubesphere.io/description: advertisement-medium
# deployment主要部分
spec:
replicas: 1
selector:
matchLabels:
# 名称与上面的labels对应
app: advertisement-medium
template:
metadata:
name: zhios-mall
labels:
app: zhios-mall
# 名称与上面的matchLabels对应
app: advertisement-medium
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:
# 用于时区校正
- name: host-time
hostPath:
path: /etc/localtime
type: ''
- name: mall-cfg
# 将前面创建的configMap也挂载进来
- name: advertisement-medium-cfg
configMap:
name: zhios-mall-cfg
# 这里的名字就是前面创建的configMap的名字
name: advertisement-medium-cfg
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

+ 20
- 0
k8s/ingress_prd.yaml Целия файл

@@ -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

Зареждане…
Отказ
Запис