ソースを参照

增加根据code获取数据字典接口

huangyh 6 年 前
コミット
0fec7d0fdc

+ 13 - 0
controllers/gen/SystemController_gen.go

@@ -946,3 +946,16 @@ func (c *SystemController) UpdateOptionset(ctx *gin.Context) {
 	db := c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
 	partial.System_UpdateOptionset(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
 }
+
+// GetOptionsetByCode
+// @Title GetOptionsetByCode
+// @Description 根据编码查找字典
+// @Param	code    string  false  "字典编码"
+// @Success 200 {object} sysReturn
+// @Failure 403 :id is empty
+// @router /get_optionset_by_code  [get]
+func (c *SystemController) GetOptionsetByCode(ctx *gin.Context) {
+	//
+	db := c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
+	partial.System_GetOptionsetByCode(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
+}

+ 18 - 0
controllers/partial/SystemController.go

@@ -2272,6 +2272,24 @@ func System_FindOptionsetPage(c *entitys.CtrlContext) {
 
 }
 
+// _GetOptionsetByCode
+// @Title _GetOptionsetByCode
+// @Description 根据编码查找字典
+// @Param	code    string  false  "字典编码"
+// @Success 200 {object} Account
+// @Failure 403 :id is empty
+func System_GetOptionsetByCode(c *entitys.CtrlContext) {
+	code := c.Ctx.Query("code")
+
+	var option sysmodel.SysOptionset
+	exit, err := c.Db.Table(new(sysmodel.SysOptionset)).Where("code = ?", code).Get(&option)
+	if exit && err == nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", option})
+	} else {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
 func __none_func_system__(params ...interface{}) bool {
 	return true
 }

+ 7 - 0
light-apiengine.xml

@@ -509,6 +509,13 @@
                     <failure ref="$sys_return"></failure>
                 </return>
             </api>
+            <api name="get_optionset_by_code" desc="根据编码查找字典" method="get">
+                <param name="code" type="string" desc="字典编码"/>
+                <return>
+                    <success ref="$sys_return"></success>
+                    <failure ref="$sys_return"></failure>
+                </return>
+            </api>
         </controller>
         <controller name="api" desc="api接口">
             <api name="api_doc" method="get" desc="api文档">

+ 3 - 0
routers/system_gen.go

@@ -226,4 +226,7 @@ func registerSystemRouter(e *engine.ApiEngine) {
 	v1.GET("/update_optionset", ctrler.UpdateOptionset)
 	v1.POST("/update_optionset", ctrler.UpdateOptionset)
 
+	v1.GET("/get_optionset_by_code", ctrler.GetOptionsetByCode)
+	//v1.POST("/get_optionset_by_code",ctrler.GetOptionsetByCode)
+
 }