|
@@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.flyer.exception.BusinessException;
|
|
import com.flyer.exception.BusinessException;
|
|
import com.flyer.foster.consts.WechatConst;
|
|
import com.flyer.foster.consts.WechatConst;
|
|
import com.flyer.foster.dto.*;
|
|
import com.flyer.foster.dto.*;
|
|
|
|
+import com.flyer.foster.entity.AppInfo;
|
|
import com.flyer.foster.entity.Area;
|
|
import com.flyer.foster.entity.Area;
|
|
import com.flyer.foster.entity.Garden;
|
|
import com.flyer.foster.entity.Garden;
|
|
import com.flyer.foster.mapper.IGardenMapper;
|
|
import com.flyer.foster.mapper.IGardenMapper;
|
|
|
|
+import com.flyer.foster.service.IAppInfoService;
|
|
import com.flyer.foster.service.IAreaService;
|
|
import com.flyer.foster.service.IAreaService;
|
|
import com.flyer.foster.service.IGardenService;
|
|
import com.flyer.foster.service.IGardenService;
|
|
import com.flyer.foster.util.HttpUtils;
|
|
import com.flyer.foster.util.HttpUtils;
|
|
@@ -47,6 +49,9 @@ public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implem
|
|
@Autowired
|
|
@Autowired
|
|
private QiniuUploadService qiniuUploadService;
|
|
private QiniuUploadService qiniuUploadService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAppInfoService iAppInfoService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public IPage<GardenRespDTO> getPageList(IPage<GardenRespDTO> page, GardenQueryDTO queryDTO) {
|
|
public IPage<GardenRespDTO> getPageList(IPage<GardenRespDTO> page, GardenQueryDTO queryDTO) {
|
|
IPage<GardenRespDTO> pageList = baseMapper.getPageList(page, queryDTO);
|
|
IPage<GardenRespDTO> pageList = baseMapper.getPageList(page, queryDTO);
|
|
@@ -70,7 +75,7 @@ public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implem
|
|
BeanUtil.copyProperties(addDTO, garden);
|
|
BeanUtil.copyProperties(addDTO, garden);
|
|
this.save(garden);
|
|
this.save(garden);
|
|
// 生成二维码
|
|
// 生成二维码
|
|
- String qrCode = this.generateQRCode(garden.getId());
|
|
|
|
|
|
+ String qrCode = this.generateQRCode(garden.getId(), addDTO.getAppid());
|
|
|
|
|
|
return this.lambdaUpdate()
|
|
return this.lambdaUpdate()
|
|
.set(Garden::getQrCode, qrCode)
|
|
.set(Garden::getQrCode, qrCode)
|
|
@@ -79,11 +84,11 @@ public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implem
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生成小程序二维码
|
|
* 生成小程序二维码
|
|
- *
|
|
|
|
* @param gardenId 果园id
|
|
* @param gardenId 果园id
|
|
*/
|
|
*/
|
|
- private String generateQRCode(Integer gardenId) {
|
|
|
|
- WxAccessToken wxAccessToken = WxAccessToken.getInstance(weChatApiUtil, WechatConst.APP_ID, WechatConst.APP_SECRET);
|
|
|
|
|
|
+ private String generateQRCode(Integer gardenId, String appId) {
|
|
|
|
+ AppInfo appInfo = iAppInfoService.getByAppId(appId);
|
|
|
|
+ WxAccessToken wxAccessToken = WxAccessToken.getInstance(weChatApiUtil, appInfo.getAppId(), appInfo.getAppSecret());
|
|
StringBuilder sb2 = new StringBuilder(200);
|
|
StringBuilder sb2 = new StringBuilder(200);
|
|
sb2.append("https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=");
|
|
sb2.append("https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=");
|
|
sb2.append(wxAccessToken.getAccess_token());
|
|
sb2.append(wxAccessToken.getAccess_token());
|
|
@@ -117,11 +122,17 @@ public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implem
|
|
if (garden == null) {
|
|
if (garden == null) {
|
|
throw new BusinessException("无效的果园id");
|
|
throw new BusinessException("无效的果园id");
|
|
}
|
|
}
|
|
|
|
+ // 生成二维码
|
|
|
|
+ String qrCode = this.generateQRCode(garden.getId(), updateDTO.getAppid());
|
|
|
|
+ System.out.println("------------qrCode-------------");
|
|
|
|
+ System.out.println(qrCode);
|
|
|
|
+ System.out.println("------------qrCode-------------");
|
|
return this.lambdaUpdate()
|
|
return this.lambdaUpdate()
|
|
.set(StrUtil.isNotBlank(updateDTO.getName()), Garden::getName, updateDTO.getName())
|
|
.set(StrUtil.isNotBlank(updateDTO.getName()), Garden::getName, updateDTO.getName())
|
|
.set(updateDTO.getWorldMapId() != null, Garden::getWorldMapId, updateDTO.getWorldMapId())
|
|
.set(updateDTO.getWorldMapId() != null, Garden::getWorldMapId, updateDTO.getWorldMapId())
|
|
.set(StrUtil.isNotBlank(updateDTO.getWkt()), Garden::getWkt, updateDTO.getWkt())
|
|
.set(StrUtil.isNotBlank(updateDTO.getWkt()), Garden::getWkt, updateDTO.getWkt())
|
|
.set(StrUtil.isNotBlank(updateDTO.getIcon()), Garden::getIcon, updateDTO.getIcon())
|
|
.set(StrUtil.isNotBlank(updateDTO.getIcon()), Garden::getIcon, updateDTO.getIcon())
|
|
|
|
+ .set(StrUtil.isNotBlank(updateDTO.getAppid()), Garden::getAppid, updateDTO.getAppid())
|
|
.set(StrUtil.isNotBlank(updateDTO.getDayBg()), Garden::getDayBg, updateDTO.getDayBg())
|
|
.set(StrUtil.isNotBlank(updateDTO.getDayBg()), Garden::getDayBg, updateDTO.getDayBg())
|
|
.set(StrUtil.isNotBlank(updateDTO.getNightBg()), Garden::getNightBg, updateDTO.getNightBg())
|
|
.set(StrUtil.isNotBlank(updateDTO.getNightBg()), Garden::getNightBg, updateDTO.getNightBg())
|
|
.set(updateDTO.getBirdseyeGardenId() != null, Garden::getBirdseyeGardenId, updateDTO.getBirdseyeGardenId())
|
|
.set(updateDTO.getBirdseyeGardenId() != null, Garden::getBirdseyeGardenId, updateDTO.getBirdseyeGardenId())
|