张延森 3 年前
父节点
当前提交
fac0790477

src/main/java/com/yunzhi/shigongli/controller/TaShopImagesController.java → src/main/java/com/yunzhi/shigongli/controller/TaImageController.java 查看文件

@@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.RequestBody;
16 16
 import org.springframework.web.bind.annotation.RequestMapping;
17 17
 import org.springframework.web.bind.annotation.RequestMethod;
18 18
 import org.springframework.web.bind.annotation.RequestParam;
19
-import com.yunzhi.shigongli.service.ITaShopImagesService;
20
-import com.yunzhi.shigongli.entity.TaShopImages;
19
+import com.yunzhi.shigongli.service.ITaImageService;
20
+import com.yunzhi.shigongli.entity.TaImage;
21 21
 import org.springframework.web.bind.annotation.RestController;
22 22
 
23 23
 /**
@@ -32,12 +32,12 @@ import org.springframework.web.bind.annotation.RestController;
32 32
 @Api(tags = "商铺图片")
33 33
 @RestController
34 34
 @RequestMapping("/")
35
-public class TaShopImagesController extends BaseController {
35
+public class TaImageController extends BaseController {
36 36
 
37
-    private final Logger logger = LoggerFactory.getLogger(TaShopImagesController.class);
37
+    private final Logger logger = LoggerFactory.getLogger(TaImageController.class);
38 38
 
39 39
     @Autowired
40
-    public ITaShopImagesService iTaShopImagesService;
40
+    public ITaImageService iTaImageService;
41 41
 
42 42
 
43 43
 //    /**
@@ -51,11 +51,11 @@ public class TaShopImagesController extends BaseController {
51 51
 //    public ResponseBean taShopImagesList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52 52
 //									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53 53
 //
54
-//		    IPage<TaShopImages> pg = new Page<>(pageNum, pageSize);
55
-//            QueryWrapper<TaShopImages> queryWrapper = new QueryWrapper<>();
54
+//		    IPage<TaImage> pg = new Page<>(pageNum, pageSize);
55
+//            QueryWrapper<TaImage> queryWrapper = new QueryWrapper<>();
56 56
 //            queryWrapper.orderByDesc("create_date");
57 57
 //
58
-//            IPage<TaShopImages> result = iTaShopImagesService.page(pg, queryWrapper);
58
+//            IPage<TaImage> result = iTaImageService.page(pg, queryWrapper);
59 59
 //            return ResponseBean.success(result);
60 60
 //    }
61 61
 //
@@ -66,9 +66,9 @@ public class TaShopImagesController extends BaseController {
66 66
 //     */
67 67
 //    @RequestMapping(value="/taShopImages",method= RequestMethod.POST)
68 68
 //    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-//    public ResponseBean taShopImagesAdd(@ApiParam("保存内容") @RequestBody TaShopImages taShopImages) throws Exception{
69
+//    public ResponseBean taShopImagesAdd(@ApiParam("保存内容") @RequestBody TaImage taShopImages) throws Exception{
70 70
 //
71
-//        if (iTaShopImagesService.save(taShopImages)){
71
+//        if (iTaImageService.save(taShopImages)){
72 72
 //            return ResponseBean.success(taShopImages);
73 73
 //        }else {
74 74
 //            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -82,7 +82,7 @@ public class TaShopImagesController extends BaseController {
82 82
 //    @RequestMapping(value="/taShopImages/{id}", method= RequestMethod.DELETE)
83 83
 //    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84 84
 //    public ResponseBean taShopImagesDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-//        if(iTaShopImagesService.removeLogicById(id)){
85
+//        if(iTaImageService.removeLogicById(id)){
86 86
 //            return ResponseBean.success("success");
87 87
 //        }else {
88 88
 //            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -98,10 +98,10 @@ public class TaShopImagesController extends BaseController {
98 98
 //    @RequestMapping(value="/taShopImages/{id}",method= RequestMethod.PUT)
