|
@@ -4,7 +4,11 @@ package com.usky.dxtop.controller.web;
|
|
|
import com.usky.dxtop.common.constant.UserConstants;
|
|
|
import com.usky.dxtop.common.core.domain.AjaxResult;
|
|
|
import com.usky.dxtop.common.core.page.TableDataInfo;
|
|
|
+import com.usky.dxtop.common.exception.CustomException;
|
|
|
+import com.usky.dxtop.common.utils.QRCodeUtil;
|
|
|
import com.usky.dxtop.common.utils.SecurityUtils;
|
|
|
+import com.usky.dxtop.common.utils.file.FileUtils;
|
|
|
+import com.usky.dxtop.common.utils.spring.GlobalUtils;
|
|
|
import com.usky.dxtop.controller.BaseController;
|
|
|
import com.usky.dxtop.model.QrCode;
|
|
|
import com.usky.dxtop.model.TopRadio;
|
|
@@ -14,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.net.ConnectException;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -43,7 +48,16 @@ public class QrCodeController extends BaseController {
|
|
|
{
|
|
|
return AjaxResult.error("新增二维码信息'" + qrCode.getName() + "'失败,二维码信息已存在");
|
|
|
}
|
|
|
- qrCode.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ try {
|
|
|
+ String codeName = String.format("%s-%s.jpg", qrCode.getName(), System.currentTimeMillis() + "");
|
|
|
+ String destPath = String.format("%s%s", GlobalUtils.getTempBaseDir(),codeName);
|
|
|
+ //生成二维码
|
|
|
+ QRCodeUtil.encode("内容暂定", null, destPath, true);
|
|
|
+ qrCode.setQrPath(destPath);
|
|
|
+ qrCode.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException("生成二维码图片失败");
|
|
|
+ }
|
|
|
return toAjax(qrCodeService.save(qrCode));
|
|
|
|
|
|
}
|
|
@@ -76,10 +90,7 @@ public class QrCodeController extends BaseController {
|
|
|
@DeleteMapping("/{id}")
|
|
|
public AjaxResult remove(@PathVariable("id") Long id)
|
|
|
{
|
|
|
- QrCode qrCode = new QrCode();
|
|
|
- qrCode.setId(id);
|
|
|
- qrCode.setDelFlag(true);
|
|
|
- return toAjax(qrCodeService.updateById(qrCode));
|
|
|
+ return toAjax(qrCodeService.remove(id));
|
|
|
}
|
|
|
}
|
|
|
|