Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

**

项目迁移

https://git.oschina.net/JiaGou-XiaoGe/payshop

已完成的功能 后台权限管理 用户 角色 菜单 商城 前台页面 后台管理 此项目主要是学习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 输入图片说明

Comments ( 0 )

Sign in for post a comment

About

springmvc ,spring,mybatis dubbo redis做商城的数据库 spread retract
Java
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more