suppliercertappendsub.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  4. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  5. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  7. "dashoo.cn/business2/parameter"
  8. "encoding/json"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
  13. . "dashoo.cn/backend/api/controllers"
  14. "dashoo.cn/utils"
  15. )
  16. type OilSupplierCertAppendSubController struct {
  17. BaseController
  18. }
  19. // @Title 获取列表
  20. // @Description 获取列表
  21. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  22. // @router /getList [get]
  23. func (this *OilSupplierCertAppendSubController) GetList() {
  24. //获取分页信息
  25. //page := this.GetPageInfoForm()
  26. //where := " 1=1 "
  27. //orderby := "Id"
  28. //asc := false
  29. //Order := this.GetString("Order")
  30. //Prop := this.GetString("Prop")
  31. //if Order != "" && Prop != "" {
  32. // orderby = Prop
  33. // if Order == "asc" {
  34. // asc = true
  35. // }
  36. //}
  37. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  38. //if SupplierCertAppendId != "" {
  39. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  40. //}
  41. SupplierCertId := this.GetString("SupCertId")
  42. SupplierTypeCode := this.GetString("SupTypeCode")
  43. suwhere := " SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = "+ SupplierTypeCode
  44. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  45. var list []suppliercertsub.OilSupplierCertSub
  46. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  47. svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere,"CreateOn asc", &list)
  48. var datainfo ErrorDataInfo
  49. datainfo.Item = list
  50. this.Data["json"] = &datainfo
  51. this.ServeJSON()
  52. }
  53. // @Title 获取列表
  54. // @Description 获取列表
  55. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  56. // @router /getMyList [get]
  57. func (this *OilSupplierCertAppendSubController) GetMyList() {
  58. SupplierCertId := this.GetString("SupCertId")
  59. SupplierTypeCode := this.GetString("SupTypeCode")
  60. SuppAppendId := this.GetString("SupplierCertAppendId")
  61. suwhere := " SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = '"+ SupplierTypeCode +"' and SupplierCertAppendId = "+ SuppAppendId
  62. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  63. var list []suppliercertsub.OilSupplierCertSub
  64. svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere,"CreateOn asc", &list)
  65. var datainfo ErrorDataInfo
  66. datainfo.Item = list
  67. this.Data["json"] = &datainfo
  68. this.ServeJSON()
  69. }
  70. // @Title 获取列表
  71. // @Description 获取列表
  72. // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
  73. // @router /getListappend [get]
  74. func (this *OilSupplierCertAppendSubController) GetListAppend() {
  75. //获取分页信息
  76. //page := this.GetPageInfoForm()
  77. //where := " 1=1 "
  78. //orderby := "Id"
  79. //asc := false
  80. //Order := this.GetString("Order")
  81. //Prop := this.GetString("Prop")
  82. //if Order != "" && Prop != "" {
  83. // orderby = Prop
  84. // if Order == "asc" {
  85. // asc = true
  86. // }
  87. //}
  88. //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  89. //if SupplierCertAppendId != "" {
  90. // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
  91. //}
  92. SupplierCertAppendId := this.GetString("SupplierCertAppendId")
  93. SupplierCertId := this.GetString("SupCertId")
  94. SupplierTypeCode := this.GetString("SupTypeCode")
  95. suwhere := " SupplierCertId = "+ SupplierCertId+ " and SupplierCertAppendId= "+ SupplierCertAppendId +" and SupplierTypeCode = '"+ SupplierTypeCode +"' and Type in(2,3) "
  96. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  97. var list []suppliercertsub.OilSupplierCertSub
  98. //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
  99. svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere,"CreateOn asc", &list)
  100. var datainfo ErrorDataInfo
  101. datainfo.Item = list
  102. this.Data["json"] = &datainfo
  103. this.ServeJSON()
  104. }
  105. // @Title 添加
  106. // @Description 添加增项分类信息基建类
  107. // @Success 200 {object} controllers.Request
  108. // @router /addappendsub [post]
  109. func (this *OilSupplierCertAppendSubController) AddAppendSub() {
  110. var model suppliercertsub.OilSupplierCertSub
  111. var err error
  112. var jsonblob = this.Ctx.Input.RequestBody
  113. json.Unmarshal(jsonblob, &model)
  114. model.CreateBy = this.User.Realname
  115. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  116. model.CertSubStatus="1"
  117. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  118. var submodel suppliercertsub.OilSupplierCertSub
  119. where_certsub := " SupplierCertId = "+ utils.ToStr(model.SupplierCertId) + " and SupplierTypeCode = 02"
  120. where_certsub += " and SubClassId = '" + utils.ToStr(model.SubClassId) + "'"
  121. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_certsub, &submodel)
  122. if !has{
  123. //添加到准入分类表中
  124. _, err = svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
  125. }else{
  126. model.Id = submodel.Id
  127. }
  128. var supplierCertModel suppliercert.OilSupplierCert
  129. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  130. svcCert.GetEntityById(model.SupplierCertId, &supplierCertModel)
  131. var supplierModel supplier.OilSupplier
  132. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  133. svcSupplier.GetEntityById(model.SupplierId, &supplierModel)
  134. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  135. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  136. var needList []supplierfile.FileList
  137. if model.SupplierTypeCode == "01" {
  138. // needList = filesvc.GetGoodsNeedFileList(model.SubClassId)
  139. } else if model.SupplierTypeCode == "02" {
  140. needList = filesvc.GetBasicNeedFileList(model.SubClassId)
  141. } else {
  142. // needList = filesvc.GetTechNeedFileList(model.SubClassId)
  143. }
  144. if supplierCertModel.InStyle == "4" {
  145. var needFile supplierfile.FileList
  146. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  147. needList = append(needList, needFile)
  148. }
  149. if err == nil {
  150. var list []supplierfile.OilSupplierFile
  151. where := "SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
  152. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  153. //三证合一或五证合一不需要的字段
  154. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  155. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  156. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  157. for i := 0; i < len(needList); i++ {
  158. var entity supplierfile.OilSupplierFile
  159. entity.SupplierId = model.SupplierId
  160. //加入对应表OilSupplierCert2File
  161. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  162. cert2File.SupplierId = model.SupplierId
  163. cert2File.SupplierCertId = model.SupplierCertId
  164. cert2File.SupplierTypeCode = model.SupplierTypeCode
  165. cert2File.SubClassId= model.SubClassId
  166. cert2File.Code = model.Code
  167. cert2File.Name = model.Name
  168. cert2File.NeedFileType = needList[i].FileName
  169. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  170. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  171. continue
  172. }
  173. if strings.Contains(mustField, needList[i].FileName+",") {
  174. entity.SupplierTypeCode = "000"
  175. } else {
  176. entity.SupplierTypeCode = model.SupplierTypeCode
  177. }
  178. entity.NeedFileType = needList[i].FileName
  179. entity.FileType = 1
  180. entity.EffectDate = time.Now()
  181. entity.CreateBy = this.User.Realname
  182. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  183. entity.SupType = 2
  184. entity.SupplierCertSubId = model.SupplierCertAppendId
  185. isRepeat := false
  186. for j := 0; j < len(list); j++ {
  187. if list[j].NeedFileType == needList[i].FileName{
  188. isRepeat = true
  189. break
  190. }
  191. }
  192. if isRepeat == true {
  193. continue
  194. }
  195. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  196. }
  197. }
  198. var errinfo ErrorDataInfo
  199. if err == nil {
  200. errinfo.Message = "操作成功!"
  201. errinfo.Code = 0
  202. errinfo.Item = model.Id
  203. this.Data["json"] = &errinfo
  204. this.ServeJSON()
  205. } else {
  206. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  207. errinfo.Code = -1
  208. this.Data["json"] = &errinfo
  209. this.ServeJSON()
  210. }
  211. }
  212. // @Title 批量添加增项准入范围--技术服务类
  213. // @Description 批量添加准入范围
  214. // @Success 200 {object} business.device.DeviceChannels
  215. // @router /addtechbus [post]
  216. func (this *OilSupplierCertAppendSubController) AddTechBus() {
  217. var jsonblob = this.Ctx.Input.RequestBody
  218. var datamain suppliercertsub.OilSupplierCertSub
  219. var dataother suppliercertsub.TechnologySubModel
  220. json.Unmarshal(jsonblob, &datamain)
  221. json.Unmarshal(jsonblob, &dataother)
  222. var supplierCertModel suppliercert.OilSupplierCert
  223. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  224. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  225. var supplierModel supplier.OilSupplier
  226. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  227. svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
  228. for n := 0; n < len(dataother.CheckList); n++ {
  229. where_sub := "SupplierTypeCode = 03 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  230. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  231. where_sub += " and SubClassId = '" + strconv.Itoa(dataother.CheckList[n].Id) + "'"
  232. var model suppliercertsub.OilSupplierCertSub
  233. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  234. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  235. if !has {
  236. datamain.SubClassId = dataother.CheckList[n].Id
  237. datamain.Code = dataother.CheckList[n].Code
  238. datamain.Name = dataother.CheckList[n].Name
  239. datamain.Remark = dataother.Remark
  240. datamain.CertSubStatus="1"
  241. datamain.IsDelete = 0
  242. datamain.CreateBy = this.User.Realname
  243. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  244. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  245. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  246. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  247. needList := filesvc.GetTechNeedFileList(dataother.CheckList[n].Id)
  248. if supplierCertModel.InStyle == "4" {
  249. var needFile supplierfile.FileList
  250. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  251. needList = append(needList, needFile)
  252. }
  253. var list []supplierfile.OilSupplierFile
  254. where := "SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  255. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  256. //三证合一或五证合一不需要的字段
  257. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  258. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  259. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  260. for i := 0; i < len(needList); i++ {
  261. var entity supplierfile.OilSupplierFile
  262. entity.SupplierId = dataother.SupplierId
  263. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  264. continue
  265. }
  266. //加入对应表OilSupplierCert2File
  267. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  268. cert2File.SupplierId = dataother.SupplierId
  269. cert2File.SupplierCertId = dataother.SupplierCertId
  270. cert2File.SupplierTypeCode = dataother.SupplierTypeCode
  271. cert2File.SubClassId= dataother.CheckList[n].Id
  272. cert2File.Code = dataother.CheckList[n].Code
  273. cert2File.Name = dataother.CheckList[n].Name
  274. cert2File.NeedFileType = needList[i].FileName
  275. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  276. if strings.Contains(mustField, needList[i].FileName+",") {
  277. entity.SupplierTypeCode = "000"
  278. } else {
  279. entity.SupplierTypeCode = dataother.SupplierTypeCode
  280. }
  281. entity.SupplierCertSubId = datamain.SupplierCertAppendId
  282. entity.NeedFileType = needList[i].FileName
  283. entity.FileType = 1
  284. entity.EffectDate = time.Now()
  285. entity.CreateBy = this.User.Realname
  286. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  287. entity.SupType = 2
  288. isRepeat := false
  289. for j := 0; j < len(list); j++ {
  290. if list[j].NeedFileType == needList[i].FileName{
  291. isRepeat = true
  292. break
  293. }
  294. }
  295. if isRepeat == true {
  296. continue
  297. }
  298. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  299. }
  300. }
  301. }
  302. var errinfo ErrorDataInfo
  303. errinfo.Message = "操作成功!"
  304. errinfo.Code = 0
  305. this.Data["json"] = &errinfo
  306. this.ServeJSON()
  307. }
  308. // @Title 批量添加增项准入范围--物资类
  309. // @Description 批量添加增项准入范围
  310. // @Success 200 {object} business.device.DeviceChannels
  311. // @router /addgoodsbus [post]
  312. func (this *OilSupplierCertAppendSubController) AddGoodsBus() {
  313. var jsonblob = this.Ctx.Input.RequestBody
  314. var datamain suppliercertsub.OilSupplierCertSub
  315. var dataother suppliercertsub.SupplierCertSubModel
  316. json.Unmarshal(jsonblob, &datamain)
  317. json.Unmarshal(jsonblob, &dataother)
  318. var supplierCertModel suppliercert.OilSupplierCert
  319. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  320. svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
  321. var supplierModel supplier.OilSupplier
  322. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  323. svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
  324. for n := 0; n < len(dataother.CheckList); n++ {
  325. where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  326. where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
  327. where_sub += " and SubClassId = '" + dataother.CheckList[n].Id + "'"
  328. var model suppliercertsub.OilSupplierCertSub
  329. svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  330. has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
  331. if !has {
  332. datamain.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
  333. datamain.Code = dataother.CheckList[n].Code
  334. datamain.Name = dataother.CheckList[n].Name
  335. datamain.CertSubStatus="1"
  336. datamain.Remark = dataother.Remark
  337. datamain.IsDelete = 0
  338. datamain.CreateBy = this.User.Realname
  339. datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  340. svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
  341. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  342. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  343. needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id)
  344. if supplierCertModel.InStyle == "4" {
  345. var needFile supplierfile.FileList
  346. //战略合作协议扫描件
  347. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  348. needList = append(needList, needFile)
  349. }
  350. var list []supplierfile.OilSupplierFile
  351. where := "SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
  352. svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
  353. //三证合一或五证合一不需要的字段
  354. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  355. //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
  356. mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
  357. for i := 0; i < len(needList); i++ {
  358. var entity supplierfile.OilSupplierFile
  359. entity.SupplierId = dataother.SupplierId
  360. if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
  361. continue
  362. }
  363. //加入对应表OilSupplierCert2File
  364. var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
  365. cert2File.SupplierId = dataother.SupplierId
  366. cert2File.SupplierCertId = dataother.SupplierCertId
  367. cert2File.SupplierTypeCode = dataother.SupplierTypeCode
  368. cert2File.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
  369. cert2File.Code = dataother.CheckList[n].Code
  370. cert2File.Name = dataother.CheckList[n].Name
  371. cert2File.NeedFileType = needList[i].FileName
  372. svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
  373. if strings.Contains(mustField, needList[i].FileName+",") {
  374. entity.SupplierTypeCode = "000"
  375. } else {
  376. entity.SupplierTypeCode = dataother.SupplierTypeCode
  377. }
  378. entity.NeedFileType = needList[i].FileName
  379. entity.FileType = 1
  380. entity.EffectDate = time.Now()
  381. entity.CreateBy = this.User.Realname
  382. entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  383. entity.SupType = 2
  384. entity.SupplierCertSubId = datamain.SupplierCertAppendId
  385. isRepeat := false
  386. for j := 0; j < len(list); j++ {
  387. if list[j].NeedFileType == needList[i].FileName{
  388. isRepeat = true
  389. break
  390. }
  391. }
  392. if isRepeat == true {
  393. continue
  394. }
  395. svc.InsertEntityBytbl(OilSupplierFileName, &entity)
  396. }
  397. }
  398. }
  399. var errinfo ErrorDataInfo
  400. errinfo.Message = "操作成功!"
  401. errinfo.Code = 0
  402. this.Data["json"] = &errinfo
  403. this.ServeJSON()
  404. }
  405. // @Title 修改实体
  406. // @Description 修改实体
  407. // @Success 200 {object} controllers.Request
  408. // @router /update/:id [post]
  409. func (this *OilSupplierCertAppendSubController) UpdateEntity() {
  410. var errinfo ErrorInfo
  411. var model suppliercertappendsub.OilSupplierCertAppendSub
  412. id := this.Ctx.Input.Param(":id")
  413. if id == "" {
  414. errinfo.Message = "操作失败!请求信息不完整"
  415. errinfo.Code = -2
  416. this.Data["json"] = &errinfo
  417. this.ServeJSON()
  418. return
  419. }
  420. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  421. var jsonBlob = this.Ctx.Input.RequestBody
  422. json.Unmarshal(jsonBlob, &model)
  423. model.ModifiedOn = time.Now()
  424. model.ModifiedBy = this.User.Realname
  425. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  426. cols := []string{
  427. "SortFlag",
  428. "Code",
  429. "Name",
  430. "Remark",
  431. "ModifiedOn",
  432. "ModifiedUserId",
  433. "ModifiedBy",
  434. }
  435. err := svc.UpdateEntityBytbl(OilSupplierCertAppendSubName, id, &model, cols)
  436. if err == nil {
  437. errinfo.Message = "修改成功!"
  438. errinfo.Code = 0
  439. this.Data["json"] = &errinfo
  440. this.ServeJSON()
  441. } else {
  442. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  443. errinfo.Code = -1
  444. this.Data["json"] = &errinfo
  445. this.ServeJSON()
  446. }
  447. }
  448. // @Title 删除
  449. // @Description 删除信息
  450. // @Success 200 {object} ErrorInfo
  451. // @Failure 403 :id 为空
  452. // @router /delete/:Id [delete]
  453. func (this *OilSupplierCertAppendSubController) DeleteEntity() {
  454. Id := this.Ctx.Input.Param(":Id")
  455. var errinfo ErrorInfo
  456. if Id == "" {
  457. errinfo.Message = "操作失败!请求信息不完整"
  458. errinfo.Code = -2
  459. this.Data["json"] = &errinfo
  460. this.ServeJSON()
  461. return
  462. }
  463. var model suppliercertappendsub.OilSupplierCertAppendSub
  464. var entityempty suppliercertappendsub.OilSupplierCertAppendSub
  465. svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  466. opdesc := "删除-" + Id
  467. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertAppendSubName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "增项分类")
  468. if err == nil {
  469. errinfo.Message = "删除成功"
  470. errinfo.Code = 0
  471. this.Data["json"] = &errinfo
  472. this.ServeJSON()
  473. } else {
  474. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  475. errinfo.Code = -1
  476. this.Data["json"] = &errinfo
  477. this.ServeJSON()
  478. }
  479. }