dingxin 6 years ago
parent
commit
2491c9bbb0

+ 13
- 22
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/ImageController.java View File

1
 package com.community.huiju.controller;
1
 package com.community.huiju.controller;
2
 
2
 
3
-import com.aliyun.oss.OSSClient;
4
-import io.swagger.annotations.*;
3
+import com.community.huiju.service.ImageServiceI;
4
+import io.swagger.annotations.Api;
5
+import io.swagger.annotations.ApiOperation;
6
+import io.swagger.annotations.ApiParam;
7
+import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.cloud.context.config.annotation.RefreshScope;
8
 import org.springframework.cloud.context.config.annotation.RefreshScope;
6
-import org.springframework.web.bind.annotation.*;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RestController;
7
 import org.springframework.web.multipart.MultipartFile;
12
 import org.springframework.web.multipart.MultipartFile;
8
 
13
 
9
-import java.io.ByteArrayInputStream;
10
-import java.util.Date;
11
-
12
 /**
14
 /**
13
  * @author weichaochao
15
  * @author weichaochao
14
  * @Title: ImageController
16
  * @Title: ImageController
21
 @Api(value = "图片操作API", description = "图片操作API")
23
 @Api(value = "图片操作API", description = "图片操作API")
22
 public class ImageController {
24
 public class ImageController {
23
 
25
 
24
-    private static String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
25
-    private static String accessKeyId = "LTAIiG6xeHbVzTXC";
26
-    private static String accessKeySecret = "YUci8oBtm5WzobH6SP2eyZUbjCBKBo";
27
-    private static String bucketName = "imgurlspace";
26
+
27
+
28
+    @Autowired
29
+    private ImageServiceI imageService;
28
 
30
 
29
     @ApiOperation(value = "图片上传以及获取url", notes = "图片上传以及获取url")
31
     @ApiOperation(value = "图片上传以及获取url", notes = "图片上传以及获取url")
30
     @PostMapping(value = "/getUrl", consumes = "multipart/*", headers = "content-type=multipart/form-data")
32
     @PostMapping(value = "/getUrl", consumes = "multipart/*", headers = "content-type=multipart/form-data")
31
     public String uploadImgAndGetUrl(@ApiParam(value = "file" ,required = true) MultipartFile uploadFile) throws Exception {
33
     public String uploadImgAndGetUrl(@ApiParam(value = "file" ,required = true) MultipartFile uploadFile) throws Exception {
32
 
34
 
33
-        String imgName = System.currentTimeMillis() + ".png";
34
-        // 创建OSSClient实例
35
-        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
36
-        // 上传
37
-        long time = System.currentTimeMillis();
38
-
39
-        ossClient.putObject(bucketName, imgName, new ByteArrayInputStream(uploadFile.getBytes()));
40
-
41
-        // 关闭client
42
-        ossClient.shutdown();
43
-        Date expiration = new Date(time + 3600 * 1000 * 24 * 365 * 10);
44
-        String url = ossClient.generatePresignedUrl(bucketName, imgName, expiration).toString();
35
+        String url = imageService.getImageUrl(uploadFile);
45
         return url;
36
         return url;
46
     }
37
     }
47
 }
38
 }

+ 6
- 7
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/SocialController.java View File

8
 import com.community.huiju.model.TpTicket;
8
 import com.community.huiju.model.TpTicket;
9
 import com.community.huiju.model.TpTransaction;
9
 import com.community.huiju.model.TpTransaction;
10
 import com.community.huiju.service.SocialServiceI;
10
 import com.community.huiju.service.SocialServiceI;
11
-import io.swagger.annotations.Api;
12
-import io.swagger.annotations.ApiImplicitParam;
13
-import io.swagger.annotations.ApiImplicitParams;
14
-import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.*;
15
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.cloud.context.config.annotation.RefreshScope;
13
 import org.springframework.cloud.context.config.annotation.RefreshScope;
17
 import org.springframework.web.bind.annotation.*;
14
 import org.springframework.web.bind.annotation.*;
15
+import org.springframework.web.multipart.MultipartFile;
18
 
16
 
19
 import javax.servlet.http.HttpSession;
17
 import javax.servlet.http.HttpSession;
18
+import java.io.IOException;
20
 import java.util.List;
19
 import java.util.List;
21
 
20
 
22
 /**
21
 /**
163
                     "title:小区标题,content:小区内容, type:0二手,1求购,2租赁"),
162
                     "title:小区标题,content:小区内容, type:0二手,1求购,2租赁"),
164
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
163
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
165
     })
164
     })
166
-    @RequestMapping(value = "/addTransaction", method = RequestMethod.POST)
165
+    @PostMapping(value = "/addTransaction", consumes = "multipart/*", headers = "content-type=multipart/form-data")
167
     @ResponseBody
166
     @ResponseBody
168
-    public ResponseBean addTransaction(@RequestBody String paramets, HttpSession session) {
167
+    public ResponseBean addTransaction(@RequestBody String paramets, @ApiParam(value = "file" ,required = true) MultipartFile uploadFile, HttpSession session) throws IOException {
169
         ResponseBean responseBean = new ResponseBean();
168
         ResponseBean responseBean = new ResponseBean();
170
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
169
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
171
         Integer userId = userElement.getId();
170
         Integer userId = userElement.getId();
172
-        ResponseBean response = socialServiceI.addAllTransaction(userId, paramets);
171
+        ResponseBean response = socialServiceI.addAllTransaction(userId, paramets, uploadFile);
173
         return response;
172
         return response;
174
     }
173
     }
175
 
174
 

+ 11
- 12
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/TaFaceController.java View File

5
 import com.community.huiju.model.TaAgreement;
5
 import com.community.huiju.model.TaAgreement;
6
 import com.community.huiju.model.TaFace;
6
 import com.community.huiju.model.TaFace;
7
 import com.community.huiju.service.TaFaceServicel;
7
 import com.community.huiju.service.TaFaceServicel;
8
-import io.swagger.annotations.Api;
9
-import io.swagger.annotations.ApiImplicitParam;
10
-import io.swagger.annotations.ApiImplicitParams;
11
-import io.swagger.annotations.ApiOperation;
8
+import io.swagger.annotations.*;
9
+import org.apache.commons.lang3.StringUtils;
12
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.cloud.context.config.annotation.RefreshScope;
11
 import org.springframework.cloud.context.config.annotation.RefreshScope;
14
 import org.springframework.web.bind.annotation.RequestMapping;
12
 import org.springframework.web.bind.annotation.RequestMapping;
15
 import org.springframework.web.bind.annotation.RequestMethod;
13
 import org.springframework.web.bind.annotation.RequestMethod;
16
 import org.springframework.web.bind.annotation.RequestParam;
14
 import org.springframework.web.bind.annotation.RequestParam;
17
 import org.springframework.web.bind.annotation.RestController;
15
 import org.springframework.web.bind.annotation.RestController;
16
+import org.springframework.web.multipart.MultipartFile;
18
 
17
 
19
 import javax.servlet.http.HttpSession;
18
 import javax.servlet.http.HttpSession;
20
 
19
 
28
 
27
 
29
     @ApiOperation(value = "添加人脸图片", notes = "添加人脸图片")
28
     @ApiOperation(value = "添加人脸图片", notes = "添加人脸图片")
30
     @ApiImplicitParams({
29
     @ApiImplicitParams({
31
-            @ApiImplicitParam(paramType = "query",dataType = "Integer",name = "communityId",value = "小区id"),
32
-            @ApiImplicitParam(paramType = "query",dataType = "String",name = "faceImg",value = "上传的图片"),
30
+//            @ApiImplicitParam(paramType = "query",dataType = "String",name = "faceImg",value = "上传的图片"),
33
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
31
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
34
     })
32
     })
35
     @RequestMapping(value = "/addFace",method = RequestMethod.POST)
33
     @RequestMapping(value = "/addFace",method = RequestMethod.POST)
36
-    public Object getTaFace(HttpSession session,@RequestParam Integer communityId,
37
-                                @RequestParam String faceImg){
34
+    public Object getTaFace(HttpSession session,
35
+                            @ApiParam(value = "file" ,required = true) MultipartFile uploadFile){
38
         ResponseBean responseBean = new ResponseBean();
36
         ResponseBean responseBean = new ResponseBean();
39
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
37
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
40
         Integer userId = userElement.getId();
38
         Integer userId = userElement.getId();
41
-        responseBean = faceServicel.addFace(faceImg,userId);
39
+        responseBean = faceServicel.addFace(userId ,uploadFile);
42
         return responseBean;
40
         return responseBean;
43
     }
41
     }
44
 
42
 
45
     @ApiOperation(value = "修改人脸图片", notes = "修改人脸图片")
43
     @ApiOperation(value = "修改人脸图片", notes = "修改人脸图片")
46
     @ApiImplicitParams({
44
     @ApiImplicitParams({
47
-            @ApiImplicitParam(paramType = "query",dataType = "String",name = "faceImg",value = "上传的图片"),
45
+    /*        @ApiImplicitParam(paramType = "query",dataType = "String",name = "faceImg",value = "上传的图片"),*/
48
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
46
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
49
     })
