sys_company_app.api 4.5 KB

syntax = "v1"

info(
    title: "xx实例"
    desc: "xx实例"
    author: "author"
    email: "email"
    version: "v1"
)

@server(
    prefix: v1
    group: sys_company_app
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_company_appGet
    get /sys_company_app/:id (SysCompanyAppGetRequest) returns (SysCompanyAppGetResponse)
    @doc  "保存"
	@handler sys_company_appSave
    post /sys_company_app (SysCompanyAppSaveRequest) returns (SysCompanyAppSaveResponse)
    @doc  "删除"
	@handler sys_company_appDelete
    delete /sys_company_app/:id (SysCompanyAppDeleteRequest) returns (SysCompanyAppDeleteResponse)
    @doc  "更新"
	@handler sys_company_appUpdate
    put /sys_company_app/:id (SysCompanyAppUpdateRequest) returns (SysCompanyAppUpdateResponse)
    @doc  "搜索"
	@handler sys_company_appSearch
    post /sys_company_app/search (SysCompanyAppSearchRequest) returns (SysCompanyAppSearchResponse)
}

type (
    SysCompanyAppGetRequest {
		Id int64 `path:"id"`
	}
    SysCompanyAppGetResponse {
		SysCompanyApp SysCompanyAppItem `json:"sys_company_app"`
    }

	SysCompanyAppSaveRequest {
		SysCompanyApp SysCompanyAppItem `json:"sys_company_app"`
    }
    SysCompanyAppSaveResponse {}

	SysCompanyAppDeleteRequest {
        Id int64 `path:"id"`
    }
    SysCompanyAppDeleteResponse {}

	SysCompanyAppUpdateRequest {
		Id int64 `path:"id"`
        SysCompanyApp SysCompanyAppItem `json:"sys_company_app"`
    }
    SysCompanyAppUpdateResponse {}

 	SysCompanyAppSearchRequest {
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysCompanyAppSearchResponse{
        List []SysCompanyAppItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysCompanyAppItem {
	
	}
)

// logic CRUD
// Save
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysCompanyApp
	//)
	//// 唯一判断

	//dm = NewDomainSysCompanyApp(req.SysCompanyApp)
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	dm, err = l.svcCtx.SysCompanyAppRepository.Insert(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("保存失败")
	//}
	////resp = &types.SysCompanyAppSaveResponse{}
	//return

//func NewDomainSysCompanyApp(item types.SysCompanyAppItem) *domain.SysCompanyApp {
//	return &domain.SysCompanyApp{

//	}
//}
//
//func NewTypesSysCompanyApp(item *domain.SysCompanyApp) types.SysCompanyAppItem {
//	return types.SysCompanyAppItem{
//		Id:     item.Id,
//	}
//}

// Get
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysCompanyApp
	//)
	//// 货号唯一
	//if dm, err = l.svcCtx.SysCompanyAppRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//resp = &types.SysCompanyAppGetResponse{
	//	SysCompanyApp: NewTypesSysCompanyApp(dm),
	//}
	//return

// Delete
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysCompanyApp
	//)
	//if dm, err = l.svcCtx.SysCompanyAppRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	if dm, err = l.svcCtx.SysCompanyAppRepository.Delete(l.ctx, conn, dm); err != nil {
	//		return err
	//	}
	//	return nil
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsgErr("移除失败", err)
	//}
	//return

// Search
	//var (
	//	conn  = l.svcCtx.DefaultDBConn()
	//	dms   []*domain.SysCompanyApp
	//	total int64
	//)
	//
	//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
	//	WithKV("", "")

	//total, dms, err = l.svcCtx.SysCompanyAppRepository.Find(l.ctx, conn, queryOptions)
	//list := make([]types.SysCompanyAppItem, 0)
	//for i := range dms {
	//	list = append(list, NewTypesSysCompanyApp(dms[i]))
	//}
	//resp = &types.SysCompanyAppSearchResponse{
	//	List:  list,
	//	Total: total,
	//}
	//return

// Update
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysCompanyApp
	//)
	//if dm, err = l.svcCtx.SysCompanyAppRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//// 不可编辑判断
	
	//// 赋值

	//// 更新
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	dm, err = l.svcCtx.SysCompanyAppRepository.UpdateWithVersion(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("更新失败")
	//}
	//resp = &types.SysCompanyAppUpdateResponse{}
	//return