作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !1
正在显示 100 个修改的文件 包含 2525 行增加1092 行删除

要显示太多修改。

为保证性能只显示 100 of 100+ 个文件。

... ... @@ -23,4 +23,7 @@ _testmain.go
*.test
.log
.idea
*.tmp
\ No newline at end of file
*.tmp
swagger.json
swagger.yaml
\ No newline at end of file
... ...
FROM golang:latest
MAINTAINER <>
ENV APP_DIR $GOPATH/src/project
FROM 192.168.0.243:5000/mmm/allied-creation-user:20210809
ENV APP_DIR $GOPATH/src/project-20210906
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
COPY ./conf conf
COPY ./config config
COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
... ... @@ -12,6 +11,6 @@ RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
ENV GO111MODULE on
ENV GOPROXY https://goproxy.io
RUN ["go","mod","tidy"]
RUN ["ls"]
RUN ["go","build"]
ENTRYPOINT ["./project"]
\ No newline at end of file
RUN ["ls"]
ENTRYPOINT ["./allied-creation-user"]
\ No newline at end of file
... ...
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAy0OxRf+NheQG9epxbrudwnrzqVgqK5zCuRAkLUgaSMATVXEA
iDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8tJq0E+bSDtSK3n+2mjZb6pChmgHw
KEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpog1RlfKgft6NYUzNLUqE5Mxzq7lpD
eRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttKeg+hKqIottQ/H6Tq4c8deEQGnO0+
RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr6uCOq5MSt2WsU8CTuhRwGXSvcQCO
FLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm+QIDAQABAoIBAQC8X7+qX2uI6gqJ
XPxC4x0RX2DxUAPE50KOv6bHUEsLoPZJ+K/Fko/oHuuTja47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teRCBaho1+V
-----END CERTIFICATE-----
... ...
apiVersion: v1
kind: Service
metadata:
name: allied-creation-user
namespace: mmm-suplus-dev
labels:
k8s-app: allied-creation-user
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: allied-creation-user
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: allied-creation-user
namespace: mmm-suplus-dev
labels:
k8s-app: allied-creation-user
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: allied-creation-user
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: allied-creation-user
image: 192.168.0.243:5000/mmm/allied-creation-user:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
env:
- name: POSTGRESQL_DB_NAME
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresqlalliedcreation.dbname
- name: POSTGRESQL_USER
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.user
- name: POSTGRESQL_PASSWORD
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.password
- name: POSTGRESQL_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.host
- name: POSTGRESQL_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.port
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: ENABLE_KAFKA_LOG
value: "true"
- name: HTTP_PORT
value: "8082"
- name: SERVICE_ENV
value: "dev"
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n <replace-your-k8s-namespace> get pods | grep -q project
kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
if [ "$?" == "1" ];then
kubectl create -f /tmp/dev/project/project.yaml --record
kubectl -n <replace-your-k8s-namespace> get svc | grep -q project
kubectl create -f /tmp/dev/allied-creation-user/allied-creation-user.yaml --record
kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "project service install success!"
echo "allied-creation-user service install success!"
else
echo "project service install fail!"
echo "allied-creation-user service install fail!"
fi
kubectl -n <replace-your-k8s-namespace> get pods | grep -q project
kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "project deployment install success!"
echo "allied-creation-user deployment install success!"
else
echo "project deployment install fail!"
echo "allied-creation-user deployment install fail!"
fi
else
kubectl delete -f /tmp/dev/project/project.yaml
kubectl -n <replace-your-k8s-namespace> get svc | grep -q project
kubectl delete -f /tmp/dev/allied-creation-user/allied-creation-user.yaml
kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
while [ "$?" == "0" ]
do
kubectl -n <replace-your-k8s-namespace> get svc | grep -q project
kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
done
kubectl -n <replace-your-k8s-namespace> get pods | grep -q project
kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
while [ "$?" == "0" ]
do
kubectl -n <replace-your-k8s-namespace> get pods | grep -q project
kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
done
kubectl create -f /tmp/dev/project/project.yaml --record
kubectl -n <replace-your-k8s-namespace> get svc | grep -q project
kubectl create -f /tmp/dev/allied-creation-user/allied-creation-user.yaml --record
kubectl -n mmm-suplus-dev get svc | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "project service update success!"
echo "allied-creation-user service update success!"
else
echo "project service update fail!"
echo "allied-creation-user service update fail!"
fi
kubectl -n <replace-your-k8s-namespace> get pods | grep -q project
kubectl -n mmm-suplus-dev get pods | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "project deployment update success!"
echo "allied-creation-user deployment update success!"
else
echo "project deployment update fail!"
echo "allied-creation-user deployment update fail!"
fi
fi
\ No newline at end of file
... ...
apiVersion: v1
kind: Service
metadata:
name: project
namespace: <replace-your-k8s-namespace>
name: allied-creation-user
namespace: mmm-suplus-dev
labels:
k8s-app: project
k8s-app: allied-creation-user
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: project
k8s-app: allied-creation-user
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: project
namespace: <replace-your-k8s-namespace>
name: allied-creation-user
namespace: mmm-suplus-dev
labels:
k8s-app: project
k8s-app: allied-creation-user
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: project
k8s-app: allied-creation-user
spec:
affinity:
nodeAffinity:
... ... @@ -43,8 +43,8 @@ spec:
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: project
image: 192.168.0.243:5000/mmm/project:dev
- name: allied-creation-user
image: 192.168.0.243:5000/mmm/allied-creation-user:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
... ...
apiVersion: v1
kind: Service
metadata:
name: allied-creation-user
namespace: mmm-suplus-preonline
labels:
k8s-app: allied-creation-user
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: allied-creation-user
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: allied-creation-user
namespace: mmm-suplus-preonline
labels:
k8s-app: allied-creation-user
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: allied-creation-user
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: allied-creation-user
image: 192.168.0.243:5000/mmm/allied-creation-user:preonline
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
env:
- name: POSTGRESQL_DB_NAME
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresqlalliedcreation.dbname
- name: POSTGRESQL_USER
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.user
- name: POSTGRESQL_PASSWORD
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.password
- name: POSTGRESQL_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.host
- name: POSTGRESQL_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.port
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: ENABLE_KAFKA_LOG
value: "true"
- name: HTTP_PORT
value: "8082"
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: SERVICE_ENV
value: "pre"
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
if [ "$?" == "1" ];then
kubectl create -f /tmp/preonline/allied-creation-user/allied-creation-user.yaml --record
kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user service install success!"
else
echo "allied-creation-user service install fail!"
fi
kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user deployment install success!"
else
echo "allied-creation-user deployment install fail!"
fi
else
kubectl delete -f /tmp/preonline/allied-creation-user/allied-creation-user.yaml
kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
done
kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
done
kubectl create -f /tmp/preonline/allied-creation-user/allied-creation-user.yaml --record
kubectl -n mmm-suplus-preonline get svc | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user service update success!"
else
echo "allied-creation-user service update fail!"
fi
kubectl -n mmm-suplus-preonline get pods | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user deployment update success!"
else
echo "allied-creation-user deployment update fail!"
fi
fi
\ No newline at end of file
... ...
apiVersion: v1
kind: Service
metadata:
name: allied-creation-user
namespace: mmm-suplus-test
labels:
k8s-app: allied-creation-user
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: allied-creation-user
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: allied-creation-user
namespace: mmm-suplus-test
labels:
k8s-app: allied-creation-user
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: allied-creation-user
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: allied-creation-user
image: 192.168.0.243:5000/mmm/allied-creation-user:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
- containerPort: 443
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
env:
- name: POSTGRESQL_DB_NAME
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresqlalliedcreation.dbname
- name: POSTGRESQL_USER
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.user
- name: POSTGRESQL_PASSWORD
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.password
- name: POSTGRESQL_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.host
- name: POSTGRESQL_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.port
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: ENABLE_KAFKA_LOG
value: "true"
- name: HTTP_PORT
value: "8082"
- name: SERVICE_ENV
value: "test"
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
if [ "$?" == "1" ];then
kubectl create -f /tmp/test/allied-creation-user/allied-creation-user.yaml --record
kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user service install success!"
else
echo "allied-creation-user service install fail!"
fi
kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user deployment install success!"
else
echo "allied-creation-user deployment install fail!"
fi
else
kubectl delete -f /tmp/test/allied-creation-user/allied-creation-user.yaml
kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
done
kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
done
kubectl create -f /tmp/test/allied-creation-user/allied-creation-user.yaml --record
kubectl -n mmm-suplus-test get svc | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user service update success!"
else
echo "allied-creation-user service update fail!"
fi
kubectl -n mmm-suplus-test get pods | grep -q allied-creation-user
if [ "$?" == "0" ];then
echo "allied-creation-user deployment update success!"
else
echo "allied-creation-user deployment update fail!"
fi
fi
\ No newline at end of file
... ...
version: v1
kind: HttpApi
metadata:
service: menu
path: /menus
endpoints:
- method: createMenu
route:
post: /
- method: updateMenu
route:
put: /{menuId}
- method: getMenu
route:
get: /{menuId}
- method: removeMenu
route:
delete: /{menuId}
- method: listMenu
route:
get: /
params:
- name: offset
- name: limit
version: v1
kind: Attribute
metadata:
name: count
description: 匹配数目
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: createAt
description: 创建时间
type:
primitive: datetime
version: v1
kind: Attribute
metadata:
name: deleteAt
description: 删除时间
type:
primitive: datetime
version: v1
kind: Attribute
metadata:
name: limit
description: 查询限制
type:
primitive: int
version: v1
kind: Attribute
metadata:
name: offset
description: 查询偏离量
type:
primitive: int
version: v1
kind: Attribute
metadata:
name: remark
description: 备注
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: updateAt
description: 更新时间
type:
primitive: datetime
version: v1
kind: Attribute
metadata:
name: companyId
description: 企业id
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: companyName
description: 企业名称
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: configCode
description: 参数编码
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: configId
description: 系统配置id
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: configLevel
description: 参数管控层级 (1.平台级 2.系统级 3.功能级)
type:
primitive: int
version: v1
kind: Attribute
metadata:
name: configName
description: 参数名称
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: desc
description: 参数描述
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: value
description: 管控值
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: valueType
description: 参数管控层级 (1.字符 2.数值 3.时间)
type:
primitive: int
version: v1
kind: Attribute
metadata:
name: menuId
description: 菜单编号
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: orgCode
description: 组织编码
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: orgId
description: 组织ID
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: orgName
description: 组织名称
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: roleId
description: 角色ID
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: roleName
description: 角色名称
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: status
description: 用户状态
type:
primitive: int
version: v1
kind: Attribute
metadata:
name: usersCode
description: 用户编号
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: usersCompanyId
description: 用户公司编号
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: usersId
description: 用户编号
type:
primitive: int64
version: v1
kind: Attribute
metadata:
name: usersName
description: 用户姓名
type:
primitive: string
version: v1
kind: Attribute
metadata:
name: usersType
description: 用户类型 : 1:普通用户 2:共创用户 1024:超级管理员
type:
primitive: int
version: v1
kind: Project
metadata:
name: project
description: 天联企业管理系统
version: 0.0.1
repository: gitlab.fjmaimaimai.com/allied-creation/allied-creation-user
contact:
name:
email:
\ No newline at end of file
version: v1
kind: Schema
metadata:
name: app
description: app项目管理
attributes:
- name: appId
description: appId
type:
primitive: int64
- name: project
description: 项目标识 ability
type:
primitive: string
- name: app
description: 应用标识 ability.boss.pad
type:
primitive: string
- name: icon
description: 图标地址
type:
primitive: string
- name: remark
description: 备注信息
type:
primitive: string
- ref: createAt
required: true
- ref: updateAt
required: true
- ref: deleteAt
required: true
\ No newline at end of file
version: v1
kind: Schema
metadata:
name: appVersion
description: App版本管理
attributes:
- name: appVersionId
description: app版本id
type:
primitive: int64
- name: app
description: 应用
type:
schema: app
- name: os
description: 设备类型 0:IOS 1:安卓
type:
primitive: int
- name: version
description: 版本信息
type:
schema: appVersionInfo
- name: remark
description: 备注信息
type:
primitive: string
- ref: createAt
required: true
- ref: updateAt
required: true
- ref: deleteAt
required: true
version: v1
kind: Schema
metadata:
name: appVersionInfo
description: app 版本信息
attributes:
- name: versionNo
description: 版本号
type:
primitive: string
- name: versionName
description: 版本名称
type:
primitive: string
- name: title
description: 标题
type:
primitive: string
- name: summary
description: 版本概要
type:
primitive: string
- name: content
description: 版本内容
type:
primitive: string
- name: deviceType
description: 设备类型 0:ios , 1:android
type:
primitive: int
- name: downloadPage
description: 下载页面
type:
primitive: string
- name: downloadFile
description: 文件下载地址
type:
primitive: string
- name: updateType
description: 更新类型 0不需要更新 1是引导更新 2是强制更新
type:
primitive: int
- name: channel
description: 更新的渠道 当前渠道 0_AppStore、1_fir平台、2_华为、3_小米、4_魅族、5_oppo、6_vivo、7_360、8_百度、9_应用宝、10_其他(使用应用宝地址)
type:
array: int
\ No newline at end of file
version: v1
kind: Schema
metadata:
name: company
description: 企业信息 (base)
attributes:
- ref: companyId
required: true
- name: companyConfig
description: 企业配置信息
type:
schema: companyConfig
- name: companyInfo
description: 企业基本信息
type:
schema: companyInfo
- name: status
description: 公司状态
type:
primitive: int
- ref: createAt
required: false
- ref: updateAt
required: false
version: v1
kind: Schema
metadata:
name: companyConfig
description: 公司配置信息
attributes:
- name: systemName
description: 系统名称
type:
primitive: string
- name: theme
description: 主题
type:
primitive: string
version: v1
kind: Schema
metadata:
name: companyInfo
description: 公司信息
attributes:
- name: companyName
description: 公司名称
type:
primitive: string
- name: scale
description: 规模
type:
primitive: string
- name: logo
description: 公司Logo地址
type:
primitive: string
- name: address
description: 公司地址
type:
primitive: string
- name: taxpayerCode
description: 纳税人识别号
type:
primitive: string
- name: businessLicense
description: 营业执照
type:
primitive: string
- name: industryCategory
description: 所属行业
type:
primitive: string
- name: contacts
description: 联系人
type:
primitive: string
- name: registTime
description: 注册时间
type:
primitive: datetime
- name: registStatus
description: 注册状态
type:
primitive: int
\ No newline at end of file
version: v1
kind: Schema
metadata:
name: config
description: 系统参数配置
attributes:
- ref: configId
required: true
- ref: companyId
required: true
- ref: configCode
required: true
- ref: configName
required: true
- ref: configLevel
required: true
- ref: valueType
required: true
- ref: value
required: true
- ref: desc
required: true
version: v1
kind: Schema
metadata:
name: cooperationInfo
description: 共创信息
attributes:
- name: cooperationCompany
description: 共创公司
type:
primitive: string
- name: cooperationDeadline
description: 共创到期时间 (yyyy-MM-dd)
type:
primitive: datetime
version: v1
kind: Schema
metadata:
name: credentialAuth
description: 凭证认证 (base) (停用)
attributes:
- name: credential
description: 凭证
type:
primitive: string
- name: deviceType
description: 设备类型
type:
primitive: string
- name: expire
description: 过期时间蹉(unix)
type:
primitive: int64
version: v1
kind: Schema
metadata:
name: customizeMenus
description: 自定义菜单 (base)(菜单维护)
attributes:
- name: customizeMenusId
description: 自定义菜单id
type:
primitive: int64
- ref: companyId
required: true
- name: menuId
description: 菜单id
type:
primitive: int64
- name: menuName
description: 菜单名称
type:
primitive: string
- name: menuAlias
description: 菜单别名
type:
primitive: string
- name: sort
description: 排序
type:
primitive: int
version: v1
kind: Schema
metadata:
name: dataColumn
description: 数据列
attributes:
- name: dataIndex
description: 数据列字段代码名称
type:
primitive: string
- name: title
description: 数据列字段中文描述
type:
primitive: string
- name: sortBy
description: 默认的排序
type:
primitive: int64
- name: isDefault
description: 是否是默认配置字段
type:
primitive: int
version: v1
kind: Schema
metadata:
name: dataColumnPerson
description: 列表设置个人:页面列表数据的输出列的个人配置
attributes:
- name: dataColumnPersonId
description: 数据id
type:
primitive: int64
- name: resource
description: 资源 (列如表单 user)
type:
primitive: string
- name: columns
description: 配置的用户显示的字段,例 `["c1","c2"]``
type:
array: string
- name: usersId
description: 归属的用户id
type:
primitive: int64
version: v1
kind: Schema
metadata:
name: dataColumnSys
description: 列表设置系统:页面列表数据的输出列的系统全局配置
attributes:
- name: dataColumnSysId
description: 数据id
type:
primitive: int64
- name: resource
description: 资源 (列如表单 user)
type:
primitive: string
- name: columns
description: 数据列字段代码名称
type:
array: dataColumn
version: v1
kind: Schema
metadata:
name: dictionary
description: 字典
attributes:
- name: dictionaryId
description: 字典编号 主键
type:
primitive: int
- name: dictCode
description: 字典编码
type:
primitive: string
- name: dictName
description: 字典名称
type:
primitive: string
- name: enableStatus
description: 启用状态(启用:1 禁用:2)
type:
primitive: int
- name: desc
description: 备注信息
type:
primitive: string
- name: dictItems
description: 字典值列表
type:
array: dictionaryItem
version: v1
kind: Schema
metadata:
name: dictionaryItem
description: 字典明细项
attributes:
- name: itemCode
description: 项编码
type:
primitive: string
- name: itemLabel
description: 项标签
type:
primitive: string
- name: itemValue
description:
type:
primitive: string
- name: enableStatus
description: 启用状态(启用:1 禁用:2)
type:
primitive: string
- name: sort
description: 显示序号
type:
primitive: int
version: v1
kind: Schema
metadata:
name: ext
description: 冗余附加数据
attributes:
- ref: usersName
required: true
- ref: orgName
required: true
- name: phone
description: 手机号
type:
primitive: string
- name: depName
description: 部门名称
type:
primitive: string
version: v1
kind: Schema
metadata:
name: im
description: 冗余附加数据
attributes:
- name: accid
description: 网易云信ID
type:
primitive: string
- name: imToken
description: 网易云信Token
type:
primitive: string
- name: csAccountId
description: 系统分配客服ID
type:
primitive: string
version: v1
kind: Schema
metadata:
name: menu
description: 系统菜单
attributes:
- ref: menuId
required: true
- name: parentId
description: 父级id
type:
primitive: int64
- name: menuName
description: 菜单名称
type:
primitive: string
- name: code
description: 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码)
type:
primitive: string
- name: accessCode
description: 权限编码 users:edit
type:
primitive: string
- name: menuType
description: 菜单类型 (目录catalog、菜单menu、按钮button)
type:
primitive: string
- name: icon
description: 菜单图标
type:
primitive: string
- name: sort
description: 排序
type:
primitive: int
- name: remark
description: 菜单说明
type:
primitive: string
- name: category
description: 菜单类别 (web:1、app:2)
type:
primitive: string
- name: parentPath
description: 父级节点路径("0,11,12,")
type:
primitive: string
- name: isPublish
description: 菜单是否公开状态,[0:隐藏],[1:显示],默认显示
type:
primitive: int
- name: isSystem
description: 菜单是否是系统级,[0:否],[1:是],默认否
type:
primitive: int
version: v1
kind: Schema
metadata:
name: org
description: 组织 organization
attributes:
- ref: orgId
required: true
- ref: companyId
required: true
- ref: createAt
required: true
- ref: updateAt
required: true
- ref: deleteAt
required: true
- ref: orgCode
required: true
- ref: orgName
required: true
- name: isOrg
description: 是否是组织
type:
primitive: int
- name: parentId
description: 父级ID
type:
primitive: int64
version: v1
kind: Schema
metadata:
name: phoneAuth
description: 手机认证 (base)
attributes:
- name: phone
description: 手机号
type:
primitive: string
- name: password
description: 密码
type:
primitive: string
version: v1
kind: Schema
metadata:
name: role
description: 角色 (base)
attributes:
- ref: roleId
required: true
- ref: companyId
required: true
- ref: orgId
required: true
- ref: roleName
required: true
- name: menuAccess
description: 菜单权限列表
type:
array: int64
- name: desc
description: 角色描述
type:
primitive: string
- name: ext
description: 扩展数据
type:
schema: ext
- ref: createAt
required: true
- ref: updateAt
required: true
version: v1
kind: Schema
metadata:
name: users
description: 用户(base)
attributes:
- ref: usersId
required: true
- name: usersInfo
description: 用户信息
type:
schema: usersInfo
- name: phoneAuth
description: 手机认证
type:
schemal: phoneAuth
- name: im
description: IM信息
type:
schemal: im
- ref: createAt
required: true
- ref: updateAt
required: true
\ No newline at end of file
version: v1
kind: Schema
metadata:
name: usersCompany
description: 用户 (base)
attributes:
- ref: usersCompanyId
required: true
- ref: companyId
required: true
- ref: usersId
required: true
- ref: usersType
required: true
- ref: usersCode
required: true
- name: organization
description: 组织机构
type:
primitive: int64
- name: department
description: 所属部门
type:
primitive: int64
- name: usersOrg
description: 用户关联的组织
type:
array: int64
- name: usersRole
description: 用户关联的角色
type:
array: int64
- name: collectedMenus
description: 收藏的菜单(工作台)(菜单编码列表)
type:
array: string
- name: cooperationInfo
description: 共创信息 (共创用户有效)
type:
schema: cooperationInfo
- name: enableStatus
description: 启用状态(启用:1 禁用:2)
type:
primitive: int
- name: ext
description: 扩展数据
type:
schema: ext
- ref: createAt
required: true
- ref: updateAt
required: true
version: v1
kind: Schema
metadata:
name: usersInfo
description: 用户信息 (base)
attributes:
- ref: usersName
required: true
- name: phone
description: 手机号码
type:
primitive: string
- name: avator
description: 头像
type:
primitive: string
- name: email
description: 邮箱
type:
primitive: string
version: v1
kind: Method
metadata:
name: createMenu
type: command
description: 创建菜单服务
payload:
- name: parentId
description: 父级id
type:
primitive: int64
- name: menuName
description: 菜单名称
type:
primitive: string
required: true
- name: code
description: 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码)
type:
primitive: string
required: true
- name: accessCode
description: 权限编码 users:edit
type:
primitive: string
required: true
- name: menuType
description: 菜单类型 (目录catalog、菜单menu、按钮button)
type:
primitive: string
required: true
- name: icon
description: 菜单图标
type:
primitive: string
- name: sort
description: 排序
type:
primitive: int
required: true
- name: remark
description: 菜单说明
type:
primitive: string
- name: isPublish
description: 菜单是否公开状态,[0:隐藏],[1:显示],默认显示
type:
primitive: int
required: true
result:
- name: menu
type:
schema: menu
required: true
version: v1
kind: Method
metadata:
name: getMenu
type: query
description: 返回菜单服务
payload:
- ref: menuId
required: true
result:
- name: menu
type:
schema: menu
required: true
version: v1
kind: Method
metadata:
name: listMenu
type: query
description: 返回菜单服务列表
payload:
- name: menuCategory
description: 菜单类别 web app
required: false
type:
primitive: string
- name: parentId
description: 菜单父级id 0:查询所有 n:父级id为n的菜单列表
required: false
type:
primitive: int64
- name: menuName
description: 菜单名称过滤
required: false
type:
primitive: string
- ref: offset
required: true
- ref: limit
required: true
result:
- ref: count
required: true
- name: menus
type:
array: menu
required: true
version: v1
kind: Method
metadata:
name: removeMenu
type: command
description: 移除菜单服务
payload:
- ref: menuId
required: true
result:
- name: menu
type:
schema: menu
required: true
version: v1
kind: Method
metadata:
name: updateMenu
type: command
description: 更新菜单服务
payload:
- ref: menuId
required: true
- name: menuName
description: 菜单名称
type:
primitive: string
required: true
- name: code
description: 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码)
type:
primitive: string
required: true
- name: accessCode
description: 权限编码 users:edit
type:
primitive: string
- name: menuType
description: 菜单类型 (目录catalog、菜单menu、按钮button)
type:
primitive: string
required: true
- name: icon
description: 菜单图标
type:
primitive: string
- name: sort
description: 排序
type:
primitive: int
required: true
- name: remark
description: 菜单说明
type:
primitive: string
- name: isPublish
description: 菜单是否公开状态,[0:隐藏],[1:显示],默认显示
type:
primitive: int
result:
- name: menu
type:
schema: menu
required: true
version: v1
kind: Service
metadata:
name: menu
description: 菜单服务
... ... @@ -5,6 +5,7 @@ go 1.16
require (
github.com/ajg/form v1.5.1 // indirect
github.com/beego/beego/v2 v2.0.1
github.com/emirpasic/gods v1.12.0
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gavv/httpexpect v2.0.0+incompatible
... ... @@ -18,6 +19,7 @@ require (
github.com/onsi/gomega v1.11.0
github.com/sergi/go-diff v1.2.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.7.0
github.com/valyala/fasthttp v1.23.0 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
... ...
... ... @@ -73,6 +73,8 @@ github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
... ...
package main
import (
"fmt"
"github.com/beego/beego/v2/server/web"
"github.com/linmadan/egglib-go/log/logrus"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/redis"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/port/beego"
)
func main() {
log.Logger.Info("server start ....")
log.Logger.Info(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG))
if constant.ENABLE_KAFKA_LOG {
w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false)
log.Logger.AddHook(w)
}
log.Logger.Info("server start!")
web.Run()
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type CompanySignUpCommand struct {
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
// 联系人
Contacts string `cname:"联系人" json:"contacts" valid:"Required"`
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 规模
Scale string `cname:"规模" json:"scale" valid:"Required"`
// 所属行业
IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
}
func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (companySignUpCommand *CompanySignUpCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(companySignUpCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(companySignUpCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type DestroyAccountCommand struct {
// 用户Id 用户唯一标识
Account string `cname:"账号" json:"account" valid:"Required"`
}
func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) {
}
func (destroyAccountCommand *DestroyAccountCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(destroyAccountCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(destroyAccountCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type PhoneAuthChangePasswordCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
// 旧密码
OldPassword string `cname:"旧密码" json:"oldPassword" valid:"Required"`
// 新密码
NewPassword string `cname:"新密码" json:"newPassword" valid:"Required"`
}
func (phoneAuthChangePasswordCommand *PhoneAuthChangePasswordCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthChangePasswordCommand *PhoneAuthChangePasswordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthChangePasswordCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthChangePasswordCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type PhoneAuthCheckCommand struct {
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
}
func (phoneAuthCheckCommand *PhoneAuthCheckCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthCheckCommand *PhoneAuthCheckCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthCheckCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthCheckCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type PhoneAuthResetPasswordCommand struct {
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
}
func (phoneAuthResetPasswordCommand *PhoneAuthResetPasswordCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthResetPasswordCommand *PhoneAuthResetPasswordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthResetPasswordCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthResetPasswordCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type PhoneAuthResetPhoneCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId"`
OldPhone string `cname:"" json:"oldPhone" valid:"Required"`
NewPhone string `cname:"" json:"newPhone" valid:"Required"`
}
func (phoneAuthResetPhoneCommand *PhoneAuthResetPhoneCommand) Valid(validation *validation.Validation) {
}
func (phoneAuthResetPhoneCommand *PhoneAuthResetPhoneCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(phoneAuthResetPhoneCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(phoneAuthResetPhoneCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type RefreshIMCommand struct {
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 刷新标识 0:刷新IM信息,并返回 1:使用旧的im信息
RefreshFlag int `cname:"刷新标识" json:"refreshFlag"`
}
func (refreshIMCommand *RefreshIMCommand) Valid(validation *validation.Validation) {
}
func (refreshIMCommand *RefreshIMCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(refreshIMCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(refreshIMCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
)
type UserBaseDto struct {
// 用户基础数据id
UserBaseId int64 `json:"userBaseId,omitempty"`
UserType int `json:"userType"`
// 用户信息
UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
// 手机号码
//Account string `json:"phone,omitempty"`
// 密码
//Password string `json:"password,omitempty"`
// IM信息
Im *domain.Im `json:"im,omitempty"`
// 关联的用户 (冗余)
//RelatedUsers []int64 `json:"relatedUsers,omitempty"`
// 账号状态 1:正常 2.禁用 3:注销
//Status int `json:"status,omitempty"`
// 创建时间
//CreatedAt time.Time `json:"createdAt,omitempty"`
// 更新时间
//UpdatedAt time.Time `json:"updatedAt,omitempty"`
}
func (u *UserBaseDto) LoadDto(ub *domain.UserBase) {
u.UserBaseId = ub.UserBaseId
u.UserInfo = ub.UserInfo
u.UserType = domain.UserTypeVisitor
u.Im = ub.Im
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UserInfoQuery struct {
Account string `cname:"账号" json:"account"`
UserBaseId int64 `cname:"用户编号" json:"userBaseId"`
}
func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
if len(userInfoQuery.Account) == 0 && userInfoQuery.UserBaseId <= 0 {
validation.SetError("CustomValid", "参数不能为空")
}
}
func (userInfoQuery *UserInfoQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(userInfoQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(userInfoQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/auth/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"strconv"
"time"
)
// 认证服务
type AuthService struct {
}
// 企业注册
func (authService *AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) {
if err := companySignUpCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
//var user *domain.User
signUpCompanyService, err := factory.CreateSignUpCompanyService(map[string]interface{}{
"transactionContext": transactionContext,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
companyInfo := &domain.CompanyInfo{
CompanyName: companySignUpCommand.CompanyName,
Scale: companySignUpCommand.Scale,
Logo: "",
Address: "",
IndustryCategory: companySignUpCommand.IndustryCategory,
RegisteredTime: time.Now(),
}
userInfo := &domain.UserInfo{
UserName: companySignUpCommand.Contacts,
Phone: companySignUpCommand.Phone,
}
if _, err = signUpCompanyService.SignUpCompany(companySignUpCommand.Phone, companySignUpCommand.Password, companyInfo, userInfo); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct{}{}, nil
}
// 注销账号 (添加用户时重新激活)
func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.DestroyAccountCommand) (interface{}, error) {
if err := destroyAccountCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
accountDestroyService, err := factory.CreatePgAuthAccountDestroyService(map[string]interface{}{
"transactionContext": transactionContext,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.Account); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct{}{}, nil
}
// 修改密码
func (authService *AuthService) PhoneAuthChangePassword(phoneAuthChangePasswordCommand *command.PhoneAuthChangePasswordCommand) (interface{}, error) {
if err := phoneAuthChangePasswordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var userRepository domain.UserRepository
if value, err := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userRepository = value
}
var userBaseId int64
if user, err := userRepository.FindOne(map[string]interface{}{"userId": phoneAuthChangePasswordCommand.UserId}); err != nil {
if err == domain.ErrorNotFound {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
}
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
userBaseId = user.UserBaseId
}
var userBaseRepository domain.UserBaseRepository
if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userBaseRepository = value
}
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err == domain.ErrorNotFound {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
}
if err := userBase.CheckAccountPassword(userBase.Account, phoneAuthChangePasswordCommand.OldPassword); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := userBase.ResetPassword(userBase.Account, phoneAuthChangePasswordCommand.NewPassword); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if _, err = userBaseRepository.Save(userBase); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 手机账号密码检查
func (authService *AuthService) PhoneAuthCheck(phoneAuthCheckCommand *command.PhoneAuthCheckCommand) (interface{}, error) {
if err := phoneAuthCheckCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var userBaseRepository domain.UserBaseRepository
if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userBaseRepository = value
}
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": phoneAuthCheckCommand.Phone})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err == domain.ErrorNotFound {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
}
if err := userBase.CheckAccountPassword(phoneAuthCheckCommand.Phone, phoneAuthCheckCommand.Password); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return userBase, nil
}
// 重置密码(忘记密码)
func (authService *AuthService) PhoneAuthResetPassword(phoneAuthResetPasswordCommand *command.PhoneAuthResetPasswordCommand) (interface{}, error) {
if err := phoneAuthResetPasswordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var userBaseRepository domain.UserBaseRepository
if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userBaseRepository = value
}
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": phoneAuthResetPasswordCommand.Phone})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err == domain.ErrorNotFound {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
}
if err := userBase.ResetPassword(phoneAuthResetPasswordCommand.Phone, phoneAuthResetPasswordCommand.Password); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if _, err = userBaseRepository.Save(userBase); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct{}{}, nil
}
// 重置手机号
func (authService *AuthService) PhoneAuthResetPhone(phoneAuthResetPhoneCommand *command.PhoneAuthResetPhoneCommand) (interface{}, error) {
if err := phoneAuthResetPhoneCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
resetPhoneService, err := factory.CreatePgAuthResetPhoneService(map[string]interface{}{
"transactionContext": transactionContext,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := resetPhoneService.ResetPhone(nil, phoneAuthResetPhoneCommand.OldPhone, phoneAuthResetPhoneCommand.NewPhone); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct{}{}, nil
}
// 刷新IM信息
func (authService *AuthService) RefreshIM(refreshIMCommand *command.RefreshIMCommand) (interface{}, error) {
if err := refreshIMCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
imService, _ := factory.CreatePgImService(map[string]interface{}{
"transactionContext": transactionContext,
})
userId, _ := strconv.Atoi(refreshIMCommand.Phone)
imInfo, err := imService.InitOrUpdateUserIMInfo(int64(userId), refreshIMCommand.RefreshFlag)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return imInfo, nil
}
// 用户信息
func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (interface{}, error) {
if err := userInfoQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var userBase *domain.UserBase
userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0)
if len(userInfoQuery.Account) > 0 {
userBase, err = userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account})
} else if userInfoQuery.UserBaseId > 0 {
userBase, err = userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userInfoQuery.UserBaseId})
}
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
ubDto := &dto.UserBaseDto{}
ubDto.LoadDto(userBase)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return ubDto, nil
}
func NewAuthService(options map[string]interface{}) *AuthService {
newAuthService := &AuthService{}
return newAuthService
}
... ...
package service
type CommonService struct {
}
// 创建菜单服务
func (commonService *CommonService) DictionarySearch(codes []string) (interface{}, error) {
type dictItem struct {
ItemCode string `json:"itemCode"`
ItemValue string `json:"itemValue"`
}
dictionaries := make([]interface{}, 0)
for i := range codes {
switch codes[i] {
case "MenuType":
dictionaries = append(dictionaries, map[string]interface{}{
"dictName": "菜单类型",
"dictItems": []dictItem{
{"目录", "catalog"},
{"菜单", "menu"},
{"按钮", "button"},
},
})
}
}
return map[string]interface{}{"dictionary": dictionaries}, nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"time"
"github.com/beego/beego/v2/core/validation"
)
type CreateCompanyCommand struct {
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
// 规模
Scale string `cname:"规模" json:"scale" valid:"Required"`
// 公司Logo地址
Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
// 公司地址
Address string `cname:"公司地址" json:"address" valid:"Required"`
// 所属行业
IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
// 联系人
Contacts string `cname:"联系人" json:"contacts" valid:"Required"`
// 注册时间
RegisteredTime time.Time `cname:"注册时间" json:"registeredTime,omitempty"`
// 注册状态 1:已注册 2:待认证 3:已认证
Status int `cname:"注册状态 1:已注册 2:待认证 3:已认证" json:"status,omitempty"`
}
func (createCompanyCommand *CreateCompanyCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createCompanyCommand *CreateCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(createCompanyCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListCompanyCustomizeMenusCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
// 菜单类别 web app
MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty" valid:"Required"`
}
func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
}
func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(listCompanyCustomizeMenusCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listCompanyCustomizeMenusCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type RemoveCompanyCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
}
func (removeCompanyCommand *RemoveCompanyCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeCompanyCommand *RemoveCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeCompanyCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateCompanyCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
// 企业名称
CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
// 公司地址
Address string `cname:"公司地址" json:"address" valid:"Required"`
// 系统名称
SystemName string `cname:"系统名称" json:"systemName" valid:"Required"`
// 公司Logo地址
Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
}
func (updateCompanyCommand *UpdateCompanyCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCompanyCommand *UpdateCompanyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCompanyCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateCompanyCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateCompanyCustomizeMenusCommand struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
// 菜单编号
MenuId int64 `cname:"菜单编号" json:"menuId" valid:"Required"`
// 菜单名称
//MenuName string `cname:"菜单名称" json:"menuName" valid:"Required"`
// 菜单别名
MenuAlias string `cname:"菜单别名" json:"menuAlias" valid:"Required"`
// 排序
Sort int `cname:"排序" json:"sort" valid:"Required"`
}
func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCompanyCustomizeMenusCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateCompanyCustomizeMenusCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils"
)
type CustomizeMenuDto struct {
}
func (dto *CustomizeMenuDto) LoadDto(menus []*domain.Menu, customizeMenus []*domain.CustomizeMenu, rootMenu *domain.Menu) (interface{}, error) {
var ret []interface{}
ret = append(ret, rootMenu)
menusMap := make(map[int64]*domain.Menu)
menusMap[rootMenu.MenuId] = rootMenu
for i := range menus {
menusMap[menus[i].MenuId] = menus[i]
}
for i := range customizeMenus {
m := customizeMenus[i]
if menu, ok := menusMap[m.MenuId]; ok {
menu.MenuAlias = m.MenuAlias
menu.Sort = m.Sort
}
}
for i := range menus {
fieldMenu := utils.LoadCustomFieldToMap(menus[i], "MenuId", "ParentId", "MenuName", "Code", "Icon", "MenuAlias", "MenuType", "Remark", "Sort", "EnableStatus")
fieldMenu["parentMenuName"] = ""
if menu, ok := menusMap[menus[i].ParentId]; ok {
fieldMenu["parentMenuName"] = menu.MenuName
}
ret = append(ret, fieldMenu)
}
return ret, nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type GetCompanyQuery struct {
// 企业id
CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
}
func (getCompanyQuery *GetCompanyQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getCompanyQuery *GetCompanyQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getCompanyQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(getCompanyQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListCompanyQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
// 查询限制
Limit int `cname:"查询限制" json:"limit" valid:"Required"`
}
func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listCompanyQuery *ListCompanyQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listCompanyQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listCompanyQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/company/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/company/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/company/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/common"
"strconv"
)
// 企业
type CompanyService struct {
}
// 创建企业
func (companyService *CompanyService) CreateCompany(createCompanyCommand *command.CreateCompanyCommand) (interface{}, error) {
if err := createCompanyCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
newCompany := &domain.Company{
//CompanyInfo: createCompanyCommand.CompanyInfo,
}
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
if company, err := companyRepository.Save(newCompany); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return company, nil
}
}
// 返回企业
func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompanyQuery) (interface{}, error) {
if err := getCompanyQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
company, err := companyRepository.FindOne(map[string]interface{}{"companyId": getCompanyQuery.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if company == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCompanyQuery.CompanyId)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return company, nil
}
}
// 返回企业列表
func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCompanyQuery) (interface{}, error) {
if err := listCompanyQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
if count, companys, err := companyRepository.Find(tool_funs.SimpleStructToMap(listCompanyQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"companys": companys,
}, nil
}
}
// 返回自定义菜单列表(匹配有设置的菜单)
func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand *command.ListCompanyCustomizeMenusCommand) (interface{}, error) {
if err := listCompanyCustomizeMenusCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var menuRepository domain.MenuRepository
if value, err := factory.CreateMenuRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
menuRepository = value
}
queryOptions := common.SimpleStructToMap(listCompanyCustomizeMenusCommand)
var menuCategory *domain.Menu
if m, e := menuRepository.FindOne(map[string]interface{}{"code": listCompanyCustomizeMenusCommand.MenuCategory}); e == nil && m != nil {
queryOptions["category"] = strconv.Itoa(int(m.MenuId))
menuCategory = m
}
queryOptions["menuTypeIn"] = []string{"catalog", "menu"}
queryOptions["isPublish"] = domain.MenuPublic
_, menus, err := menuRepository.Find(queryOptions)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var customizeMenuRepository domain.CustomizeMenuRepository
if value, err := factory.CreateCustomizeMenuRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
customizeMenuRepository = value
}
_, customizeMenus, err := customizeMenuRepository.Find(queryOptions)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
customizeMenuDto := dto.CustomizeMenuDto{}
ret, _ := customizeMenuDto.LoadDto(menus, customizeMenus, menuCategory)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{"menus": ret}, nil
}
// 移除企业
func (companyService *CompanyService) RemoveCompany(removeCompanyCommand *command.RemoveCompanyCommand) (interface{}, error) {
if err := removeCompanyCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
company, err := companyRepository.FindOne(map[string]interface{}{"companyId": removeCompanyCommand.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if company == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCompanyCommand.CompanyId)))
}
if company, err := companyRepository.Remove(company); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return company, nil
}
}
// 更新企业
func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *command.UpdateCompanyCommand) (interface{}, error) {
if err := updateCompanyCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var companyRepository domain.CompanyRepository
if value, err := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyRepository = value
}
company, err := companyRepository.FindOne(map[string]interface{}{"companyId": updateCompanyCommand.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if company == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCompanyCommand.CompanyId)))
}
if err := company.Update(tool_funs.SimpleStructToMap(updateCompanyCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
orgRepository, _, _ := factory.FastPgOrg(transactionContext, 0)
if org, err := orgRepository.FindOne(map[string]interface{}{"companyId": updateCompanyCommand.CompanyId, "parentId": 0}); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
} else {
if org.OrgName != company.CompanyInfo.CompanyName {
org.Update(map[string]interface{}{"orgName": company.CompanyInfo.CompanyName})
}
if _, err := orgRepository.Save(org); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
}
if company, err := companyRepository.Save(company); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return company, nil
}
}
// 更新自定义菜单
func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) {
if err := updateCompanyCustomizeMenusCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var menuRepository domain.MenuRepository
if value, err := factory.CreateMenuRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
menuRepository = value
}
var menuName string
if menu, err := menuRepository.FindOne(map[string]interface{}{"menuId": updateCompanyCustomizeMenusCommand.MenuId}); err != nil || (menu != nil && menu.IsPublish != domain.MenuPublic) {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "菜单不存在")
} else {
menuName = menu.MenuName
}
var customizeMenuRepository domain.CustomizeMenuRepository
if value, err := factory.CreateCustomizeMenuRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
customizeMenuRepository = value
}
customizeMenu, e := customizeMenuRepository.FindOne(map[string]interface{}{
"companyId": updateCompanyCustomizeMenusCommand.CompanyId,
"menuId": updateCompanyCustomizeMenusCommand.MenuId,
"isPublish": domain.MenuPublic,
})
if e == domain.ErrorNotFound {
customizeMenu = &domain.CustomizeMenu{
CompanyId: updateCompanyCustomizeMenusCommand.CompanyId,
MenuId: updateCompanyCustomizeMenusCommand.MenuId,
MenuName: menuName,
MenuAlias: updateCompanyCustomizeMenusCommand.MenuAlias,
Sort: updateCompanyCustomizeMenusCommand.Sort,
}
} else if customizeMenu != nil {
data := tool_funs.SimpleStructToMap(updateCompanyCustomizeMenusCommand)
data["menuName"] = menuName
if err := customizeMenu.Update(data); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
} else {
return nil, application.ThrowError(application.TRANSACTION_ERROR, e.Error())
}
if customizeMenu, err = customizeMenuRepository.Save(customizeMenu); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, e.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return customizeMenu, nil
}
func NewCompanyService(options map[string]interface{}) *CompanyService {
newCompanyService := &CompanyService{}
return newCompanyService
}
... ...
package factory
import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/domainService"
)
func CreateSignUpCompanyService(options map[string]interface{}) (service.PgSignUpCompanyService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgSignUpCompanyServiceService(transactionContext)
}
func CreatePgAuthResetPhoneService(options map[string]interface{}) (service.PgAuthResetPhoneService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgAuthResetPhoneService(transactionContext)
}
func CreatePgAuthAccountDestroyService(options map[string]interface{}) (service.PgAuthAccountDestroyService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgAuthAccountDestroyService(transactionContext)
}
func CreatePgCreateUserService(options map[string]interface{}) (service.PgCreateUserService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgCreateUserService(transactionContext)
}
func CreatePgDataAuthService(options map[string]interface{}) (domain.DataAuthor, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgDataAuthService(transactionContext)
}
func CreatePgUpdateUserService(options map[string]interface{}) (service.PgUpdateUserService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgUpdateUserService(transactionContext)
}
func CreatePgCreateRoleService(options map[string]interface{}) (service.PgCreateRoleService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgCreateRoleService(transactionContext)
}
func CreatePgCreateOrgService(options map[string]interface{}) (service.PgCreateOrgService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgCreateOrgService(transactionContext)
}
func CreatePgRoleAccessMenusService(options map[string]interface{}) (service.PgRoleAccessMenusService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgRoleAccessMenusService(transactionContext)
}
func CreatePgImService(options map[string]interface{}) (service.PgImService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgImService(transactionContext)
}
func CreateBatchAddUserService(options map[string]interface{}) (service.PgBatchAddUserService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgBatchAddUserService(transactionContext)
}
func CreatePgBatchRemoveRoleService(options map[string]interface{}) (service.PgBatchRemoveRoleService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgBatchRemoveRoleService(transactionContext)
}
func CreatePgBatchAddOrgService(options map[string]interface{}) (service.PgBatchAddOrgService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewPgBatchAddOrgService(transactionContext)
}
... ...
package factory
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
)
/***** 1.快速模块 *****/
// FastPgUser 快速返回领域用户
//
// transactionContext 事务
// userId 用户ID
func FastPgUser(transactionContext application.TransactionContext, userId int64, options ...option) (domain.UserRepository, *domain.User, error) {
var rep domain.UserRepository
var mod *domain.User
var err error
if value, err := CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if userId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"userId": userId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该用户不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
return nil, nil, err
}
return rep, mod, err
}
// FastPgUser 快速返回领域用户基础
//
// transactionContext 事务
// userBaseId 用户基础ID
func FastPgUserBase(transactionContext application.TransactionContext, userBaseId int64) (domain.UserBaseRepository, *domain.UserBase, error) {
var rep domain.UserBaseRepository
var mod *domain.UserBase
var err error
if value, err := CreateUserBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if userBaseId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"userBaseId": userBaseId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "用户基础不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgRole 快速返回领域角色
//
// transactionContext 事务
// roleId 角色Id
func FastPgRole(transactionContext application.TransactionContext, roleId int64, options ...option) (domain.RoleRepository, *domain.Role, error) {
var rep domain.RoleRepository
var mod *domain.Role
var err error
if value, err := CreateRoleRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if roleId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"roleId": roleId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该角色不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
return nil, nil, err
}
return rep, mod, err
}
// FastPgRole 快速返回领域组织
//
// transactionContext 事务
// orgId 组织Id
func FastPgOrg(transactionContext application.TransactionContext, orgId int64) (domain.OrgRepository, *domain.Org, error) {
var rep domain.OrgRepository
var mod *domain.Org
var err error
if value, err := CreateOrgRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if orgId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"orgId": orgId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该组织不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgCompany 快速返回领域公司
//
// transactionContext 事务
// companyId 公司Id
func FastPgCompany(transactionContext application.TransactionContext, companyId int64) (domain.CompanyRepository, *domain.Company, error) {
var rep domain.CompanyRepository
var mod *domain.Company
var err error
if value, err := CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if companyId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"companyId": companyId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该企业不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgMenu 快速返回领域菜单
//
// transactionContext 事务
// menuId 菜单Id
func FastPgMenu(transactionContext application.TransactionContext, menuId int64) (domain.MenuRepository, *domain.Menu, error) {
var rep domain.MenuRepository
var mod *domain.Menu
var err error
if value, err := CreateMenuRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if menuId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"menuId": menuId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该菜单不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgCustomizeMenu 快速返回领域自定义菜单
//
// transactionContext 事务
// customizeMenuId 自定义菜单Id
func FastPgCustomizeMenu(transactionContext application.TransactionContext, customizeMenuId int64) (domain.CustomizeMenuRepository, *domain.CustomizeMenu, error) {
var rep domain.CustomizeMenuRepository
var mod *domain.CustomizeMenu
var err error
if value, err := CreateCustomizeMenuRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if customizeMenuId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"customizeMenuId": customizeMenuId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "自定义菜单不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// FastPgAccountDestroyRecord 快速返回领域账号注销记录
//
// transactionContext 事务
// accountDestroyRecordId 账号注销记录Id
func FastPgAccountDestroyRecord(transactionContext application.TransactionContext, accountDestroyRecordId int64) (domain.AccountDestroyRecordRepository, *domain.AccountDestroyRecord, error) {
var rep domain.AccountDestroyRecordRepository
var mod *domain.AccountDestroyRecord
var err error
if value, err := CreateAccountDestroyRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
rep = value
}
if accountDestroyRecordId > 0 {
if mod, err = rep.FindOne(map[string]interface{}{"accountDestroyRecord": accountDestroyRecordId}); err != nil {
if err == domain.ErrorNotFound {
return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "账号注销记录不存在")
}
return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
return rep, mod, err
}
// fastPgDataAuth 快速数据权限验证
//
// data 待认证的数据
// options 配置项
func fastPgDataAuth(transactionContext application.TransactionContext, data domain.AuthedData, options ...option) error {
option := NewFastOptions(options...)
if option.DataAuthRequired && data != nil {
if data.BelongOrg() != option.OperateInfo.OrgId {
return application.ThrowError(application.BUSINESS_ERROR, "当前登录的组织机构与操作数据组织机构不一致")
}
}
return nil
}
/***** 2.配置 *****/
type FastOptions struct {
DataAuthRequired bool
OperateInfo *domain.OperateInfo
}
func NewFastOptions(options ...option) *FastOptions {
o := &FastOptions{
DataAuthRequired: false,
}
for i := 0; i < len(options); i++ {
options[i](o)
}
return o
}
type option func(options *FastOptions)
// 需要数据权限
func WithDataAuthRequired() option {
return func(options *FastOptions) {
options.DataAuthRequired = true
}
}
// WithOperator 操作人
func WithOperator(op *domain.OperateInfo) option {
return func(options *FastOptions) {
options.OperateInfo = op
}
}
... ...
... ... @@ -13,3 +13,59 @@ func CreateMenuRepository(options map[string]interface{}) (domain.MenuRepository
}
return repository.NewMenuRepository(transactionContext)
}
func CreateOrgRepository(options map[string]interface{}) (domain.OrgRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewOrgRepository(transactionContext)
}
func CreateRoleRepository(options map[string]interface{}) (domain.RoleRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewRoleRepository(transactionContext)
}
func CreateUserBaseRepository(options map[string]interface{}) (domain.UserBaseRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewUserBaseRepository(transactionContext)
}
func CreateUserRepository(options map[string]interface{}) (domain.UserRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewUserRepository(transactionContext)
}
func CreateCompanyRepository(options map[string]interface{}) (domain.CompanyRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewCompanyRepository(transactionContext)
}
func CreateCustomizeMenuRepository(options map[string]interface{}) (domain.CustomizeMenuRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewCustomizeMenuRepository(transactionContext)
}
func CreateAccountDestroyRecordRepository(options map[string]interface{}) (domain.AccountDestroyRecordRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewAccountDestroyRecordRepository(transactionContext)
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchDeleteMenuCommand struct {
// 菜单ID列表
MenuIds []int64 `cname:"菜单ID列表" json:"menuIds,omitempty"`
}
func (batchDeleteMenuCommand *BatchDeleteMenuCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (batchDeleteMenuCommand *BatchDeleteMenuCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(batchDeleteMenuCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(batchDeleteMenuCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...