industrial_analyst.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type IndustrialAnalystAdd struct {
  7. AnalystName string `description:"分析师名称"`
  8. IndustrialManagementId int `description:"产业id"`
  9. }
  10. type IndustrialAnalystDelete struct {
  11. IndustrialAnalystId int `orm:"column(industrial_analyst_id);pk" description:"分析师id"`
  12. }
  13. type CygxIndustrialAnalyst struct {
  14. IndustrialAnalystId int `orm:"column(industrial_analyst_id);pk" description:"分析师id"`
  15. IndustrialManagementId int `description:"产业id"`
  16. AnalystName string `description:"分析师名称"`
  17. CreateTime time.Time `description:"创建时间"`
  18. }
  19. type GetIndustrialAnalystList struct {
  20. List []*CygxIndustrialAnalyst
  21. }
  22. // 新增
  23. func AddIndustrialAnalyst(item *CygxIndustrialAnalyst) (err error) {
  24. o := orm.NewOrm()
  25. _, err = o.Insert(item)
  26. return
  27. }
  28. // 列表
  29. func GetIndustrialAnalystAll(IndustrialManagementId int) (items []*CygxIndustrialAnalyst, err error) {
  30. o := orm.NewOrmUsingDB("hz_cygx")
  31. sql := `SELECT * FROM cygx_industrial_analyst where industrial_management_id = ? `
  32. _, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items)
  33. return
  34. }
  35. // 获取数量
  36. func GetIndustrialAnalystCount(condition string, pars []interface{}) (count int, err error) {
  37. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_industrial_analyst WHERE 1=1 `
  38. if condition != "" {
  39. sqlCount += condition
  40. }
  41. o := orm.NewOrmUsingDB("hz_cygx")
  42. err = o.Raw(sqlCount, pars).QueryRow(&count)
  43. return
  44. }
  45. // 修改
  46. func EditIndustrialAnalyst(item *CygxIndustrialAnalyst) (err error) {
  47. sql := `UPDATE cygx_industrial_analyst SET analyst_name=? WHERE industrial_analyst_id=? `
  48. o := orm.NewOrmUsingDB("hz_cygx")
  49. _, err = o.Raw(sql, item.AnalystName, item.IndustrialAnalystId).Exec()
  50. return
  51. }
  52. // 删除数据
  53. func DeleteIndustrialAnalyst(industrialAnalystId int) (err error) {
  54. o := orm.NewOrmUsingDB("hz_cygx")
  55. sql := ` DELETE FROM cygx_industrial_analyst WHERE industrial_analyst_id = ?`
  56. _, err = o.Raw(sql, industrialAnalystId).Exec()
  57. return
  58. }