99 99
 //    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100 100
 //    public ResponseBean taShopImagesUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-//                                        @ApiParam("更新内容") @RequestBody TaShopImages taShopImages) throws Exception{
101
+//                                        @ApiParam("更新内容") @RequestBody TaImage taShopImages) throws Exception{
102 102
 //
103
-//        if (iTaShopImagesService.updateById(taShopImages)){
104
-//            return ResponseBean.success(iTaShopImagesService.getById(id));
103
+//        if (iTaImageService.updateById(taShopImages)){
104
+//            return ResponseBean.success(iTaImageService.getById(id));
105 105
 //        }else {
106 106
 //            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 107
 //        }
@@ -114,6 +114,6 @@ public class TaShopImagesController extends BaseController {
114 114
 //    @RequestMapping(value="/taShopImages/{id}",method= RequestMethod.GET)
115 115
 //    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116 116
 //    public ResponseBean taShopImagesGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-//        return ResponseBean.success(iTaShopImagesService.getById(id));
117
+//        return ResponseBean.success(iTaImageService.getById(id));
118 118
 //    }
119 119
 }

+ 14
- 9
src/main/java/com/yunzhi/shigongli/controller/TaSaveController.java 查看文件

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7 8
 import com.yunzhi.shigongli.common.ResponseBean;
8 9
 import com.yunzhi.shigongli.entity.TaLike;
9 10
 import com.yunzhi.shigongli.entity.TaSave;
@@ -118,13 +119,17 @@ public class TaSaveController extends BaseController {
118 119
 //        }
119 120
 //    }
120 121
 //
121
-//    /**
122
-//     * 根据id查询对象
123
-//     * @param id  实体ID
124
-//     */
125
-//    @RequestMapping(value="/taLike/{id}",method= RequestMethod.GET)
126
-//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
127
-//    public ResponseBean taLikeGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
128
-//        return ResponseBean.success(iTaLikeService.getById(id));
129
-//    }
122
+    /**
123
+     * 根据id查询对象
124
+     * @param targetType  对象类型
125
+     * @param targetId  对象ID
126
+     */
127
+    @RequestMapping(value="/wx/{targetType}/save/{targetId}",method= RequestMethod.GET)
128
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
129
+    public ResponseBean taLikeGet(@ApiParam("对象类型") @PathVariable String targetType,
130
+                                  @ApiParam("对象ID") @PathVariable String targetId) throws Exception{
131
+        TaSave taSave = iTaSaveService.getByTarget(targetType, targetId, getCurrentPerson().getPersonId());
132
+
133
+        return ResponseBean.success(taSave);
134
+    }
130 135
 }

+ 4
- 4
src/main/java/com/yunzhi/shigongli/controller/TaShopController.java 查看文件