47
     })
50
     @RequestMapping(value = "/upDateFace",method = RequestMethod.PUT)
48
     @RequestMapping(value = "/upDateFace",method = RequestMethod.PUT)
51
-    public Object upDateTaFace(HttpSession session, @RequestParam String faceImg
49
+    public Object upDateTaFace(HttpSession session,
50
+                               @ApiParam(value = "file" ,required = true) MultipartFile uploadFile
52
                                ){
51
                                ){
53
         ResponseBean responseBean = new ResponseBean();
52
         ResponseBean responseBean = new ResponseBean();
54
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
53
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
55
         Integer userId = userElement.getId();
54
         Integer userId = userElement.getId();
56
-         responseBean = faceServicel.upDateFace(faceImg,userId);
55
+         responseBean = faceServicel.upDateFace(userId,uploadFile);
57
         return responseBean;
56
         return responseBean;
58
     }
57
     }
59
 
58
 

+ 19
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TdImagesMapper.java View File

1
+package com.community.huiju.dao;
2
+
3
+import com.community.huiju.model.TdImages;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface TdImagesMapper {
8
+    int deleteByPrimaryKey(Integer id);
9
+
10
+    int insert(TdImages record);
11
+
12
+    int insertSelective(TdImages record);
13
+
14
+    TdImages selectByPrimaryKey(Integer id);
15
+
16
+    int updateByPrimaryKeySelective(TdImages record);
17
+
18
+    int updateByPrimaryKey(TdImages record);
19
+}

