sys_app.api 4.1 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_app
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_appGet
    get /sys_app/:id (SysAppGetRequest) returns (SysAppGetResponse)
    @doc  "保存"
	@handler sys_appSave
    post /sys_app (SysAppSaveRequest) returns (SysAppSaveResponse)
    @doc  "删除"
	@handler sys_appDelete
    delete /sys_app/:id (SysAppDeleteRequest) returns (SysAppDeleteResponse)
    @doc  "更新"
	@handler sys_appUpdate
    put /sys_app/:id (SysAppUpdateRequest) returns (SysAppUpdateResponse)
    @doc  "搜索"
	@handler sys_appSearch
    post /sys_app/search (SysAppSearchRequest) returns (SysAppSearchResponse)
}

type (
    SysAppGetRequest {
		Id int64 `path:"id"`
	}
    SysAppGetResponse struct{
		SysApp SysAppItem `json:"sys_app"`
    }

	SysAppSaveRequest struct{
		SysApp SysAppItem `json:"sys_app"`
    }
    SysAppSaveResponse struct{}

	SysAppDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysAppDeleteResponse struct{}

	SysAppUpdateRequest struct{
		Id int64 `path:"id"`
        SysApp SysAppItem `json:"sys_app"`
    }
    SysAppUpdateResponse struct{}

 	SysAppSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysAppSearchResponse{
        List []SysAppItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysAppItem struct{
	
	}
)

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

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

//func NewDomainSysApp(item types.SysAppItem) *domain.SysApp {
//	return &domain.SysApp{

//	}
//}
//
//func NewTypesSysApp(item *domain.SysApp) types.SysAppItem {
//	return types.SysAppItem{
//		Id:     item.Id,
//	}
//}

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

// Delete
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysApp
	//)
	//if dm, err = l.svcCtx.SysAppRepository.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.SysAppRepository.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.SysApp
	//	total int64
	//)
	//
	//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
	//	WithKV("", "")

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

// Update
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysApp
	//)
	//if dm, err = l.svcCtx.SysAppRepository.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.SysAppRepository.UpdateWithVersion(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("更新失败")
	//}
	//resp = &types.SysAppUpdateResponse{}
	//return