Merge remote-tracking branch 'origin/test' into txb
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-actuator</artifactId> |
| | | </dependency> |
| | | <!--minio文件存储--> |
| | | <dependency> |
| | | <groupId>io.minio</groupId> |
| | | <artifactId>minio</artifactId> |
| | | <version>6.0.8</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActReserveCommitVO; |
| | | import com.panzhihua.common.model.vos.community.ComActReserveIndexVo; |
| | | import com.panzhihua.common.model.vos.community.reserve.ComActReserveAppletsVO; |
| | | import com.panzhihua.common.model.vos.community.reserve.ComActReserveDetailVO; |
| | | import com.panzhihua.common.model.vos.community.reserve.ComOperationDetailVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @ApiOperation("详情") |
| | | @ApiOperation(value = "详情",response = ComActReserveDetailVO.class) |
| | | @GetMapping("/detail") |
| | | public R detail(@RequestParam("id") Long id,@RequestParam("recordId") Long recordId,@RequestParam("isBack") Integer isBack){ |
| | | return communityService.reserveDetail(id,this.getUserId(),recordId,isBack); |
| | |
| | | * @param pageUserReserveDTO |
| | | * @return |
| | | */ |
| | | @ApiOperation("我的预约/登记") |
| | | @ApiOperation(value = "我的预约/登记",response = ComActReserveAppletsVO.class) |
| | | @PostMapping("/userReserveList") |
| | | public R userReserveList(@RequestBody PageUserReserveDTO pageUserReserveDTO){ |
| | | pageUserReserveDTO.setUserId(this.getUserId()); |
| | |
| | | /** |
| | | * 预约详情操作记录 |
| | | */ |
| | | @ApiOperation("预约详情操作记录") |
| | | @ApiOperation(value = "预约详情操作记录",response = ComOperationDetailVO.class) |
| | | @PostMapping("/detailOperation") |
| | | public R reserveOperation(@RequestBody OperationDetailDTO comActReserveOperationRecordDO){ |
| | | comActReserveOperationRecordDO.setUserId(this.getUserId()); |
| | | return communityService.reserveOperation(comActReserveOperationRecordDO); |
| | | } |
| | | |
| | | @ApiOperation("预约登记列表") |
| | | @ApiOperation(value = "预约登记列表",response = ComActReserveIndexVo.class) |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam("communityId") Long communityId){ |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin(); |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.panzhihua.applets.config.MinioUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.apache.commons.lang3.RandomUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | |
| | | private WxMaConfiguration wxMaConfiguration; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | |
| | | public static void main(String[] args) { |
| | | // int nextInt = RandomUtils.nextInt(99999, 1000000); |
| | |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "新上传照片接口") |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "发送验证码") |
| | | @PostMapping(value = "smscode") |
| | | public R smscode(@RequestBody UserPhoneVO userPhoneVO) { |
| | |
| | | addNeighborCircleAppDTO.setIsExamine(AddComActNeighborCircleAppDTO.isExamine.yes); |
| | | } |
| | | }else{ |
| | | communityService.addSysConfValue(key + communityId,communityId,"社区邻里圈自动审核参数","2"); |
| | | addNeighborCircleAppDTO.setIsExamine(AddComActNeighborCircleAppDTO.isExamine.yes); |
| | | communityService.addSysConfValue(key + communityId,communityId,"社区邻里圈自动审核参数","1"); |
| | | addNeighborCircleAppDTO.setIsExamine(AddComActNeighborCircleAppDTO.isExamine.no); |
| | | } |
| | | }else{ |
| | | addNeighborCircleAppDTO.setIsExamine(AddComActNeighborCircleAppDTO.isExamine.yes); |
New file |
| | |
| | | package com.panzhihua.applets.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio存储信息配置 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Data |
| | | @ConfigurationProperties(prefix = "minio") |
| | | public class MinioConfig { |
| | | |
| | | private String host; |
| | | |
| | | private String accessKey; |
| | | |
| | | private String secretKey; |
| | | |
| | | private String url; |
| | | |
| | | private String bucket; |
| | | |
| | | private String aliasName; |
| | | |
| | | private String aliasPCName; |
| | | } |
New file |
| | |
| | | package com.panzhihua.applets.config; |
| | | |
| | | import io.minio.MinioClient; |
| | | import io.minio.ObjectStat; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio工具类 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Component |
| | | @EnableConfigurationProperties(MinioConfig.class) |
| | | public class MinioUtil { |
| | | |
| | | @Resource |
| | | private MinioConfig minioProperties; |
| | | |
| | | public static byte[] toByteArray(InputStream input) throws IOException { |
| | | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[4096]; |
| | | int n = 0; |
| | | while (-1 != (n = input.read(buffer))) { |
| | | output.write(buffer, 0, n); |
| | | } |
| | | return output.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 文件上传 |
| | | * |
| | | * @param file |
| | | * 要上传的文件 |
| | | * @return |
| | | */ |
| | | public String upload(MultipartFile file, String name) { |
| | | if (null != file) { |
| | | try { |
| | | UUID uuid = UUID.randomUUID(); |
| | | StringBuilder s = new StringBuilder(); |
| | | s.append(uuid.toString().replace("-", "")).append("/"); |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | // bucket 不存在,创建 |
| | | if (!minioClient.bucketExists(minioProperties.getBucket())) { |
| | | minioClient.makeBucket(minioProperties.getBucket()); |
| | | } |
| | | // 得到文件流 |
| | | InputStream input = file.getInputStream(); |
| | | // 文件名 |
| | | // String fileName = uuid + "/images." + FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String fileName = s.append(name).toString(); |
| | | String contentType = file.getContentType(); |
| | | minioClient.putObject(minioProperties.getBucket(), fileName, input, contentType); |
| | | StringBuilder fileUrl = new StringBuilder(minioProperties.getUrl()); |
| | | String url = fileUrl.append(fileName).toString(); |
| | | return url; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public void download(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | ObjectStat stat = minioClient.statObject(minioProperties.getBucket(), fileName); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | response.setContentType(stat.contentType()); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); |
| | | IOUtils.copy(inputStream, response.getOutputStream()); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public byte[] getBytes(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | byte[] bytes = new byte[0]; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | bytes = toByteArray(inputStream); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return bytes; |
| | | } |
| | | } |
| | |
| | | active: ${ENV:dev} |
| | | servlet: |
| | | multipart: |
| | | max-file-size: 10MB |
| | | max-request-size: 10MB |
| | | max-file-size: 200MB |
| | | max-request-size: 200MB |
| | | |
| | | server: |
| | | max-http-header-size: 10MB |
| | |
| | | <artifactId>spring-boot-starter-actuator</artifactId> |
| | | </dependency> |
| | | |
| | | <!--minio文件存储--> |
| | | <dependency> |
| | | <groupId>io.minio</groupId> |
| | | <artifactId>minio</artifactId> |
| | | <version>6.0.8</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.panzhihua.applets_backstage.config.MinioUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | private int port; |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | |
| | | @ApiOperation("新增广告") |
| | | @PostMapping("advertisement") |
| | |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "新上传照片接口") |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "删除广告") |
| | | @DeleteMapping("advertisement") |
| | | public R deleteAdvertisement(@RequestParam("id") Long id) { |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.panzhihua.applets_backstage.config.MinioUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | |
| | | @Value("${excel.convenientUrl}") |
| | | private String excelConvenientUrl = "http://panzhihua.nhys.cdnhxx.com/web/bianminfuwudaoru.xlsx"; |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "新上传照片接口") |
| | | @PostMapping(value = "/upload/files", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "excel导入便民服务") |
| | | @PostMapping(value = "/serve/import", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R downloadTemplate(@RequestParam MultipartFile file, HttpServletRequest request) { |
New file |
| | |
| | | package com.panzhihua.applets_backstage.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio存储信息配置 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Data |
| | | @ConfigurationProperties(prefix = "minio") |
| | | public class MinioConfig { |
| | | |
| | | private String host; |
| | | |
| | | private String accessKey; |
| | | |
| | | private String secretKey; |
| | | |
| | | private String url; |
| | | |
| | | private String bucket; |
| | | |
| | | private String aliasName; |
| | | |
| | | private String aliasPCName; |
| | | } |
New file |
| | |
| | | package com.panzhihua.applets_backstage.config; |
| | | |
| | | import io.minio.MinioClient; |
| | | import io.minio.ObjectStat; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio工具类 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Component |
| | | @EnableConfigurationProperties(MinioConfig.class) |
| | | public class MinioUtil { |
| | | |
| | | @Resource |
| | | private MinioConfig minioProperties; |
| | | |
| | | public static byte[] toByteArray(InputStream input) throws IOException { |
| | | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[4096]; |
| | | int n = 0; |
| | | while (-1 != (n = input.read(buffer))) { |
| | | output.write(buffer, 0, n); |
| | | } |
| | | return output.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 文件上传 |
| | | * |
| | | * @param file |
| | | * 要上传的文件 |
| | | * @return |
| | | */ |
| | | public String upload(MultipartFile file, String name) { |
| | | if (null != file) { |
| | | try { |
| | | UUID uuid = UUID.randomUUID(); |
| | | StringBuilder s = new StringBuilder(); |
| | | s.append(uuid.toString().replace("-", "")).append("/"); |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | // bucket 不存在,创建 |
| | | if (!minioClient.bucketExists(minioProperties.getBucket())) { |
| | | minioClient.makeBucket(minioProperties.getBucket()); |
| | | } |
| | | // 得到文件流 |
| | | InputStream input = file.getInputStream(); |
| | | // 文件名 |
| | | // String fileName = uuid + "/images." + FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String fileName = s.append(name).toString(); |
| | | String contentType = file.getContentType(); |
| | | minioClient.putObject(minioProperties.getBucket(), fileName, input, contentType); |
| | | StringBuilder fileUrl = new StringBuilder(minioProperties.getUrl()); |
| | | String url = fileUrl.append(fileName).toString(); |
| | | return url; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public void download(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | ObjectStat stat = minioClient.statObject(minioProperties.getBucket(), fileName); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | response.setContentType(stat.contentType()); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); |
| | | IOUtils.copy(inputStream, response.getOutputStream()); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public byte[] getBytes(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | byte[] bytes = new byte[0]; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | bytes = toByteArray(inputStream); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return bytes; |
| | | } |
| | | } |
| | |
| | | active: ${ENV:dev} |
| | | servlet: |
| | | multipart: |
| | | max-file-size: 10MB |
| | | max-request-size: 10MB |
| | | max-file-size: 200MB |
| | | max-request-size: 200MB |
| | | |
| | | eureka: |
| | | client: |
| | |
| | | * 获取token |
| | | */ |
| | | public static final String GRID_GET_TOKEN_URL = |
| | | "http://171.217.92.33:53303/aaToken?username=#username&password=#password"; |
| | | "/aaToken?username=#username&password=#password"; |
| | | /** |
| | | * 提交事件登记(自处) |
| | | */ |
| | | public static final String GRID_REGIST_EVENT_URL = "http://171.217.92.33:53303/businessData/registEventInfo"; |
| | | public static final String GRID_REGIST_EVENT_URL = "/businessData/registEventInfo"; |
| | | /** |
| | | * 上传附件,仅上传文件流,服务器根据文件名自行匹配 |
| | | */ |
| | | public static final String GRID_EVENT_FILE_UPLOAD_URL = "http://171.217.92.33:53303/businessData/upload"; |
| | | public static final String GRID_EVENT_FILE_UPLOAD_URL = "/businessData/upload"; |
| | | /** |
| | | * 事件类型获取 |
| | | */ |
| | | public static final String GRID_EVENT_CATEGORY_URL = "http://171.217.92.33:53303/businessData/getEventType"; |
| | | public static final String GRID_EVENT_CATEGORY_URL = "/businessData/getEventType"; |
| | | /** |
| | | * 事件查询接口 |
| | | */ |
| | | public static final String GRID_EVENT_INFO_URL = "http://171.217.92.33:53303/businessData/getEventListInfo"; |
| | | public static final String GRID_EVENT_INFO_URL = "/businessData/getEventListInfo"; |
| | | /** |
| | | * 获取指定APP登记事件详情信息 |
| | | */ |
| | | public static final String GRID_EVENT_INFO_DETAIL_URL = "http://171.217.92.33:53303/businessData/getEventDetails"; |
| | | public static final String GRID_EVENT_INFO_DETAIL_URL = "/businessData/getEventDetails"; |
| | | /** |
| | | * 获取指定事件信息 |
| | | */ |
| | | public static final String GRID_APP_EVENT_INFO_DETAIL_URL = |
| | | "http://171.217.92.33:53303/businessData/getAppointEventInfo"; |
| | | "/businessData/getAppointEventInfo"; |
| | | /** |
| | | * 通过AREAID获取辖区网格树 |
| | | */ |
| | | public static final String GRID_GET_EVENT_INFO_AREA_ID_URL = |
| | | "http://171.217.92.33:53303/area/getAreaGridTreeByAreaId"; |
| | | "/area/getAreaGridTreeByAreaId"; |
| | | /** |
| | | * 通过AREAID获取辖区网格数据列表 |
| | | */ |
| | | public static final String GRID_GET_GRID_DATA_AREA_ID_URL = |
| | | "http://171.217.92.33:53303/gridDefined/getGridInfoByAreaId"; |
| | | "/gridDefined/getGridInfoByAreaId"; |
| | | /** |
| | | * 获取所有或者根据姓名和工号查询,分页 |
| | | */ |
| | | public static final String GRID_GET_GETALL_SEARCH_PAGE_URL = |
| | | "http://171.217.92.33:53303/gridOperator/getAllOrSearchByPage?areaId=jhRxqEQp"; |
| | | "/gridOperator/getAllOrSearchByPage?areaId=jhRxqEQp"; |
| | | /** |
| | | * 流动人口 走访记录列表 |
| | | */ |
| | | public static final String VISIT_RECORD_FLOW_PERSON_PAGE_URL = |
| | | "http://171.217.92.33:53303/businessData/getFPVisitRecordByPageApp"; |
| | | "/businessData/getFPVisitRecordByPageApp"; |
| | | |
| | | /** |
| | | * 下面的接口全部都是走访任务接口 |
| | |
| | | * 流动人口 走访详情(民警带领下工作或者自己走访) |
| | | */ |
| | | public static final String VISIT_RECORD_FLOW_PERSON_DETAIL_URL = |
| | | "http://171.217.92.33:53303/businessData/getFPVisitRecordDetailByIdApp"; |
| | | "/businessData/getFPVisitRecordDetailByIdApp"; |
| | | /** |
| | | * 流动人口 添加走访记录 (民警带领下工作或者自己走访) |
| | | */ |
| | | public static final String VISIT_RECORD_FLOW_PERSON_SAVE_URL = |
| | | "http://171.217.92.33:53303/businessData/saveFpVisitRecordAppDock"; |
| | | "/businessData/saveFpVisitRecordAppDock"; |
| | | /** |
| | | * 重点人员 日常管理 走访记录列表 |
| | | */ |
| | | public static final String VISIT_RECORD_KEY_PERSON_PAGE_URL = |
| | | "http://171.217.92.33:53303/businessData/getKeyPersonVisitRecordByPageApp"; |
| | | "/businessData/getKeyPersonVisitRecordByPageApp"; |
| | | /** |
| | | * 重点人员 日常管理 走访详情 |
| | | */ |
| | | public static final String VISIT_RECORD_KEY_PERSON_DETAIL_URL = |
| | | "http://171.217.92.33:53303/businessData/getKeyPersonVisitRecordDetailByIdApp"; |
| | | "/businessData/getKeyPersonVisitRecordDetailByIdApp"; |
| | | /** |
| | | * 重点人员 日常管理 添加走访记录 |
| | | */ |
| | | public static final String VISIT_RECORD_KEY_PERSON_SAVE_REMOTE_URL = |
| | | "http://171.217.92.33:53303/businessData/saveKeyPersonVisitRecordAppDock"; |
| | | "/businessData/saveKeyPersonVisitRecordAppDock"; |
| | | |
| | | private LcApiConstants() { |
| | | throw new IllegalStateException("Utility class"); |
| | |
| | | package com.panzhihua.common.model.vos.community.reserve; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | |
| | | |
| | | /** |
| | | * @auther lyq |
| | | * @author lyq |
| | | * @create 2021-08-23 10:33:11 |
| | | * @describe 预约登记信息 |
| | | */ |
| | |
| | | /** |
| | | * 发布时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date publishTime; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createAt; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateAt; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date endTime; |
| | | |
| | | /** |
| | |
| | | * 操作记录 |
| | | */ |
| | | private List<ComOperationListVO> operationList; |
| | | |
| | | /** |
| | | * 预约登记id |
| | | */ |
| | | private Long reserveId; |
| | | } |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | private Integer isBoutique; |
| | | |
| | | @ApiModelProperty("发布时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createAt; |
| | | |
| | | @ApiModelProperty("最后回复时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date replyAt; |
| | | |
| | | @ApiModelProperty("邻里圈评论列表") |
New file |
| | |
| | | package com.panzhihua.common.redis; |
| | | |
| | | import java.time.Duration; |
| | | |
| | | import org.springframework.cache.CacheManager; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.cache.RedisCacheConfiguration; |
| | | import org.springframework.data.redis.cache.RedisCacheManager; |
| | | import org.springframework.data.redis.connection.RedisConnectionFactory; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
| | | import org.springframework.data.redis.serializer.RedisSerializationContext; |
| | | import org.springframework.data.redis.serializer.RedisSerializer; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
| | | import com.fasterxml.jackson.annotation.PropertyAccessor; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 缓存配置类 |
| | | * |
| | | * @author manailin Date 2021-08-27 15:30 |
| | | **/ |
| | | @Configuration |
| | | public class CacheConfig { |
| | | |
| | | private Duration timeToLive = Duration.ofHours(1); |
| | | |
| | | @Bean |
| | | public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { |
| | | RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); |
| | | redisTemplate.setConnectionFactory(redisConnectionFactory); |
| | | |
| | | // 使用Jackson2JsonRedisSerialize 替换默认序列化 |
| | | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); |
| | | |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
| | | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
| | | |
| | | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); |
| | | |
| | | // 设置value的序列化规则和 key的序列化规则 |
| | | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); |
| | | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.afterPropertiesSet(); |
| | | return redisTemplate; |
| | | } |
| | | |
| | | @Bean |
| | | public CacheManager cacheManager(RedisConnectionFactory factory) { |
| | | RedisSerializer<String> redisSerializer = new StringRedisSerializer(); |
| | | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); |
| | | |
| | | // 解决查询缓存转换异常的问题 |
| | | ObjectMapper om = new ObjectMapper(); |
| | | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
| | | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
| | | jackson2JsonRedisSerializer.setObjectMapper(om); |
| | | |
| | | // 配置序列化(解决乱码的问题) |
| | | RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(timeToLive) |
| | | .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer)) |
| | | .serializeValuesWith( |
| | | RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer)) |
| | | .disableCachingNullValues(); |
| | | RedisCacheManager cacheManager = RedisCacheManager.builder(factory).cacheDefaults(config).build(); |
| | | |
| | | return cacheManager; |
| | | } |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.redis; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.*; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 攀枝花智慧社区项目 |
| | | * <p> |
| | | * redis 操作工具类 |
| | | * <p> |
| | | * Copyright: Copyright (C) 2021 XXX, Inc. All rights reserved. |
| | | * <p> |
| | | * Company: 成都呐喊信息技术有限公司 |
| | | * <p> |
| | | * |
| | | * @author manailin |
| | | * @since 2021/8/27 8:58 |
| | | */ |
| | | @Component |
| | | public class RedisUtils { |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | /** |
| | | * 写入缓存 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public boolean set(final String key, Object value) { |
| | | boolean result = false; |
| | | try { |
| | | ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue(); |
| | | operations.set(key, value); |
| | | result = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 写入缓存设置时效时间 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public boolean set(final String key, Object value, Long expireTime) { |
| | | boolean result = false; |
| | | try { |
| | | ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue(); |
| | | operations.set(key, value); |
| | | redisTemplate.expire(key, expireTime, TimeUnit.SECONDS); |
| | | result = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 批量删除对应的value |
| | | * |
| | | * @param keys |
| | | */ |
| | | public void remove(final String... keys) { |
| | | for (String key : keys) { |
| | | remove(key); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量删除对应的value (带事务,业务代码中用到事务,则需用此方法) |
| | | * |
| | | * @param keys |
| | | */ |
| | | public void removeTransactional(final String... keys) { |
| | | for (String key : keys) { |
| | | removeTransactional(key); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量删除key |
| | | * |
| | | * @param pattern |
| | | */ |
| | | public void removePattern(final String pattern) { |
| | | Set<Serializable> keys = redisTemplate.keys(pattern); |
| | | if (keys.size() > 0) { |
| | | redisTemplate.delete(keys); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除对应的value |
| | | * |
| | | * @param key |
| | | */ |
| | | public void remove(final String key) { |
| | | if (exists(key)) { |
| | | redisTemplate.delete(key); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断缓存中是否有对应的value |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public boolean exists(final String key) { |
| | | return redisTemplate.hasKey(key); |
| | | } |
| | | |
| | | /** |
| | | * 读取缓存 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public Object get(final String key) { |
| | | ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue(); |
| | | return operations.get(key); |
| | | } |
| | | |
| | | /** |
| | | * 哈希 添加 |
| | | * |
| | | * @param key |
| | | * @param hashKey |
| | | * @param value |
| | | */ |
| | | public void hmSet(String key, Object hashKey, Object value) { |
| | | HashOperations<String, Object, Object> hash = redisTemplate.opsForHash(); |
| | | hash.put(key, hashKey, value); |
| | | } |
| | | |
| | | /** |
| | | * 哈希获取数据 |
| | | * |
| | | * @param key |
| | | * @param hashKey |
| | | * @return |
| | | */ |
| | | public Object hmGet(String key, Object hashKey) { |
| | | HashOperations<String, Object, Object> hash = redisTemplate.opsForHash(); |
| | | return hash.get(key, hashKey); |
| | | } |
| | | |
| | | /** |
| | | * 列表添加 |
| | | * |
| | | * @param k |
| | | * @param v |
| | | */ |
| | | public void lPush(String k, Object v) { |
| | | ListOperations<String, Object> list = redisTemplate.opsForList(); |
| | | list.rightPush(k, v); |
| | | } |
| | | |
| | | /** |
| | | * 列表获取 |
| | | * |
| | | * @param k |
| | | * @param l |
| | | * @param l1 |
| | | * @return |
| | | */ |
| | | public List<Object> lRange(String k, long l, long l1) { |
| | | ListOperations<String, Object> list = redisTemplate.opsForList(); |
| | | return list.range(k, l, l1); |
| | | } |
| | | |
| | | /** |
| | | * 集合添加 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | public void add(String key, Object value) { |
| | | SetOperations<String, Object> set = redisTemplate.opsForSet(); |
| | | set.add(key, value); |
| | | } |
| | | |
| | | /** |
| | | * 集合获取 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public Set<Object> setMembers(String key) { |
| | | SetOperations<String, Object> set = redisTemplate.opsForSet(); |
| | | return set.members(key); |
| | | } |
| | | |
| | | /** |
| | | * 有序集合添加 |
| | | * |
| | | * @param key |
| | | * @param value |
| | | * @param scoure |
| | | */ |
| | | public void zAdd(String key, Object value, double scoure) { |
| | | ZSetOperations<String, Object> zset = redisTemplate.opsForZSet(); |
| | | zset.add(key, value, scoure); |
| | | } |
| | | |
| | | /** |
| | | * 有序集合获取 |
| | | * |
| | | * @param key |
| | | * @param scoure |
| | | * @param scoure1 |
| | | * @return |
| | | */ |
| | | public Set<Object> rangeByScore(String key, double scoure, double scoure1) { |
| | | ZSetOperations<String, Object> zset = redisTemplate.opsForZSet(); |
| | | return zset.rangeByScore(key, scoure, scoure1); |
| | | } |
| | | |
| | | /** |
| | | * 加锁 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public boolean tryLock(String key) { |
| | | try { |
| | | long currTime = System.currentTimeMillis(); |
| | | // 加锁成功 |
| | | return redisTemplate.opsForValue().setIfAbsent(key, currTime); |
| | | } finally { |
| | | redisTemplate.expire(key, 5, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.panzhihua.community_backstage; |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | | import org.springframework.cloud.client.SpringCloudApplication; |
| | | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; |
| | | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; |
| | |
| | | |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | @EnableCaching |
| | | @EnableSwagger2 |
| | | @SpringCloudApplication |
| | | @EnableCircuitBreaker |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.panzhihua.community_backstage.config.MinioUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | private int port; |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | |
| | | @ApiOperation(value = "社区所有启用的党组织列表", response = PartyOrganizationVO.class) |
| | | @GetMapping("listpartyorganization") |
| | |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "新上传照片接口") |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "批量新增党员导入excel") |
| | | @PostMapping(value = "downloadtemplate", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R downloadTemplate(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | |
| | | if(isOk.getData() != null){ |
| | | return isOk; |
| | | }else{ |
| | | communityService.addSysConfValue(key + communityId,communityId,"社区邻里圈自动审核参数","2"); |
| | | isOk.setData("2"); |
| | | communityService.addSysConfValue(key + communityId,communityId,"社区邻里圈自动审核参数","1"); |
| | | isOk.setData("1"); |
| | | return isOk; |
| | | } |
| | | } |
| | |
| | | active: ${ENV:dev} |
| | | servlet: |
| | | multipart: |
| | | max-file-size: 100MB |
| | | max-request-size: 100MB |
| | | max-file-size: 200MB |
| | | max-request-size: 200MB |
| | | |
| | | eureka: |
| | | client: |
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-actuator</artifactId> |
| | | </dependency> |
| | | |
| | | <!--minio文件存储--> |
| | | <dependency> |
| | | <groupId>io.minio</groupId> |
| | | <artifactId>minio</artifactId> |
| | | <version>6.0.8</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.panzhihua.grid_app.config.MinioUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private String url; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | |
| | | @ApiOperation(value = "上传照片/视频 (jpg/jpeg/png/mp4/mov)") |
| | | @PostMapping(value = "uploadimage", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "新上传照片接口") |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "批量上传照片/视频 (jpg/jpeg/png/mp4/mov)") |
| | | @PostMapping(value = "uploads", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile[] files, HttpServletRequest request) throws IOException { |
| | | public R uploads(@RequestParam MultipartFile[] files, HttpServletRequest request) throws IOException { |
| | | // 微信图片内容校验 |
| | | // WxMaSecCheckService wxMaSecCheckService = wxMaConfiguration.getMaService().getSecCheckService(); |
| | | String property = System.getProperty("user.dir"); |
| | |
| | | return R.ok(urlList); |
| | | } |
| | | |
| | | @ApiOperation(value = "新批量文件上传接口") |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R ossUploads(@RequestParam MultipartFile[] files, HttpServletRequest request) { |
| | | try { |
| | | List<String> urlList = new ArrayList<>(); |
| | | for (MultipartFile file : files) { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | urlList.add(imageUrl); |
| | | } |
| | | return R.ok(urlList); |
| | | } catch (Exception e) { |
| | | log.error("上传文件失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getConf/noToken") |
| | | @ApiOperation(value = "根据code查询系统配置") |
| | | public R getConf(@RequestParam("code") String code) { |
New file |
| | |
| | | package com.panzhihua.grid_app.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio存储信息配置 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Data |
| | | @ConfigurationProperties(prefix = "minio") |
| | | public class MinioConfig { |
| | | |
| | | private String host; |
| | | |
| | | private String accessKey; |
| | | |
| | | private String secretKey; |
| | | |
| | | private String url; |
| | | |
| | | private String bucket; |
| | | |
| | | private String aliasName; |
| | | |
| | | private String aliasPCName; |
| | | } |
New file |
| | |
| | | package com.panzhihua.grid_app.config; |
| | | |
| | | import io.minio.MinioClient; |
| | | import io.minio.ObjectStat; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio工具类 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Component |
| | | @EnableConfigurationProperties(MinioConfig.class) |
| | | public class MinioUtil { |
| | | |
| | | @Resource |
| | | private MinioConfig minioProperties; |
| | | |
| | | public static byte[] toByteArray(InputStream input) throws IOException { |
| | | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[4096]; |
| | | int n = 0; |
| | | while (-1 != (n = input.read(buffer))) { |
| | | output.write(buffer, 0, n); |
| | | } |
| | | return output.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 文件上传 |
| | | * |
| | | * @param file |
| | | * 要上传的文件 |
| | | * @return |
| | | */ |
| | | public String upload(MultipartFile file, String name) { |
| | | if (null != file) { |
| | | try { |
| | | UUID uuid = UUID.randomUUID(); |
| | | StringBuilder s = new StringBuilder(); |
| | | s.append(uuid.toString().replace("-", "")).append("/"); |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | // bucket 不存在,创建 |
| | | if (!minioClient.bucketExists(minioProperties.getBucket())) { |
| | | minioClient.makeBucket(minioProperties.getBucket()); |
| | | } |
| | | // 得到文件流 |
| | | InputStream input = file.getInputStream(); |
| | | // 文件名 |
| | | // String fileName = uuid + "/images." + FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String fileName = s.append(name).toString(); |
| | | String contentType = file.getContentType(); |
| | | minioClient.putObject(minioProperties.getBucket(), fileName, input, contentType); |
| | | StringBuilder fileUrl = new StringBuilder(minioProperties.getUrl()); |
| | | String url = fileUrl.append(fileName).toString(); |
| | | return url; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public void download(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | ObjectStat stat = minioClient.statObject(minioProperties.getBucket(), fileName); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | response.setContentType(stat.contentType()); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); |
| | | IOUtils.copy(inputStream, response.getOutputStream()); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public byte[] getBytes(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | byte[] bytes = new byte[0]; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | bytes = toByteArray(inputStream); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return bytes; |
| | | } |
| | | } |
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-actuator</artifactId> |
| | | </dependency> |
| | | |
| | | <!--minio文件存储--> |
| | | <dependency> |
| | | <groupId>io.minio</groupId> |
| | | <artifactId>minio</artifactId> |
| | | <version>6.0.8</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import java.util.UUID; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.panzhihua.grid_backstage.config.MinioUtil; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | private int port; |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | |
| | | @ApiOperation(value = "上传照片/视频 (jpg/jpeg/png/mp4/mov)") |
| | | @PostMapping(value = "uploadimage", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "新上传照片接口") |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.grid_backstage.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio存储信息配置 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Data |
| | | @ConfigurationProperties(prefix = "minio") |
| | | public class MinioConfig { |
| | | |
| | | private String host; |
| | | |
| | | private String accessKey; |
| | | |
| | | private String secretKey; |
| | | |
| | | private String url; |
| | | |
| | | private String bucket; |
| | | |
| | | private String aliasName; |
| | | |
| | | private String aliasPCName; |
| | | } |
New file |
| | |
| | | package com.panzhihua.grid_backstage.config; |
| | | |
| | | import io.minio.MinioClient; |
| | | import io.minio.ObjectStat; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 description minio工具类 |
| | | * |
| | | * @author manailin Date 2021-08-19 15:30 |
| | | **/ |
| | | @Component |
| | | @EnableConfigurationProperties(MinioConfig.class) |
| | | public class MinioUtil { |
| | | |
| | | @Resource |
| | | private MinioConfig minioProperties; |
| | | |
| | | public static byte[] toByteArray(InputStream input) throws IOException { |
| | | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[4096]; |
| | | int n = 0; |
| | | while (-1 != (n = input.read(buffer))) { |
| | | output.write(buffer, 0, n); |
| | | } |
| | | return output.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 文件上传 |
| | | * |
| | | * @param file |
| | | * 要上传的文件 |
| | | * @return |
| | | */ |
| | | public String upload(MultipartFile file, String name) { |
| | | if (null != file) { |
| | | try { |
| | | UUID uuid = UUID.randomUUID(); |
| | | StringBuilder s = new StringBuilder(); |
| | | s.append(uuid.toString().replace("-", "")).append("/"); |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | // bucket 不存在,创建 |
| | | if (!minioClient.bucketExists(minioProperties.getBucket())) { |
| | | minioClient.makeBucket(minioProperties.getBucket()); |
| | | } |
| | | // 得到文件流 |
| | | InputStream input = file.getInputStream(); |
| | | // 文件名 |
| | | // String fileName = uuid + "/images." + FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String fileName = s.append(name).toString(); |
| | | String contentType = file.getContentType(); |
| | | minioClient.putObject(minioProperties.getBucket(), fileName, input, contentType); |
| | | StringBuilder fileUrl = new StringBuilder(minioProperties.getUrl()); |
| | | String url = fileUrl.append(fileName).toString(); |
| | | return url; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public void download(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | ObjectStat stat = minioClient.statObject(minioProperties.getBucket(), fileName); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | response.setContentType(stat.contentType()); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); |
| | | IOUtils.copy(inputStream, response.getOutputStream()); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 文件下载 |
| | | * |
| | | * @param response |
| | | * @param url |
| | | */ |
| | | public byte[] getBytes(HttpServletResponse response, String url) { |
| | | // 从链接中得到文件名 |
| | | String replace = url.replace(minioProperties.getBucket() + "/", "#"); |
| | | String fileName = replace.split("#")[1]; |
| | | InputStream inputStream; |
| | | byte[] bytes = new byte[0]; |
| | | try { |
| | | MinioClient minioClient = new MinioClient(minioProperties.getHost(), minioProperties.getAccessKey(), |
| | | minioProperties.getSecretKey()); |
| | | inputStream = minioClient.getObject(minioProperties.getBucket(), fileName); |
| | | bytes = toByteArray(inputStream); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return bytes; |
| | | } |
| | | } |
| | |
| | | active: ${ENV:dev} |
| | | servlet: |
| | | multipart: |
| | | max-file-size: 10MB |
| | | max-request-size: 10MB |
| | | max-file-size: 200MB |
| | | max-request-size: 200MB |
| | | |
| | | eureka: |
| | | client: |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class LcApiServiceImpl implements LcApiService { |
| | | |
| | | @Value("${langchao.url}") |
| | | private String host; |
| | | |
| | | @Resource |
| | | private GridService gridService; |
| | |
| | | } else { |
| | | // 如果第一次请求浪潮的token请求,请求完成后,保存对于的token到数据库中。便于12小时内重复调用 |
| | | HttpRequest request = HttpUtil.createPost( |
| | | host + |
| | | LcApiConstants.GRID_GET_TOKEN_URL.replace("#username", name).replace("#password", password)); |
| | | HttpResponse result = request.execute(); |
| | | ValueOperations<String, String> valueOperations = redisTemplate.opsForValue(); |
| | |
| | | |
| | | @Override |
| | | public String getAllEventTypeList() { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.GRID_EVENT_CATEGORY_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_EVENT_CATEGORY_URL); |
| | | request.auth(getAuthToken()); |
| | | HttpResponse result = request.execute(); |
| | | return result.body(); |
| | |
| | | |
| | | @Override |
| | | public String submitEventRegister(EventInfo eventInfo) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.GRID_REGIST_EVENT_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_REGIST_EVENT_URL); |
| | | request.auth(getAuthToken()); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | |
| | | |
| | | @Override |
| | | public R submitEventOrVisitRecordRelationFile(EventFile eventFile) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.GRID_EVENT_FILE_UPLOAD_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_EVENT_FILE_UPLOAD_URL); |
| | | request.auth(getAuthToken()); |
| | | try { |
| | | HttpURLConnection httpUrl = (HttpURLConnection)new URL(eventFile.getFiles()).openConnection(); |
| | |
| | | |
| | | @Override |
| | | public String getEventInfoById(String eventId) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.GRID_APP_EVENT_INFO_DETAIL_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_APP_EVENT_INFO_DETAIL_URL); |
| | | request.auth(getAuthToken()); |
| | | request.form("eventId", eventId); |
| | | HttpResponse result = request.execute(); |
| | |
| | | |
| | | @Override |
| | | public List<LcGridData> getGridTreeByAreaId(String areaId) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.GRID_GET_EVENT_INFO_AREA_ID_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_GET_EVENT_INFO_AREA_ID_URL); |
| | | request.auth(getAuthToken()); |
| | | request.form("areaId", areaId); |
| | | request.form("level", 4); |
| | |
| | | |
| | | @Override |
| | | public List<LcGridData> getGridDataListByAreaId(String areaId) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.GRID_GET_GRID_DATA_AREA_ID_URL); |
| | | log.info("浪潮请求url"); |
| | | log.info(host + LcApiConstants.GRID_GET_GRID_DATA_AREA_ID_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_GET_GRID_DATA_AREA_ID_URL); |
| | | request.auth(getAuthToken()); |
| | | request.form("areaId", areaId); |
| | | HttpResponse result = request.execute(); |
| | |
| | | @Override |
| | | public List<GridMemberPageListDTO> getGridMemberListByAreaIdOrName(String areaId, String param, Long pageNum, |
| | | Long pageSize) { |
| | | HttpRequest request = HttpUtil.createGet(LcApiConstants.GRID_GET_GETALL_SEARCH_PAGE_URL); |
| | | HttpRequest request = HttpUtil.createGet(host + LcApiConstants.GRID_GET_GETALL_SEARCH_PAGE_URL); |
| | | request.auth(getAuthToken()); |
| | | request.form("areaId", areaId); |
| | | request.form("limit", pageSize); |
| | |
| | | |
| | | @Override |
| | | public String getFlowPersonVisitRecordDetailById(String recordId) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.VISIT_RECORD_FLOW_PERSON_DETAIL_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_FLOW_PERSON_DETAIL_URL); |
| | | request.auth(getAuthToken()); |
| | | request.form("id", recordId); |
| | | HttpResponse result = request.execute(); |
| | |
| | | public String getFlowPersonVisitRecordPage(LcKeyPersonVisitRecordQueryDTO personVisitRecordQueryDTO, |
| | | Long loginUserId) { |
| | | HttpResponse result = getHttpResponse(personVisitRecordQueryDTO, loginUserId, |
| | | host + |
| | | LcApiConstants.VISIT_RECORD_FLOW_PERSON_PAGE_URL, "flowPeopleId"); |
| | | return result.body(); |
| | | } |
| | | |
| | | @Override |
| | | public String uploadFlowPersonVisitRecord(LcFlowPersonVisitRecordDTO lcFlowPersonVisitRecordDTO) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.VISIT_RECORD_FLOW_PERSON_SAVE_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_FLOW_PERSON_SAVE_URL); |
| | | request.auth(getAuthToken()); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | |
| | | |
| | | @Override |
| | | public String uploadKeyPersonVisitRecord(LcKeyPersonVisitRecordDTO lcKeyPersonVisitRecordDTO) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.VISIT_RECORD_KEY_PERSON_SAVE_REMOTE_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_KEY_PERSON_SAVE_REMOTE_URL); |
| | | request.auth(getAuthToken()); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | |
| | | |
| | | @Override |
| | | public String getKeyPersonVisitRecordDetailById(String recordId) { |
| | | HttpRequest request = HttpUtil.createPost(LcApiConstants.VISIT_RECORD_KEY_PERSON_DETAIL_URL); |
| | | HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_KEY_PERSON_DETAIL_URL); |
| | | request.auth(getAuthToken()); |
| | | request.form("id", recordId); |
| | | HttpResponse result = request.execute(); |
| | |
| | | public String getKeyPersonVisitRecordPage(LcKeyPersonVisitRecordQueryDTO personVisitRecordQueryDTO, |
| | | Long loginUserId) { |
| | | HttpResponse result = getHttpResponse(personVisitRecordQueryDTO, loginUserId, |
| | | host + |
| | | LcApiConstants.VISIT_RECORD_KEY_PERSON_PAGE_URL, "keyPersonId"); |
| | | return result.body(); |
| | | } |
| | |
| | | "count(DISTINCT c.id)commentNum, " + |
| | | "u.image_url, " + |
| | | "p.happen_addr, " + |
| | | "p.addr_remark, " + |
| | | "su.`name` handler_name, " + |
| | | "p.`status`, " + |
| | | "p.`is_hide`, " + |
| | |
| | | noLoginUrl.add("/api/applets/community/pagedynamic"); |
| | | noLoginUrl.add("/api/applets/community/pageactivity"); |
| | | noLoginUrl.add("/api/applets/community/listactivitysign"); |
| | | noLoginUrl.add("/api/applets/common/uploadimages"); |
| | | noLoginUrl.add("/api/applets/workguide/pageworkguide"); |
| | | noLoginUrl.add("/api/applets/workguide/detailworkguide"); |
| | | noLoginUrl.add("/api/applets/workguide/list"); |
| | |
| | | noLoginUrl.add("/api/applets/community/pagevolunteer"); |
| | | noLoginUrl.add("/api/applets/community/volunteer"); |
| | | noLoginUrl.add("/api/applets/community/evaluate/page"); |
| | | |
| | | if (noLoginUrl.contains(requestURI)) { |
| | | List<SimpleGrantedAuthority> authorities = new ArrayList<>(); |
| | | authorities.add(new SimpleGrantedAuthority(SecurityConstants.ROLE_APPLETS)); |