b60f59c9ee9f9f5bfe037e31d6fbb50f1dde4db3.svn-base 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package cn.com.goldenwater.dcproj.controller.system;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers;
  5. import cn.com.goldenwater.dcproj.service.BisInspAllRlationPersService;
  6. import cn.com.goldenwater.dcproj.utils.QRCodeUtil;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiOperation;
  9. import io.swagger.annotations.ApiParam;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.slf4j.Logger;
  12. import org.slf4j.LoggerFactory;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.beans.factory.annotation.Value;
  15. import org.springframework.data.redis.core.RedisTemplate;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestMethod;
  19. import org.springframework.web.bind.annotation.RestController;
  20. import javax.servlet.http.HttpServletRequest;
  21. @Api(value = "获取人员信息", tags = "07获取人员信息")
  22. @RestController
  23. @RequestMapping("/QRCode")
  24. public class QRCodeController extends BaseController {
  25. private Logger logger = LoggerFactory.getLogger(getClass());
  26. @Autowired
  27. private BisInspAllRlationPersService bisInspAllRlationPersService;
  28. @Autowired
  29. private RedisTemplate redisTemplate;
  30. @Value("${web.upload-path}")
  31. public String fileDir;
  32. @Value("${work.url}")
  33. private String workUrl;
  34. @ApiOperation(value = "人员信息二维码", notes = "参数字段说明:{\n\r" +
  35. " \"persId\":\"人员ID\",\n\r" +
  36. " \"hostPath\":\"服务器路径(如:http://192.168.1.107:8101)\",\n\r" +
  37. " };\n\r" +
  38. "返回结构说明:{\n\r" +
  39. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  40. " \"code\":\"错误代码\",\n\r" +
  41. " \"message\":\"描述信息\",\n\r" +
  42. " \"throwable\":\"异常信息\",\n\r" +
  43. " \"data(数据信息)\":\"二维码路径\",\n\r" +
  44. " }")
  45. @RequestMapping(value = "/getQRCode", method = RequestMethod.POST)
  46. public BaseResponse getQRCode(String persId, String hostPath) throws Exception {
  47. QRCodeUtil.encode(workUrl+"/sldc/work.html?pserId=" + persId, fileDir + "QRCode\\logo\\logo.jpg", fileDir + "QRCode", persId, true);
  48. return buildSuccessResponse(hostPath + "/upload/QRCode/" + persId + ".jpg");
  49. }
  50. @ApiOperation(value = "人员信息", notes = "参数字段说明:{\n\r" +
  51. " \"persId\":\"人员ID\",\n\r" +
  52. " };\n\r" +
  53. "返回结构说明:{\n\r" +
  54. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  55. " \"code\":\"错误代码\",\n\r" +
  56. " \"message\":\"描述信息\",\n\r" +
  57. " \"throwable\":\"异常信息\",\n\r" +
  58. " \"data(数据信息)\":\"二维码路径\",\n\r" +
  59. " }")
  60. @RequestMapping(value = "/{persId}", method = RequestMethod.POST)
  61. public BaseResponse<BisInspAllRlationPers> getQRCode(@ApiParam(name = "persId", value = "persId", required = true) @PathVariable String persId, HttpServletRequest request) {
  62. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(persId);
  63. bisInspAllRlationPers.setPwd(null);
  64. if(StringUtils.isBlank(bisInspAllRlationPers.getPersType())){
  65. bisInspAllRlationPers.setPersType("3");
  66. bisInspAllRlationPersService.update(bisInspAllRlationPers);
  67. }
  68. return buildSuccessResponse(bisInspAllRlationPers);
  69. }
  70. }