/** * Copyright 2018 人人开源 https://www.renren.io *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.epmet.redis; import cn.hutool.core.bean.BeanUtil; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dto.CustomerAgencyUserRoleDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Map; import static com.epmet.commons.tools.redis.RedisUtils.NOT_EXPIRE; /** * 工作人员-角色关系表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-04-22 */ @Component public class StaffRoleRedis { @Autowired private RedisUtils redisUtils; public void delete(Object[] ids) { } public void set(){ } public String get(String id){ return null; } /** * @Description 查询工作人员的角色 * @Param customerId * @Param userId * @author zxc * @date 2021/6/15 3:20 下午 */ public CustomerAgencyUserRoleDTO getRole(String customerId, String userId){ String key = "epmet:staffrole:"+customerId+":"+userId; Map roleMap = redisUtils.hGetAll(key); boolean empty = roleMap.isEmpty(); if (!empty){ CustomerAgencyUserRoleDTO result = ConvertUtils.mapToEntity(roleMap, CustomerAgencyUserRoleDTO.class); return result; } return null; } /** * @Description 放入缓存角色 * @Param customerId * @Param userId * @Param dto * @author zxc * @date 2021/6/15 4:01 下午 */ public void setRole(String customerId,String userId,CustomerAgencyUserRoleDTO dto){ String key = "epmet:staffrole:"+customerId+":"+userId; Map map = BeanUtil.beanToMap(dto, false, true); redisUtils.hMSet(key, map,NOT_EXPIRE); } }