package cn.com.goldenwater.dcproj.controller.system; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers; import cn.com.goldenwater.dcproj.service.BisInspAllRlationPersService; import cn.com.goldenwater.dcproj.utils.QRCodeUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; @Api(value = "获取人员信息", tags = "07获取人员信息") @RestController @RequestMapping("/QRCode") public class QRCodeController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspAllRlationPersService bisInspAllRlationPersService; @Autowired private RedisTemplate redisTemplate; @Value("${web.upload-path}") public String fileDir; @Value("${work.url}") private String workUrl; @ApiOperation(value = "人员信息二维码", notes = "参数字段说明:{\n\r" + " \"persId\":\"人员ID\",\n\r" + " \"hostPath\":\"服务器路径(如:http://192.168.1.107:8101)\",\n\r" + " };\n\r" + "返回结构说明:{\n\r" + " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" + " \"code\":\"错误代码\",\n\r" + " \"message\":\"描述信息\",\n\r" + " \"throwable\":\"异常信息\",\n\r" + " \"data(数据信息)\":\"二维码路径\",\n\r" + " }") @RequestMapping(value = "/getQRCode", method = RequestMethod.POST) public BaseResponse getQRCode(String persId, String hostPath) throws Exception { QRCodeUtil.encode(workUrl+"/sldc/work.html?pserId=" + persId, fileDir + "QRCode\\logo\\logo.jpg", fileDir + "QRCode", persId, true); return buildSuccessResponse(hostPath + "/upload/QRCode/" + persId + ".jpg"); } @ApiOperation(value = "人员信息", notes = "参数字段说明:{\n\r" + " \"persId\":\"人员ID\",\n\r" + " };\n\r" + "返回结构说明:{\n\r" + " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" + " \"code\":\"错误代码\",\n\r" + " \"message\":\"描述信息\",\n\r" + " \"throwable\":\"异常信息\",\n\r" + " \"data(数据信息)\":\"二维码路径\",\n\r" + " }") @RequestMapping(value = "/{persId}", method = RequestMethod.POST) public BaseResponse getQRCode(@ApiParam(name = "persId", value = "persId", required = true) @PathVariable String persId, HttpServletRequest request) { BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(persId); bisInspAllRlationPers.setPwd(null); if(StringUtils.isBlank(bisInspAllRlationPers.getPersType())){ bisInspAllRlationPers.setPersType("3"); bisInspAllRlationPersService.update(bisInspAllRlationPers); } return buildSuccessResponse(bisInspAllRlationPers); } }