Commit ba9f93dd authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/master'

parents 3ff97718 97b63558
......@@ -15,6 +15,8 @@ public interface CategoryDao {
Category findByName(String name);
List<Category> queryByName(String name);
List<Category> querySelective(String id, String name, Integer page, Integer size, String sort, String order);
int updateById(Category category);
......
......@@ -13,6 +13,8 @@ public interface ItemDao {
List<Item> findList(CoinRequestDto coinRequestDto);
List<Item> findListNotDeleted(CoinRequestDto coinRequestDto);
List<Item> findListByPage(CoinRequestDto coinRequestDto);
PageInfo<Item> findByPage(CoinRequestDto coinRequestDto);
......
......@@ -58,6 +58,12 @@ public class CategoryDaoImpl implements CategoryDao {
return categoryMapper.selectOneByExample(example);
}
public List<Category> queryByName(String name) {
CategoryExample example = new CategoryExample();
example.or().andNameLike("%" + name + "%").andIsDeletedEqualTo(false);
return categoryMapper.selectByExample(example);
}
public List<Category> querySelective(String id, String name, Integer page, Integer size, String sort,
String order) {
CategoryExample example = new CategoryExample();
......
......@@ -52,6 +52,15 @@ public class ItemDaoImpl implements ItemDao {
return itemMapper.selectByExample(example);
}
@Override
public List<Item> findListNotDeleted(CoinRequestDto coinRequestDto) {
ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(coinRequestDto.getIds(), criteria::andIdIn);
criteria.andIsDeletedEqualTo(false);
return itemMapper.selectByExampleWithBLOBs(example);
}
@Override
public List<Item> findListByPage(CoinRequestDto coinRequestDto) {
ItemExample example = new ItemExample();
......
......@@ -29,7 +29,9 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/wx/user/loginByWx"
, "/wx/user/loginByMobile", "/wx/user/loginRegCaptcha", "/wx/user/updateRegCaptcha", "/wx/item/page", "/wx/item/info", "/wx/favorites/info", "/wx/favorites/itemList");
.excludePathPatterns("/*.html", "/**/*.html", "/**/*.css", "/**/*.js"
, "/wx/user/loginByWx", "/wx/user/loginByMobile", "/wx/user/loginRegCaptcha", "/wx/user/updateRegCaptcha"
, "/wx/item/page", "/wx/item/info", "/wx/item/findNames", "/wx/item/recommend"
, "/wx/favorites/info", "/wx/favorites/itemList");
}
}
......@@ -63,7 +63,7 @@ public class CategoryServiceImpl implements CategoryService {
i --;
}
List<CategoryResponseVo> responseVoList = categoryList.stream()
.map(this::toCategotyResongseVo).collect(Collectors.toList());
.map(this::toCategoryResponseVo).collect(Collectors.toList());
for (CategoryResponseVo vo : responseVoList) {
if (vo.getCid().equals(category.getId())) {
vo.setIsChosen(1);
......@@ -71,10 +71,30 @@ public class CategoryServiceImpl implements CategoryService {
}
return Result.success(convertVoList(responseVoList));
} catch (Exception e) {
return null;
logger.error("搜索分类失败", e);
return Result.failed("搜索分类失败");
}
}
@Override
public Result findNames(CategoryRequestDto dto) {
if (StringUtils.isBlank(dto.getName())) {
return Result.success(new ArrayList<>());
}
try {
return Result.success(categoryDao.queryByName(dto.getName()));
} catch (Exception e) {
logger.error("搜索分类失败", e);
return Result.failed("搜索分类失败");
}
}
/**
* 分类列表树形转换
*
* @param voList
* @return
*/
public List<CategoryResponseVo> convertVoList(List<CategoryResponseVo> voList) {
Map<Integer, CategoryResponseVo> menuMap = new HashMap<>();
CategoryResponseVo root = new CategoryResponseVo();
......@@ -102,7 +122,7 @@ public class CategoryServiceImpl implements CategoryService {
return root.getChild();
}
private CategoryResponseVo toCategotyResongseVo(Category category) {
private CategoryResponseVo toCategoryResponseVo(Category category) {
CategoryResponseVo vo = new CategoryResponseVo();
vo.setCid(category.getId());
vo.setPid(category.getPid());
......
package com.wwdz.ch.wx.interceptor;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.wx.service.UserTokenManager;
import com.wwdz.ch.wx.manager.UserTokenManager;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,10 +27,7 @@ public class LoginInterceptor implements HandlerInterceptor {
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
logger.info("-------------进入拦截器");
logger.info("请求头名称:" + JSON.toJSONString(request.getHeaderNames()));
String token = request.getHeader("Authorization");
logger.info("token的值是:" + token);
if (StringUtils.isNotBlank(token)) {
if (userTokenManager.checkLogin(token)) {
return true;
......
......@@ -4,7 +4,35 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.CategoryRequestDto;
public interface CategoryService {
/**
* 按level分页查询
*
* @param dto
* @return
*/
Result top(CategoryRequestDto dto);
/**
* 子分类列表查询
*
* @param dto
* @return
*/
Result child(CategoryRequestDto dto);
/**
* 按名称搜索精确匹配返回分类的树形列表
*
* @param dto
* @return
*/
Result find(CategoryRequestDto dto);
/**
* 按名称搜索模糊匹配返回分类列表
*
* @param dto
* @return
*/
Result findNames(CategoryRequestDto dto);
}
......@@ -68,4 +68,10 @@ public class WxCategoryController {
public Result find(@RequestBody CategoryRequestDto dto) {
return categoryService.find(dto);
}
@ApiOperation(value = "名称模糊联想")
@PostMapping(value = "/findNames")
public Result findNames(@RequestBody CategoryRequestDto dto) {
return categoryService.findNames(dto);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment