wuxw 6 lat temu
rodzic
commit
5350ec080a

+ 3 - 3
Api/src/main/java/com/java110/api/ApiApplicationStart.java

@@ -108,10 +108,10 @@ public class ApiApplicationStart {
      */
     private ApiInfo apiInfo() {
         return new ApiInfoBuilder()
-                .title("Swagger2构建RESTful APIs")
-                .description("api信息")
+                .title("HC小区管理系统 APIs")
+                .description("HC小区管理系统提供的所有能力")
                 .termsOfServiceUrl("https://github.com/java110/MicroCommunity")
-                .contact("sunf")
+                .contact("吴学文")
                 .version("1.0")
                 .build();
     }

+ 4 - 0
Api/src/main/java/com/java110/api/listener/app/ListAppsListener.java

@@ -11,6 +11,8 @@ import com.java110.dto.app.AppDto;
 import com.java110.event.service.api.ServiceDataFlowEvent;
 import com.java110.vo.api.app.ApiAppDataVo;
 import com.java110.vo.api.app.ApiAppVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
@@ -24,6 +26,7 @@ import java.util.List;
  * 查询小区侦听类
  */
 @Java110Listener("listAppsListener")
+@Api(value = "查询应用服务")
 public class ListAppsListener extends AbstractServiceApiListener {
 
     @Autowired
@@ -59,6 +62,7 @@ public class ListAppsListener extends AbstractServiceApiListener {
         super.validatePageInfo(reqJson);
     }
 
+    @ApiOperation(value = "查询应用信息", notes = "test: 返回 2XX 表示服务正常", httpMethod = "GET", response = ApiAppVo.class)
     @Override
     protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
 

+ 0 - 94
Api/src/main/java/com/java110/api/rest/GetPhotoByInst.java

@@ -1,94 +0,0 @@
-package com.java110.api.rest;
-
-import org.apache.commons.io.FileUtils;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.util.StringUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-
-/**
- * @ClassName GetPhotoByInst
- * @Description TODO
- * @Author wuxw
- * @Date 2019/8/28 22:49
- * @Version 1.0
- * add by wuxw 2019/8/28
- **/
-public class GetPhotoByInst {
-
-    final static String PHOTO_INFO_PATH= "photoInfo.txt";
-    final static String DEFAULTE_PHOTO_DIR= "./Api/photos/";
-
-    public static void main(String[] args) {
-        //读取文件
-        Reader reader = null;
-        String sb = "";
-        try {
-            InputStream inputStream = new ClassPathResource(PHOTO_INFO_PATH).getInputStream();
-            //InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(File.separator + filePath);
-            reader = new InputStreamReader(inputStream, "UTF-8");
-            int tempChar;
-            StringBuffer b = new StringBuffer();
-            while ((tempChar = reader.read()) != -1) {
-                b.append((char) tempChar);
-            }
-            sb = b.toString();
-
-            String[] strs = sb.split("\n");
-
-            for(String str : strs){
-                dealPhoto(str);
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-
-    private static void dealPhoto(String str) {
-
-        String[] tmpPhotoPaths = str.split("\\|");
-
-        String instId = tmpPhotoPaths[0];
-        String photoUrl = tmpPhotoPaths[1];
-
-        downloadFromUrl(photoUrl,DEFAULTE_PHOTO_DIR,"qhdx_"+instId+"_17.jpg");
-        //downloadFromUrl(photoUrl,DEFAULTE_PHOTO_DIR,instId+".jpg");
-    }
-
-
-    /**
-     * 文件下载的方法
-     * @param  url 地址
-     * @param  dir 目录
-     * @return String fileName
-     */
-    public static String downloadFromUrl(String url, String dir,String fileName) {
-
-        try {
-            URL httpurl = new URL(url);
-            //	fileName = getFileNameFromUrl(url);
-            //String[] us=url.split("/");
-            //fileName=us[us.length-1];
-            System.out.println("fileName:"+fileName);
-            File f = new File(dir + fileName);
-            FileUtils.copyURLToFile(httpurl, f);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return "Fault!";
-        }
-        return fileName;
-    }
-}

+ 0 - 134
Api/src/main/java/com/java110/api/rest/PicTest.java

@@ -1,134 +0,0 @@
-package com.java110.api.rest;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-import javax.imageio.ImageIO;
-import javax.imageio.stream.FileImageOutputStream;
-
-public class PicTest {
-
-    static int a = 0;
-    public static void main(String[] args) throws IOException {
-        /*long timeStart = System.currentTimeMillis();
-        String imgLocalUrl = "D:\\白静雪.jpg";
-
-        byte[] imgBytes = getByteByPic(imgLocalUrl);
-        byte[] resultImg = compressUnderSize(imgBytes,800 * 1024);
-        byte2image(resultImg,"E:\\tp\\timga.jpg");
-        long timeEnd = System.currentTimeMillis();
-        System.out.println("耗时:"+ (timeEnd - timeStart));*/
-        char i= 8;
-        int j = 0;
-        for (;i >0;j-=3){
-            ++j;
-        }
-        System.out.printf("%d\n",j);
-
-       // System.out.printf("a= "+ fib(5));
-    }
-
-    public static int fib(int i) {
-        a++;
-        if(i == 0){
-            return 1;
-        }else{
-            if(i== 1){
-                return 2;
-            }else{
-                return  fib(i-1)+fib(i-2);
-            }
-
-        }
-
-    }
-
-    public static byte[] getByteByPic(String imageUrl) throws IOException{
-        File imageFile = new File(imageUrl);
-        InputStream inStream = new FileInputStream(imageFile);
-        BufferedInputStream bis = new BufferedInputStream(inStream);
-        BufferedImage bm = ImageIO.read(bis);
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        String type = imageUrl.substring(imageUrl.length() - 3);
-        ImageIO.write(bm, type, bos);
-        bos.flush();
-        byte[] data = bos.toByteArray();
-        return data;
-    }
-    /**
-     * 将图片压缩到指定大小以内
-     *
-     * @param srcImgData 源图片数据
-     * @param maxSize 目的图片大小
-     * @return 压缩后的图片数据
-     */
-    public static byte[] compressUnderSize(byte[] srcImgData, long maxSize) {
-        double scale = 0.9;
-        byte[] imgData = Arrays.copyOf(srcImgData, srcImgData.length);
-
-        if (imgData.length > maxSize) {
-            do {
-                try {
-                    imgData = compress(imgData, scale);
-
-                } catch (IOException e) {
-                    throw new IllegalStateException("压缩图片过程中出错,请及时联系管理员!", e);
-                }
-
-            } while (imgData.length > maxSize);
-        }
-
-        return imgData;
-    }
-
-    /**
-     * 按照 宽高 比例压缩
-     *
-     * @param scale 压缩刻度
-     * @return 压缩后图片数据
-     * @throws IOException 压缩图片过程中出错
-     */
-    public static byte[] compress(byte[] srcImgData, double scale) throws IOException {
-        BufferedImage bi = ImageIO.read(new ByteArrayInputStream(srcImgData));
-        int width = (int) (bi.getWidth() * scale); // 源图宽度
-        int height = (int) (bi.getHeight() * scale); // 源图高度
-
-        Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH);
-        BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
-
-        Graphics g = tag.getGraphics();
-        g.setColor(Color.RED);
-        g.drawImage(image, 0, 0, null); // 绘制处理后的图
-        g.dispose();
-
-        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
-        ImageIO.write(tag, "JPEG", bOut);
-
-        return bOut.toByteArray();
-    }
-
-    //byte数组到图片
-    public static void byte2image(byte[] data,String path){
-        if(data.length<3||path.equals("")) return;
-        try{
-            FileImageOutputStream imageOutput = new FileImageOutputStream(new File(path));
-            imageOutput.write(data, 0, data.length);
-            imageOutput.close();
-            System.out.println("Make Picture success,Please find image in " + path);
-        } catch(Exception ex) {
-            System.out.println("Exception: " + ex);
-            ex.printStackTrace();
-        }
-    }
-
-}