| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.Element; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.CriteriaDefinition; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | |
| | | private RestTemplate restTemplate; |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private OSSService ossService; |
| | | @Value("${wx.appletsAppid}") |
| | | private String wxAppletsAppid; |
| | | |
| | | @Value("${wx.appletsAppSecret}") |
| | | private String wxAppletsAppSecret; |
| | | /** |
| | | * 生成小程序码地址 |
| | | */ |
| | | public static final String CREATE_CODE_URL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN"; |
| | | // 生成小程序码 |
| | | |
| | | public String generateMiniProgramCode(String outputFilePath) throws IOException { |
| | | // 获取access_token |
| | | String accessToken = wxAppletTools.getAccessToken(); |
| | | // 替换CREATE_CODE_URL |
| | | String uri = CREATE_CODE_URL.replace("ACCESS_TOKEN", accessToken); |
| | | // 跳转到的小程序页面路径 |
| | | String pagePath = "pages/index/index"; |
| | | URL url = new URL(uri); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | // 设置请求方法 |
| | | connection.setRequestMethod("POST"); |
| | | connection.setDoOutput(true); |
| | | // 构建请求参数 |
| | | String params = "path=" + URLEncoder.encode(pagePath, "UTF-8"); |
| | | // 获取输出流 |
| | | try (OutputStream outputStream = connection.getOutputStream()) { |
| | | outputStream.write(params.getBytes()); |
| | | } |
| | | // 获取输入流 |
| | | try (InputStream inputStream = connection.getInputStream(); |
| | | FileOutputStream outputStream = new FileOutputStream(outputFilePath)) { |
| | | // 将返回的图片数据写入文件 |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | outputStream.write(buffer, 0, bytesRead); |
| | | } |
| | | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer); |
| | | MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), byteArrayInputStream); |
| | | return ossService.uploadFile(file); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取房源列表 |
| | | * @param req |
| | |
| | | } |
| | | @Override |
| | | public ResultUtil addHouse(AddHouseReq req) { |
| | | // Integer appUserId = appUserService.getAppUser().getId(); |
| | | Integer appUserId = appUserService.getAppUser().getId(); |
| | | AppUser appUser = appUserService.selectOne(new EntityWrapper<AppUser>() |
| | | .eq("id", 40) |
| | | .eq("id", appUserId) |
| | | .eq("status", 1)); |
| | | if (appUser!=null){ |
| | | if (req.getId()==null){ |
| | |
| | | if (appUser.getAuth()!=2){ |
| | | // 未认证 只能能发布三条房源信息 |
| | | List<HouseResource> houseResources = this.selectList(new EntityWrapper<HouseResource>() |
| | | .eq("app_user_id", 40) |
| | | .eq("app_user_id", appUserId) |
| | | .eq("is_delete", 0) |
| | | .eq("type", 2) |
| | | ); |
| | |
| | | houseResource.setInsertTime(new Date()); |
| | | houseResource.setGoodHouse(0); |
| | | houseResource.setIsDelete(0); |
| | | houseResource.setInsertUserId(40); |
| | | houseResource.setInsertUserId(appUserId); |
| | | houseResource.setViewsNumber(0); |
| | | houseResource.setUpdateTime(new Date()); |
| | | // todo 修改回审核和上下架状态 |
| | |
| | | houseResource.setDataType(req.getDataType()); |
| | | houseResource.setAuthStatus(1); |
| | | houseResource.setLeaseTime(req.getTime()); |
| | | houseResource.setAppUserId(40); |
| | | houseResource.setAppUserId(appUserId); |
| | | houseResource.setFirmHouse(req.getFirmHouse()); |
| | | if (StringUtils.hasLength(req.getTime())){ |
| | | if (req.getTime().contains("年")){ |
| | |
| | | } |
| | | if (req.getType()==2){ |
| | | if (req.getId()==null){ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.insert(houseResource); |
| | | }else{ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource); |
| | | } |
| | | }else{ |
| | | if (req.getId()==null){ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.insert(houseResource); |
| | | }else{ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource); |
| | | } |
| | | } |
| | |
| | | pointLocation.setHouseId(houseResource.getId()); |
| | | mongoTemplate.insert(pointLocation); |
| | | houseResource.setCode(pointLocation.getId()); |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource); |
| | | InputStream inputStream = null; |
| | | OutputStream outputStream = null; |
| | |
| | | pointLocation.setHouseId(req.getId()); |
| | | mongoTemplate.insert(pointLocation); |
| | | houseResource1.setCode(pointLocation.getId()); |
| | | houseResource1.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource1); |
| | | } |
| | | Query query = Query.query(Criteria.where("_id").is(houseResource1.getCode())); |