ALTER TABLE `feedtemplet`
    ADD COLUMN `is_modify` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否可修改 0 无效 1 是 2 否';


## SELECT * FROM apisql WHERE sqlname = 'getFTList' AND ENABLE >0
## 需要更新的语句如下
SELECT * FROM ( SELECT
    tname,tcolor,ccid,ccname,fttype, remark,`enable`,source,fttypeid,tcode,is_modify,
    TRIM(id) id,
    TRIM(pastureid)pastureid,
    isissue,
    (SELECT GROUP_CONCAT( DISTINCT fp.`pastureName`) FROM feedtemplet_pasture fp
     WHERE fp.ftid=ft.`id` AND fp.pastureid =ft.pastureid ) grouppastures,
    (SELECT COUNT(1) FROM feedp WHERE pastureid = ft.pastureid AND (ptsfid = ft.id OR ftid = ft.id) LIMIT 1  ) AS state,
    IF((SELECT COUNT(1) FROM ftdetail_issue fi
        WHERE fi.pastureid = ft.pastureid AND fi.ftid = ft.id)+
       (SELECT COUNT(1)
        FROM  `ftdetail` ftd
        WHERE ftd.pastureid = ft.pastureid AND ftd.ftid = ft.id)>0,1,0)  AS isadjust,ft.sort
FROM
    feedtemplet ft
WHERE pastureid = ?
  AND (ccname LIKE CONCAT("%",?,"%") OR ?='')
  AND (tname LIKE CONCAT("%",?,"%") OR ?='')
  AND (fttype LIKE CONCAT("%",?,"%") OR ?='')
) f
WHERE (f.enable = ? OR ? = '' ) AND (isadjust = ? OR ? = '') AND (source = IF( ? = 0 ,"自定义",IF (? = 1,"集团下发未调整",IF(? = 2,"集团下发有调整",IF(? = 3 ,"导入","")))) OR ? = '')
ORDER BY  f.sort ASC;


ALTER TABLE cowclass ADD COLUMN group_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '集团端id';
ALTER TABLE feedclass ADD COLUMN group_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '集团端id';