增加热门搜索
This commit is contained in:
parent
c006488a4a
commit
c6534f3ab4
|
|
@ -40,8 +40,6 @@ public class TabbarController {
|
|||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody Map<String, Object> params) {
|
||||
// System.out.println( ArrayUtil.objectToListAsStr(params.get("list")));
|
||||
|
||||
iDecorateTabbarService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.mdd.admin.service.setting.ISettingSearchService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 热搜设置
|
||||
|
|
@ -9,4 +13,35 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RestController("settingSearchController")
|
||||
@RequestMapping("api/setting/search")
|
||||
public class SearchController {
|
||||
|
||||
@Resource
|
||||
ISettingSearchService iSettingSearchService;
|
||||
|
||||
/**
|
||||
* 热门搜索详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail() {
|
||||
Map<String, Object> map = iSettingSearchService.detail();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 热门搜索保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody Map<String, Object> params) {
|
||||
iSettingSearchService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.mdd.admin.controller.setting;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.mdd.admin.service.setting.ISettingUserService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户设置管理
|
||||
|
|
@ -12,14 +14,32 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RequestMapping("api/setting/user")
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
ISettingUserService iSettingUserService;
|
||||
|
||||
/**
|
||||
* 用户设置详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail() {
|
||||
return null;
|
||||
Map<String, Object> map = iSettingUserService.detail();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户设置保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save() {
|
||||
return null;
|
||||
public Object save(@RequestBody Map<String, String> params) {
|
||||
iSettingUserService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,27 @@
|
|||
package com.mdd.admin.service.setting;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 热门搜索服务接口类
|
||||
*/
|
||||
public interface ISettingSearchService {
|
||||
|
||||
/**
|
||||
* 热门搜索详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> detail();
|
||||
|
||||
/**
|
||||
* 热门搜索新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void save(Map<String, Object> params);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,26 @@
|
|||
package com.mdd.admin.service.setting;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户设置服务接口类
|
||||
*/
|
||||
public interface ISettingUserService {
|
||||
|
||||
/**
|
||||
* 用户设置详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
Map<String, Object> detail();
|
||||
|
||||
/**
|
||||
* 用户设置保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void save(Map<String, String> params);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package com.mdd.admin.service.setting.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.service.setting.ISettingSearchService;
|
||||
import com.mdd.common.entity.setting.HotSearch;
|
||||
import com.mdd.common.mapper.setting.HotSearchMapper;
|
||||
import com.mdd.common.utils.ArrayUtil;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 热门搜索服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SettingSearchServiceImpl implements ISettingSearchService {
|
||||
|
||||
@Resource
|
||||
HotSearchMapper hotSearchMapper;
|
||||
|
||||
/**
|
||||
* 热门搜索详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> detail() {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
|
||||
Integer isHotSearch = Integer.parseInt(ConfigUtil.get("search", "isHotSearch", "0"));
|
||||
response.put("isHotSearch", isHotSearch);
|
||||
|
||||
List<HotSearch> list = hotSearchMapper.selectList(new QueryWrapper<HotSearch>().orderByDesc("sort"));
|
||||
response.put("list", list);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 热门搜索新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void save(Map<String, Object> params) {
|
||||
String isHotSearch = params.getOrDefault("isHotSearch", "0").toString();
|
||||
ConfigUtil.set("search", "isHotSearch", isHotSearch);
|
||||
|
||||
hotSearchMapper.delete(new QueryWrapper<HotSearch>().ge("id", 0));
|
||||
for (String obj : ArrayUtil.objectToListAsStr(params.get("list"))) {
|
||||
Map<String, String> item = ToolsUtil.jsonToMap(obj);
|
||||
HotSearch hotSearch = new HotSearch();
|
||||
hotSearch.setName(item.getOrDefault("name", ""));
|
||||
hotSearch.setSort(Integer.parseInt(item.getOrDefault("sort", "0")));
|
||||
hotSearchMapper.insert(hotSearch);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.mdd.admin.service.setting.impl;
|
||||
|
||||
import com.mdd.admin.service.setting.ISettingUserService;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.common.utils.UrlUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户设置服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class SettingUserServiceImpl implements ISettingUserService {
|
||||
|
||||
/**
|
||||
* 用户设置详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> detail() {
|
||||
String defaultAvatar = ConfigUtil.get("user", "defaultAvatar", "");
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("defaultAvatar", UrlUtil.toAbsoluteUrl(defaultAvatar));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户设置保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
public void save(Map<String, String> params) {
|
||||
ConfigUtil.set("user", "defaultAvatar", UrlUtil.toRelativeUrl(params.getOrDefault("defaultAvatar", "")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.mdd.common.entity.setting;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 热门搜索实体
|
||||
*/
|
||||
@Data
|
||||
public class HotSearch implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
private Integer id; // 主键
|
||||
private String name; // 关键词
|
||||
private Integer sort; // 排序号
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.mdd.common.mapper.setting;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.setting.HotSearch;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 热门搜索Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface HotSearchMapper extends IBaseMapper<HotSearch> {
|
||||
}
|
||||
Loading…
Reference in New Issue