(c *gin.Context)
| 825 | } |
| 826 | |
| 827 | func GetTagModels(c *gin.Context) { |
| 828 | tag := c.Query("tag") |
| 829 | if tag == "" { |
| 830 | c.JSON(http.StatusBadRequest, gin.H{ |
| 831 | "success": false, |
| 832 | "message": "tag不能为空", |
| 833 | }) |
| 834 | return |
| 835 | } |
| 836 | |
| 837 | channels, err := model.GetChannelsByTag(tag, false) // Assuming false for idSort is fine here |
| 838 | if err != nil { |
| 839 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 840 | "success": false, |
| 841 | "message": err.Error(), |
| 842 | }) |
| 843 | return |
| 844 | } |
| 845 | |
| 846 | var longestModels string |
| 847 | maxLength := 0 |
| 848 | |
| 849 | // Find the longest models string among all channels with the given tag |
| 850 | for _, channel := range channels { |
| 851 | if channel.Models != "" { |
| 852 | currentModels := strings.Split(channel.Models, ",") |
| 853 | if len(currentModels) > maxLength { |
| 854 | maxLength = len(currentModels) |
| 855 | longestModels = channel.Models |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | c.JSON(http.StatusOK, gin.H{ |
| 861 | "success": true, |
| 862 | "message": "", |
| 863 | "data": longestModels, |
| 864 | }) |
| 865 | return |
| 866 | } |
| 867 | |
| 868 | // CopyChannel handles cloning an existing channel with its key. |
| 869 | // POST /api/channel/copy/:id |
nothing calls this directly
no test coverage detected