+ 65
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TdImages.java View File

1
+package com.community.huiju.model;
2
+
3
+import java.util.Date;
4
+
5
+public class TdImages {
6
+    private Integer id;
7
+
8
+    private String imageUrl;
9
+
10
+    private Integer uuid;
11
+
12
+    private String type;
13
+
14
+    private Integer createUser;
15
+
16
+    private Date createTime;
17
+
18
+    public Integer getId() {
19
+        return id;
20
+    }
21
+
22
+    public void setId(Integer id) {
23
+        this.id = id;
24
+    }
25
+
26
+    public String getImageUrl() {
27
+        return imageUrl;
28
+    }
29
+
30
+    public void setImageUrl(String imageUrl) {
31
+        this.imageUrl = imageUrl == null ? null : imageUrl.trim();
32
+    }
33
+
34
+    public Integer getUuid() {
35
+        return uuid;
36
+    }
37
+
38
+    public void setUuid(Integer uuid) {
39
+        this.uuid = uuid;
40
+    }
41
+
42
+    public String getType() {
43
+        return type;
44
+    }
45
+
46
+    public void setType(String type) {
47
+        this.type = type == null ? null : type.trim();
48
+    }
49
+
50
+    public Integer getCreateUser() {
51
+        return createUser;
52
+    }
53
+
54
+    public void setCreateUser(Integer createUser) {
55
+        this.createUser = createUser;
56
+    }
57
+
58
+    public Date getCreateTime() {
59
+        return createTime;
60
+    }
61
+
62
+    public void setCreateTime(Date createTime) {
63
+        this.createTime = createTime;
64
+    }
65
+}

+ 15
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/ImageServiceI.java View File

1
+package com.community.huiju.service;
2
+
3
+import org.springframework.web.multipart.MultipartFile;
4
+
5
+import java.io.IOException;
6
+
7
+/**
8
+ * @author admin
9
+ * @Title: ImageServiceI
10
+ * @Description: TODO
11
+ * @date 2018/11/5
12
+ */
13
+public interface ImageServiceI {
14
+    String getImageUrl(MultipartFile uploadFile) throws IOException;
15
+}

+ 3
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/SocialServiceI.java View File

2
 
2
 
3
 import com.community.commom.mode.ResponseBean;
3
 import com.community.commom.mode.ResponseBean;
4
 import com.community.huiju.model.*;
4
 import com.community.huiju.model.*;
5
+import org.springframework.web.multipart.MultipartFile;
5
 
6
 
7
+import java.io.IOException;
6
 import java.util.List;
8
 import java.util.List;
7
 
9
 
8
 /**
10
 /**
69
 	/**
71
 	/**
70
 	 * 添加二手租赁帖子
72
 	 * 添加二手租赁帖子
71
 	 */
73
 	 */
72
-    ResponseBean addAllTransaction(Integer userId, String paramets);
74
+    ResponseBean addAllTransaction(Integer userId, String paramets, MultipartFile uploadFile) throws IOException;
73
 
75
 
74
 	/**
76
 	/**
75
 	 * 获取当前用户发布所有的帖子
77
 	 * 获取当前用户发布所有的帖子

+ 3
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/TaFaceServicel.java View File

2
 
2
 
3
 
3
 
4
 import com.community.commom.mode.ResponseBean;
4
 import com.community.commom.mode.ResponseBean;
5
+import org.springframework.web.multipart.MultipartFile;
5
 
6
 
6
 public interface TaFaceServicel {
7
 public interface TaFaceServicel {
7
     /**
8
     /**
8
      * 添加人脸
9
      * 添加人脸
9
-     * @param faceImg
10
      * @param userId
10
      * @param userId
11
      * @return
11
      * @return
12
      */
12
      */
13
-    ResponseBean addFace(String faceImg, Integer userId);
13
+    ResponseBean addFace(Integer userId ,MultipartFile uploadFile);
14
 
14
 
15
     /**
15
     /**
16
      * 更新当前人脸
16
      * 更新当前人脸
17
-     * @param faceImg
18
      * @param userId
17
      * @param userId
19
      * @return
18
      * @return
20
      */
19
      */
21
-    ResponseBean upDateFace(String faceImg, Integer userId);
20
+    ResponseBean upDateFace(Integer userId , MultipartFile uploadFile);
22
 }
21
 }

+ 43
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/ImageServiceimpl.java View File

