小程序-手动绑定仪器

master
382696293@qq.com 2 years ago
parent e7775f1979
commit 7f9d51c0a7

@ -1,12 +1,18 @@
package com.flossom.miniProgram.controller; 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.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.common.core.web.controller.BaseController;
import com.flossom.miniProgram.service.IWxInstrumentService; import com.flossom.miniProgram.service.IWxInstrumentService;
import com.flossom.system.api.RemoteFileService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/** /**
* Controller * Controller
@ -21,6 +27,47 @@ public class WxInstrumentController extends BaseController {
@Autowired @Autowired
private IWxInstrumentService wxInstrumentService; 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)); 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();
}
} }

@ -14,7 +14,7 @@ import java.util.List;
public interface IWxInstrumentService { public interface IWxInstrumentService {
WxInstrumentSerial getInstrumentInfoBySerial(String serial); WxInstrumentSerial getInstrumentInfoBySerial(String serial);
void binding(String serial); void binding(String serial, String serialImage);
void exchangeBinding(String serial); void exchangeBinding(String serial);

@ -73,7 +73,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
@Override @Override
@Transactional @Transactional
public void binding(String serial) { public void binding(String serial, String serialImage) {
WxUserMember wxUserMember = SecurityUtils.getLoginUser().getWxUserMember(); WxUserMember wxUserMember = SecurityUtils.getLoginUser().getWxUserMember();
/* 1、获取序列号信息 */ /* 1、获取序列号信息 */
WxInstrumentSerial wxInstrumentSerial = getInstrumentInfoBySerial(serial); WxInstrumentSerial wxInstrumentSerial = getInstrumentInfoBySerial(serial);
@ -130,6 +130,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
WxUserInstrument saveEntity = new WxUserInstrument(); WxUserInstrument saveEntity = new WxUserInstrument();
saveEntity.setUserId(wxUserMember.getId()); saveEntity.setUserId(wxUserMember.getId());
saveEntity.setSerial(serial); saveEntity.setSerial(serial);
saveEntity.setSerialImage(serialImage);
saveEntity.setInstrumentId(wxInstrumentSerial.getInstrumentId()); saveEntity.setInstrumentId(wxInstrumentSerial.getInstrumentId());
saveEntity.setInstrumentName(wxInstrumentSerial.getInstrumentName()); saveEntity.setInstrumentName(wxInstrumentSerial.getInstrumentName());
saveEntity.setGuarantee(wxInstrument.getGuarantee()); saveEntity.setGuarantee(wxInstrument.getGuarantee());
@ -156,6 +157,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
wxUserInstrumentLog.setUserInstrumentId(saveEntity.getId()); wxUserInstrumentLog.setUserInstrumentId(saveEntity.getId());
wxUserInstrumentLog.setUserId(wxUserMember.getId()); wxUserInstrumentLog.setUserId(wxUserMember.getId());
wxUserInstrumentLog.setSerial(serial); wxUserInstrumentLog.setSerial(serial);
wxUserInstrumentLog.setSerialImage(saveEntity.getSerialImage());
wxUserInstrumentLog.setInstrumentId(wxInstrument.getId()); wxUserInstrumentLog.setInstrumentId(wxInstrument.getId());
wxUserInstrumentLog.setInstrumentName(wxInstrument.getName()); wxUserInstrumentLog.setInstrumentName(wxInstrument.getName());
wxUserInstrumentLog.setGuarantee(wxInstrument.getGuarantee()); wxUserInstrumentLog.setGuarantee(wxInstrument.getGuarantee());

Loading…
Cancel
Save