{
  "Controller查询": {
    "prefix": [
      "csearch"
    ],
    "body": [
      "// @Summary     查询",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Search   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/search [post]",
      "func (*${1:结构}Controller) Search(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Search",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Search(&req)",
      " httpx.ReturnGin(c, \"查询\", &reply, &start)",
      "}"
    ],
    "description": "查询"
  },
  "Controller增加": {
    "prefix": [
      "ccreate"
    ],
    "body": [
      "// @Summary     增加",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Create   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/create [post]",
      "func (*${1:结构}Controller) Create(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Create",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Create(&req)",
      " httpx.ReturnGin(c, \"增加\", &reply, &start)",
      "}"
    ],
    "description": "增加"
  },
  "Controller更新": {
    "prefix": [
      "cupdate"
    ],
    "body": [
      "// @Summary     更新",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Update   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/update [put]",
      "func (*${1:结构}Controller) Update(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Update",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Update(&req)",
      " httpx.ReturnGin(c, \"更新\", &reply, &start)",
      "}"
    ],
    "description": "更新"
  },
  "Controller删除": {
    "prefix": [
      "cdelete"
    ],
    "body": [
      "// @Summary     删除",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Delete   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/delete [delete]",
      "func (*${1:结构}Controller) Delete(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Delete",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Delete(&req)",
      " httpx.ReturnGin(c, \"删除\", &reply, &start)",
      "}"
    ],
    "description": "删除"
  },
  "ControllerCURD": {
    "prefix": [
      "ccurd"
    ],
    "body": [
      "package controller",
      "",
      "import (",
      " \"encoding/json\"",
      " \"io\"",
      "",
      " \"${4:项目名}/internal/handler\"",
      "",
      " \"github.com/gin-gonic/gin\"",
      " \"github.com/qida/gohp/httpx\"",
      ")",
      "",
      "type ${1:结构}Controller struct{}",
      "// @Summary     查询",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Search   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/search [post]",
      "func (*${1:结构}Controller) Search(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Search",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Search(&req)",
      " httpx.ReturnGin(c, \"查询\", &reply, &start)",
      "}",
      "// @Summary     增加",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Create   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/create [post]",
      "func (*${1:结构}Controller) Create(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Create",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Create(&req)",
      " httpx.ReturnGin(c, \"增加\", &reply, &start)",
      "}",
      "// @Summary     更新",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Update   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/update [put]",
      "func (*${1:结构}Controller) Update(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Update",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Update(&req)",
      " httpx.ReturnGin(c, \"更新\", &reply, &start)",
      "}",
      "// @Summary     删除",
      "// @Schemes",
      "// @Description",
      "// @Tags        ${3:分组}",
      "// @Accept      json",
      "// @Produce     json",
      "// @Param       body      body      handler.Req${1:结构}Delete   true  \"请求体\"",
      "// @Success     200       {object}  handler.Resp${1:结构}s",
      "// @Router /${2:路径}/delete [delete]",
      "func (*${1:结构}Controller) Delete(c *gin.Context) {",
      " start := time.Now()",
      " var req handler.Req${1:结构}Delete",
      " reply := httpx.NewReply()",
      " bytBody, _ := io.ReadAll(c.Request.Body)",
      " if reply.Err = json.Unmarshal(bytBody, &req); reply.Err != nil {",
      "  return",
      " }",
      " reply.Data, reply.Err = handler.${1:结构}Delete(&req)",
      " httpx.ReturnGin(c, \"删除\", &reply, &start)",
      "}"
    ],
    "description": "ControllerCURD"
  },
  "HandlerReqResp": {
    "prefix": [
      "hreqresp"
    ],
    "body": [
      "package handler",
      "",
      "import (",
      " \"github.com/qida/gohp/timex\"",
      ")",
      "",
      "type Req${1:结构}Search struct {",
      " KeyWord       string      `json: \"KeyWord\"`               // 关键词",
      " Id${2:编号}            int64       `json: \"Id${2:编号}\"`                    // ID",
      " Remark        string      `json: \"Remark,omitempty\"`      // 备注",
      " Status        int8        `json: \"Status\"`                // 状态",
      " TimeCreateMin timex.ODate `json: \"TimeCreateMin\"`         // 记录创建时间",
      " TimeCreateMax timex.ODate `json: \"TimeCreateMax\"`         // 记录创建时间",
      " Page          int64       `json: \"Page\"`                  // 必填 指定返回页码号",
      " Limit         int64       `json: \"Limit\"`                 // 必填 指定返回每页条数",
      " FieldOrders   []string    `json: \"FieldOrders,omitempty\"` // 指定要排序的字段数组，默认升序，降序加前缀-，如 [\"-Id${2:编号}\", \"Name\"] 按Id${2:编号}降序Name升序排列",
      "}",
      "",
      "type Req${1:结构}Delete struct {",
      " Id${2:编号}s []int64 `json: \"Id${2:编号}s\"` // ID",
      "}",
      "",
      "type Req${1:结构}Update struct {",
      " Id${2:编号}     int64  `json: \"Id${2:编号}\"`               // ID",
      " Status int8   `json: \"Status\"`           // 状态",
      " Remark string `json: \"Remark,omitempty\"` // 备注",
      "}",
      "",
      "type Req${1:结构}Create struct {",
      " Id${2:编号}     int64  `json: \"Id${2:编号}\"`               // ID",
      " Remark string `json: \"Remark,omitempty\"` // 备注",
      "}",
      "",
      "type Resp${1:结构} struct {",
      " Id${2:编号}         int64           `json: \"Id${2:编号}\"`         // ID",
      " Remark     string          `json: \"Remark\"`     // 备注",
      " Status     int8            `json: \"Status\"`     // 状态",
      " StatusText string          `json: \"StatusText\"` //",
      " TimeUpdate timex.ODateTime `json: \"TimeUpdate\"` // 记录更新时间",
      " TimeCreate timex.ODateTime `json: \"TimeCreate\"` // 记录创建时间",
      " TimeDelete timex.ODateTime `json: \"TimeDelete\"` // 记录删除时间",
      "}",
      "",
      "type Resp${1:结构}s struct {",
      " ${1:结构}s []Resp${1:结构} `json: \"${1:结构}s\"` // 返回列表对象",
      "}"
    ],
    "description": "HandlerReqResp"
  },
  "Handler方法": {
    "prefix": [
      "hcurd"
    ],
    "body": [
      "package handler",
      "",
      "import (",
      " \"fmt\"",
      " \"log\"",
      " \"strings\"",
      " \"time\"",
      "",
      " \"github.com/jinzhu/copier\"",
      " \"github.com/qida/gohp/stringx\"",
      " \"github.com/qida/gohp/appx\"",
      " \"github.com/qida/gohp/structx\"",
      ")",
      "",
      "func ${1:结构}Create(req *Req${1:结构}Create) (_resp Resp${1:结构}, _err error) {",
      " if _err = structx.RequestVerify(*req, \"${4:必传}\"); _err != nil {",
      "  return",
      " }",
      " if _err = structx.RequestSpaceTrim(req); _err != nil {",
      "  return",
      " }",
      " ${3:小对象} := model.${1:结构}{",
      "  Id${2:编号}:  appx.SNOW_FLAK.GetId(),",
      "  Remark:     req.Remark,",
      "  TimeCreate: time.Now(),",
      " }",
      " _err = app.DB.Model(&model.${1:结构}{}).",
      "  Where(&model.${1:结构}{}).",
      "  FirstOrCreate(&${3:小对象}).Error",
      " if _err != nil {",
      "  log.Print(\"插入 错误\")",
      "  return",
      " }",
      " _err = copier.Copy(&_resp, &${3:小对象})",
      " return",
      "}",
      "",
      "func ${1:结构}Delete(req *Req${1:结构}Delete) (_err error) {",
      " _err = app.DB.Model(&model.${1:结构}{}).Debug().Where(stringx.ToSnakeCase(\"Id${2:编号}\")+\" IN ?\", req.Id${2:编号}s).Delete(&model.${1:结构}{}).Error",
      " return",
      "}",
      "",
      "func ${1:结构}Update(req *Req${1:结构}Update) (_resp Resp${1:结构}, _err error) {",
      " if _err = structx.RequestVerify(*req, \"Id${2:编号}\"); _err != nil {",
      "  return",
      " }",
      " if _err = structx.RequestSpaceTrim(req); _err != nil {",
      "  return",
      " }",
      " ${3:小对象} := model.${1:结构}{",
      "  Id${2:编号}:  req.Id${2:编号},",
      "  Remark:     req.Remark,",
      "  TimeUpdate: time.Now(),",
      " }",
      " _err = app.DB.Model(&model.${1:结构}{}).Where(stringx.ToSnakeCase(\"Id${2:编号}\")+\" = ?\", req.Id${2:编号}).",
      "  Save(&${3:小对象}).Error",
      " if _err != nil {",
      "  log.Print(\"更新 错误\")",
      "  return",
      " }",
      " _err = copier.Copy(&_resp, &${3:小对象})",
      " return",
      "}",
      "",
      "func ${1:结构}Search(req *Req${1:结构}Search) (_rs Resp${1:结构}s, _err error) {",
      " if req.Page <= 0 {",
      "  req.Page = 1",
      " }",
      " if req.Limit <= 0 {",
      "  req.Limit = 10",
      " }",
      " cli_db := app.DB.Model(&model.${1:结构}{})",
      " if req.Id${2:编号} != 0 {",
      "  cli_db = cli_db.",
      "   Where(stringx.ToSnakeCase(\"Id${2:编号}\")+\" = ?\", req.Id${2:编号})",
      " } else if len(req.Id${2:编号}s) != 0 {",
      "  cli_db = cli_db.",
      "   Where(stringx.ToSnakeCase(\"Id${2:编号}\")+\" IN ?\", req.Id${2:编号}s)",
      " }",
      " if !req.TimeCreateMin.IsZero() {",
      "  cli_db = cli_db.",
      "   Where(\"time_create >= ?\", req.TimeCreateMin)",
      " }",
      " if !req.TimeCreateMin.IsZero() {",
      "  cli_db = cli_db.",
      "   Where(\"time_create >= ?\", req.TimeCreateMin)",
      " }",
      " if !req.TimeCreateMax.IsZero() {",
      "  cli_db = cli_db.",
      "   Where(\"time_create < ?\", req.TimeCreateMax)",
      " }",
      " if len(req.FieldOrders) > 0 {",
      "  for i := 0; i < len(req.FieldOrders); i++ {",
      "   if req.FieldOrders[i] == \"\" {",
      "    break",
      "   }",
      "   if strings.HasPrefix(req.FieldOrders[i], \"-\") {",
      "    cli_db = cli_db.Order(fmt.Sprintf(\"%s desc\", stringx.Camel2Case(strings.TrimLeft(req.FieldOrders[i], \"-\"))))",
      "   } else {",
      "    cli_db = cli_db.Order(fmt.Sprintf(\"%s asc\", stringx.Camel2Case(req.FieldOrders[i])))",
      "   }",
      "  }",
      " }",
      " var ${3:小对象}s []model.${1:结构}",
      " _err = cli_db.Scopes(gormx.Paginate(req.Page, req.Limit)).Find(&${3:小对象}s).Error",
      " if _err != nil {",
      "  return",
      " }",
      " for i := 0; i < len(${3:小对象}s); i++ {",
      "  var tmp${1:结构} Resp${1:结构}",
      "  err := copier.Copy(&tmp${1:结构}, ${3:小对象}s[i])",
      "  if err != nil {",
      "   log.Printf(\"Err:%+v\", err)",
      "   continue",
      "  }",
      "  _rs.${1:结构}s = append(_rs.${1:结构}s, tmp${1:结构})",
      " }",
      " return",
      "}"
    ],
    "description": "Handler方法"
  }
}