Просмотр исходного кода

修改小程序更新浏览次数及获取详情接口

tianboguang 3 лет назад
Родитель
Сommit
cc00b130d6

+ 19 - 9
platform-api/src/main/java/com/platform/api/ApiBrandController.java

@@ -7,7 +7,6 @@ import com.platform.entity.*;
 import com.platform.interceptor.AuthorizationInterceptor;
 import com.platform.service.ApiBrandService;
 import com.platform.service.ApiRecommendService;
-import com.platform.service.ApiSceneService;
 import com.platform.service.ApiUserService;
 import com.platform.service.custom.MyApiTmBrandTypeService;
 import com.platform.service.custom.MySysUserBrandService;
@@ -49,9 +48,6 @@ public class ApiBrandController extends ApiBaseAction {
     private ApiBrandService brandService;
 
     @Autowired
-    private ApiSceneService sceneService;
-
-    @Autowired
     private MyApiTmBrandTypeService myApiTmBrandTypeService;
 
     @Autowired
@@ -219,9 +215,13 @@ public class ApiBrandController extends ApiBaseAction {
             }
             entity.setSceneUrl(entity.getLiveRoomUrl());
             // 获取场景数据
-            BrandVo sceneVo = sceneService.queryByScene(entity.getSceneNum());
-            if(!ObjectUtils.isEmpty(sceneVo)){
-                entity.setSceneName(sceneVo.getName());
+            RequestScene requestScene = new RequestScene();
+            requestScene.setNums(entity.getSceneNum());
+            JSONObject mySceneJsonData = zhiHouseService.getSceneFromZhiHouse(requestScene);
+            List<Object> mySceneList = mySceneJsonData.getJSONArray("list");
+            JSONObject sceneRes = JSONObject.parseObject(JSONObject.toJSONString(mySceneList.get(0)));
+            if(!ObjectUtils.isEmpty(sceneRes)){
+                entity.setSceneName(sceneRes.getString("sceneName"));
             }
             Long userId = getUserId();
             int canshow = 0;
@@ -239,7 +239,16 @@ public class ApiBrandController extends ApiBaseAction {
             }
             entity.setCanShow(canshow);
         } else {
-            entity = sceneService.queryObject(id);
+            RequestScene requestScene = new RequestScene();
+            requestScene.setSceneId(Long.valueOf(id));
+            JSONObject mySceneJsonData = zhiHouseService.getSceneFromZhiHouse(requestScene);
+            List<Object> mySceneList = mySceneJsonData.getJSONArray("list");
+            JSONObject sceneRes = JSONObject.parseObject(JSONObject.toJSONString(mySceneList.get(0)));
+            entity = new BrandVo();
+            entity.setSceneUrl(sceneRes.getString("webSite"));
+            entity.setSceneName(sceneRes.getString("sceneName"));
+            entity.setAppListPicUrl(sceneRes.getString("appListPicUrl"));
+            entity.setSceneNum(sceneRes.getString("num"));
         }
         resultObj.put("brand", entity);
         return toResponsSuccess(resultObj);
@@ -256,7 +265,8 @@ public class ApiBrandController extends ApiBaseAction {
         if(!(ObjectUtils.isEmpty(type) || type == 21 || type == 31)) {
             return toResponsSuccess(brandService.increaseViewCount(brandId));
         }
-        return toResponsSuccess(sceneService.increaseViewCount(brandId));
+        BrandVo brandVo = brandService.queryByScene(brandId);
+        return toResponsSuccess(zhiHouseService.increaseViewCount(brandVo.getSceneNum()));
     }
 
     /**

+ 0 - 23
platform-api/src/main/java/com/platform/dao/ApiSceneMapper.java

@@ -1,23 +0,0 @@
-package com.platform.dao;
-
-import com.platform.entity.BrandVo;
-
-import java.util.List;
-
-/**
- * @author lipengjun
- * @email 939961241@qq.com
- * @gitee https://gitee.com/fuyang_lipengjun/platform
- * @date 2017-08-11 09:14:25
- */
-public interface ApiSceneMapper extends BaseDao<BrandVo> {
-
-    Integer queryIdByScene(String sceneNum);
-    BrandVo queryByScene(String sceneNum);
-
-    List<BrandVo> getRecommondDeptBrand();
-
-    void increaseViewCount(String id);
-
-    Integer getTopPvNumByDeptId(Integer deptId);
-}

+ 0 - 69
platform-api/src/main/java/com/platform/service/ApiSceneService.java

@@ -1,69 +0,0 @@
-package com.platform.service;
-
-import com.platform.dao.ApiSceneMapper;
-import com.platform.entity.BrandVo;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-
-import java.util.List;
-import java.util.Map;
-
-
-@Service
-public class ApiSceneService {
-	@Autowired
-	private ApiSceneMapper sceneMapper;
-	
-	
-	public BrandVo queryObject(Integer id){
-		return sceneMapper.queryObject(id);
-	}
-
-	public BrandVo queryByScene(String sceneNum){
-		return sceneMapper.queryByScene(sceneNum);
-	}
-	
-	public List<BrandVo> queryList(Map<String, Object> map){
-		return sceneMapper.queryList(map);
-	}
-	
-	
-	public int queryTotal(Map<String, Object> map){
-		return sceneMapper.queryTotal(map);
-	}
-	
-	
-	public void save(BrandVo brand){
-		sceneMapper.save(brand);
-	}
-	
-	
-	public void update(BrandVo brand){
-		sceneMapper.update(brand);
-	}
-	
-	
-	public void delete(Integer id){
-		sceneMapper.delete(id);
-	}
-	
-	
-	public void deleteBatch(Integer[] ids){
-		sceneMapper.deleteBatch(ids);
-	}
-
-	public Long increaseViewCount(String brandId) {
-		if(ObjectUtils.isEmpty(brandId)){
-			return 0L;
-		}
-		// 查找数据
-		sceneMapper.increaseViewCount(brandId);
-		BrandVo brandVo = sceneMapper.queryObject(brandId);
-		if(!ObjectUtils.isEmpty(brandVo) && !ObjectUtils.isEmpty(brandVo.getPvTotalNum())){
-			return brandVo.getPvTotalNum();
-		}
-		return 0L;
-	}
-}

+ 0 - 167
platform-api/src/main/resources/com/platform/dao/ApiSceneMapper.xml

@@ -1,167 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.platform.dao.ApiSceneMapper">
-
-    <!-- 可根据自己的需求,是否要使用 -->
-    <resultMap type="com.platform.entity.BrandVo" id="brandMap">
-        <result property="id" column="id"/>
-        <result property="name" column="name"/>
-        <result property="listPicUrl" column="list_pic_url"/>
-        <result property="simpleDesc" column="simple_desc"/>
-        <result property="picUrl" column="pic_url"/>
-        <result property="sortOrder" column="sort_order"/>
-        <result property="isShow" column="is_show"/>
-        <result property="floorPrice" column="floor_price"/>
-        <result property="appListPicUrl" column="app_list_pic_url"/>
-        <result property="isNew" column="is_new"/>
-        <result property="newPicUrl" column="new_pic_url"/>
-        <result property="newSortOrder" column="new_sort_order"/>
-        <result property="type" column="type"/>
-        <result property="sceneUrl" column="scene_url"/>
-        <result property="sceneNum" column="scene_num"/>
-        <result property="shareWxQrCode" column="share_wx_qr_code"/>
-        <result property="address" column="address"/>
-        <result property="retailPrice" column="retail_price"/>
-        <result property="averagePrice" column="average_price"/>
-        <result property="pvTotalNum" column="pv_total_num"/>
-        <result property="liveRoomUrl" column="live_room_url"/>
-        <result property="sceneName" column="scene_name"/>
-    </resultMap>
-
-    <select id="queryIdByScene" resultType="java.lang.Integer">
-        select
-        `id`
-        from nideshop_scene
-        where scene_num = #{sceneNum}
-    </select>
-
-    <select id="queryByScene" resultMap="brandMap">
-        select
-        *
-        from nideshop_scene
-        where scene_num = #{sceneNum}
-    </select>
-
-    <select id="queryObject" resultMap="brandMap">
-		select * from nideshop_scene where id = #{value}
-	</select>
-
-    <select id="queryList" resultMap="brandMap">
-        select
-        <if test="fields != null and fields != ''">
-            ${fields}
-        </if>
-        <if test="fields == null or fields == ''">
-            *
-        </if>
-        from nideshop_scene
-        <where>
-            <if test="isShow != null">
-                and is_show = #{isShow}
-            </if>
-            <if test="userId != null">
-                and create_user_id = #{userId}
-            </if>
-            <if test="name != null and name!=''">
-                and name like concat('%',#{name},'%')
-            </if>
-        </where>
-        <choose>
-            <when test="sidx != null and sidx.trim() != ''">
-                order by ${sidx} ${order}
-            </when>
-            <otherwise>
-                order by nideshop_scene.id desc
-            </otherwise>
-        </choose>
-        <if test="offset != null and limit != null">
-            limit #{offset}, #{limit}
-        </if>
-
-    </select>
-
-    <select id="queryTotal" resultType="int">
-		select count(*) from nideshop_scene
-        where is_show = 1
-        <if test="name != null">
-            and name like concat('%',#{name},'%')
-        </if>
-	</select>
-
-    <insert id="save" parameterType="com.platform.entity.BrandVo" useGeneratedKeys="true" keyProperty="id">
-		insert into nideshop_scene
-		(
-			`name`, 
-			`list_pic_url`,
-			`simple_desc`,
-			`pic_url`,
-			`sort_order`, 
-			`is_show`, 
-			`floor_price`, 
-			`app_list_pic_url`, 
-			`is_new`, 
-			`new_pic_url`, 
-			`new_sort_order`,
-			`type`,
-			`scene_url`,
-			`scene_num`,
-			`share_wx_qr_code`
-		)
-		values
-		(
-			#{name}, 
-			#{listPicUrl},
-			#{simpleDesc},
-			#{picUrl},
-			#{sortOrder},
-			#{isShow},
-			#{floorPrice},
-			#{appListPicUrl},
-			#{isNew},
-			#{newPicUrl},
-			#{newSortOrder},
-			#{type},
-			#{sceneUrl},
-			#{sceneNum},
-			#{shareWxQrCode}
-		)
-	</insert>
-
-    <update id="update" parameterType="com.platform.entity.BrandVo">
-        update nideshop_scene
-        <set>
-            <if test="name != null">`name` = #{name},</if>
-            <if test="is_show != null">`is_show` = #{is_show},</if>
-            <if test="sceneNum != null">`scene_num` = #{sceneNum},</if>
-            <if test="sceneUrl != null">`scene_url` = #{sceneUrl}</if>
-        </set>
-        where id = #{id}
-    </update>
-
-    <delete id="delete">
-		update nideshop_scene set deleted = 1 where id = #{value}
-	</delete>
-
-    <delete id="deleteBatch">
-        update nideshop_scene set deleted = 1 where id in
-        <foreach item="id" collection="array" open="(" separator="," close=")">
-            #{id}
-        </foreach>
-    </delete>
-
-    <select id="getRecommondDeptBrand" resultType="com.platform.entity.BrandVo">
-        select dept.logo_url appListPicUrl,dept.dept_id id,dept.name from sys_dept dept
-        join nideshop_scene brand on dept.dept_id = brand.create_user_dept_id
-        group by dept.dept_id order by count(*) desc limit 0,3
-    </select>
-
-    <select id="increaseViewCount">
-        update nideshop_scene set pv_total_num = pv_total_num + 1 where id= #{id}
-    </select>
-
-    <select id="getTopPvNumByDeptId" resultType="java.lang.Integer">
-        select id from nideshop_scene brand where create_user_dept_id = #{deptId} order by pv_total_num desc limit 1
-    </select>
-
-</mapper>

+ 16 - 0
platform-common/src/main/java/com/platform/service/impl/ZhiHouseService.java

@@ -143,4 +143,20 @@ public class ZhiHouseService {
 
         return responseEntity.getBody();
     }
+
+    public Object increaseViewCount(String sceneNum) {
+        String url = zhiHouseHost + "/api/scene/updateViewCount?num=" + sceneNum;
+        if(org.apache.commons.lang3.StringUtils.isBlank(sceneNum)){
+            throw new CommonBaseException(ResultCodeEnum.D101 , "入参不全");
+        }
+        ResponseEntity<ReturnDTO> responseEntity = restTemplate.getForEntity(url,ReturnDTO.class);
+        if(responseEntity.getStatusCode()!= HttpStatus.OK){
+            throw new CommonBaseException(ResultCodeEnum.D100,"登录失败");
+        }
+        if (responseEntity.getBody().getCode() != 200) {
+            throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
+        }
+
+        return responseEntity.getBody();
+    }
 }