|
@@ -16,12 +16,14 @@
|
|
|
*/
|
|
|
package org.springblade.modules.business.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrConfig;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
@@ -31,9 +33,14 @@ import org.springblade.modules.business.entity.Facility;
|
|
|
import org.springblade.modules.business.service.IFacilityService;
|
|
|
import org.springblade.modules.business.vo.FacilityVO;
|
|
|
import org.springblade.modules.business.wrapper.FacilityWrapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
|
|
|
/**
|
|
|
* 售货设备表 控制器
|
|
@@ -42,12 +49,15 @@ import javax.validation.Valid;
|
|
|
* @since 2024-07-16
|
|
|
*/
|
|
|
@RestController
|
|
|
-@AllArgsConstructor
|
|
|
@RequestMapping("/facility")
|
|
|
@Api(value = "售货设备表", tags = "售货设备表接口")
|
|
|
public class FacilityController extends BladeController {
|
|
|
|
|
|
- private final IFacilityService facilityService;
|
|
|
+ @Autowired
|
|
|
+ private IFacilityService facilityService;
|
|
|
+
|
|
|
+ @Value("${qrCode.domainUrl}")
|
|
|
+ private String domainUrl;
|
|
|
|
|
|
/**
|
|
|
* 详情
|
|
@@ -68,7 +78,13 @@ public class FacilityController extends BladeController {
|
|
|
@ApiOperation(value = "分页", notes = "传入facility")
|
|
|
public R<IPage<FacilityVO>> list(Facility facility, Query query) {
|
|
|
IPage<Facility> pages = facilityService.page(Condition.getPage(query), Condition.getQueryWrapper(facility));
|
|
|
- return R.data(FacilityWrapper.build().pageVO(pages));
|
|
|
+ IPage<FacilityVO> facilityVOIPage = FacilityWrapper.build().pageVO(pages);
|
|
|
+ if (CollectionUtil.isNotEmpty(facilityVOIPage.getRecords())){
|
|
|
+ facilityVOIPage.getRecords().forEach(facilityVO -> {
|
|
|
+ facilityVO.setQrCode(domainUrl + "?merchantCode=" + facilityVO.getId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return R.data(facilityVOIPage);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -113,7 +129,7 @@ public class FacilityController extends BladeController {
|
|
|
return R.status(facilityService.saveOrUpdate(facility));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 删除 售货设备表
|
|
|
*/
|
|
@@ -124,5 +140,17 @@ public class FacilityController extends BladeController {
|
|
|
return R.status(facilityService.removeByIds(Func.toLongList(ids)));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ @GetMapping("/buildQrcode")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "下载设备码", notes = "下载设备码")
|
|
|
+ public void buildQrcode(HttpServletResponse response, String id) throws IOException {
|
|
|
+ OutputStream osOut = response.getOutputStream();
|
|
|
+ QrConfig qrConfig = new QrConfig();
|
|
|
+ qrConfig.setWidth(600);
|
|
|
+ qrConfig.setHeight(600);
|
|
|
+ QrCodeUtil.generate(domainUrl + "?merchantCode=" + id,qrConfig, "jpg", osOut);
|
|
|
+ osOut.close();
|
|
|
+ }
|
|
|
+
|
|
|
}
|