[功能]头像上传-预约列表接口返回预约人头像

master
liuqingkun 3 years ago
parent 3a91aa3087
commit a27e1cf64c
  1. 64
      src/main/java/org/springblade/common/cache/business/CupImgCache.java
  2. 27
      src/main/java/org/springblade/modules/business/controller/CommonApiController.java
  3. 2
      src/main/java/org/springblade/modules/business/service/ICupImgService.java
  4. 6
      src/main/java/org/springblade/modules/business/service/impl/ApmRecordServiceImpl.java
  5. 4
      src/main/java/org/springblade/modules/business/service/impl/CupImgServiceImpl.java
  6. 6
      src/main/java/org/springblade/modules/business/vo/ApmRecordListVO.java

@ -0,0 +1,64 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.cache.business;
import org.springblade.common.constant.BusinessConstant;
import org.springblade.common.enums.DictBizEnum;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.modules.business.entity.CupImg;
import org.springblade.modules.business.service.ICupImgService;
import org.springblade.modules.system.entity.DictBiz;
import java.util.List;
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
/**
* 用户头像缓存工具类
*
* @author Chill
*/
public class CupImgCache {
private static final String CUP_CACHE = "blade:cup";
private static final String IMG_VALUE = "img:cardno";
private static final ICupImgService cupImgService;
static {
cupImgService = SpringUtil.getBean(ICupImgService.class);
}
/**
* 获取实体
*
* @param cardNo 身份证号
* @return CupImg
*/
public static CupImg getByCardNo(String cardNo) {
return CacheUtil.get(CUP_CACHE, IMG_VALUE, cardNo, () -> cupImgService.getByCardNo(cardNo), BusinessConstant.TENANT_MODE);
}
public static void clearCupImgCache(String cardNo) {
CacheUtil.evict(CUP_CACHE, IMG_VALUE, cardNo, BusinessConstant.TENANT_MODE);
}
}

@ -1,30 +1,21 @@
package org.springblade.modules.business.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.DictBizCache;
import org.springblade.common.constant.BusinessConstant;
import org.springblade.common.cache.business.CupImgCache;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.utils.CommonDateUtil;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.TenantDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.business.entity.Article;
import org.springblade.modules.business.entity.CupImg;
import org.springblade.modules.business.service.IArticleService;
import org.springblade.modules.business.service.ICupImgService;
import org.springblade.modules.business.vo.ArticleVO;
import org.springblade.modules.business.wrapper.ArticleWrapper;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 控制器
*
@ -55,7 +46,7 @@ public class CommonApiController extends BladeController {
@ApiOperationSupport(order = 2)
@ApiOperation(value = "获取用户头像", notes = "获取用户头像")
public R getCupImg(String cupCardNo) {
CupImg cupImg = cupImgService.getByCupCard(cupCardNo);
CupImg cupImg = CupImgCache.getByCardNo(cupCardNo);
return Func.isNotEmpty(cupImg) ? R.data(cupImg.getCupImg()) : R.data("");
}
@ -66,10 +57,15 @@ public class CommonApiController extends BladeController {
@PostMapping("/save-cup-img")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "保存用户头像", notes = "保存用户头像")
public R saveCupImg(@RequestBody Map<String, Object> requestObj) {
CupImg cupImg = BeanUtil.copy(requestObj.get("data"), CupImg.class);
public R saveCupImg(@RequestParam String data) {
if (Func.isBlank(data)) {
return R.fail("请求数据为空");
}
JSONObject json = JSONObject.parseObject(data);
CupImg cupImg = BeanUtil.copy(json, CupImg.class);
CupImg cupImgCheck = cupImgService.getByCupCard(cupImg.getCupCardNo());
CupImg cupImgCheck = cupImgService.getByCardNo(cupImg.getCupCardNo());
if (Func.isEmpty(cupImgCheck)) {
cupImgService.save(cupImg);
@ -77,6 +73,7 @@ public class CommonApiController extends BladeController {
cupImgCheck.setCupImg(cupImg.getCupImg());
cupImgService.saveOrUpdate(cupImgCheck);
}
CupImgCache.clearCupImgCache(cupImg.getCupCardNo());
return R.status(true);
}
}

@ -12,5 +12,5 @@ import org.springblade.modules.business.entity.CupImg;
*/
public interface ICupImgService extends BaseService<CupImg> {
CupImg getByCupCard(String cupCard);
CupImg getByCardNo(String cardNo);
}

@ -6,9 +6,11 @@ import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springblade.common.cache.DeptCache;
import org.springblade.common.cache.DictBizCache;
import org.springblade.common.cache.business.CupImgCache;
import org.springblade.common.constant.BusinessConstant;
import org.springblade.common.enums.ErrorMsgEnum;
import org.springblade.common.utils.CommonDateUtil;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
@ -17,6 +19,7 @@ import org.springblade.modules.business.dto.ApmRecordCountDTO;
import org.springblade.modules.business.entity.ApmConfig;
import org.springblade.modules.business.entity.ApmRecord;
import org.springblade.modules.business.entity.Blacklist;
import org.springblade.modules.business.entity.CupImg;
import org.springblade.modules.business.mapper.ApmConfigMapper;
import org.springblade.modules.business.mapper.ApmRecordMapper;
import org.springblade.modules.business.service.IApmConfigService;
@ -64,6 +67,9 @@ public class ApmRecordServiceImpl extends BaseServiceImpl<ApmRecordMapper, ApmRe
String key = vo.getCreateDept() + DateUtil.format(vo.getApmDay(), DateUtil.PATTERN_DATE) + vo.getCupCardNo();
List<ApmRecord> records = recordMap.containsKey(key) ? recordMap.get(key) : new ArrayList<>();
CupImg img = CupImgCache.getByCardNo(vo.getCupCardNo());
vo.setCupImg(Func.isNotEmpty(img) ? img.getCupImg() : "");
List<ApmRecordDetailVO> details = new ArrayList<>();
for (ApmRecord record : records) {
details.add(BeanUtil.copy(record, ApmRecordDetailVO.class));

@ -16,9 +16,9 @@ import org.springframework.stereotype.Service;
public class CupImgServiceImpl extends BaseServiceImpl<CupImgMapper, CupImg> implements ICupImgService {
@Override
public CupImg getByCupCard(String cupCard) {
public CupImg getByCardNo(String cardNo) {
return baseMapper.selectOne(Wrappers.<CupImg>lambdaQuery()
.eq(CupImg::getIsDeleted, false)
.eq(CupImg::getCupCardNo, cupCard));
.eq(CupImg::getCupCardNo, cardNo));
}
}

@ -58,5 +58,11 @@ public class ApmRecordListVO implements Serializable {
@ApiModelProperty(value = "体检人联系方式")
private String cupPhone;
/**
* 体检人头像
*/
@ApiModelProperty(value = "体检人头像")
private String cupImg;
private List<ApmRecordDetailVO> details;
}

Loading…
Cancel
Save