1
+package com.community.huiju.service.impl;
2
+
3
+import com.aliyun.oss.OSSClient;
4
+import com.community.huiju.service.ImageServiceI;
5
+import org.springframework.stereotype.Service;
6
+import org.springframework.web.multipart.MultipartFile;
7
+
8
+import java.io.ByteArrayInputStream;
9
+import java.io.IOException;
10
+import java.util.Date;
11
+
12
+/**
13
+ * @author weichaochao
14
+ * @Title: ImageServiceimpl
15
+ * @Description: 获取图片地址实现类
16
+ * @date 2018/11/5
17
+ */
18
+@Service("ImageService")
19
+public class ImageServiceimpl implements ImageServiceI {
20
+
21
+    private static String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
22
+    private static String accessKeyId = "LTAIiG6xeHbVzTXC";
23
+    private static String accessKeySecret = "YUci8oBtm5WzobH6SP2eyZUbjCBKBo";
24
+    private static String bucketName = "imgurlspace";
25
+
26
+    @Override
27
+    public String getImageUrl(MultipartFile uploadFile) throws IOException {
28
+
29
+        String imgName = System.currentTimeMillis() + ".png";
30
+        // 创建OSSClient实例
31
+        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
32
+        // 上传
33
+        long time = System.currentTimeMillis();
34
+
35
+        ossClient.putObject(bucketName, imgName, new ByteArrayInputStream(uploadFile.getBytes()));
36
+
37
+        // 关闭client
38
+        ossClient.shutdown();
39
+        Date expiration = new Date(time + 3600 * 1000 * 24 * 365 * 10);
40
+        String url = ossClient.generatePresignedUrl(bucketName, imgName, expiration).toString();
41
+        return url;
42
+    }
43
+}

+ 24
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/SocialServiceImpl.java View File

5
 import com.community.commom.mode.ResponseBean;
5
 import com.community.commom.mode.ResponseBean;
6
 import com.community.huiju.dao.*;
6
 import com.community.huiju.dao.*;
7
 import com.community.huiju.model.*;
7
 import com.community.huiju.model.*;
8
+import com.community.huiju.service.ImageServiceI;
8
 import com.community.huiju.service.SocialServiceI;
9
 import com.community.huiju.service.SocialServiceI;
9
 import com.github.pagehelper.PageHelper;
10
 import com.github.pagehelper.PageHelper;
10
-import com.netflix.discovery.converters.Auto;
11
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
13
 import org.springframework.transaction.annotation.Transactional;
13
 import org.springframework.transaction.annotation.Transactional;
14
+import org.springframework.web.multipart.MultipartFile;
14
 
15
 
15
-import java.text.SimpleDateFormat;
16
+import java.io.IOException;
16
 import java.util.Date;
17
 import java.util.Date;
17
 import java.util.List;
18
 import java.util.List;
18
 
19
 
57
     @Autowired
58
     @Autowired
58
     private TpTicketMapper tpTicketMapper;
59
     private TpTicketMapper tpTicketMapper;
59
 
60
 
61
+    @Autowired
62
+    private TdImagesMapper tdImagesMapper;
63
+
64
+    @Autowired
65
+    private ImageServiceI imageServiceI;
66
+
60
     @Override
67
     @Override
61
     @Transactional
68
     @Transactional
