处理golang map无序导致的bug
This commit is contained in:
		
							parent
							
								
									206e60fa17
								
							
						
					
					
						commit
						22ed7ab185
					
				@ -68,11 +68,14 @@ func (this *UserEventDetail) GetList() (interface{}, error) {
 | 
			
		||||
 | 
			
		||||
	res := map[string][]map[string]interface{}{}
 | 
			
		||||
 | 
			
		||||
	tmp := []string{}
 | 
			
		||||
 | 
			
		||||
	for index := range list {
 | 
			
		||||
		if _, ok := res[list[index]["date_year"].(string)]; !ok {
 | 
			
		||||
			m := []map[string]interface{}{}
 | 
			
		||||
			m = append(m, list[index])
 | 
			
		||||
			res[list[index]["date_year"].(string)] = m
 | 
			
		||||
			tmp = append(tmp, list[index]["date_year"].(string))
 | 
			
		||||
		} else {
 | 
			
		||||
			m := res[list[index]["date_year"].(string)]
 | 
			
		||||
			m = append(m, list[index])
 | 
			
		||||
@ -80,7 +83,15 @@ func (this *UserEventDetail) GetList() (interface{}, error) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return map[string]interface{}{"list": res}, nil
 | 
			
		||||
	resList := []map[string][]map[string]interface{}{}
 | 
			
		||||
 | 
			
		||||
	for index:= range tmp{
 | 
			
		||||
		val := res[tmp[index]]
 | 
			
		||||
		m := map[string][]map[string]interface{}{tmp[index]:val}
 | 
			
		||||
		resList = append(resList, m)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return map[string]interface{}{"list": resList}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *UserEventDetail) GetExecSql() (SQL string, allArgs []interface{}, err error) {
 | 
			
		||||
 | 
			
		||||
@ -263,6 +263,15 @@ export default {
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if(res.data.list != null){
 | 
			
		||||
        let tmp = {}
 | 
			
		||||
        for(let v of res.data.list){
 | 
			
		||||
          let key = Object.keys(v)[0]
 | 
			
		||||
          tmp[key] = v[key]
 | 
			
		||||
        }
 | 
			
		||||
        res.data.list = tmp
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (res.data.list == null || Object.keys(res.data.list).length == 0) {
 | 
			
		||||
        res.data.list = {}
 | 
			
		||||
        this.$message({
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user