Browse Source

新增表单放redis

dev_shibei_match
yinzuomei 4 years ago
parent
commit
75f33e47d8
  1. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 25
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java
  3. 13
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -579,4 +579,14 @@ public class RedisKeys {
public static String loginTicket(String app, String ticket) {
return rootPrefix.concat("sys:security:ticket:").concat(app).concat(":").concat(ticket);
}
/**
* 政府端机关单位缓存Key
* @param formCode
* @param customerId
* @return
*/
public static String getIcFormKey(String formCode,String customerId) {
return rootPrefix.concat("icform:").concat(formCode).concat(":").concat(customerId);
}
}

25
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java

@ -17,9 +17,15 @@
package com.epmet.redis;
import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dto.result.CustomerFormResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Map;
/**
* APP底部菜单栏信息
@ -44,4 +50,23 @@ public class CustomerFootBarRedis {
return null;
}
public void deleteIcForm(String formCode,String customerId) {
String key = RedisKeys.getIcFormKey(formCode,customerId);
redisUtils.delete(key);
}
public void setCustomerFormResultDTO(String formCode,String customerId, CustomerFormResultDTO value){
String key = RedisKeys.getIcFormKey(formCode,customerId);
Map<String, Object> map = BeanUtil.beanToMap(value, false, true);
redisUtils.hMSet(key, map);
}
public CustomerFormResultDTO getCustomerFormResultDTO(String formCode,String customerId){
String key = RedisKeys.getIcFormKey(formCode,customerId);
Map<String, Object> resultMap = redisUtils.hGetAll(key);
if (CollectionUtils.isEmpty(resultMap)) {
return null;
}
return BeanUtil.mapToBean(resultMap, CustomerFormResultDTO.class, true);
}
}

13
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java

@ -32,8 +32,10 @@ import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.dto.result.FormGroupDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.entity.IcFormEntity;
import com.epmet.redis.CustomerFootBarRedis;
import com.epmet.service.IcFormService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -49,7 +51,8 @@ import java.util.Map;
*/
@Service
public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> implements IcFormService {
@Autowired
private CustomerFootBarRedis customerFootBarRedis;
@Override
public PageData<IcFormDTO> page(Map<String, Object> params) {
@ -113,17 +116,19 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity>
*/
@Override
public CustomerFormResultDTO getCustomerForm(CustomerFormQueryDTO formDto) {
//todo
CustomerFormResultDTO customerFormResultDTO = customerFootBarRedis.getCustomerFormResultDTO(formDto.getFormCode(), formDto.getCustomerId());
if (null != customerFormResultDTO) {
return customerFormResultDTO;
}
CustomerFormResultDTO resultDTO=baseDao.selectByCode(formDto.getCustomerId(),formDto.getFormCode());
if (null == resultDTO) {
throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg());
}
List<FormItem> itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic());
List<FormGroupDTO> groupList=baseDao.selectListGroup(resultDTO.getFormId());
resultDTO.setItemList(itemList);
resultDTO.setGroupList(groupList);
customerFootBarRedis.setCustomerFormResultDTO(formDto.getFormCode(),formDto.getCustomerId(),resultDTO);
return resultDTO;
}
}

Loading…
Cancel
Save