|
|
|
|
@ -1,12 +1,18 @@
|
|
|
|
|
package com.flossom.miniProgram.controller;
|
|
|
|
|
|
|
|
|
|
import com.flossom.common.core.constant.Constants;
|
|
|
|
|
import com.flossom.common.core.domain.R;
|
|
|
|
|
import com.flossom.common.core.domain.SysFile;
|
|
|
|
|
import com.flossom.common.core.exception.ServiceException;
|
|
|
|
|
import com.flossom.common.core.web.controller.BaseController;
|
|
|
|
|
import com.flossom.miniProgram.service.IWxInstrumentService;
|
|
|
|
|
import com.flossom.system.api.RemoteFileService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotBlank;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 仪器列Controller
|
|
|
|
|
@ -21,6 +27,47 @@ public class WxInstrumentController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IWxInstrumentService wxInstrumentService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteFileService remoteFileService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户、序列号与仪器绑定
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/binding")
|
|
|
|
|
public R binding(@NotBlank(message = "序列号不能为空") @RequestParam("serial") String serial) {
|
|
|
|
|
wxInstrumentService.binding(serial, null);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 换绑
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/exchangeBinding")
|
|
|
|
|
public R exchangeBinding(@NotBlank(message = "序列号不能为空") @RequestParam("serial") String serial) {
|
|
|
|
|
wxInstrumentService.exchangeBinding(serial);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手动输入序列号绑定仪器
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/manualCodeBinding")
|
|
|
|
|
public R manualCodeBinding(@NotNull(message = "请上传序列号图片") @RequestParam(value = "file") MultipartFile file,
|
|
|
|
|
@NotBlank(message = "请输入序列号") String serial) {
|
|
|
|
|
String serialImage = "";
|
|
|
|
|
if (file != null) {
|
|
|
|
|
R<SysFile> result = remoteFileService.upload(file);
|
|
|
|
|
if (result.getCode() != Constants.SUCCESS) {
|
|
|
|
|
logger.error("上传序列号图片失败");
|
|
|
|
|
throw new ServiceException("上传序列号图片失败");
|
|
|
|
|
}
|
|
|
|
|
serialImage = result.getData().getUrl();
|
|
|
|
|
}
|
|
|
|
|
wxInstrumentService.binding(serial, serialImage);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取已绑定的仪器列表
|
|
|
|
|
@ -48,23 +95,7 @@ public class WxInstrumentController extends BaseController {
|
|
|
|
|
return R.ok(wxInstrumentService.getInstrumentInfoBySerial(serial));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户、序列号与仪器绑定
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/binding")
|
|
|
|
|
public R binding(@NotBlank(message = "序列号不能为空") @RequestParam("serial") String serial) {
|
|
|
|
|
wxInstrumentService.binding(serial);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 换绑
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/exchangeBinding")
|
|
|
|
|
public R exchangeBinding(@NotBlank(message = "序列号不能为空") @RequestParam("serial") String serial) {
|
|
|
|
|
wxInstrumentService.exchangeBinding(serial);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|