🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

courier_curd

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

courier_curd - npm Package Compare versions

Comparing version
1.0.1
to
1.0.2
+98
test/create_apply.go
package apply
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/constants/types"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"g7fintech/service-etrip-approval/services"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx"
"github.com/sirupsen/logrus"
)
func init() {
ApplyRouter.Register(courier.NewRouter(CreateApply{}))
}
//创建申请单
type CreateApply struct {
httpx.MethodPost
Body CreateApplyBody `json:"body" in:"body"`
}
type CreateApplyBody struct {
//实体ID
CustomerID uint64 `json:"customerID,string" validate:"@uint64[1,]"`
//产品ID
ProductID uint64 `json:"productID,string" validate:"@uint64[1,]"`
//资方ID
ChannelID uint64 `json:"channelID,string" validate:"@uint64[1,]"`
//人工额度
Amount int64 `json:"amount,string" validate:"@int64[1,]"`
//还款方式
RepayType string `json:"repayType" validate:"@string[1,32]"`
//申请状态
ApplyStatus types.ApplyStatus `json:"applyStatus" validate:""`
//申请单上一次状态
LastStatus types.ApplyStatus `json:"lastStatus" validate:""`
//caseID
CaseID uint64 `json:"caseID,string" validate:"@uint64[1,]"`
//贷款期限单位
DueTimeUnit types.DueTimeUnit `json:"dueTimeUnit" validate:""`
//贷款期限
DueTime int `json:"dueTime" validate:""`
//操作人ID
OperatorID string `json:"operatorID" validate:"@string[1,255]"`
//操作人
Operator string `json:"operator" validate:"@string[1,32]"`
}
func (req CreateApply) Path() string {
return ""
}
func (req CreateApply) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("CreateApply-req:%#v", req)
defer func() {
logrus.Infof("CreateApply-resp:%#v", resp)
}()
id, err := services.GetUniqueID()
if err != nil {
return
}
apply := &database.Apply{
ApplyID: id,
ProductID: req.Body.ProductID,
ChannelID: req.Body.ChannelID,
Amount: req.Body.Amount,
RepayType: req.Body.RepayType,
ApplyStatus: req.Body.ApplyStatus,
LastStatus: req.Body.LastStatus,
CaseID: req.Body.CaseID,
DueTimeUnit: req.Body.DueTimeUnit,
DueTime: req.Body.DueTime,
OperatorID: req.Body.OperatorID,
Operator: req.Body.Operator,
}
db := global.Config.MasterDB.Get()
err = apply.Create(db)
if err != nil {
logrus.Warningf("Apply-Create err:%s", err.Error())
if err == sqlx.ErrConflict {
err = errors.CreateApplyConflict.StatusError()
return
}
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
resp = apply
return
}
package apply
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/constants/types"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx/builder"
"github.com/sirupsen/logrus"
)
func init() {
ApplyRouter.Register(courier.NewRouter(GetApplyList{}))
}
//获取申请单列表
type GetApplyList struct {
httpx.MethodGet
GetApplyListReq
}
type GetApplyListReq struct {
//申请单ID
ApplyID uint64 `in:"query" json:"applyID,string" default:""`
//实体ID
CustomerID uint64 `in:"query" json:"customerID,string" default:""`
//资方ID
ChannelID uint64 `in:"query" json:"channelID,string" default:""`
//申请状态
ApplyStatus types.ApplyStatus `in:"query" json:"applyStatus" default:""`
// 每页数据大小
Size int32 `json:"size" in:"query" default:"10" validate:"@int32[-1,100]"`
// 偏移量
Offset int32 `json:"offset" in:"query" default:"0" validate:"@int32[0,]"`
}
type GetApplyListResp struct {
//偏移量
Offset int32 `json:"offset"`
//每页数量
Size int32 `json:"size"`
//总数
Total int32 `json:"total"`
//数据
Data database.ApplyList `json:"data"`
}
func (req GetApplyList) Path() string {
return ""
}
func (req GetApplyList) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("GetApplyList-req:%#v", req)
defer func() {
logrus.Infof("GetApplyList-resp:%#v", resp)
}()
db := global.Config.MasterDB.Get()
applyList := database.Apply{}
table := applyList.T()
var queryFilter *builder.Condition
if req.ApplyID > 0 {
queryFilter = builder.And(queryFilter, table.F("ApplyID").Eq(req.ApplyID))
}
if req.CustomerID > 0 {
queryFilter = builder.And(queryFilter, table.F("CustomerID").Eq(req.CustomerID))
}
if req.ChannelID > 0 {
queryFilter = builder.And(queryFilter, table.F("ChannelID").Eq(req.ChannelID))
}
if req.ApplyStatus > 0 {
queryFilter = builder.And(queryFilter, table.F("ApplyStatus").Eq(req.ApplyStatus))
}
getApplyList, count, err := applyList.FetchList(db, req.Size, req.Offset, queryFilter)
if err != nil {
logrus.Warningf("ApplyList.FetchList-err:%s", err.Error())
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
if len(getApplyList) == 0 {
getApplyList = make([]database.Apply, 0)
}
resp = GetApplyListResp{
Offset: req.Offset,
Size: req.Size,
Total: count,
Data: getApplyList,
}
return
}
package apply
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx"
"github.com/sirupsen/logrus"
)
func init() {
ApplyRouter.Register(courier.NewRouter(GetApply{}))
}
//获取申请单
type GetApply struct {
httpx.MethodGet
ApplyID uint64 `json:"applyID,string" in:"path" validate:"@uint64[1,]" `
}
func (req GetApply) Path() string {
return "/:applyID"
}
func (req GetApply) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("GetApply-req:%#v", req)
defer func() {
logrus.Infof("GetApply-resp:%#v", resp)
}()
apply := &database.Apply{
ApplyID: req.ApplyID,
}
db := global.Config.MasterDB.Get()
err = apply.FetchByApplyID(db)
if err != nil {
logrus.Warningf("Apply.FetchByApplyID-err:%s", err.Error())
if sqlx.DBErr(err).IsNotFound() {
err = errors.ApplyNotFoundError
return
}
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
resp = apply
return
}
package apply
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/constants/types"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx"
"github.com/sirupsen/logrus"
)
func init() {
ApplyRouter.Register(courier.NewRouter(UpdateApply{}))
}
//更新申请单
type UpdateApply struct {
httpx.MethodPut
ApplyID uint64 `json:"applyID,string" in:"path" validate:"@uint64[1,]" `
Body UpdateApplyBody `json:"body" in:"body"`
}
type UpdateApplyBody struct {
//实体ID
CustomerID uint64 `json:"customerID,string" validate:"@uint64[0,]"`
//产品ID
ProductID uint64 `json:"productID,string" validate:"@uint64[0,]"`
//资方ID
ChannelID uint64 `json:"channelID,string" validate:"@uint64[0,]"`
//人工额度
Amount int64 `json:"amount,string" validate:"@int64[0,]"`
//还款方式
RepayType string `json:"repayType" validate:"@string[0,32]"`
//申请状态
ApplyStatus types.ApplyStatus `json:"applyStatus" validate:""`
//申请单上一次状态
LastStatus types.ApplyStatus `json:"lastStatus" validate:""`
//caseID
CaseID uint64 `json:"caseID,string" validate:"@uint64[0,]"`
//贷款期限单位
DueTimeUnit types.DueTimeUnit `json:"dueTimeUnit" validate:""`
//贷款期限
DueTime int `json:"dueTime" validate:""`
//操作人ID
OperatorID string `json:"operatorID" validate:"@string[0,255]"`
//操作人
Operator string `json:"operator" validate:"@string[0,32]"`
}
func (req UpdateApply) Path() string {
return "/:applyID"
}
func (req UpdateApply) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("UpdateApply-req:%#v", req)
defer func() {
logrus.Infof("UpdateApply-resp:%#v", resp)
}()
apply := &database.Apply{
ApplyID: req.ApplyID,
CustomerID: req.Body.CustomerID,
ProductID: req.Body.ProductID,
ChannelID: req.Body.ChannelID,
Amount: req.Body.Amount,
RepayType: req.Body.RepayType,
ApplyStatus: req.Body.ApplyStatus,
LastStatus: req.Body.LastStatus,
CaseID: req.Body.CaseID,
DueTimeUnit: req.Body.DueTimeUnit,
DueTime: req.Body.DueTime,
OperatorID: req.Body.OperatorID,
Operator: req.Body.Operator,
}
db := global.Config.MasterDB.Get()
err = apply.UpdateByIDWithStruct(db)
if err != nil {
logrus.Warningf("Apply-UpdateByIDWithStruct err:%s", err.Error())
if err == sqlx.ErrConflict {
err = errors.UpdateApplyConflict.StatusError()
return
}
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
resp = apply
return
}
+1
-1
{
"name": "courier_curd",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,3 +21,6 @@ 'use strict';

this.fields = this.model.fields();
if(this.fields.length){
this.nameCN = this.fields[0].desc.replace('ID', '');
}
this.renderRoot();

@@ -32,2 +35,3 @@ this.renderCreate();

let ctx = fs.readFileSync(__dirname + '/../tpl/root.tpl').toString();
ctx = ctx.replace(/#nameCN#/g, this.nameCN);
ctx = ctx.replace(/#raw_id#/g, this.rawID);

@@ -41,2 +45,3 @@ ctx = ctx.replace(/#id#/g, this.id);

let ctx = fs.readFileSync(__dirname + '/../tpl/create.tpl').toString();
ctx = ctx.replace(/#nameCN#/g, this.nameCN);
ctx = ctx.replace(/#raw_id#/g, this.rawID);

@@ -52,4 +57,7 @@ ctx = ctx.replace(/#id#/g, this.id);

for (let k in this.fields) {
if(this.fields[k].name === `${this.ID}ID`){
continue;
}
fields.push(`//${this.fields[k].desc}`);
fields.push(`${this.fields[k].name} ${this.fields[k].type} \`json:"${this.fields[k].json}" validate:"${this.fields[k].validate}"\``);
fields.push(`${this.fields[k].name} ${this.fields[k].type} \`json:"${this.fields[k].json}" validate:"${this.fields[k].validate[1]}"\``);
if (first) {

@@ -71,2 +79,3 @@ first = false;

let ctx = fs.readFileSync(__dirname + '/../tpl/update.tpl').toString();
ctx = ctx.replace(/#nameCN#/g, this.nameCN);
ctx = ctx.replace(/#raw_id#/g, this.rawID);

@@ -79,9 +88,14 @@ ctx = ctx.replace(/#id#/g, this.id);

let fields = [];
let setFields = [];
for (let k in this.fields) {
if(this.fields[k].name === `${this.ID}ID`){
continue;
}
fields.push(`//${this.fields[k].desc}`);
fields.push(`${this.fields[k].name} ${this.fields[k].type} \`json:"${this.fields[k].json}" validate:"${this.fields[k].validate}"\``);
fields.push(`${this.fields[k].name} ${this.fields[k].type} \`json:"${this.fields[k].json}" validate:"${this.fields[k].validate[0]}"\``);
setFields.push(`${this.fields[k].name}: req.Body.${this.fields[k].name},`);
}
ctx = ctx.replace(/#fields#/g, fields.join(EOL));
ctx = ctx.replace(/#setFields#/g, setFields.join(EOL));
}

@@ -94,2 +108,3 @@

let ctx = fs.readFileSync(__dirname + '/../tpl/get.tpl').toString();
ctx = ctx.replace(/#nameCN#/g, this.nameCN);
ctx = ctx.replace(/#raw_id#/g, this.rawID);

@@ -104,2 +119,3 @@ ctx = ctx.replace(/#id#/g, this.id);

let ctx = fs.readFileSync(__dirname + '/../tpl/get_list.tpl').toString();
ctx = ctx.replace(/#nameCN#/g, this.nameCN);
ctx = ctx.replace(/#raw_id#/g, this.rawID);

@@ -109,2 +125,3 @@ ctx = ctx.replace(/#id#/g, this.id);

ctx = ctx.replace(/#project#/g, this.project);
let indexes = this.model.indexes;
if (this.fields.length) {

@@ -114,2 +131,6 @@ let fields = [];

for (let k in this.fields) {
if(indexes[this.fields[k].name] === undefined){
//没有索引的字段不做搜索条件
continue;
}
fields.push(`//${this.fields[k].desc}`);

@@ -116,0 +137,0 @@ fields.push(`${this.fields[k].name} ${this.fields[k].type} \`in:"query" json:"${this.fields[k].json}" default:""\``);

@@ -10,4 +10,33 @@ 'use strict';

getIndexes(matched){
if(!matched || matched.length<1){
return {};
}
matched.shift();
let indexes = {};
for(let k in matched){
let pieces = matched[k].split(/\s|\n/);
pieces.shift();
pieces.pop();
let [type,name,fields] = [pieces.shift(),pieces.shift(), pieces];
fields.forEach((item)=>{
indexes[item] = indexes[item] || [];
indexes[item].push({
name,
type,
});
});
}
return indexes;
}
fields() {
let ctx = fs.readFileSync(this.modelFilePath).toString();
this.indexes = this.getIndexes(ctx.match(/@def(.*?)\n/g));
let matches = ctx.match(/\/\/(.*?)\s(.*?)\s`(.*?)`/g);

@@ -44,3 +73,3 @@

json,
validate:this.defaultValidate(arr[4]),
validate:this.defaultValidate(arr),
};

@@ -54,19 +83,22 @@ }

defaultValidate(type) {
switch (type) {
switch (type[4]) {
case 'uint64':
return '@uint64[1,]';
return ['@uint64[0,]','@uint64[1,]'];
case 'int64':
return '@int64[1,]';
return ['@int64[0,]','@int64[1,]'];
case 'int32':
return '@int32[0,]';
return ['@int32[0,]','@int32[1,]'];
case 'uint32':
return '@uint32[0,]';
return ['@uint32[0,]','@uint32[1,]'];
case 'string':
return '@string[1,]';
let sql = type[6];
let length = sql.match(/\d+/g)
return [`@string[0,${length}]`,`@string[1,${length}]`];
case 'httplib.Uint64List':
return '@array[0,1000]:@uint64[1,]';
return ['@array[0,1000]:@uint64[1,]','@array[0,1000]:@uint64[1,]'];
default:
return '';
return ['',''];
}
}
};

@@ -1,2 +0,2 @@

package company_entity
package apply

@@ -7,10 +7,10 @@ import (

var CompanyEntityRouter = courier.NewRouter(GroupCompanyEntity{})
var ApplyRouter = courier.NewRouter(GroupApply{})
type GroupCompanyEntity struct {
type GroupApply struct {
courier.EmptyOperator
}
func (root GroupCompanyEntity) Path() string {
return "/companyEntity"
func (root GroupApply) Path() string {
return "/apply"
}
package company_entity
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/constants/types"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"g7fintech/service-etrip-approval/services"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx"
"github.com/sirupsen/logrus"
)
func init() {
CompanyEntityRouter.Register(courier.NewRouter(CreateCompanyEntity{}))
}
//创建XXX
type CreateCompanyEntity struct {
httpx.MethodPost
Body CreateCompanyEntityBody `json:"body" in:"body"`
}
type CreateCompanyEntityBody struct {
//企业ID
CompanyEntityID uint64 `json:"companyEntityID,string" validate:"@uint64[1,]"`
//实体ID
EntityID uint64 `json:"entityID,string" validate:"@uint64[1,]"`
//法人ID
LegalID uint64 `json:"legalID,string" validate:"@uint64[1,]"`
//企业名称
CompanyName string `json:"companyName" validate:"@string[1,]"`
//证件类型
CertificateType types.CertificateType `json:"certificateType" validate:""`
//证件号
CertificateNo string `json:"certificateNo" validate:"@string[1,]"`
}
func (req CreateCompanyEntity) Path() string {
return ""
}
func (req CreateCompanyEntity) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("CreateCompanyEntity-req:%#v", req)
defer func() {
logrus.Infof("CreateCompanyEntity-resp:%#v", resp)
}()
id, err := services.GetUniqueID()
if err != nil {
return
}
companyEntity := &database.CompanyEntity{
CompanyEntityID: id,
EntityID: req.Body.EntityID,
LegalID: req.Body.LegalID,
CompanyName: req.Body.CompanyName,
CertificateType: req.Body.CertificateType,
CertificateNo: req.Body.CertificateNo,
}
db := global.Config.MasterDB.Get()
err = companyEntity.Create(db)
if err != nil {
logrus.Warningf("CompanyEntity-Create err:%s", err.Error())
if err == sqlx.ErrConflict {
err = errors.CreateCompanyEntityConflict.StatusError()
return
}
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
return *companyEntity, err
}
package company_entity
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/constants/types"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx/builder"
"github.com/sirupsen/logrus"
)
func init() {
CompanyEntityRouter.Register(courier.NewRouter(GetCompanyEntityList{}))
}
//获取XXX列表
type GetCompanyEntityList struct {
httpx.MethodGet
GetCompanyEntityListReq
}
type GetCompanyEntityListReq struct {
//企业ID
CompanyEntityID uint64 `in:"query" json:"companyEntityID,string" default:""`
//实体ID
EntityID uint64 `in:"query" json:"entityID,string" default:""`
//法人ID
LegalID uint64 `in:"query" json:"legalID,string" default:""`
//企业名称
CompanyName string `in:"query" json:"companyName" default:""`
//证件类型
CertificateType types.CertificateType `in:"query" json:"certificateType" default:""`
//证件号
CertificateNo string `in:"query" json:"certificateNo" default:""`
// 每页数据大小
Size int32 `json:"size" in:"query" default:"10" validate:"@int32[-1,100]"`
// 偏移量
Offset int32 `json:"offset" in:"query" default:"0" validate:"@int32[0,]"`
}
type GetCompanyEntityListResp struct {
//偏移量
Offset int32 `json:"offset"`
//每页数量
Size int32 `json:"size"`
//总数
Total int32 `json:"total"`
//数据
Data database.CompanyEntityList `json:"data"`
}
func (req GetCompanyEntityList) Path() string {
return ""
}
func (req GetCompanyEntityList) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("GetCompanyEntityList-req:%#v", req)
defer func() {
logrus.Infof("GetCompanyEntityList-resp:%#v", resp)
}()
db := global.Config.MasterDB.Get()
companyEntityList := database.CompanyEntity{}
table := companyEntityList.T()
var queryFilter *builder.Condition
if req.CompanyEntityID >0 {
queryFilter = builder.And(queryFilter, table.F("CompanyEntityID").Eq(req.CompanyEntityID))
}
if req.EntityID >0 {
queryFilter = builder.And(queryFilter, table.F("EntityID").Eq(req.EntityID))
}
if req.LegalID >0 {
queryFilter = builder.And(queryFilter, table.F("LegalID").Eq(req.LegalID))
}
if req.CompanyName !="" {
queryFilter = builder.And(queryFilter, table.F("CompanyName").Eq(req.CompanyName))
}
if req.CertificateType >0 {
queryFilter = builder.And(queryFilter, table.F("CertificateType").Eq(req.CertificateType))
}
if req.CertificateNo !="" {
queryFilter = builder.And(queryFilter, table.F("CertificateNo").Eq(req.CertificateNo))
}
getCompanyEntityList, count, err := companyEntityList.FetchList(db, req.Size, req.Offset, queryFilter)
if err != nil {
logrus.Warningf("CompanyEntityList.FetchList-err:%s", err.Error())
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
if len(getCompanyEntityList) == 0 {
getCompanyEntityList = make([]database.CompanyEntity, 0)
}
resp = GetCompanyEntityListResp{
Offset: req.Offset,
Size: req.Size,
Total: count,
Data: getCompanyEntityList,
}
return
}
package company_entity
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx"
"github.com/sirupsen/logrus"
)
func init() {
CompanyEntityRouter.Register(courier.NewRouter(GetCompanyEntity{}))
}
//获取XXX
type GetCompanyEntity struct {
httpx.MethodGet
CompanyEntityID uint64 `json:"companyEntityID,string" validate:"@uint64[1,]" `
}
func (req GetCompanyEntity) Path() string {
return "/:companyEntityID"
}
func (req GetCompanyEntity) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("GetCompanyEntity-req:%#v", req)
defer func() {
logrus.Infof("GetCompanyEntity-resp:%#v", resp)
}()
companyEntity := &database.CompanyEntity{
CompanyEntityID: req.CompanyEntityID,
}
db := global.Config.MasterDB.Get()
err = companyEntity.FetchByCompanyEntityID(db)
if err != nil {
logrus.Warningf("CompanyEntity.FetchByCompanyEntityID-err:%s", err.Error())
if sqlx.DBErr(err).IsNotFound() {
err = errors.CreditBillNotFoundError
return
}
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
return
}
package company_entity
import (
"context"
"g7fintech/service-etrip-approval/constants/errors"
"g7fintech/service-etrip-approval/constants/types"
"g7fintech/service-etrip-approval/database"
"g7fintech/service-etrip-approval/global"
"g7fintech/service-etrip-approval/services"
"golib/tools/courier"
"golib/tools/courier/httpx"
"golib/tools/sqlx"
"github.com/sirupsen/logrus"
)
func init() {
CompanyEntityRouter.Register(courier.NewRouter(UpdateCompanyEntity{}))
}
//更新XXX
type UpdateCompanyEntity struct {
httpx.MethodPut
CompanyEntityID uint64 `json:"companyEntityID,string" validate:"@uint64[1,]" `
Body UpdateCompanyEntityBody `json:"body" in:"body"`
}
type UpdateCompanyEntityBody struct {
//企业ID
CompanyEntityID uint64 `json:"companyEntityID,string" validate:"@uint64[1,]"`
//实体ID
EntityID uint64 `json:"entityID,string" validate:"@uint64[1,]"`
//法人ID
LegalID uint64 `json:"legalID,string" validate:"@uint64[1,]"`
//企业名称
CompanyName string `json:"companyName" validate:"@string[1,]"`
//证件类型
CertificateType types.CertificateType `json:"certificateType" validate:""`
//证件号
CertificateNo string `json:"certificateNo" validate:"@string[1,]"`
}
func (req UpdateCompanyEntity) Path() string {
return "/:companyEntityID"
}
func (req UpdateCompanyEntity) Output(ctx context.Context) (resp interface{}, err error) {
logrus.Infof("UpdateCompanyEntity-req:%#v", req)
defer func() {
logrus.Infof("UpdateCompanyEntity-resp:%#v", resp)
}()
companyEntity := &database.CompanyEntity{
CompanyEntityID: req.CompanyEntityID,
}
db := global.Config.MasterDB.Get()
err = companyEntity.UpdateByIDWithStruct(db)
if err != nil {
logrus.Warningf("CompanyEntity-UpdateByIDWithStruct err:%s", err.Error())
if err == sqlx.ErrConflict {
err = errors.UpdateCompanyEntityConflict.StatusError()
return
}
err = errors.InternalError.StatusError().WithDesc(err.Error())
return
}
return *companyEntity, err
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet