123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package cygx
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type IndustrialAnalystAdd struct {
- AnalystName string `description:"分析师名称"`
- IndustrialManagementId int `description:"产业id"`
- }
- type IndustrialAnalystDelete struct {
- IndustrialAnalystId int `orm:"column(industrial_analyst_id);pk" description:"分析师id"`
- }
- type CygxIndustrialAnalyst struct {
- IndustrialAnalystId int `orm:"column(industrial_analyst_id);pk" description:"分析师id"`
- IndustrialManagementId int `description:"产业id"`
- AnalystName string `description:"分析师名称"`
- CreateTime time.Time `description:"创建时间"`
- }
- type GetIndustrialAnalystList struct {
- List []*CygxIndustrialAnalyst
- }
- //新增
- func AddIndustrialAnalyst(item *CygxIndustrialAnalyst) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(item)
- return
- }
- //列表
- func GetIndustrialAnalystAll(IndustrialManagementId int) (items []*CygxIndustrialAnalyst, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_industrial_analyst where industrial_management_id = ? `
- _, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items)
- return
- }
- //获取数量
- func GetIndustrialAnalystCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_industrial_analyst WHERE 1=1 `
- if condition != "" {
- sqlCount += condition
- }
- fmt.Println(sqlCount)
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- //修改
- func EditIndustrialAnalyst(item *CygxIndustrialAnalyst) (err error) {
- sql := `UPDATE cygx_industrial_analyst SET analyst_name=? WHERE industrial_analyst_id=? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, item.AnalystName, item.IndustrialAnalystId).Exec()
- return
- }
- //删除数据
- func DeleteIndustrialAnalyst(industrialAnalystId int) (err error) {
- o := orm.NewOrm()
- sql := ` DELETE FROM cygx_industrial_analyst WHERE industrial_analyst_id = ?`
- _, err = o.Raw(sql, industrialAnalystId).Exec()
- return
- }
|