使用管理员进入侧菜单-【系统接口管理】界面,新建或修改接口
得到的restful路径为:https://ip:port/imedical/rest/open/接口代码
如:
https://ip:port/imedical/rest/open/getMenu路径,body-json方式可以访问
当访问第2点的restful时,会进入M中维护好的对外接口中的类方法,入参为restful的JsonBody数据
示例一:
ClassMethod GetMenu(JsonBody = "")
{
// JsonBody内容: {"Request":{"Data":{["roleCode": "住院医师"]}}}
// 且会解析JSON字符串得到进程Global以便使用
// ^||BodyJson("Request","Data",0,"roleCode")="住院医师"
}
示例二:
ClassMethod GrantMenu(BodyJson = "")
{
Set RetObj =##class(BSP.SYS.DTO.HosBase).%New() // 与HOS对接时返回值JSON对象基础类
Set GroupCode = ^||BodyJson("Request","Data",0,"roleCode")
Set GroupId = ##class(web.SSGroup).GetIdFromCodeOrDescription(GroupCode)
If GroupId'>0 Set RetObj.msg="not find group",RetObj.code=400 Quit RetObj
//赋权菜单
Set Ind="" for {
Set Ind = $o(^||BodyJson("Request","Data",0,"perms",Ind))
Quit:Ind=""
Set PermMenuGrant = ^||BodyJson("Request","Data",0,"perms",Ind)
//省略代码...
}
//保存
set sc=objEprGroupSetting.%Save()
if $$$ISERR(sc) {
Set RetObj.msg=$system.Status.GetErrorCodes(sc),RetObj.code=400
Quit RetObj
}
Quit RetObj //平台会转成JSON字符串
}
访问量: 510609