Commit 8d593906 authored by shiyu's avatar shiyu

钱币列表

parent c3327171
......@@ -72,6 +72,12 @@
<artifactId>hutool-all</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.2.3</version>
</dependency>
</dependencies>
<build>
......
......@@ -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.BasicHttpAuthenticationFilter;
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.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -34,11 +40,64 @@ import javax.servlet.http.HttpServletResponse;
@Configuration
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
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")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
......@@ -64,19 +123,49 @@ public class ShiroConfig {
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() {
AdminWebSessionManager mySessionManager = new AdminWebSessionManager();
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() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm());
securityManager.setSessionManager(sessionManager());
return securityManager;
}
}*/
@Bean
......
......@@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.wwdz.ch.admin.util.AdminResponseCode;
import com.wwdz.ch.admin.util.AdminResponseUtil;
......@@ -40,7 +39,6 @@ import com.wwdz.ch.admin.util.PermissionUtil;
import com.wwdz.ch.admin.util.VerifyCodeUtils;
import com.wwdz.ch.core.captcha.CaptchaCodeManager;
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.UUID;
import com.wwdz.ch.db.domain.Admin;
......@@ -119,6 +117,7 @@ public class AdminAuthController {
@RequiresAuthentication
@GetMapping("/info")
public Object info() {
try {
Subject currentUser = SecurityUtils.getSubject();
Admin admin = (Admin) currentUser.getPrincipal();
......@@ -136,6 +135,10 @@ public class AdminAuthController {
logger.info("【请求结束】系统管理->用户信息获取,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
} catch (Exception e) {
logger.error("用户信息获取 error{}", e);
}
return ResponseUtil.fail();
}
@Autowired
......
......@@ -14,7 +14,7 @@ import com.wwdz.ch.admin.service.AdminGoodsService;
import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.admin.util.CatVo;
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.util.CollectionUtils;
import org.slf4j.Logger;
......@@ -43,7 +43,7 @@ public class AdminGoodsController {
private AdminGoodsService adminGoodsService;
@Autowired
private CategoryService categoryService;
private CategoryManagerImpl categoryManager;
@Autowired
private AdminDataAuthService adminDataAuthService;
......@@ -139,7 +139,7 @@ public class AdminGoodsController {
}
private List<CatVo> getChildCat(Integer parentId) {
List<Category> rawChildren = categoryService.queryByPid(parentId);
List<Category> rawChildren = categoryManager.queryByPid(parentId);
if (CollectionUtils.isEmpty(rawChildren)) {
return null;
}
......
......@@ -13,7 +13,7 @@ import com.wwdz.ch.admin.entity.vo.CategoryVo;
import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.type.ListResult;
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.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
......@@ -40,7 +40,7 @@ public class CategoryController {
private static final Logger logger = LoggerFactory.getLogger(CategoryController.class);
@Autowired
private CategoryService categoryService;
private CategoryManagerImpl categoryManager;
@RequiresPermissions("admin:category:list")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询")
......@@ -51,7 +51,7 @@ public class CategoryController {
@Order @RequestParam(defaultValue = "desc") String order) {
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());
logger.info("【请求结束】商场管理->类目管理->查询:total:{}", JSONObject.toJSONString(data));
return new ListResult<>(data, data.size());
......@@ -65,12 +65,12 @@ public class CategoryController {
/**
* 获取最大深度
*/
Integer maxLevel = categoryService.getMaxCagtegoryLevel();
Integer maxLevel = categoryManager.getMaxCagtegoryLevel();
Integer level = maxLevel;
Map<Integer, List<CategoryVo>> parentCategoryMap = new HashMap<>();
while (level > 0) {
List<Category> categoryList = categoryService.queryByLevel(level, 0, 10000);
List<Category> categoryList = categoryManager.queryByLevel(level, 0, 10000);
for (Category c : categoryList) {
Integer parentId = c.getPid();
List<CategoryVo> children = parentCategoryMap.get(parentId);
......@@ -97,15 +97,15 @@ public class CategoryController {
public Object getSubCategory(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 查询根据类目ID查询子类目");
List<CategoryVo> categoryVoList = new ArrayList<>();
List<Category> categoryList = categoryService.queryByPid(id);
List<Category> categoryList = categoryManager.queryByPid(id);
for (Category c : categoryList) {
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));
}
Map<String, Object> data = new HashMap<>();
data.put("categoryList", categoryVoList);
data.put("categoryPath", categoryService.getCategoryPath(id));
data.put("categoryPath", categoryManager.getCategoryPath(id));
logger.info("【请求结束】查询根据类目ID查询子类目 : {}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
......@@ -123,11 +123,11 @@ public class CategoryController {
Category pCat = new Category();
pCat.setId(pid);
pCat.setIsLeaf(false);
categoryService.updateById(pCat);
categoryManager.updateById(pCat);
} else {
category.setIsLeaf(true);
}
categoryService.add(category);
categoryManager.add(category);
logger.info("【请求结束】商场管理->类目管理->添加:响应结果:{}", JSONObject.toJSONString(category));
return ResponseUtil.ok(category);
......@@ -139,7 +139,7 @@ public class CategoryController {
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->详情,请求参数,id:{}", id);
Category category = categoryService.findById(id);
Category category = categoryManager.findById(id);
logger.info("【请求结束】商场管理->类目管理->详情:响应结果:{}", JSONObject.toJSONString(category));
return ResponseUtil.ok(category);
......@@ -152,7 +152,7 @@ public class CategoryController {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->编辑,请求参数:{}", JSONObject.toJSONString(categoryVo));
if (categoryService.updateById(categoryVo.toDo()) == 0) {
if (categoryManager.updateById(categoryVo.toDo()) == 0) {
logger.error("商场管理->类目管理->编辑 失败,更新数据失败!");
return ResponseUtil.updatedDataFailed();
}
......@@ -171,7 +171,7 @@ public class CategoryController {
if (id == null) {
return ResponseUtil.badArgument();
}
categoryService.deleteById(id);
categoryManager.deleteById(id);
logger.info("【请求结束】商场管理->类目管理->删除:响应结果:{}", "成功!");
return ResponseUtil.ok();
......@@ -183,7 +183,7 @@ public class CategoryController {
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());
for (Category category : l1CatList) {
Map<String, Object> d = new HashMap<>(2);
......
......@@ -4,6 +4,7 @@ import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class CoinVo implements Entity {
......@@ -114,4 +115,11 @@ public class CoinVo implements Entity {
* 质量(重量)
*/
private String weight;
/**
* 对应的分类
*
*/
private List<Integer> categoryIds;
}
......@@ -7,9 +7,11 @@ import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.storage.QiniuStorage;
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.OperateLog;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.manager.CategoryManager;
import com.wwdz.ch.db.manager.ItemManager;
import com.xxdxxs.utils.EntityMapper;
import com.xxdxxs.utils.JsonUtils;
......@@ -38,6 +40,9 @@ public class ItemServiceImpl implements ItemService {
@Autowired
OperateLogService operateLogService;
@Autowired
CategoryManager categoryManager;
@Override
public List<CoinVo> findList(CoinRequestDto coinRequestDto) {
try {
......@@ -65,6 +70,24 @@ public class ItemServiceImpl implements ItemService {
item = itemManager.findOne(coinRequestDto);
}
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);
} catch (Exception e) {
logger.error("钱币设置查询明细 error : {}", e);
......
......@@ -5,7 +5,8 @@ import java.util.stream.Collectors;
import com.wwdz.ch.admin.entity.vo.ItemVo;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,7 +28,7 @@ public class AdminGoodsService {
private ItemService itemService;
@Autowired
private CategoryService categoryService;
private CategoryManager categoryManager;
@Autowired
private QCodeService qCodeService;
......@@ -57,7 +58,7 @@ public class AdminGoodsService {
// 分类可以不设置,如果设置则需要验证分类存在
Integer categoryId = item.getCid();
if (categoryId != null && categoryId != 0) {
if (categoryService.findById(categoryId) == null) {
if (categoryManager.findById(categoryId) == null) {
return ResponseUtil.badArgumentValue();
}
}
......@@ -146,14 +147,14 @@ public class AdminGoodsService {
//用于展示商品归属的类目(页面级联下拉控件数据展示)
Integer categoryId = item.getCid();
Category category = categoryService.findById(categoryId);
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 = categoryService.findById(pid);
Category pCategory = categoryManager.findById(pid);
if (null != pCategory) {
pid = pCategory.getPid();
} else {
......
package com.wwdz.ch.db.domain;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
public class Admin {
@Data
public class Admin implements Entity {
/**
* This field was generated by MyBatis Generator.
* 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.wwdz.ch.db.dao.CategoryMapper;
import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.domain.CategoryExample;
import com.wwdz.ch.db.manager.CategoryManager;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
......@@ -14,7 +15,7 @@ import java.util.Collections;
import java.util.List;
@Service
public class CategoryService {
public class CategoryManagerImpl implements CategoryManager {
@Resource
private CategoryMapper categoryMapper;
......
......@@ -8,7 +8,7 @@ import java.util.Map;
import javax.validation.constraints.NotNull;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -31,7 +31,7 @@ public class WxCatalogController {
private static final Logger logger = LoggerFactory.getLogger(WxCatalogController.class);
@Autowired
private CategoryService categoryService;
private CategoryManagerImpl categoryManager;
/**
* 分类详情
......@@ -49,10 +49,10 @@ public class WxCatalogController {
Category currentCategory = null;
// 所有一级分类目录
if (null == id || 0 == id) {
l1CatList = categoryService.queryByLevel(1, 1, 100);
l1CatList = categoryManager.queryByLevel(1, 1, 100);
currentCategory = l1CatList.get(0);
} else {
currentCategory = categoryService.findById(id);
currentCategory = categoryManager.findById(id);
l1CatList = new ArrayList<>();
l1CatList.add(currentCategory);
}
......@@ -60,7 +60,7 @@ public class WxCatalogController {
// 当前一级分类目录对应的二级分类目录
List<Category> currentSubCategory = null;
if (null != currentCategory) {
currentSubCategory = categoryService.queryByPid(currentCategory.getId());
currentSubCategory = categoryManager.queryByPid(currentCategory.getId());
}
Map<String, Object> data = new HashMap<String, Object>();
......@@ -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<>();
List<Category> sub;
for (Category category : l1CatList) {
sub = categoryService.queryByPid(category.getId());
sub = categoryManager.queryByPid(category.getId());
allList.put(category.getId(), sub);
}
......@@ -102,7 +102,7 @@ public class WxCatalogController {
// 当前一级分类目录对应的二级分类目录
List<Category> currentSubCategory = null;
if (null != currentCategory) {
currentSubCategory = categoryService.queryByPid(currentCategory.getId());
currentSubCategory = categoryManager.queryByPid(currentCategory.getId());
}
Map<String, Object> data = new HashMap<String, Object>();
......@@ -135,8 +135,8 @@ public class WxCatalogController {
logger.info("【请求开始】当前分类栏目查询,id:{}", id);
// 当前分类
Category currentCategory = categoryService.findById(id);
List<Category> currentSubCategory = categoryService.queryByPid(currentCategory.getId());
Category currentCategory = categoryManager.findById(id);
List<Category> currentSubCategory = categoryManager.queryByPid(currentCategory.getId());
Map<String, Object> data = new HashMap<String, Object>();
data.put("currentCategory", currentCategory);
......
......@@ -13,6 +13,7 @@ import com.alibaba.druid.support.json.JSONUtils;
import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.core.util.ZincUtil;
import com.wwdz.ch.db.domain.*;
import com.wwdz.ch.db.manager.impl.CategoryManagerImpl;
import com.wwdz.ch.db.service.*;
import com.wwdz.ch.wx.annotation.LoginUser;
import org.apache.commons.collections.CollectionUtils;
......@@ -63,7 +64,7 @@ public class WxGoodsController {
private DtsFootprintService footprintService;
@Autowired
private CategoryService categoryService;
private CategoryManagerImpl categoryManager;
@Autowired
private DtsSearchHistoryService searchHistoryService;
......@@ -181,17 +182,17 @@ public class WxGoodsController {
public Object category(@NotNull Integer id) {
logger.info("【请求开始】商品分类类目,请求参数,id:{}", id);
Category cur = categoryService.findById(id);
Category cur = categoryManager.findById(id);
Category parent = null;
List<Category> children = null;
if (cur.getPid() == 0) {
parent = cur;
children = categoryService.queryByPid(cur.getId());
children = categoryManager.queryByPid(cur.getId());
cur = children.size() > 0 ? children.get(0) : cur;
} else {
parent = categoryService.findById(cur.getPid());
children = categoryService.queryByPid(cur.getPid());
parent = categoryManager.findById(cur.getPid());
children = categoryManager.queryByPid(cur.getPid());
}
Map<String, Object> data = new HashMap<>();
data.put("currentCategory", cur);
......
......@@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit;
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.service.HomeCacheManager;
import org.slf4j.Logger;
......@@ -41,7 +41,7 @@ public class WxHomeController {
@Autowired
private CategoryService categoryService;
private CategoryManagerImpl categoryManager;
private final static ArrayBlockingQueue<Runnable> WORK_QUEUE = new ArrayBlockingQueue<>(9);
......@@ -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;
......
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