1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /*
- * @description: 标段相关的接口api
- * @Author: CP
- * @Date: 2020-09-28 10:26:49
- * @FilePath: \construction_management\web\api\bidsection_api.go
- */
- package api
- import (
- "fmt"
- "strconv"
- "github.com/kataras/iris/v12"
- "go.mod/services"
- "go.mod/web/utils"
- )
- type BidsectionApi struct {
- //框架-web应用上下文环境
- Ctx iris.Context
- // 需要用的service
- ServiceBidsection services.BidsectionService
- }
- // 获得项目目录结构
- func (c *BidsectionApi) Get() {
- }
- // 添标段结构
- func (c *BidsectionApi) PostCreate() {
- ErrMsg := ""
- // 验证内容
- BidsectionData, err := c.ServiceBidsection.ValidRule(c.Ctx)
- if err != nil {
- ErrMsg = utils.FormValidError(err)
- c.Ctx.JSON(iris.Map{
- "code": -1,
- "msg": ErrMsg,
- })
- return
- } else {
- // 获得项目ID
- projectIdInt, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{
- "code": -1,
- "msg": fmt.Sprintf("%s", err),
- })
- return
- }
- BidsectionData.ProjectId = strconv.Itoa(projectIdInt)
- // 新增标段-新增树结构里的标段
- err = c.ServiceBidsection.Create(BidsectionData)
- if err != nil {
- c.Ctx.JSON(iris.Map{
- "code": -1,
- "msg": fmt.Sprintf("%s", err),
- })
- return
- }
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "新增成功",
- })
- }
- }
|