contract_section_tree_api.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. /*
  2. * @description: 合同管理 -项目节相关API
  3. * @Author: CP
  4. * @Date: 2020-10-26 15:27:04
  5. * @FilePath: \construction_management\web\api\contract_section_tree_api.go
  6. */
  7. package api
  8. import (
  9. "fmt"
  10. "github.com/kataras/iris/v12"
  11. "go.mod/web/utils"
  12. )
  13. // @Summary 升级降级合同项目节
  14. // @Tags 合同管理-项目节
  15. // @Description operation{upDepth,downDepth}
  16. // @Accept json
  17. // @Produce json
  18. // @Security ApiKeyAuth
  19. // @Param id body string true "项目节ID"
  20. // @Param bidsectionId body string true "标段ID"
  21. // @Param treeType body string true "项目节类型(0收入1支出) 不传为0" default(0)
  22. // @Param operation body string true "操作名称" default(upDepth)
  23. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  24. // @Router /api/contract/section/depth [post]
  25. func (c *ContractApi) PostSectionDepth() {
  26. // 验证字段-项目节ID 操作类型
  27. sectionData, err := c.ServiceContract.ValidRuleDepth(c.Ctx)
  28. if err != nil {
  29. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  30. return
  31. }
  32. // 项目ID
  33. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  34. // if err != nil {
  35. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  36. // return
  37. // }
  38. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  39. // if err != nil {
  40. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  41. // return
  42. // }
  43. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  44. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  45. // return
  46. // }
  47. err = c.ServiceContract.MoveDepth(sectionData)
  48. if err != nil {
  49. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  50. return
  51. }
  52. //2.请求当前项目信息
  53. // 1.验证项目节ID
  54. // treeId, _ := utils.GetDecryptId(sectionData.Id)
  55. // sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
  56. c.Ctx.JSON(iris.Map{
  57. "code": 0,
  58. "msg": "操作成功",
  59. })
  60. }
  61. // @Summary 上移下移合同项目节
  62. // @Tags 合同管理-项目节
  63. // @Description operation{upSerial,downSerial}
  64. // @Accept json
  65. // @Produce json
  66. // @Security ApiKeyAuth
  67. // @Param id body string true "项目节ID"
  68. // @Param bidsectionId body string true "标段ID"
  69. // @Param treeType body string true "项目节类型(0收入1支出) 不传为0" default(0)
  70. // @Param operation body string true "操作名称" default(upSerial)
  71. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  72. // @Router /api/contract/section/serial [post]
  73. func (c *ContractApi) PostSectionSerial() {
  74. // 验证字段-项目节ID 操作类型
  75. sectionData, err := c.ServiceContract.ValidRuleDepth(c.Ctx)
  76. if err != nil {
  77. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  78. return
  79. }
  80. // 项目ID
  81. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  82. // if err != nil {
  83. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  84. // return
  85. // }
  86. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  87. // if err != nil {
  88. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  89. // return
  90. // }
  91. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  92. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  93. // return
  94. // }
  95. err = c.ServiceContract.MoveSerial(sectionData)
  96. if err != nil {
  97. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  98. return
  99. }
  100. //2.请求当前项目信息
  101. // 1.验证项目节ID
  102. // treeId, _ := utils.GetDecryptId(sectionData.Id)
  103. // sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
  104. c.Ctx.JSON(iris.Map{
  105. "code": 0,
  106. "msg": "操作成功",
  107. // "section": sectionDetail,
  108. })
  109. }
  110. // @Summary 更新合同节序号
  111. // @Tags 合同管理-项目节
  112. // @Description
  113. // @Accept json
  114. // @Produce json
  115. // @Security ApiKeyAuth
  116. // @Param id body string true "项目节ID"
  117. // @Param bidsectionId body string true "标段ID"
  118. // @Param treeType body string true "项目节类型(0收入1支出) 不传为0" default(0)
  119. // @Param serial body int true "操作名称"
  120. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  121. // @Router /api/contract/section/serial/update [post]
  122. func (c *ContractApi) PostSectionSerialUpdate() {
  123. // 验证字段-项目节ID 操作类型
  124. sectionData, err := c.ServiceContract.ValidRuleSerial(c.Ctx)
  125. if err != nil {
  126. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  127. return
  128. }
  129. // 项目ID
  130. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  131. // if err != nil {
  132. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  133. // return
  134. // }
  135. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  136. // if err != nil {
  137. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  138. // return
  139. // }
  140. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  141. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  142. // return
  143. // }
  144. err = c.ServiceContract.UpdateSerial(sectionData)
  145. if err != nil {
  146. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  147. return
  148. }
  149. //2.请求当前项目信息
  150. // 1.验证项目节ID
  151. // treeId, _ := utils.GetDecryptId(sectionData.Id)
  152. // sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
  153. c.Ctx.JSON(iris.Map{
  154. "code": 0,
  155. "msg": "操作成功",
  156. // "section": sectionDetail,
  157. })
  158. }
  159. // @Summary 设置合同项目节模板
  160. // @Tags 合同管理-项目节
  161. // @Description 设置合同项目节模板
  162. // @Accept json
  163. // @Produce json
  164. // @Security ApiKeyAuth
  165. // @Param templateNumber body int true "模板号" default(1)
  166. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  167. // @Router /api/contract/section/template [post]
  168. func (c *ContractApi) PostSectionTemplate() {
  169. // 获得模板号
  170. sectionData, err := c.ServiceContract.ValidRuleTemplate(c.Ctx)
  171. if err != nil {
  172. c.Ctx.JSON(iris.Map{"code": -1, "msg": "解析参数出错"})
  173. return
  174. }
  175. // 项目ID
  176. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  177. // if err != nil {
  178. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  179. // return
  180. // }
  181. // 标段ID
  182. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  183. // if err != nil {
  184. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  185. // return
  186. // }
  187. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  188. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  189. // return
  190. // }
  191. //获得合同项目节
  192. // sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, sectionData.TreeType)
  193. err = c.ServiceContract.SetSection(sectionData.TemplateNumber)
  194. if err != nil {
  195. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  196. return
  197. }
  198. if err != nil {
  199. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  200. }
  201. c.Ctx.JSON(iris.Map{"code": 0, "msg": "设置成功"})
  202. // 1.未设置了项目节
  203. // if len(sectionTree.Children) == 0 {
  204. // } else {
  205. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "项目节已经设置"})
  206. // return
  207. // }
  208. }
  209. // @Summary 新增 合同项目节
  210. // @Tags 合同管理-项目节
  211. // @Description 新增 合同项目节
  212. // @Accept json
  213. // @Produce json
  214. // @Security ApiKeyAuth
  215. // @Param id body string true "项目节ID"
  216. // @Param name body string true "项目节名称"
  217. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  218. // @Router /api/contract/section/add [post]
  219. func (c *ContractApi) PostSectionAdd() {
  220. // 获得模板号
  221. sectionData, err := c.ServiceContract.ValidRuleSectionAdd(c.Ctx)
  222. if err != nil {
  223. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  224. return
  225. }
  226. // 项目ID
  227. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  228. // if err != nil {
  229. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  230. // return
  231. // }
  232. // // 标段ID
  233. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  234. // if err != nil {
  235. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  236. // return
  237. // }
  238. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  239. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  240. // return
  241. // }
  242. _, err = c.ServiceContract.SectionAdd(sectionData)
  243. if err != nil {
  244. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  245. return
  246. }
  247. c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功"})
  248. }
  249. // @Summary 修改合同项目节 名称
  250. // @Tags 合同管理-项目节
  251. // @Description 修改合同项目节 名称
  252. // @Accept json
  253. // @Produce json
  254. // @Security ApiKeyAuth
  255. // @Param id body string true "项目节ID"
  256. // @Param name body string true "项目节名称"
  257. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  258. // @Router /api/contract/section/save [post]
  259. func (c *ContractApi) PostSectionSave() {
  260. // 获得模板号
  261. sectionData, err := c.ServiceContract.ValidRuleSectionAdd(c.Ctx)
  262. if err != nil {
  263. c.Ctx.JSON(iris.Map{"code": -1, "msg": "解析参数出错"})
  264. return
  265. }
  266. // 项目ID
  267. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  268. // if err != nil {
  269. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  270. // return
  271. // }
  272. // // 标段ID
  273. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  274. // if err != nil {
  275. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  276. // return
  277. // }
  278. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  279. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  280. // return
  281. // }
  282. err = c.ServiceContract.SectionSave(sectionData)
  283. if err != nil {
  284. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  285. return
  286. }
  287. //2.请求当前项目信息
  288. // 1.验证项目节ID
  289. // treeId, _ := utils.GetDecryptId(sectionData.Id)
  290. // sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
  291. c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功"})
  292. }
  293. // @Summary 删除 合同项目节
  294. // @Tags 合同管理-项目节
  295. // @Description 删除 合同项目节
  296. // @Accept json
  297. // @Produce json
  298. // @Security ApiKeyAuth
  299. // @Param id body string true "项目节ID"
  300. // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
  301. // @Router /api/contract/section [delete]
  302. func (c *ContractApi) DeleteSection() {
  303. // 获得模板号-=1
  304. sectionData, err := c.ServiceContract.ValidRuleSectionDelete(c.Ctx)
  305. if err != nil {
  306. c.Ctx.JSON(iris.Map{"code": -1, "msg": "解析参数出错"})
  307. return
  308. }
  309. // 项目ID
  310. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  311. // if err != nil {
  312. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  313. // return
  314. // }
  315. // // 标段ID
  316. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  317. // if err != nil {
  318. // c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  319. // return
  320. // }
  321. // 项目节ID
  322. treeId, err := utils.GetDecryptId(sectionData.Id)
  323. if err != nil {
  324. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  325. return
  326. }
  327. // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
  328. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
  329. // return
  330. // }
  331. err = c.ServiceContract.SectionDelete(treeId)
  332. if err != nil {
  333. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  334. return
  335. }
  336. c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
  337. }