/** * @Title: * @Description: * @Author: Yuki Wong(iyuki0430@msn.com) * @Update: * @Date: 2020/7/9 10:39 * @File: Jyt2012OpenAPI.go * @Software: GoLand **/ package Jyt2012OpenAPI import ( "dsSupport/MyModel/JYT2012/Jyt2012Service" "dsSupport/MyModel/MySwagger" "dsSupport/models" "fmt" "github.com/gin-gonic/gin" "net/http" ) // 获取标准字典列表 godoc // @Summary 获取标准字典列表 // @Description json:"dic_name" xorm:"not null comment('字典/字典项名称') VARCHAR(100)" example:"sex" // @Description json:"dic_value" xorm:"not null comment('字典/字典项值') VARCHAR(100)" example:"10" // @Description json:"dic_type" xorm:"not null default 1 comment('字典类型【1:国标数据、关联数据源,2:国标字典、关联元数据】') INT(11)" example:"1" // @Description json:"dic_info" xorm:"default ''NULL'' comment('字典项说明') VARCHAR(500)" example:"我是字典项说明" // @Description json:"root_flag" xorm:"not null default -1 comment('是否是字典【1:是,-1:否】') INT(11)" example:"1" // @Description json:"jyt_flag" xorm:"not null default 1 comment('是否国标【1:是,-1:自定义】') INT(11)" example:"1" // @Description json:"parent_id" xorm:"default ''NULL'' comment('字典ID【字典项父节点】') VARCHAR(36)" example:"38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_flag" xorm:"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)" example:"1" // @Description json:"enable_flag" xorm:"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)" example:"1" // @Description json:"page" example:"1" // @Tags jyt2012 // @ID readJyt2012 // @Accept json // @Produce json // @Param input body MySwagger.Jyt2012Swag true "标准字典" // @Success 200 {object} MySwagger.Result // @Failure 400 {object} MySwagger.Result // @Router /v1/openapi/jyt2012/ReadJyt2012 [post] func ReadJyt2012(c *gin.Context) { var raw MySwagger.Jyt2012Swag //input.AuthToken = c.Request.Header["Authorization"][0] //queryString := c.Request.URL.Query().Encode() if err := c.ShouldBindJSON(&raw); err != nil { c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"}) fmt.Println(err) return } success, message, count, data, _ := Jyt2012Service.GetJyt2012Results(raw) if success { c.JSON(http.StatusOK, MySwagger.Result{ Success: true, Fail: false, Message: message, Total: count, Data: data, }) return } else { c.JSON(http.StatusOK, MySwagger.Result{ Success: false, Fail: true, Message: message, }) return } return } // 创建标准字典 godoc // @Summary 创建标准字典 // @Description `*`json:"dic_name" xorm:"not null comment('字典/字典项名称') VARCHAR(100)" example:"sex" // @Description `*`json:"dic_value" xorm:"not null comment('字典/字典项值') VARCHAR(100)" example:"10" // @Description `*`json:"dic_type" xorm:"not null default 1 comment('字典类型【1:国标数据、关联数据源,2:国标字典、关联元数据】') INT(11)" example:"1" // @Description `*`json:"dic_info" xorm:"default ''NULL'' comment('字典项说明') VARCHAR(500)" example:"我是字典项说明" // @Description json:"root_flag" xorm:"not null default -1 comment('是否是字典【1:是,-1:否】') INT(11)" example:"1" // @Description json:"jyt_flag" xorm:"not null default 1 comment('是否国标【1:是,-1:自定义】') INT(11)" example:"1" // @Description `*`json:"parent_id" xorm:"default ''NULL'' comment('字典ID【字典项父节点】') VARCHAR(36)" example:"38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_flag" xorm:"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)" example:"1" // @Description json:"enable_flag" xorm:"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)" example:"1" // @Tags jyt2012 // @ID createJyt2012 // @Accept json // @Produce json // @Param input body MySwagger.Jyt2012Swag true "标准字典" // @Success 200 {object} MySwagger.Result // @Failure 400 {object} MySwagger.Result // @Router /v1/openapi/jyt2012/CreateJyt2012 [post] func CreateJyt2012(c *gin.Context) { var raw models.TDataexJyt2012 if err := c.ShouldBindJSON(&raw); err != nil { c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"}) fmt.Println(err) return } success, message, _ := Jyt2012Service.CreateJyt2012(raw) if success { c.JSON(http.StatusOK, MySwagger.ResultOne{ Success: true, Fail: false, Message: message, }) return } else { c.JSON(http.StatusOK, MySwagger.ResultOne{ Success: false, Fail: true, Message: message, }) return } return } // 修改标准字典 godoc // @Summary 修改标准字典 // @Description json:"dic_name" xorm:"not null comment('字典/字典项名称') VARCHAR(100)" example:"sex" // @Description json:"dic_value" xorm:"not null comment('字典/字典项值') VARCHAR(100)" example:"10" // @Description json:"dic_type" xorm:"not null default 1 comment('字典类型【1:国标数据、关联数据源,2:国标字典、关联元数据】') INT(11)" example:"1" // @Description json:"dic_info" xorm:"default ''NULL'' comment('字典项说明') VARCHAR(500)" example:"我是字典项说明" // @Description json:"root_flag" xorm:"not null default -1 comment('是否是字典【1:是,-1:否】') INT(11)" example:"1" // @Description json:"jyt_flag" xorm:"not null default 1 comment('是否国标【1:是,-1:自定义】') INT(11)" example:"1" // @Description json:"parent_id" xorm:"default ''NULL'' comment('字典ID【字典项父节点】') VARCHAR(36)" example:"38BD0DB-0142-4356-8F2B-623813FC2578" // @Description json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME" example:"2020-06-22 17:26:53" // @Description json:"delete_flag" xorm:"not null default -1 comment('删除标志【默认-1,1:删除,-1:正常】') INT(11)" example:"1" // @Description json:"enable_flag" xorm:"not null default 1 comment('启用标志【默认1,1:启用,-1:禁用】') INT(11)" example:"1" // @Tags jyt2012 // @ID updateJyt2012 // @Accept json // @Produce json // @Param id path string true "标准字典ID" // @Param input body MySwagger.Jyt2012Swag true "标准字典" // @Success 200 {object} MySwagger.Result // @Failure 400 {object} MySwagger.Result // @Router /v1/openapi/jyt2012/UpdateJyt2012/{id} [post] func UpdateJyt2012(c *gin.Context) { var raw models.TDataexJyt2012 ID := c.Param("id") if err := c.ShouldBindJSON(&raw); err != nil { c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Fail: true, Message: "接入系统数据JSON格式错误"}) return } success, message, _ := Jyt2012Service.UpdateJyt2012(ID, raw) if success { c.JSON(http.StatusOK, MySwagger.ResultOne{ Success: true, Fail: false, Message: message, }) return } else { c.JSON(http.StatusOK, MySwagger.ResultOne{ Success: false, Fail: true, Message: message, }) return } return } // 删除标准字典 godoc // @Summary 删除标准字典 // @Description `*`json:"id" xorm:"not null pk comment('ID') VARCHAR(36)" // @Tags jyt2012 // @ID deleteJyt2012 // @Accept json // @Produce json // @Param id path string true "标准字典ID" // @Success 200 {object} MySwagger.Result // @Failure 400 {object} MySwagger.Result // @Router /v1/openapi/jyt2012/DeleteJyt2012/{id} [post] func DeleteJyt2012(c *gin.Context) { ID := c.Param("id") success, message, _ := Jyt2012Service.RemoveJyt2012(ID) if success { c.JSON(http.StatusOK, MySwagger.ResultOne{ Success: true, Fail: false, Message: message, }) return } else { c.JSON(http.StatusOK, MySwagger.ResultOne{ Success: false, Fail: true, Message: message, }) return } return }