12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_mfyx/utils"
- "time"
- )
- type AddCygxQuestionnaireThemeReq struct {
- QuestionnaireThemeId int `description:"ID"`
- ActivityTheme string `description:"活动主题"`
- DisabledRadio bool `description:"是否选择,配合前端添加的字段"`
- }
- type CygxQuestionnaireResp struct {
- QuestionnaireId int `description:"ID"`
- ActivityTypeId int `description:"活动类型id"`
- ActivityTypeName string `description:"活动类型名称"`
- Content string `description:"内容"`
- EndTime string `description:"截止日期"`
- PublishTime string `description:"发布时间"`
- MaxChooseTotal int `description:"最多可选几项"`
- State string `description:"状态"`
- ListTheme []*AddCygxQuestionnaireThemeReq
- }
- type GetCygxQuestionnaireResp struct {
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxQuestionnaireResp
- }
- type GetCygxQuestionnaireDetailResp struct {
- Detail *CygxQuestionnaireResp
- }
- // 通过ID获取详情
- func GetCygxQuestionnaireDetail(questionnaireId int) (item *CygxQuestionnaireResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_questionnaire WHERE questionnaire_id=? `
- err = o.Raw(sql, questionnaireId).QueryRow(&item)
- return
- }
- // 获取数量
- func GetCygxQuestionnaireCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_questionnaire as art WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 通过ID获取详情
- func GetCygxQuestionnaireDetailBestNew() (item *CygxQuestionnaireResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_questionnaire WHERE end_time >= ? ORDER BY publish_time DESC LIMIT 1 `
- err = o.Raw(sql, time.Now().Format(utils.FormatDate)).QueryRow(&item)
- return
- }
- // 列表
- func GetCygxQuestionnaireThemeListByQuestionnaireId(questionnaireId int) (items []*AddCygxQuestionnaireThemeReq, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_questionnaire_theme as art WHERE questionnaire_id = ? `
- _, err = o.Raw(sql, questionnaireId).QueryRows(&items)
- return
- }
|