Commit 8d593906 authored by shiyu's avatar shiyu

钱币列表

parent c3327171
...@@ -72,6 +72,12 @@ ...@@ -72,6 +72,12 @@
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>4.5.0</version> <version>4.5.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.2.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -13,8 +13,14 @@ import org.apache.shiro.spring.web.ShiroFilterFactoryBean; ...@@ -13,8 +13,14 @@ import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.filter.authc.AuthenticationFilter; import org.apache.shiro.web.filter.authc.AuthenticationFilter;
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter; import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.crazycake.shiro.IRedisManager;
import org.crazycake.shiro.RedisCacheManager;
import org.crazycake.shiro.RedisManager;
import org.crazycake.shiro.RedisSessionDAO;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -34,11 +40,64 @@ import javax.servlet.http.HttpServletResponse; ...@@ -34,11 +40,64 @@ import javax.servlet.http.HttpServletResponse;
@Configuration @Configuration
public class ShiroConfig { public class ShiroConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private String port;
@Value("${spring.redis.password}")
private String password;
@Bean @Bean
public Realm realm() { public Realm realm() {
return new AdminAuthorizingRealm(); // return new AdminAuthorizingRealm();
AdminAuthorizingRealm userRealm = new AdminAuthorizingRealm();
// userRealm.setCredentialsMatcher(hashedCredentialsMatcher());
userRealm.setCachingEnabled(true);
//启用身份验证缓存,即缓存AuthenticationInfo信息,默认false
userRealm.setAuthenticationCachingEnabled(false);
//缓存AuthenticationInfo信息的缓存名称
userRealm.setAuthenticationCacheName("authenticationCache");
//启用授权缓存,即缓存AuthorizationInfo信息,默认false
userRealm.setAuthorizationCachingEnabled(true);
//缓存AuthorizationInfo信息的缓存名称
userRealm.setAuthorizationCacheName("authorizationCache");
//设置缓存管理器
userRealm.setCacheManager(cacheManager());
return userRealm;
}
//配置redisSessionDAO
@Bean
public RedisSessionDAO redisSessionDAO() {
RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
redisSessionDAO.setRedisManager(redisManager());
return redisSessionDAO;
} }
//配置cacheManager
public RedisCacheManager cacheManager() {
RedisCacheManager redisCacheManager = new RedisCacheManager();
redisCacheManager.setRedisManager(redisManager());
redisCacheManager.setExpire(60*60*12);
return redisCacheManager;
}
//配置redisManager
public IRedisManager redisManager() {
RedisManager redisManager = new RedisManager();
String address = host + ":" + port;
redisManager.setHost(address);
redisManager.setPassword(password);
return redisManager;
}
@Bean(name="shiroFilterFactoryBean") @Bean(name="shiroFilterFactoryBean")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
...@@ -64,19 +123,49 @@ public class ShiroConfig { ...@@ -64,19 +123,49 @@ public class ShiroConfig {
return shiroFilterFactoryBean; return shiroFilterFactoryBean;
} }
@Bean
/**
* 设置会话管理器
*
* @return
*/
@Bean("sessionManager")
public SessionManager sessionManager() {
AdminWebSessionManager sessionManager = new AdminWebSessionManager();
sessionManager.setSessionDAO(redisSessionDAO());
sessionManager.setCacheManager(cacheManager());
return sessionManager;
}
/*@Bean
public SessionManager sessionManager() { public SessionManager sessionManager() {
AdminWebSessionManager mySessionManager = new AdminWebSessionManager(); AdminWebSessionManager mySessionManager = new AdminWebSessionManager();
return mySessionManager; return mySessionManager;
} }
*/
/**
* 设置安全管理器
*
* @param sessionManager
* @return
*/
@Bean("securityManager")
public DefaultWebSecurityManager securityManager(SessionManager sessionManager) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm());
securityManager.setSessionManager(sessionManager);
return securityManager;
}
@Bean
/*@Bean
public DefaultWebSecurityManager securityManager() { public DefaultWebSecurityManager securityManager() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm()); securityManager.setRealm(realm());
securityManager.setSessionManager(sessionManager()); securityManager.setSessionManager(sessionManager());
return securityManager; return securityManager;
} }*/
@Bean @Bean
......
...@@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.wwdz.ch.admin.util.AdminResponseCode; import com.wwdz.ch.admin.util.AdminResponseCode;
import com.wwdz.ch.admin.util.AdminResponseUtil; import com.wwdz.ch.admin.util.AdminResponseUtil;
...@@ -40,7 +39,6 @@ import com.wwdz.ch.admin.util.PermissionUtil; ...@@ -40,7 +39,6 @@ import com.wwdz.ch.admin.util.PermissionUtil;
import com.wwdz.ch.admin.util.VerifyCodeUtils; import com.wwdz.ch.admin.util.VerifyCodeUtils;
import com.wwdz.ch.core.captcha.CaptchaCodeManager; import com.wwdz.ch.core.captcha.CaptchaCodeManager;
import com.wwdz.ch.core.util.Base64; import com.wwdz.ch.core.util.Base64;
import com.wwdz.ch.core.util.JacksonUtil;
import com.wwdz.ch.core.util.ResponseUtil; import com.wwdz.ch.core.util.ResponseUtil;
import com.wwdz.ch.core.util.UUID; import com.wwdz.ch.core.util.UUID;
import com.wwdz.ch.db.domain.Admin; import com.wwdz.ch.db.domain.Admin;
...@@ -119,23 +117,28 @@ public class AdminAuthController { ...@@ -119,23 +117,28 @@ public class AdminAuthController {
@RequiresAuthentication @RequiresAuthentication
@GetMapping("/info") @GetMapping("/info")
public Object info() { public Object info() {
Subject currentUser = SecurityUtils.getSubject(); try {
Admin admin = (Admin) currentUser.getPrincipal(); Subject currentUser = SecurityUtils.getSubject();
Admin admin = (Admin) currentUser.getPrincipal();
Map<String, Object> data = new HashMap<>();
data.put("name", admin.getUsername()); Map<String, Object> data = new HashMap<>();
data.put("avatar", admin.getAvatar()); data.put("name", admin.getUsername());
data.put("avatar", admin.getAvatar());
Integer[] roleIds = admin.getRoleIds();
Set<String> roles = roleService.queryByIds(roleIds); Integer[] roleIds = admin.getRoleIds();
Set<String> permissions = permissionService.queryByRoleIds(roleIds); Set<String> roles = roleService.queryByIds(roleIds);
data.put("roles", roles); Set<String> permissions = permissionService.queryByRoleIds(roleIds);
// NOTE data.put("roles", roles);
// 这里需要转换perms结构,因为对于前端而已API形式的权限更容易理解 // NOTE
data.put("perms", toAPI(permissions)); // 这里需要转换perms结构,因为对于前端而已API形式的权限更容易理解
data.put("perms", toAPI(permissions));
logger.info("【请求结束】系统管理->用户信息获取,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data); logger.info("【请求结束】系统管理->用户信息获取,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
} catch (Exception e) {
logger.error("用户信息获取 error{}", e);
}
return ResponseUtil.fail();
} }
@Autowired @Autowired
......
...@@ -14,7 +14,7 @@ import com.wwdz.ch.admin.service.AdminGoodsService; ...@@ -14,7 +14,7 @@ import com.wwdz.ch.admin.service.AdminGoodsService;
import com.wwdz.ch.admin.util.AuthSupport; import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.admin.util.CatVo; import com.wwdz.ch.admin.util.CatVo;
import com.wwdz.ch.db.domain.Category; import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.service.CategoryService; import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.util.CollectionUtils; import org.apache.shiro.util.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -43,7 +43,7 @@ public class AdminGoodsController { ...@@ -43,7 +43,7 @@ public class AdminGoodsController {
private AdminGoodsService adminGoodsService; private AdminGoodsService adminGoodsService;
@Autowired @Autowired
private CategoryService categoryService; private CategoryManagerImpl categoryManager;
@Autowired @Autowired
private AdminDataAuthService adminDataAuthService; private AdminDataAuthService adminDataAuthService;
...@@ -139,7 +139,7 @@ public class AdminGoodsController { ...@@ -139,7 +139,7 @@ public class AdminGoodsController {
} }
private List<CatVo> getChildCat(Integer parentId) { private List<CatVo> getChildCat(Integer parentId) {
List<Category> rawChildren = categoryService.queryByPid(parentId); List<Category> rawChildren = categoryManager.queryByPid(parentId);
if (CollectionUtils.isEmpty(rawChildren)) { if (CollectionUtils.isEmpty(rawChildren)) {
return null; return null;
} }
......
...@@ -13,7 +13,7 @@ import com.wwdz.ch.admin.entity.vo.CategoryVo; ...@@ -13,7 +13,7 @@ import com.wwdz.ch.admin.entity.vo.CategoryVo;
import com.wwdz.ch.admin.util.AuthSupport; import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.type.ListResult; import com.wwdz.ch.core.type.ListResult;
import com.wwdz.ch.db.domain.Category; import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.service.CategoryService; import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -40,7 +40,7 @@ public class CategoryController { ...@@ -40,7 +40,7 @@ public class CategoryController {
private static final Logger logger = LoggerFactory.getLogger(CategoryController.class); private static final Logger logger = LoggerFactory.getLogger(CategoryController.class);
@Autowired @Autowired
private CategoryService categoryService; private CategoryManagerImpl categoryManager;
@RequiresPermissions("admin:category:list") @RequiresPermissions("admin:category:list")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询") @RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询")
...@@ -51,7 +51,7 @@ public class CategoryController { ...@@ -51,7 +51,7 @@ public class CategoryController {
@Order @RequestParam(defaultValue = "desc") String order) { @Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->查询,请求参数:name:{},page:{}", name, page); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->查询,请求参数:name:{},page:{}", name, page);
List<Category> collectList = categoryService.querySelective(id, name, page, limit, sort, order); List<Category> collectList = categoryManager.querySelective(id, name, page, limit, sort, order);
List<CategoryVo> data = collectList.parallelStream().map(a -> new CategoryVo(a)).collect(Collectors.toList()); List<CategoryVo> data = collectList.parallelStream().map(a -> new CategoryVo(a)).collect(Collectors.toList());
logger.info("【请求结束】商场管理->类目管理->查询:total:{}", JSONObject.toJSONString(data)); logger.info("【请求结束】商场管理->类目管理->查询:total:{}", JSONObject.toJSONString(data));
return new ListResult<>(data, data.size()); return new ListResult<>(data, data.size());
...@@ -65,12 +65,12 @@ public class CategoryController { ...@@ -65,12 +65,12 @@ public class CategoryController {
/** /**
* 获取最大深度 * 获取最大深度
*/ */
Integer maxLevel = categoryService.getMaxCagtegoryLevel(); Integer maxLevel = categoryManager.getMaxCagtegoryLevel();
Integer level = maxLevel; Integer level = maxLevel;
Map<Integer, List<CategoryVo>> parentCategoryMap = new HashMap<>(); Map<Integer, List<CategoryVo>> parentCategoryMap = new HashMap<>();
while (level > 0) { while (level > 0) {
List<Category> categoryList = categoryService.queryByLevel(level, 0, 10000); List<Category> categoryList = categoryManager.queryByLevel(level, 0, 10000);
for (Category c : categoryList) { for (Category c : categoryList) {
Integer parentId = c.getPid(); Integer parentId = c.getPid();
List<CategoryVo> children = parentCategoryMap.get(parentId); List<CategoryVo> children = parentCategoryMap.get(parentId);
...@@ -97,15 +97,15 @@ public class CategoryController { ...@@ -97,15 +97,15 @@ public class CategoryController {
public Object getSubCategory(@NotNull Integer id) { public Object getSubCategory(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 查询根据类目ID查询子类目"); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 查询根据类目ID查询子类目");
List<CategoryVo> categoryVoList = new ArrayList<>(); List<CategoryVo> categoryVoList = new ArrayList<>();
List<Category> categoryList = categoryService.queryByPid(id); List<Category> categoryList = categoryManager.queryByPid(id);
for (Category c : categoryList) { for (Category c : categoryList) {
CategoryVo categoryVo = new CategoryVo(c); CategoryVo categoryVo = new CategoryVo(c);
categoryVo.setCategoryPath(StringUtils.join(categoryService.getCategoryPath(c.getId()), ">")); categoryVo.setCategoryPath(StringUtils.join(categoryManager.getCategoryPath(c.getId()), ">"));
categoryVoList.add(new CategoryVo(c)); categoryVoList.add(new CategoryVo(c));
} }
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("categoryList", categoryVoList); data.put("categoryList", categoryVoList);
data.put("categoryPath", categoryService.getCategoryPath(id)); data.put("categoryPath", categoryManager.getCategoryPath(id));
logger.info("【请求结束】查询根据类目ID查询子类目 : {}", JSONObject.toJSONString(data)); logger.info("【请求结束】查询根据类目ID查询子类目 : {}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data); return ResponseUtil.ok(data);
} }
...@@ -123,11 +123,11 @@ public class CategoryController { ...@@ -123,11 +123,11 @@ public class CategoryController {
Category pCat = new Category(); Category pCat = new Category();
pCat.setId(pid); pCat.setId(pid);
pCat.setIsLeaf(false); pCat.setIsLeaf(false);
categoryService.updateById(pCat); categoryManager.updateById(pCat);
} else { } else {
category.setIsLeaf(true); category.setIsLeaf(true);
} }
categoryService.add(category); categoryManager.add(category);
logger.info("【请求结束】商场管理->类目管理->添加:响应结果:{}", JSONObject.toJSONString(category)); logger.info("【请求结束】商场管理->类目管理->添加:响应结果:{}", JSONObject.toJSONString(category));
return ResponseUtil.ok(category); return ResponseUtil.ok(category);
...@@ -139,7 +139,7 @@ public class CategoryController { ...@@ -139,7 +139,7 @@ public class CategoryController {
public Object read(@NotNull Integer id) { public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->详情,请求参数,id:{}", id); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->详情,请求参数,id:{}", id);
Category category = categoryService.findById(id); Category category = categoryManager.findById(id);
logger.info("【请求结束】商场管理->类目管理->详情:响应结果:{}", JSONObject.toJSONString(category)); logger.info("【请求结束】商场管理->类目管理->详情:响应结果:{}", JSONObject.toJSONString(category));
return ResponseUtil.ok(category); return ResponseUtil.ok(category);
...@@ -152,7 +152,7 @@ public class CategoryController { ...@@ -152,7 +152,7 @@ public class CategoryController {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->编辑,请求参数:{}", JSONObject.toJSONString(categoryVo)); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->编辑,请求参数:{}", JSONObject.toJSONString(categoryVo));
if (categoryService.updateById(categoryVo.toDo()) == 0) { if (categoryManager.updateById(categoryVo.toDo()) == 0) {
logger.error("商场管理->类目管理->编辑 失败,更新数据失败!"); logger.error("商场管理->类目管理->编辑 失败,更新数据失败!");
return ResponseUtil.updatedDataFailed(); return ResponseUtil.updatedDataFailed();
} }
...@@ -171,7 +171,7 @@ public class CategoryController { ...@@ -171,7 +171,7 @@ public class CategoryController {
if (id == null) { if (id == null) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
categoryService.deleteById(id); categoryManager.deleteById(id);
logger.info("【请求结束】商场管理->类目管理->删除:响应结果:{}", "成功!"); logger.info("【请求结束】商场管理->类目管理->删除:响应结果:{}", "成功!");
return ResponseUtil.ok(); return ResponseUtil.ok();
...@@ -183,7 +183,7 @@ public class CategoryController { ...@@ -183,7 +183,7 @@ public class CategoryController {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->一级分类目录查询"); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->一级分类目录查询");
// 所有一级分类目录 // 所有一级分类目录
List<Category> l1CatList = categoryService.queryByLevel(1, 1 ,100); List<Category> l1CatList = categoryManager.queryByLevel(1, 1 ,100);
List<Map<String, Object>> data = new ArrayList<>(l1CatList.size()); List<Map<String, Object>> data = new ArrayList<>(l1CatList.size());
for (Category category : l1CatList) { for (Category category : l1CatList) {
Map<String, Object> d = new HashMap<>(2); Map<String, Object> d = new HashMap<>(2);
......
...@@ -4,6 +4,7 @@ import com.xxdxxs.entity.Entity; ...@@ -4,6 +4,7 @@ import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
public class CoinVo implements Entity { public class CoinVo implements Entity {
...@@ -114,4 +115,11 @@ public class CoinVo implements Entity { ...@@ -114,4 +115,11 @@ public class CoinVo implements Entity {
* 质量(重量) * 质量(重量)
*/ */
private String weight; private String weight;
/**
* 对应的分类
*
*/
private List<Integer> categoryIds;
} }
...@@ -7,9 +7,11 @@ import com.wwdz.ch.admin.util.AuthSupport; ...@@ -7,9 +7,11 @@ import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.consts.CommonEnum; import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.storage.QiniuStorage; import com.wwdz.ch.core.storage.QiniuStorage;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.domain.Item; import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.OperateLog; import com.wwdz.ch.db.domain.OperateLog;
import com.wwdz.ch.db.dto.request.CoinRequestDto; import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.manager.CategoryManager;
import com.wwdz.ch.db.manager.ItemManager; import com.wwdz.ch.db.manager.ItemManager;
import com.xxdxxs.utils.EntityMapper; import com.xxdxxs.utils.EntityMapper;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
...@@ -38,6 +40,9 @@ public class ItemServiceImpl implements ItemService { ...@@ -38,6 +40,9 @@ public class ItemServiceImpl implements ItemService {
@Autowired @Autowired
OperateLogService operateLogService; OperateLogService operateLogService;
@Autowired
CategoryManager categoryManager;
@Override @Override
public List<CoinVo> findList(CoinRequestDto coinRequestDto) { public List<CoinVo> findList(CoinRequestDto coinRequestDto) {
try { try {
...@@ -65,6 +70,24 @@ public class ItemServiceImpl implements ItemService { ...@@ -65,6 +70,24 @@ public class ItemServiceImpl implements ItemService {
item = itemManager.findOne(coinRequestDto); item = itemManager.findOne(coinRequestDto);
} }
CoinVo coinVo = convertEntity(item); CoinVo coinVo = convertEntity(item);
//用于展示商品归属的类目(页面级联下拉控件数据展示)
Integer categoryId = item.getCid();
Category category = categoryManager.findById(categoryId);
List<Integer> categoryIds = new ArrayList<>();
if (null != category) {
categoryIds.add(0, category.getId());
Integer pid = category.getPid();
while (pid != 0) {
categoryIds.add(0, pid);
Category pCategory = categoryManager.findById(pid);
if (null != pCategory) {
pid = pCategory.getPid();
} else {
break;
}
}
}
coinVo.setCategoryIds(categoryIds);
return Result.success(coinVo); return Result.success(coinVo);
} catch (Exception e) { } catch (Exception e) {
logger.error("钱币设置查询明细 error : {}", e); logger.error("钱币设置查询明细 error : {}", e);
......
...@@ -5,7 +5,8 @@ import java.util.stream.Collectors; ...@@ -5,7 +5,8 @@ import java.util.stream.Collectors;
import com.wwdz.ch.admin.entity.vo.ItemVo; import com.wwdz.ch.admin.entity.vo.ItemVo;
import com.wwdz.ch.db.domain.*; import com.wwdz.ch.db.domain.*;
import com.wwdz.ch.db.service.*; import com.wwdz.ch.db.manager.CategoryManager;
import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import com.wwdz.ch.db.service.ItemService; import com.wwdz.ch.db.service.ItemService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -27,7 +28,7 @@ public class AdminGoodsService { ...@@ -27,7 +28,7 @@ public class AdminGoodsService {
private ItemService itemService; private ItemService itemService;
@Autowired @Autowired
private CategoryService categoryService; private CategoryManager categoryManager;
@Autowired @Autowired
private QCodeService qCodeService; private QCodeService qCodeService;
...@@ -57,7 +58,7 @@ public class AdminGoodsService { ...@@ -57,7 +58,7 @@ public class AdminGoodsService {
// 分类可以不设置,如果设置则需要验证分类存在 // 分类可以不设置,如果设置则需要验证分类存在
Integer categoryId = item.getCid(); Integer categoryId = item.getCid();
if (categoryId != null && categoryId != 0) { if (categoryId != null && categoryId != 0) {
if (categoryService.findById(categoryId) == null) { if (categoryManager.findById(categoryId) == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
} }
...@@ -146,14 +147,14 @@ public class AdminGoodsService { ...@@ -146,14 +147,14 @@ public class AdminGoodsService {
//用于展示商品归属的类目(页面级联下拉控件数据展示) //用于展示商品归属的类目(页面级联下拉控件数据展示)
Integer categoryId = item.getCid(); Integer categoryId = item.getCid();
Category category = categoryService.findById(categoryId); Category category = categoryManager.findById(categoryId);
List<Integer> categoryIds = new ArrayList<>(); List<Integer> categoryIds = new ArrayList<>();
if (null != category) { if (null != category) {
categoryIds.add(0, category.getId()); categoryIds.add(0, category.getId());
Integer pid = category.getPid(); Integer pid = category.getPid();
while (pid != 0) { while (pid != 0) {
categoryIds.add(0, pid); categoryIds.add(0, pid);
Category pCategory = categoryService.findById(pid); Category pCategory = categoryManager.findById(pid);
if (null != pCategory) { if (null != pCategory) {
pid = pCategory.getPid(); pid = pCategory.getPid();
} else { } else {
......
package com.wwdz.ch.db.domain; package com.wwdz.ch.db.domain;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
public class Admin { @Data
public class Admin implements Entity {
/** /**
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database table dts_admin * This field corresponds to the database table dts_admin
......
package com.wwdz.ch.db.manager;
import com.github.pagehelper.PageHelper;
import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.domain.CategoryExample;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public interface CategoryManager {
List<Category> queryByLevel(Integer level, Integer offset, Integer limit);
List<Category> queryByPid(Integer pid);
Category findById(Integer id);
List<Category> querySelective(String id, String name, Integer page, Integer size, String sort, String order);
int updateById(Category category);
void deleteById(Integer id);
void add(Category category);
Integer getMaxCagtegoryLevel();
List<String> getCategoryPath(Integer id);
}
package com.wwdz.ch.db.service; package com.wwdz.ch.db.manager.impl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.wwdz.ch.db.dao.CategoryMapper; import com.wwdz.ch.db.dao.CategoryMapper;
import com.wwdz.ch.db.domain.Category; import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.domain.CategoryExample; import com.wwdz.ch.db.domain.CategoryExample;
import com.wwdz.ch.db.manager.CategoryManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -14,7 +15,7 @@ import java.util.Collections; ...@@ -14,7 +15,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
@Service @Service
public class CategoryService { public class CategoryManagerImpl implements CategoryManager {
@Resource @Resource
private CategoryMapper categoryMapper; private CategoryMapper categoryMapper;
......
...@@ -8,7 +8,7 @@ import java.util.Map; ...@@ -8,7 +8,7 @@ import java.util.Map;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import com.wwdz.ch.db.domain.Category; import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.service.CategoryService; import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import com.wwdz.ch.wx.service.HomeCacheManager; import com.wwdz.ch.wx.service.HomeCacheManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -31,7 +31,7 @@ public class WxCatalogController { ...@@ -31,7 +31,7 @@ public class WxCatalogController {
private static final Logger logger = LoggerFactory.getLogger(WxCatalogController.class); private static final Logger logger = LoggerFactory.getLogger(WxCatalogController.class);
@Autowired @Autowired
private CategoryService categoryService; private CategoryManagerImpl categoryManager;
/** /**
* 分类详情 * 分类详情
...@@ -49,10 +49,10 @@ public class WxCatalogController { ...@@ -49,10 +49,10 @@ public class WxCatalogController {
Category currentCategory = null; Category currentCategory = null;
// 所有一级分类目录 // 所有一级分类目录
if (null == id || 0 == id) { if (null == id || 0 == id) {
l1CatList = categoryService.queryByLevel(1, 1, 100); l1CatList = categoryManager.queryByLevel(1, 1, 100);
currentCategory = l1CatList.get(0); currentCategory = l1CatList.get(0);
} else { } else {
currentCategory = categoryService.findById(id); currentCategory = categoryManager.findById(id);
l1CatList = new ArrayList<>(); l1CatList = new ArrayList<>();
l1CatList.add(currentCategory); l1CatList.add(currentCategory);
} }
...@@ -60,7 +60,7 @@ public class WxCatalogController { ...@@ -60,7 +60,7 @@ public class WxCatalogController {
// 当前一级分类目录对应的二级分类目录 // 当前一级分类目录对应的二级分类目录
List<Category> currentSubCategory = null; List<Category> currentSubCategory = null;
if (null != currentCategory) { if (null != currentCategory) {
currentSubCategory = categoryService.queryByPid(currentCategory.getId()); currentSubCategory = categoryManager.queryByPid(currentCategory.getId());
} }
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
...@@ -86,13 +86,13 @@ public class WxCatalogController { ...@@ -86,13 +86,13 @@ public class WxCatalogController {
} }
// 所有一级分类目录 // 所有一级分类目录
List<Category> l1CatList = categoryService.queryByLevel(1, 1, 100); List<Category> l1CatList = categoryManager.queryByLevel(1, 1, 100);
// 所有子分类列表 // 所有子分类列表
Map<Integer, List<Category>> allList = new HashMap<>(); Map<Integer, List<Category>> allList = new HashMap<>();
List<Category> sub; List<Category> sub;
for (Category category : l1CatList) { for (Category category : l1CatList) {
sub = categoryService.queryByPid(category.getId()); sub = categoryManager.queryByPid(category.getId());
allList.put(category.getId(), sub); allList.put(category.getId(), sub);
} }
...@@ -102,7 +102,7 @@ public class WxCatalogController { ...@@ -102,7 +102,7 @@ public class WxCatalogController {
// 当前一级分类目录对应的二级分类目录 // 当前一级分类目录对应的二级分类目录
List<Category> currentSubCategory = null; List<Category> currentSubCategory = null;
if (null != currentCategory) { if (null != currentCategory) {
currentSubCategory = categoryService.queryByPid(currentCategory.getId()); currentSubCategory = categoryManager.queryByPid(currentCategory.getId());
} }
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
...@@ -135,8 +135,8 @@ public class WxCatalogController { ...@@ -135,8 +135,8 @@ public class WxCatalogController {
logger.info("【请求开始】当前分类栏目查询,id:{}", id); logger.info("【请求开始】当前分类栏目查询,id:{}", id);
// 当前分类 // 当前分类
Category currentCategory = categoryService.findById(id); Category currentCategory = categoryManager.findById(id);
List<Category> currentSubCategory = categoryService.queryByPid(currentCategory.getId()); List<Category> currentSubCategory = categoryManager.queryByPid(currentCategory.getId());
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
data.put("currentCategory", currentCategory); data.put("currentCategory", currentCategory);
......
...@@ -13,6 +13,7 @@ import com.alibaba.druid.support.json.JSONUtils; ...@@ -13,6 +13,7 @@ import com.alibaba.druid.support.json.JSONUtils;
import com.wwdz.ch.core.util.PriceUtil; import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.core.util.ZincUtil; import com.wwdz.ch.core.util.ZincUtil;
import com.wwdz.ch.db.domain.*; import com.wwdz.ch.db.domain.*;
import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import com.wwdz.ch.db.service.*; import com.wwdz.ch.db.service.*;
import com.wwdz.ch.wx.annotation.LoginUser; import com.wwdz.ch.wx.annotation.LoginUser;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -63,7 +64,7 @@ public class WxGoodsController { ...@@ -63,7 +64,7 @@ public class WxGoodsController {
private DtsFootprintService footprintService; private DtsFootprintService footprintService;
@Autowired @Autowired
private CategoryService categoryService; private CategoryManagerImpl categoryManager;
@Autowired @Autowired
private DtsSearchHistoryService searchHistoryService; private DtsSearchHistoryService searchHistoryService;
...@@ -181,17 +182,17 @@ public class WxGoodsController { ...@@ -181,17 +182,17 @@ public class WxGoodsController {
public Object category(@NotNull Integer id) { public Object category(@NotNull Integer id) {
logger.info("【请求开始】商品分类类目,请求参数,id:{}", id); logger.info("【请求开始】商品分类类目,请求参数,id:{}", id);
Category cur = categoryService.findById(id); Category cur = categoryManager.findById(id);
Category parent = null; Category parent = null;
List<Category> children = null; List<Category> children = null;
if (cur.getPid() == 0) { if (cur.getPid() == 0) {
parent = cur; parent = cur;
children = categoryService.queryByPid(cur.getId()); children = categoryManager.queryByPid(cur.getId());
cur = children.size() > 0 ? children.get(0) : cur; cur = children.size() > 0 ? children.get(0) : cur;
} else { } else {
parent = categoryService.findById(cur.getPid()); parent = categoryManager.findById(cur.getPid());
children = categoryService.queryByPid(cur.getPid()); children = categoryManager.queryByPid(cur.getPid());
} }
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("currentCategory", cur); data.put("currentCategory", cur);
......
...@@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit; ...@@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import com.wwdz.ch.db.service.CategoryService; import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import com.wwdz.ch.wx.annotation.LoginUser; import com.wwdz.ch.wx.annotation.LoginUser;
import com.wwdz.ch.wx.service.HomeCacheManager; import com.wwdz.ch.wx.service.HomeCacheManager;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -41,7 +41,7 @@ public class WxHomeController { ...@@ -41,7 +41,7 @@ public class WxHomeController {
@Autowired @Autowired
private CategoryService categoryService; private CategoryManagerImpl categoryManager;
private final static ArrayBlockingQueue<Runnable> WORK_QUEUE = new ArrayBlockingQueue<>(9); private final static ArrayBlockingQueue<Runnable> WORK_QUEUE = new ArrayBlockingQueue<>(9);
...@@ -92,7 +92,7 @@ public class WxHomeController { ...@@ -92,7 +92,7 @@ public class WxHomeController {
} }
} }
Callable<List> channelListCallable = () -> categoryService.queryByLevel(1, 1, 100); Callable<List> channelListCallable = () -> categoryManager.queryByLevel(1, 1, 100);
Callable<List> floorGoodsListCallable = this::getRecommendItems; Callable<List> floorGoodsListCallable = this::getRecommendItems;
......
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