contract_section_tree_api.go 13 KB

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