Browse Source

feat: 一键编辑标签下渠道重定向

CalciumIon 1 year ago
parent
commit
6e6e390f6f

+ 7 - 6
controller/channel.go

@@ -158,8 +158,8 @@ func SearchChannels(c *gin.Context) {
 	keyword := c.Query("keyword")
 	keyword := c.Query("keyword")
 	group := c.Query("group")
 	group := c.Query("group")
 	modelKeyword := c.Query("model")
 	modelKeyword := c.Query("model")
-	//idSort, _ := strconv.ParseBool(c.Query("id_sort"))
-	channels, err := model.SearchChannels(keyword, group, modelKeyword)
+	idSort, _ := strconv.ParseBool(c.Query("id_sort"))
+	channels, err := model.SearchChannels(keyword, group, modelKeyword, idSort)
 	if err != nil {
 	if err != nil {
 		c.JSON(http.StatusOK, gin.H{
 		c.JSON(http.StatusOK, gin.H{
 			"success": false,
 			"success": false,
@@ -294,10 +294,11 @@ func DeleteDisabledChannel(c *gin.Context) {
 }
 }
 
 
 type ChannelTag struct {
 type ChannelTag struct {
-	Tag      string  `json:"tag"`
-	NewTag   *string `json:"newTag"`
-	Priority *int64  `json:"priority"`
-	Weight   *uint   `json:"weight"`
+	Tag        string  `json:"tag"`
+	NewTag     *string `json:"new_tag"`
+	Priority   *int64  `json:"priority"`
+	Weight     *uint   `json:"weight"`
+	MapMapping *string `json:"map_mapping"`
 }
 }
 
 
 func DisableTagChannels(c *gin.Context) {
 func DisableTagChannels(c *gin.Context) {

+ 1 - 1
web/src/components/ChannelsTable.js

@@ -691,7 +691,7 @@ const ChannelsTable = () => {
     }
     }
     setSearching(true);
     setSearching(true);
     const res = await API.get(
     const res = await API.get(
-      `/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}`
+      `/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}&id_sort=${idSort}`
     );
     );
     const { success, message, data } = res.data;
     const { success, message, data } = res.data;
     if (success) {
     if (success) {

+ 7 - 4
web/src/pages/Channel/EditTagModal.js

@@ -8,7 +8,8 @@ const EditTagModal = (props) => {
   const [loading, setLoading] = useState(false);
   const [loading, setLoading] = useState(false);
   const originInputs = {
   const originInputs = {
     tag: '',
     tag: '',
-    newTag: null,
+    new_tag: null,
+    model_mapping: null,
   }
   }
   const [inputs, setInputs] = useState(originInputs);
   const [inputs, setInputs] = useState(originInputs);
 
 
@@ -18,11 +19,13 @@ const EditTagModal = (props) => {
     let data = {
     let data = {
       tag: tag,
       tag: tag,
     }
     }
-    let shouldSave = true;
     if (inputs.newTag === tag) {
     if (inputs.newTag === tag) {
       setLoading(false);
       setLoading(false);
       return;
       return;
     }
     }
+    if (inputs.model_mapping !== null) {
+      data.model_mapping = inputs.model
+    }
     data.newTag = inputs.newTag;
     data.newTag = inputs.newTag;
     if (data.newTag === '') {
     if (data.newTag === '') {
       Modal.confirm({
       Modal.confirm({
@@ -80,8 +83,8 @@ const EditTagModal = (props) => {
         <TextInput
         <TextInput
           label="新标签(留空则解散标签,不会删除标签下的渠道)"
           label="新标签(留空则解散标签,不会删除标签下的渠道)"
           name="newTag"
           name="newTag"
-          value={inputs.newTag}
-          onChange={(value) => setInputs({ ...inputs, newTag: value })}
+          value={inputs.new_tag}
+          onChange={(value) => setInputs({ ...inputs, new_tag: value })}
           placeholder="请输入新标签"
           placeholder="请输入新标签"
         />
         />
       </Spin>
       </Spin>