62
     public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId, Integer userId) {
69
     public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId, Integer userId) {
221
 
228
 
222
     @Transactional
229
     @Transactional
223
     @Override
230
     @Override
224
-    public ResponseBean addAllTransaction(Integer userId, String paramets) {
231
+    public ResponseBean addAllTransaction(Integer userId, String paramets, MultipartFile uploadFile) throws IOException {
225
 
232
 
226
         ResponseBean response = new ResponseBean();
233
         ResponseBean response = new ResponseBean();
227
 
234
 
231
         String  type= (String) jsonObject.get("type");
238
         String  type= (String) jsonObject.get("type");
232
 
239
 
233
         TaUser user=taUserMapper.selectByPrimaryKey(userId);
240
         TaUser user=taUserMapper.selectByPrimaryKey(userId);
234
-        TpTransaction tpTransaction=new TpTransaction();
241
+        TpTransaction tpTransaction = new TpTransaction();
235
         tpTransaction.setTransactionTitle(transactionTitle);
242
         tpTransaction.setTransactionTitle(transactionTitle);
236
         tpTransaction.setTransactionContent(transactionContent);
243
         tpTransaction.setTransactionContent(transactionContent);
237
         tpTransaction.setType(type);
244
         tpTransaction.setType(type);
263
 
270
 
264
         if (Constant.EFFECTIVE.equals(taUser.getStatus()) && (Constant.RELATION.equals(sysRole.getRoleName()) || Constant.TENANT.equals(sysRole.getRoleName()) || Constant.OWNER.equals(sysRole.getRoleName()))){
271
         if (Constant.EFFECTIVE.equals(taUser.getStatus()) && (Constant.RELATION.equals(sysRole.getRoleName()) || Constant.TENANT.equals(sysRole.getRoleName()) || Constant.OWNER.equals(sysRole.getRoleName()))){
265
             tpTransactionMapper.insertSelective(tpTransaction);
272
             tpTransactionMapper.insertSelective(tpTransaction);
273
+            insertTdImage(tpTransaction, uploadFile, type, userId);
274
+
266
             TpTransaction tpTransaction1=tpTransactionMapper.getById(tpTransaction.getId());
275
             TpTransaction tpTransaction1=tpTransactionMapper.getById(tpTransaction.getId());
267
             response.addSuccess(tpTransaction1);
276
             response.addSuccess(tpTransaction1);
268
             return response;
277
             return response;
271
         return response;
280
         return response;
272
     }
281
     }
273
 
282
 
283
+    private void insertTdImage(TpTransaction tpTransaction, MultipartFile uploadFile, String type, Integer userId) throws IOException {
284
+        TdImages tdImages = new TdImages();
285
+        Integer uuId = tpTransaction.getId();
286
+        String imageUrl = imageServiceI.getImageUrl(uploadFile);
287
+        tdImages.setImageUrl(imageUrl);
288
+        tdImages.setType(type);
289
+        tdImages.setUuid(uuId);
290
+        tdImages.setCreateUser(userId);
291
+        tdImages.setCreateTime(new Date());
292
+        tdImagesMapper.insertSelective(tdImages);
293
+    }
274
     @Override
294
     @Override
275
     public ResponseBean selectAllTransaction(Integer userId,Integer pageNum,Integer paeSize,Integer type) {
295
     public ResponseBean selectAllTransaction(Integer userId,Integer pageNum,Integer paeSize,Integer type) {
276
         ResponseBean responseBean = new ResponseBean();
296
         ResponseBean responseBean = new ResponseBean();

+ 21
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaFaceServicelimpl.java View File

4
 import com.community.commom.ailiyun.AESDecode;
4
 import com.community.commom.ailiyun.AESDecode;
5
 import com.community.commom.constant.Constant;
5
 import com.community.commom.constant.Constant;
6
 import com.community.commom.mode.ResponseBean;
6
 import com.community.commom.mode.ResponseBean;
7
+import com.community.huiju.controller.ImageController;
7
 import com.community.huiju.dao.TaFaceMapper;
8
 import com.community.huiju.dao.TaFaceMapper;
8
 import com.community.huiju.dao.TaSysRoleMapper;
9
 import com.community.huiju.dao.TaSysRoleMapper;
9
 import com.community.huiju.dao.TaUserMapper;
10
 import com.community.huiju.dao.TaUserMapper;
10
 import com.community.huiju.model.TaFace;
11
 import com.community.huiju.model.TaFace;
11
 import com.community.huiju.model.TaSysRole;
12
 import com.community.huiju.model.TaSysRole;
12
 import com.community.huiju.model.TaUser;
13
 import com.community.huiju.model.TaUser;
14
+import com.community.huiju.service.ImageServiceI;
13
 import com.community.huiju.service.TaFaceServicel;
15
 import com.community.huiju.service.TaFaceServicel;
14
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
18
+import org.springframework.web.multipart.MultipartFile;
16
 
19
 
20
+import java.io.IOException;
17
 import java.util.Date;
21
 import java.util.Date;
18
 
22
 
19
 @Service
23
 @Service
29
     @Autowired
33
     @Autowired
30
     private TaSysRoleMapper taSysRoleMapper;
34
     private TaSysRoleMapper taSysRoleMapper;
31
 
35
 
36
+    @Autowired
37
+    private ImageServiceI imageServiceI;
38
+
32
     @Override
39
     @Override
33
-    public ResponseBean addFace(String faceImg, Integer userid) {
40
+    public ResponseBean addFace(Integer userid,MultipartFile uploadFile) {
41
+        String faceImg = null;
42
+        try {
43
+            faceImg=imageServiceI.getImageUrl(uploadFile);
44
+        } catch (IOException e) {
45
+            e.printStackTrace();
46
+        }
34
         TaUser user=taUserMapper.selectByPrimaryKey(userid);
47
         TaUser user=taUserMapper.selectByPrimaryKey(userid);
35
         ResponseBean response = new ResponseBean();
48
         ResponseBean response = new ResponseBean();
36
         TaFace taFace = new TaFace();
49
         TaFace taFace = new TaFace();
105
     }
118
     }
106
 
119
 
107
     @Override
120
     @Override
108
-    public ResponseBean upDateFace(String faceImg, Integer userId) {
121
+    public ResponseBean upDateFace(Integer userId,MultipartFile uploadFile) {
109
         boolean isA=false;
122
         boolean isA=false;
123
+        String faceImg = null;
124
+        try {
125
+            faceImg=imageServiceI.getImageUrl(uploadFile);
126
+        } catch (IOException e) {
127
+            e.printStackTrace();
128
+        }
110
         TaUser user=taUserMapper.selectByPrimaryKey(userId);
129
         TaUser user=taUserMapper.selectByPrimaryKey(userId);
111
         ResponseBean responseBean = new ResponseBean();
130
         ResponseBean responseBean = new ResponseBean();
112
         TaFace taFace = new TaFace();
131
         TaFace taFace = new TaFace();

+ 1
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaVistorServiceImpl.java View File

56
             taVisitorMapper.insertSelective(taVisitor);
56
             taVisitorMapper.insertSelective(taVisitor);
57
         }
57
         }
58
 
58
 
59
-
60
     }
59
     }
61
 
60
 
62
     @Override
61
     @Override
63
     public List<TaVisitor> invateHis(Integer communityId, Integer userId) {
62
     public List<TaVisitor> invateHis(Integer communityId, Integer userId) {
64
         List<TaVisitor> taVisitors = taVisitorMapper.findAllVistors(communityId, userId);
63
         List<TaVisitor> taVisitors = taVisitorMapper.findAllVistors(communityId, userId);
64
+
65
         for (TaVisitor taVisitor : taVisitors){
65
         for (TaVisitor taVisitor : taVisitors){
66
             if (Constant.EFFECTIVE.equals(taVisitor.getDrivingStatus())){
66
             if (Constant.EFFECTIVE.equals(taVisitor.getDrivingStatus())){
67
                 List<Integer> taVisitorLicenses = taVisitorLicenseMapper.findTaVistorLicenseById(taVisitor.getId());
67
                 List<Integer> taVisitorLicenses = taVisitorLicenseMapper.findTaVistorLicenseById(taVisitor.getId());

+ 106
- 0
CODE/smart-community/app-api/src/main/resources/mapper/TdImagesMapper.xml View File

1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.community.huiju.dao.TdImagesMapper" >
4
+  <resultMap id="BaseResultMap" type="com.community.huiju.model.TdImages" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
7
+    <result column="uuid" property="uuid" jdbcType="INTEGER" />
8
+    <result column="type" property="type" jdbcType="CHAR" />
9
+    <result column="create_user" property="createUser" jdbcType="INTEGER" />
10
+    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
11
+  </resultMap>
12
+  <sql id="Base_Column_List" >
13
+    id, image_url, uuid, type, create_user, create_time
14
+  </sql>
15
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
16
+    select 
17
+    <include refid="Base_Column_List" />
18
+    from td_images
19
+    where id = #{id,jdbcType=INTEGER}
20
+  </select>
21
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
22
+    delete from td_images
23
+    where id = #{id,jdbcType=INTEGER}
24
+  </delete>
25
+  <insert id="insert" parameterType="com.community.huiju.model.TdImages" >
26
+    insert into td_images (id, image_url, uuid, 
27
+      type, create_user, create_time
28
+      )
29
+    values (#{id,jdbcType=INTEGER}, #{imageUrl,jdbcType=VARCHAR}, #{uuid,jdbcType=INTEGER}, 
30
+      #{type,jdbcType=CHAR}, #{createUser,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
31
+      )
32
+  </insert>
33
+  <insert id="insertSelective" parameterType="com.community.huiju.model.TdImages" >
34
+    insert into td_images
35
+    <trim prefix="(" suffix=")" suffixOverrides="," >
36
+      <if test="id != null" >
37
+        id,
38
+      </if>
39
+      <if test="imageUrl != null" >
40
+        image_url,
41
+      </if>
42
+      <if test="uuid != null" >
43
+        uuid,
44
+      </if>
45
+      <if test="type != null" >
46
+        type,
47
+      </if>
48
+      <if test="createUser != null" >
49
+        create_user,
50
+      </if>
51
+      <if test="createTime != null" >
52
+        create_time,
53
+      </if>
54
+    </trim>
55
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
56
+      <if test="id != null" >
57
+        #{id,jdbcType=INTEGER},
58
+      </if>
59
+      <if test="imageUrl != null" >
60
+        #{imageUrl,jdbcType=VARCHAR},
61
+      </if>
62
+      <if test="uuid != null" >
63
+        #{uuid,jdbcType=INTEGER},
64
+      </if>
65
+      <if test="type != null" >
66
+        #{type,jdbcType=CHAR},
67
+      </if>
68
+      <if test="createUser != null" >
69
+        #{createUser,jdbcType=INTEGER},
70
+      </if>
71
+      <if test="createTime != null" >
72
+        #{createTime,jdbcType=TIMESTAMP},
73
+      </if>
74
+    </trim>
75
+  </insert>
76
+  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TdImages" >
77
+    update td_images
78
+    <set >
79
+      <if test="imageUrl != null" >
80
+        image_url = #{imageUrl,jdbcType=VARCHAR},
81
+      </if>
82
+      <if test="uuid != null" >
83
+        uuid = #{uuid,jdbcType=INTEGER},
84
+      </if>
85
+      <if test="type != null" >
86
+        type = #{type,jdbcType=CHAR},
87
+      </if>
88
+      <if test="createUser != null" >
89
+        create_user = #{createUser,jdbcType=INTEGER},
90
+      </if>
91
+      <if test="createTime != null" >
92
+        create_time = #{createTime,jdbcType=TIMESTAMP},
93
+      </if>
94
+    </set>
95
+    where id = #{id,jdbcType=INTEGER}
96
+  </update>
97
+  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TdImages" >
98
+    update td_images
99
+    set image_url = #{imageUrl,jdbcType=VARCHAR},
100
+      uuid = #{uuid,jdbcType=INTEGER},
101
+      type = #{type,jdbcType=CHAR},
102
+      create_user = #{createUser,jdbcType=INTEGER},
103
+      create_time = #{createTime,jdbcType=TIMESTAMP}
104
+    where id = #{id,jdbcType=INTEGER}
105
+  </update>
106
+</mapper>