1 Star 0 Fork 0

XiaoLin / zsRedis商城

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

已完成的功能 后台权限管理 用户 角色 菜单 商城 前台页面 后台管理 此项目主要是学习redis使用,生产不建议这样用 ,应该结合数据库一起使用 此项目的后台权限管理采用ssm 通用mapper 做成,商城管理去掉了mybatis 全部采用redis做存储和增删该查

如 商品数据结构

    • /**
    •  * 用户基本信息
    •  * zscat:goods:{id}:{pcid}:{ptid}
    •  * hash
    •  * {
    •  *     id: '100144', //ID
    •  *     title: '1', //标题
    •  *     tag: '0', //标签
    •  *     img: '1', //图片
    •  *     remark: '1,2', //内容
    •  *     summry: '0', //摘书
    •  * }
    •  */
    • public static final String GOODS = "zscat:goods:%s:%s:%s";

输入图片说明

文章数据的redis 增删改查 public class ArticleRedis {

static RedisUtils RedisUtils = new RedisUtils(1);

/**
 * 文章列表
 * 
 * @param count
 * @return
 * @throws Exception
 */
public static List<Article> toArticle(int count) throws Exception {
	Set<String> set = RedisUtils.keys(String.format(
			RandomChatRedisKey.Article, "*"));
	Iterator<String> it = set.iterator();
	List<Article> l = new ArrayList<>();
	int j = 0;
	while (it.hasNext() && j < count) {
		j++;
		String key = it.next();
		Map<String, String> map = RedisUtils.hgetall(key);
		l.add((Article) BeanUtil.transMap2Bean(map, Article.class));
	}

	return l;
}

/**
 * 保存或者修改文章
 * 
 * @param count
 * @return
 * @throws Exception
 */
public static void saveArticleRedisDB(Article profile) {
	String key = String.format(RandomChatRedisKey.Article, profile.getId());
	Map<String, Object> map = BeanUtil.transBean2Map(profile, true);
	Map<String, String> tempMap = new HashMap<>();
	for (Map.Entry<String, Object> entry : map.entrySet()) {
		tempMap.put(entry.getKey(), entry.getValue().toString());
	}
	RedisUtils.hmset(key, tempMap);
}

/**
 * 删除文章
 * 
 * @param count
 * @return
 * @throws Exception
 */
public static Long deleteArticleRedisDB(Article profile) {
	String key = String.format(RandomChatRedisKey.Article, profile.getId());
	return RedisUtils.del(key);
}

/**
 * 获取文章文章
 * 
 * @param count
 * @return
 * @throws Exception
 */
public static Article getArticleRedisDB(Long id) {
	String key = String.format(RandomChatRedisKey.Article, id, "*");
	Map<String, String> map = RedisUtils.hgetall(key);
	return BeanUtil.transMap2Bean(map, Article.class);
}

}

创建数据库,启动redis 然后用tomcat启动项目 访问http://localhost:8081/zsRedis 输入图片说明

空文件

简介

springmvc ,spring,mybatis dubbo redis做商城的数据库 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/cuit.ck/zsredis.git
git@gitee.com:cuit.ck/zsredis.git
cuit.ck
zsredis
zsRedis商城
master

搜索帮助