@@ -44,7 +44,7 @@ public class TaShopController extends BaseController {
44 44
 
45 45
 
46 46
     @Autowired
47
-    public ITaShopImagesService shopImagesService;
47
+    public ITaImageService shopImagesService;
48 48
 
49 49
     @Autowired
50 50
     public ITaTargetTypeService taTargetTypeService;
@@ -85,7 +85,7 @@ public class TaShopController extends BaseController {
85 85
 
86 86
         try {
87 87
             iTaShopService.createNew(taShop);
88
-            shopImagesService.updateImages(taShop.getShopId(), taShop.getImageList());
88
+            shopImagesService.updateImages(Constants.TARGET_SHOP, taShop.getShopId(), taShop.getImageList());
89 89
         } catch (Exception e) {
90 90
             e.printStackTrace();
91 91
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
@@ -121,7 +121,7 @@ public class TaShopController extends BaseController {
121 121
                                         @ApiParam("更新内容") @RequestBody TaShop taShop) throws Exception{
122 122
 
123 123
         if (iTaShopService.updateById(taShop)){
124
-            shopImagesService.updateImages(taShop.getShopId(), taShop.getImageList());
124
+            shopImagesService.updateImages(Constants.TARGET_SHOP, taShop.getShopId(), taShop.getImageList());
125 125
             taTargetTypeService.updateTypes(Constants.TARGET_SHOP, taShop.getShopId(), taShop.getTypeList());
126 126
 
127 127
             ResourceFieldVO resourceVO = iTaShopService.copyProperties(taShop);
@@ -152,7 +152,7 @@ public class TaShopController extends BaseController {
152 152
         taShop.setPvNum(taResource.getPvNum());
153 153
         taShop.setUvNum(taResource.getUvNum());
154 154
         taShop.setLikeNum(taResource.getLikeNum());
155
-        taShop.setImageList(shopImagesService.getBy(TaShopImages::getShopId, id));
155
+        taShop.setImageList(shopImagesService.getListBy(Constants.TARGET_SHOP, id));
156 156
         taShop.setTypeList(taTargetTypeService.getListBy(Constants.TARGET_SHOP, id));
157 157
         
158 158
         if ("wx".equals(plat)) {

+ 7
- 0
src/main/java/com/yunzhi/shigongli/controller/TaTouristController.java 查看文件

@@ -7,6 +7,7 @@ import com.yunzhi.shigongli.common.BaseController;
7 7
 import com.yunzhi.shigongli.common.Constants;
8 8
 import com.yunzhi.shigongli.common.ResponseBean;
9 9
 import com.yunzhi.shigongli.entity.TaResource;
10
+import com.yunzhi.shigongli.service.ITaImageService;
10 11
 import com.yunzhi.shigongli.service.ITaResourceService;
11 12
 import com.yunzhi.shigongli.vo.ResourceFieldVO;
12 13
 import io.swagger.annotations.Api;
@@ -47,6 +48,9 @@ public class TaTouristController extends BaseController {
47 48
     @Autowired
48 49
     public ITaResourceService taResourceService;
49 50
 
51
+    @Autowired
52
+    public ITaImageService iTaImageService;
53
+
50 54
 
51 55
     /**
52 56
      * 分页查询列表
@@ -113,6 +117,8 @@ public class TaTouristController extends BaseController {
113 117
                                         @ApiParam("更新内容") @RequestBody TaTourist taTourist) throws Exception{
114 118
 
115 119
         if (iTaTouristService.updateById(taTourist)){
120
+            iTaImageService.updateImages(Constants.TARGET_TOURIST, taTourist.getTouristId(), taTourist.getImageList());
121
+
116 122
             ResourceFieldVO resourceVO = iTaTouristService.copyProperties(taTourist);
117 123
             TaResource taResource = taResourceService.getByTarget(Constants.TARGET_TOURIST, id);
118 124
             BeanUtils.copyProperties(resourceVO, taResource);
@@ -141,6 +147,7 @@ public class TaTouristController extends BaseController {
141 147
         taTourist.setPvNum(taResource.getPvNum());
142 148
         taTourist.setUvNum(taResource.getUvNum());
143 149
         taTourist.setLikeNum(taResource.getLikeNum());
150
+        taTourist.setImageList(iTaImageService.getListBy(Constants.TARGET_TOURIST, id));
144 151
 
145 152
         if ("wx".equals(plat)) {
146 153
             try {

src/main/java/com/yunzhi/shigongli/entity/TaShopImages.java → src/main/java/com/yunzhi/shigongli/entity/TaImage.java 查看文件

@@ -21,8 +21,8 @@ import lombok.experimental.Accessors;
21 21
 @Data
22 22
 @EqualsAndHashCode(callSuper = false)
23 23
 @Accessors(chain = true)
24
-@ApiModel(value="TaShopImages对象", description="商铺图片")
25
-public class TaShopImages implements Serializable {
24
+@ApiModel(value="TaImage对象", description="商铺图片")
25
+public class TaImage implements Serializable {
26 26
 
27 27
     private static final long serialVersionUID = 1L;
28 28
 
@@ -30,8 +30,11 @@ public class TaShopImages implements Serializable {
30 30
     @TableId(value = "image_id", type = IdType.AUTO)
31 31
     private Integer imageId;
32 32
 
33
-    @ApiModelProperty(value = "商铺ID")
34
-    private String shopId;
33
+    @ApiModelProperty(value = "所属对象ID")
34
+    private String targetId;
35
+
36
+    @ApiModelProperty(value = "所属对象Type")
37
+    private String targetType;
35 38
 
36 39
     @ApiModelProperty(value = "图片类型")
37 40
     private String imageType;

+ 1
- 1
src/main/java/com/yunzhi/shigongli/entity/TaShop.java 查看文件

@@ -98,7 +98,7 @@ public class TaShop implements Serializable {
98 98
 
99 99
     @ApiModelProperty(value = "图片列表")
100 100
     @TableField(exist = false)
101
-    private List<TaShopImages> imageList;
101
+    private List<TaImage> imageList;
102 102
 
103 103
     @ApiModelProperty(value = "分类标签")
104 104
     @TableField(exist = false)

+ 5
- 0
src/main/java/com/yunzhi/shigongli/entity/TaTourist.java 查看文件

@@ -6,6 +6,8 @@ import java.time.LocalDateTime;
6 6
 import com.baomidou.mybatisplus.annotation.TableField;
7 7
 import com.baomidou.mybatisplus.annotation.TableId;
8 8
 import java.io.Serializable;
9
+import java.util.List;
10
+
9 11
 import io.swagger.annotations.ApiModel;
10 12
 import io.swagger.annotations.ApiModelProperty;
11 13
 import lombok.Data;
@@ -87,4 +89,7 @@ public class TaTourist implements Serializable {
87 89
     @TableField(exist = false)
88 90
     private Integer uvNum;
89 91
 
92
+    @ApiModelProperty(value = "图片列表")
93
+    @TableField(exist = false)
94
+    private List<TaImage> imageList;
90 95
 }

src/main/java/com/yunzhi/shigongli/mapper/TaShopImagesMapper.java → src/main/java/com/yunzhi/shigongli/mapper/TaImageMapper.java 查看文件

@@ -1,6 +1,6 @@
1 1
 package com.yunzhi.shigongli.mapper;
2 2
 
3
-import com.yunzhi.shigongli.entity.TaShopImages;
3
+import com.yunzhi.shigongli.entity.TaImage;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6 6
 
@@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
13 13
  * @since 2021-08-17
14 14
  */
15 15
 @Mapper
16
-public interface TaShopImagesMapper extends BaseMapper<TaShopImages> {
16
+public interface TaImageMapper extends BaseMapper<TaImage> {
17 17
 
18 18
 }

+ 21
- 0
src/main/java/com/yunzhi/shigongli/service/ITaImageService.java 查看文件

@@ -0,0 +1,21 @@
1
+package com.yunzhi.shigongli.service;
2
+
3
+import com.yunzhi.shigongli.entity.TaImage;
4
+
5
+import java.util.List;
6
+
7
+
8
+/**
9
+ * <p>
10
+ * 商铺图片 服务类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2021-08-17
15
+ */
16
+public interface ITaImageService extends IBaseService<TaImage> {
17
+
18
+    void updateImages(String targetType, String targetId, List<TaImage> imageList) throws Exception;
19
+
20
+    List<TaImage> getListBy(String targetType, String targetId);
21
+}

+ 0
- 19
src/main/java/com/yunzhi/shigongli/service/ITaShopImagesService.java 查看文件

@@ -1,19 +0,0 @@
1
-package com.yunzhi.shigongli.service;
2
-
3
-import com.yunzhi.shigongli.entity.TaShopImages;
4
-
5
-import java.util.List;
6
-
7
-
8
-/**
9
- * <p>
10
- * 商铺图片 服务类
11
- * </p>
12
- *
13
- * @author yansen
14
- * @since 2021-08-17
15
- */
16
-public interface ITaShopImagesService extends IBaseService<TaShopImages> {
17
-
18
-    void updateImages(String shopId, List<TaShopImages> imageList) throws Exception;
19
-}

+ 68
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaImageServiceImpl.java 查看文件

@@ -0,0 +1,68 @@
1
+package com.yunzhi.shigongli.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.yunzhi.shigongli.common.StringUtils;
5
+import com.yunzhi.shigongli.entity.TaImage;
6
+import com.yunzhi.shigongli.mapper.TaImageMapper;
7
+import com.yunzhi.shigongli.service.ITaImageService;
8
+
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.stereotype.Service;
11
+
12
+import java.util.List;
13
+
14
+/**
15
+ * <p>
16
+ * 商铺图片 服务实现类
17
+ * </p>
18
+ *
19
+ * @author yansen
20
+ * @since 2021-08-17
21
+ */
22
+@Service
23
+public class TaImageServiceImpl extends BaseServiceImpl<TaImageMapper, TaImage> implements ITaImageService {
24
+
25
+    @Autowired
26
+    TaImageMapper taShopImagesMapper;
27
+
28
+
29
+    @Override
30
+    public void updateImages(String targetType, String targetId, List<TaImage> imageList) throws Exception {
31
+        if (null == imageList) {
32
+            throw new Exception("未找到图片列表信息");
33
+        }
34
+
35
+        if (StringUtils.isEmpty(targetType) || StringUtils.isEmpty(targetId)) {
36
+            throw new Exception("未找到有效的属主信息");
37
+        }
38
+
39
+        // 先删除所有的
40
+        removeByTarget(targetType, targetId);
41
+
42
+        // 再插入新记录
43
+        for (TaImage image: imageList) {
44
+            image.setImageId(null);
45
+            image.setTargetId(targetId);
46
+            image.setTargetType(targetType);
47
+        }
48
+
49
+        saveBatch(imageList);
50
+    }
51
+
52
+    @Override
53
+    public List<TaImage> getListBy(String targetType, String targetId) {
54
+        LambdaQueryWrapper<TaImage> queryWrapper = new LambdaQueryWrapper<>();
55
+        queryWrapper.eq(TaImage::getTargetType, targetType);
56
+        queryWrapper.eq(TaImage::getTargetId, targetId);
57
+
58
+        return list(queryWrapper);
59
+    }
60
+
61
+    private boolean removeByTarget(String targetType, String targetId) throws Exception {
62
+        LambdaQueryWrapper<TaImage> queryWrapper = new LambdaQueryWrapper<>();
63
+        queryWrapper.eq(TaImage::getTargetType, targetType);
64
+        queryWrapper.eq(TaImage::getTargetId, targetId);
65
+
66
+        return remove(queryWrapper);
67
+    }
68
+}

+ 0
- 57
src/main/java/com/yunzhi/shigongli/service/impl/TaShopImagesServiceImpl.java 查看文件

@@ -1,57 +0,0 @@
1
-package com.yunzhi.shigongli.service.impl;
2
-
3
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
-import com.yunzhi.shigongli.common.StringUtils;
5
-import com.yunzhi.shigongli.entity.TaShopImages;
6
-import com.yunzhi.shigongli.mapper.TaShopImagesMapper;
7
-import com.yunzhi.shigongli.service.ITaShopImagesService;
8
-
9
-import org.springframework.beans.factory.annotation.Autowired;
10
-import org.springframework.stereotype.Service;
11
-
12
-import java.util.List;
13
-
14
-/**
15
- * <p>
16
- * 商铺图片 服务实现类
17
- * </p>
18
- *
19
- * @author yansen
20
- * @since 2021-08-17
21
- */
22
-@Service
23
-public class TaShopImagesServiceImpl extends BaseServiceImpl<TaShopImagesMapper, TaShopImages> implements ITaShopImagesService {
24
-
25
-    @Autowired
26
-    TaShopImagesMapper taShopImagesMapper;
27
-
28
-
29
-    @Override
30
-    public void updateImages(String shopId, List<TaShopImages> imageList) throws Exception {
31
-        if (null == imageList) {
32
-            throw new Exception("未找到图片列表信息");
33
-        }
34
-
35
-        if (StringUtils.isEmpty(shopId)) {
36
-            throw new Exception("未找到有效的商铺信息");
37
-        }
38
-
39
-        // 先删除所有的
40
-        removeByShop(shopId);
41
-
42
-        // 再插入新记录
43
-        for (TaShopImages image: imageList) {
44
-            image.setImageId(null);
45
-            image.setShopId(shopId);
46
-        }
47
-
48
-        saveBatch(imageList);
49
-    }
50
-
51
-    private boolean removeByShop(String shopId) throws Exception {
52
-        LambdaQueryWrapper<TaShopImages> queryWrapper = new LambdaQueryWrapper<>();
53
-        queryWrapper.eq(TaShopImages::getShopId, shopId);
54
-
55
-        return remove(queryWrapper);
56
-    }
57
-}

+ 4
- 3
src/main/java/com/yunzhi/shigongli/service/impl/TaShopServiceImpl.java 查看文件

@@ -37,7 +37,7 @@ public class TaShopServiceImpl extends BaseServiceImpl<TaShopMapper, TaShop> imp
37 37
     TaShopAccountMapper taShopAccountMapper;
38 38
 
39 39
     @Autowired
40
-    TaShopImagesMapper imagesMapper;
40
+    TaImageMapper imagesMapper;
41 41
 
42 42
     @Autowired
43 43
     TaTargetTypeMapper targetTypeMapper;
@@ -72,8 +72,9 @@ public class TaShopServiceImpl extends BaseServiceImpl<TaShopMapper, TaShop> imp
72 72
 
73 73
         // 图片
74 74
         if (null != taShop.getImageList()) {
75
-            for (TaShopImages image: taShop.getImageList()) {
76
-                image.setShopId(taShop.getShopId());
75
+            for (TaImage image: taShop.getImageList()) {
76
+                image.setTargetType(Constants.TARGET_SHOP);
77
+                image.setTargetId(taShop.getShopId());
77 78
                 imagesMapper.insert(image);
78 79
             }
79 80
         }

+ 1
- 1
src/main/java/com/yunzhi/shigongli/service/impl/TaTargetTypeServiceImpl.java 查看文件

@@ -2,7 +2,7 @@ package com.yunzhi.shigongli.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4
 import com.yunzhi.shigongli.common.StringUtils;
5
-import com.yunzhi.shigongli.entity.TaShopImages;
5
+import com.yunzhi.shigongli.entity.TaImage;
6 6
 import com.yunzhi.shigongli.entity.TaTargetType;
7 7
 import com.yunzhi.shigongli.mapper.TaTargetTypeMapper;
8 8
 import com.yunzhi.shigongli.service.ITaTargetTypeService;

+ 14
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaTouristServiceImpl.java 查看文件

@@ -3,9 +3,11 @@ package com.yunzhi.shigongli.service.impl;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.shigongli.common.Constants;
5 5
 import com.yunzhi.shigongli.common.StringUtils;
6
+import com.yunzhi.shigongli.entity.TaImage;
6 7
 import com.yunzhi.shigongli.entity.TaResource;
7 8
 import com.yunzhi.shigongli.entity.TaShop;
8 9
 import com.yunzhi.shigongli.entity.TaTourist;
10
+import com.yunzhi.shigongli.mapper.TaImageMapper;
9 11
 import com.yunzhi.shigongli.mapper.TaResourceMapper;
10 12
 import com.yunzhi.shigongli.mapper.TaTouristMapper;
11 13
 import com.yunzhi.shigongli.service.ITaTouristService;
@@ -30,6 +32,9 @@ public class TaTouristServiceImpl extends BaseServiceImpl<TaTouristMapper, TaTou
30 32
     @Autowired
31 33
     TaResourceMapper quotaMapper;
32 34
 
35
+    @Autowired
36
+    TaImageMapper imagesMapper;
37
+
33 38
     @Override
34 39
     public IPage<TaTourist> getPagedBy(IPage<TaTourist> pg, String touristName, String cityId) {
35 40
         return baseMapper.getPagedBy(pg, touristName, cityId);
@@ -41,6 +46,15 @@ public class TaTouristServiceImpl extends BaseServiceImpl<TaTouristMapper, TaTou
41 46
         boolean isSuccess = save(taTourist);
42 47
         if (!isSuccess) return false;
43 48
 
49
+        // 图片
50
+        if (null != taTourist.getImageList()) {
51
+            for (TaImage image: taTourist.getImageList()) {
52
+                image.setTargetType(Constants.TARGET_SHOP);
53
+                image.setTargetId(taTourist.getTouristId());
54
+                imagesMapper.insert(image);
55
+            }
56
+        }
57
+
44 58
         ResourceFieldVO resourceVO = copyProperties(taTourist);
45 59
 
46 60
         TaResource taResource = new TaResource();

src/main/resources/mapper/TaShopImagesMapper.xml → src/main/resources/mapper/TaImageMapper.xml 查看文件

@@ -1,5 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.yunzhi.shigongli.mapper.TaShopImagesMapper">
3
+<mapper namespace="com.yunzhi.shigongli.mapper.TaImageMapper">
4 4
 
5 5
 </mapper>

+ 25
- 20
src/main/resources/mapper/TaTargetQuotaMapper.xml 查看文件

@@ -18,27 +18,32 @@
18 18
     </update>
19 19
     <select id="getWxPagedBy" resultType="com.yunzhi.shigongli.vo.ResourceListVO">
20 20
         SELECT
21
-            t.*,
22
-            fn_distance ( #{location}, CONCAT( t.lng, ',', t.lat ) ) AS distance,
23
-            (
24
-                SELECT
25
-                    count( 1 )
26
-                FROM
27
-                    ta_save a
28
-                WHERE
29
-                    a.target_type = t.target_type
30
-                  AND a.target_id = t.target_id
31
-                  AND a.person_id = #{personId}
32
-            ) AS is_saved
21
+        *
33 22
         FROM
34
-            ta_resource t
35
-        <if test="typeId != null and typeId != ''">
36
-            INNER JOIN ta_target_type s ON s.target_type = t.target_type
37
-                AND s.target_id = t.target_id
38
-                AND s.type_id = #{typeId}
39
-        </if>
23
+        (
24
+            SELECT
25
+                t.*,
26
+                fn_distance ( #{location}, CONCAT( t.lng, ',', t.lat ) ) AS distance,
27
+                (
28
+                    SELECT
29
+                        count( 1 )
30
+                    FROM
31
+                        ta_save a
32
+                    WHERE
33
+                        a.target_type = t.target_type
34
+                      AND a.target_id = t.target_id
35
+                      AND a.person_id = #{personId}
36
+                ) AS is_saved
37
+            FROM
38
+                ta_resource t
39
+            <if test="typeId != null and typeId != ''">
40
+                INNER JOIN ta_target_type s ON s.target_type = t.target_type
41
+                    AND s.target_id = t.target_id
42
+                    AND s.type_id = #{typeId}
43
+            </if>
44
+        ) w
40 45
         ORDER BY
41
-            IFNULL( t.weight, 0 ) DESC,
42
-            fn_distance ( #{location}, CONCAT( t.lng, ',', t.lat ) ) DESC
46
+            IFNULL( w.weight, 0 ) DESC,
47
+            w.distance DESC
43 48
     </select>
44 49
 </mapper>