|
@@ -360,12 +360,47 @@ func (m *PptV2) GetPageItemsByCondition(condition string, pars []interface{}, fi
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func (m *PptV2) GetPageItemsByConditionWithAdminId(condition string, pars []interface{}, fieldArr []string, orderRule string, adminId, startSize, pageSize int) (items []*PptV2, err error) {
|
|
|
+ fields := strings.Join(fieldArr, ",")
|
|
|
+ if len(fieldArr) == 0 {
|
|
|
+ fields = `*`
|
|
|
+ }
|
|
|
+ order := `ORDER BY create_time DESC`
|
|
|
+ if orderRule != "" {
|
|
|
+ order = ` ORDER BY ` + orderRule
|
|
|
+ }
|
|
|
+ sql := fmt.Sprintf(`
|
|
|
+ SELECT %s FROM %s WHERE 1=1 AND classify_id NOT IN (
|
|
|
+ SELECT DISTINCT "classify_id" FROM "classify_visible") %s
|
|
|
+ UNION ALL
|
|
|
+ SELECT %s FROM %s WHERE 1=1 AND classify_id IN (
|
|
|
+ SELECT DISTINCT "classify_id" FROM "classify_visible" WHERE "admin_id" = %d) %s %s LIMIT ?,? `, fields, m.TableName(), condition, fields, m.TableName(), adminId, condition, order)
|
|
|
+ pars = append(pars, pars...)
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func (m *PptV2) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
|
sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func (m *PptV2) GetCountByConditionWithAdminId(condition string, pars []interface{}, adminId int) (count int, err error) {
|
|
|
+ sql := fmt.Sprintf(`
|
|
|
+ SELECT (
|
|
|
+ (SELECT COUNT(1) FROM %s WHERE 1=1 AND classify_id NOT IN (
|
|
|
+ SELECT DISTINCT "classify_id" FROM "classify_visible") %s)
|
|
|
+ +
|
|
|
+ (SELECT COUNT(1) FROM %s WHERE 1=1 AND classify_id IN (
|
|
|
+ SELECT DISTINCT "classify_id" FROM "classify_visible" WHERE "admin_id" = %d) %s)
|
|
|
+ ) AS count `, m.TableName(), condition, m.TableName(), adminId, condition)
|
|
|
+ pars = append(pars, pars...)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// PptReportQueryFields 除富文本的常用查询字段
|
|
|
var PptReportQueryFields = []string{
|
|
|
"ppt_id", "title", "classify_id", "ppt_version", "pptx_url", "ppt_page", "title_setting", "state", "report_source", "publish_time", "submit_time", "approve_time", "create_time", "modify_time", "admin_id", "admin_real_name", "collaborate_type", "collaborate_users",
|