Browse Source

Merge branch 'dev-mysql' into feature_release-tomysql

wangdy 8 years ago
parent
commit
40ffa0e8d6

+ 15 - 15
src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandDao.java

@@ -73,6 +73,21 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	@Query("select b from Brand b where upper(b.nameCn)=upper(:nameCn)")
 	@Query("select b from Brand b where upper(b.nameCn)=upper(:nameCn)")
 	public List<Brand> findByUpperNameCn(@Param("nameCn") String nameCn);
 	public List<Brand> findByUpperNameCn(@Param("nameCn") String nameCn);
 
 
+	/**
+	 * 分页根据首字母获取品牌信息
+	 * @param initals
+	 * @return
+	 */
+	@Query(value = "select b from Brand b  where b.inital in :initals")
+	public Page<Brand> findInInitalsPage(@Param("initals") String[] initals , Pageable pageable);
+
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return
+	 */
+	@Query(nativeQuery = true , value = "select * from product$brand order by br_search_count desc LIMIT 2")
+	public List<Brand> findMostSearchBrands();
+
 	/**
 	/**
 	 * 器件点击次数加一
 	 * 器件点击次数加一
 	 * @param uuid
 	 * @param uuid
@@ -82,19 +97,4 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	@Transactional
 	@Transactional
 	@Query( nativeQuery = true, value = "update product$brand b set b.br_visit_count = ifnull(b.br_visit_count, 0) + 1 where b.br_uuid = :uuid")
 	@Query( nativeQuery = true, value = "update product$brand b set b.br_visit_count = ifnull(b.br_visit_count, 0) + 1 where b.br_uuid = :uuid")
 	public void addVisitCount(@Param("uuid") String uuid);
 	public void addVisitCount(@Param("uuid") String uuid);
-
-    /**
-     * 获取搜索量最高的2个品牌
-     * @return
-     */
-    @Query(nativeQuery = true , value = "select b from product$brand b order by br_search_count desc LIMIT 2)")
-    public List<Brand> findMostSearchBrands();
-
-    /**
-     * 分页根据首字母获取品牌信息
-     * @param initals
-     * @return
-     */
-    @Query(value = "select b from Brand b  where b.inital in :initals")
-	public Page<Brand> findInInitalsPage(@Param("initals") String[] initals , Pageable pageable);
 }
 }

+ 31 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java

@@ -121,6 +121,17 @@ public class ComponentController {
 		return componentService.findInfoPage(info);
 		return componentService.findInfoPage(info);
 	}
 	}
 
 
+	/**
+	 * 查找所有简单有效品牌信息
+	 *
+	 * @return 品牌简易信息
+	 */
+	@RequestMapping(value = "/Info", method = RequestMethod.GET)
+	public List<ComponentInfo> getComonentInfo() {
+		return componentService.getAllComponentInfo();
+	}
+
+
 	/**
 	/**
 	 * 根据UUId获取器件摘要
 	 * 根据UUId获取器件摘要
 	 * 
 	 * 
@@ -279,6 +290,26 @@ public class ComponentController {
 		return componentService.getBatchComponents(batchIds);
 		return componentService.getBatchComponents(batchIds);
 	}
 	}
 
 
+	/**
+	 * 查找已推广的按权重排序的器件信息
+	 *
+	 * @return 器件简易信息
+	 */
+	@RequestMapping(value = "/searchWeight", method = RequestMethod.GET)
+	public List<ComponentInfo> getComponentInfoOrderByWeight() {
+		return componentService.getAllComponentInfoByWeight();
+	}
+
+	/**
+	 * 修改某个器件的 权重
+	 *
+	 * @return 器件简易信息
+	 */
+	@RequestMapping(value = "/searchWeight", method = RequestMethod.PUT)
+	public ComponentInfo updateBrankInfoOrderByWeight(@RequestBody ComponentInfo componentInfo ,@RequestParam Double weight) {
+		return componentService.updateComponentInfoInfoOrderByWeight(componentInfo,weight);
+	}
+
 
 
 	/**
 	/**
 	 * 获取搜索量最高的2个器件
 	 * 获取搜索量最高的2个器件

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentDao.java

@@ -125,7 +125,7 @@ public interface ComponentDao extends JpaSpecificationExecutor<Component>, JpaRe
 	 * 获取搜索量最高的2个器件
 	 * 获取搜索量最高的2个器件
 	 * @return
 	 * @return
 	 */
 	 */
-	@Query(nativeQuery = true , value = "select c from product$component c order by cmp_search_count desc LIMIT 2)")
+	@Query(nativeQuery = true , value = "select * from product$component order by cmp_search_count desc LIMIT 2")
 	public List<Component> findMostSearchComponent();
 	public List<Component> findMostSearchComponent();
 
 
 
 

+ 16 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentInfoDao.java

@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
@@ -91,4 +92,19 @@ public interface ComponentInfoDao extends JpaSpecificationExecutor<ComponentInfo
 
 
 	@Query("select c from ComponentInfo c where c.code like :q%")
 	@Query("select c from ComponentInfo c where c.code like :q%")
 	public Page<ComponentInfo> findByFirst(@Param("q") String keyword,Pageable pageable);
 	public Page<ComponentInfo> findByFirst(@Param("q") String keyword,Pageable pageable);
+
+	/**
+	 * 根据权重倒序排列品牌信息
+	 * @return
+	 */
+	@Query(value = "select b from ComponentInfo b where b.searchWeight is not null and b.searchWeight <> 0 order by b.searchWeight desc")
+	public List<ComponentInfo> findBySearchWeight();
+
+	/**
+	 * 根据权重倒序排列品牌信息
+	 * @return
+	 */
+	@Modifying
+	@Query(value = "update ComponentInfo b set b.searchWeight = :increaseNum where b.uuid = :uuid")
+	public int setWeight(@Param("uuid") String uuid, @Param("increaseNum") Double increaseNum);
 }
 }

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/modal/ComponentInfo.java

@@ -97,6 +97,12 @@ public class ComponentInfo implements Serializable {
 	@Column(name = "cmp_weight")
 	@Column(name = "cmp_weight")
 	private Float weight;
 	private Float weight;
 
 
+	/**
+	 * 搜索排序权重
+	 */
+	@Column(name = "searchweight")
+	private Double searchWeight;
+
 	/**
 	/**
 	 * 附件id
 	 * 附件id
 	 */
 	 */
@@ -263,6 +269,14 @@ public class ComponentInfo implements Serializable {
 		this.weight = weight;
 		this.weight = weight;
 	}
 	}
 
 
+	public Double getSearchWeight() {
+		return searchWeight;
+	}
+
+	public void setSearchWeight(Double searchWeight) {
+		this.searchWeight = searchWeight;
+	}
+
 	public String getAttach() {
 	public String getAttach() {
 		if(SystemSession.getUser() != null) {
 		if(SystemSession.getUser() != null) {
 			return attach;
 			return attach;

+ 20 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java

@@ -103,6 +103,13 @@ public interface ComponentService {
 	 */
 	 */
 	public Page<ComponentInfo> findInfoPage(PageInfo info);
 	public Page<ComponentInfo> findInfoPage(PageInfo info);
 
 
+	/**
+	 * 获取所有的简易器件信息
+	 * @author yujia
+	 * @return 器件简易信息
+	 */
+	public List<ComponentInfo> getAllComponentInfo();
+
 	/**
 	/**
 	 * 关联的goods数据会被set进去
 	 * 关联的goods数据会被set进去
 	 * @param info 分页参数
 	 * @param info 分页参数
@@ -211,6 +218,19 @@ public interface ComponentService {
 	 */
 	 */
 	List<ComponentInfo> getBatchComponents(List<Long> batchIds);
 	List<ComponentInfo> getBatchComponents(List<Long> batchIds);
 
 
+	/**
+	 * 查找已推广的按权重排序的器件信息
+	 * @author wangdy
+	 * @return 品牌简易信息
+	 */
+	public List<ComponentInfo> getAllComponentInfoByWeight();
+
+	/**
+	 * 修改某个品牌的 权重
+	 * @return 品牌简易信息
+	 */
+	public ComponentInfo updateComponentInfoInfoOrderByWeight(ComponentInfo componentInfo , Double weight);
+
 	/**
 	/**
 	 * 器件点击次数加一
 	 * 器件点击次数加一
 	 * @param uuid
 	 * @param uuid

+ 17 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java

@@ -176,6 +176,11 @@ public class ComponentServiceImpl implements ComponentService {
 		return componentInfoDao.findByCode("416F374X2ALT").get(0);
 		return componentInfoDao.findByCode("416F374X2ALT").get(0);
 	}
 	}
 
 
+	@Override
+	public List<ComponentInfo> getAllComponentInfo() {
+		return componentInfoDao.findAll();
+	}
+
 	@Override
 	@Override
 	public Page<ComponentInfo> findInfoPage(final PageInfo info) {
 	public Page<ComponentInfo> findInfoPage(final PageInfo info) {
 		Map<String, Object> filter = info.getFilters();
 		Map<String, Object> filter = info.getFilters();
@@ -544,6 +549,18 @@ public class ComponentServiceImpl implements ComponentService {
 		return componentInfoDao.findByBatchids(batchIds);
 		return componentInfoDao.findByBatchids(batchIds);
 	}
 	}
 
 
+	@Override
+	public List<ComponentInfo> getAllComponentInfoByWeight() {
+		return componentInfoDao.findBySearchWeight();
+	}
+
+	@Override
+	@Transactional
+	public ComponentInfo updateComponentInfoInfoOrderByWeight(ComponentInfo componentInfo, Double weight) {
+		componentInfoDao.setWeight(componentInfo.getUuid(),weight);
+		return componentInfoDao.findOne(componentInfo.getId());
+	}
+
 	@Override
 	@Override
 	public void addVisitCount(String uuid) {
 	public void addVisitCount(String uuid) {
 		componentDao.addVisitCount(uuid);
 		componentDao.addVisitCount(uuid);

+ 2 - 0
src/main/webapp/WEB-INF/views/normal/adminWithNav.html

@@ -210,6 +210,8 @@
 			<li class="nav-header">推广管理</li>
 			<li class="nav-header">推广管理</li>
 			<li class="nav-node"><a href="#ads/brand" ><i
 			<li class="nav-node"><a href="#ads/brand" ><i
 					class="fa fa-upload"></i><span> 品牌推广</span></a></li>
 					class="fa fa-upload"></i><span> 品牌推广</span></a></li>
+			<li class="nav-node"><a href="#ads/component" ><i
+					class="fa fa-upload"></i><span> 器件推广</span></a></li>
 
 
 			<li class="nav-header">搜索预览</li>
 			<li class="nav-header">搜索预览</li>
 			<li class="nav-node"><a href="#search/see" ><i
 			<li class="nav-node"><a href="#search/see" ><i

+ 7 - 0
src/main/webapp/resources/js/admin/app.js

@@ -734,6 +734,13 @@
             controller: 'adsBrandCtrl',
             controller: 'adsBrandCtrl',
             controllerUrl: 'app/controllers/ads/ads_brand',
             controllerUrl: 'app/controllers/ads/ads_brand',
             title: '品牌推广'
             title: '品牌推广'
+        })).state('adsComponent', angularAMD.route({
+            //品牌推广
+            url : '/ads/component',
+            templateUrl: 'static/view/admin/ads/ads_component.html',
+            controller: 'adsComponentCtrl',
+            controllerUrl: 'app/controllers/ads/ads_component',
+            title: '器件推广'
         })).state('searchSee', angularAMD.route({
         })).state('searchSee', angularAMD.route({
             //搜索预览
             //搜索预览
             url : '/search/see',
             url : '/search/see',

+ 62 - 0
src/main/webapp/resources/js/admin/controllers/ads/ads_component.js

@@ -0,0 +1,62 @@
+define([ 'app/app' ], function(app) {
+    //器件推广
+    app.register.controller('adsComponentCtrl', ['$scope', 'NgTableParams', 'ComponentActive', 'toaster', 'BaseService', function($scope, NgTableParams, ComponentActive ,toaster, BaseService) {
+        BaseService.scrollBackToTop();
+        $scope.isDisable = true;
+
+        $scope.load =  function(params) {
+            if (params == "weight") {
+                ComponentActive.getSimpleInfoByWeight({}, {}, function(data) {
+                    $scope.brands =data;
+                    $scope.isDisable = true;
+                    $scope.brandsTableParams = new NgTableParams({}, { dataset: $scope.brands});
+                }, function(){
+
+                })
+            } else {
+                $scope.isDisable = false;
+                loadData();
+            }
+        };
+
+        var loadData = function(){
+            ComponentActive.getSimpleInfoByWeight({}, {}, function(data){
+                $scope.brands = data;
+                $scope.brandsTableParams = new NgTableParams({}, { dataset: $scope.brands});
+            }, function(){
+            })
+        };
+
+        loadData();
+
+        $scope.weight = function(brand){
+            ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                toaster.pop('success', '处理成功', '【' + data[0].nameCn + '】' + '禁用成功');
+                loadData();
+            }, function(res){
+                toaster.pop('error', '错误', res.data);
+            })
+        };
+        $scope.disweight = function(brand){
+            ComponentActive.setSimpleInfoWeight({weight: 0}, brand, function(data){
+                if (data.searchWeight == 0){
+                    toaster.pop('success', '处理成功', '【' + data.nameCn + '】' + '已取消推广');
+                    $scope.load('weight');
+                } else{
+                    toaster.pop('error', '错误', '取消推广失败');
+                }
+            }, function(res){
+                toaster.pop('error', '错误', res.data);
+            })
+        };
+        $scope.updateweight = function(brand){
+            ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                toaster.pop('success', '处理成功', '【' + data.nameCn + '】' + '已修改推广');
+                $scope.load('weight');
+            }, function(res){
+                toaster.pop('error', '错误', res.data);
+            })
+        };
+
+    }]);
+});

+ 12 - 2
src/main/webapp/resources/js/common/query/component.js

@@ -166,8 +166,18 @@ define([ 'ngResource' ], function() {
 			 */
 			 */
 			//根据kindid获得ComponentsActiveSimpleInfo的分页数据
 			//根据kindid获得ComponentsActiveSimpleInfo的分页数据
 			getSimpleInfo : {
 			getSimpleInfo : {
-				url : 'api/product/component/simpleInfo',
-				method : 'GET'
+				url : 'api/product/component/info',
+				method : 'GET',
+                isArray : true
+			},
+            getSimpleInfoByWeight: {
+                url : 'api/product/component/searchWeight',
+                method : 'GET',
+                isArray : true
+			},
+            setSimpleInfoWeight: {
+                url : 'api/product/component/searchWeight',
+                method : 'PUT'
 			},
 			},
 			//获取ComponentInfo的分页数据
 			//获取ComponentInfo的分页数据
 			getInfoPage: {
 			getInfoPage: {

+ 36 - 0
src/main/webapp/resources/view/admin/ads/ads_component.html

@@ -0,0 +1,36 @@
+<div class="row-fluid sortable">
+    <div class="box span12">
+        <div class="box-header well" data-original-title>
+            <h2><i class="icon-user"></i> <a ng-click="load('weight')">已推广标准器件 </a> / <a ng-click="load('disweight')">搜索标准器件</a></h2>
+        </div>
+        <div class="box-content" ng-show="isDisable">
+            <!-- ng-tableStart -->
+            <div class="fullscreen" style="padding: 10px;overflow-y:auto;">
+                <table ng-table="brandsTableParams" class="table table-condensed table-bordered table-striped">
+                    <tr ng-repeat="brand in $data">
+                        <td data-title="'器件名'" filter="{code: 'text'}">{{brand.code}}</td>
+                        <td data-title="'品牌名'" filter="{brand.nameCn: 'text'}">{{brand.brand.nameCn}}</td>
+                        <td data-title="'权重'" >{{brand.searchWeight}}</td>
+                        <td data-title="'操作'">
+                            <button ng-click="updateweight(brand)" class="btn btn-danger btn-sm" ng-if="!brand.searchWeight"><i class="fa fa-check"></i> 推广</button>
+                            <button ng-click="disweight(brand)" class="btn btn-danger btn-sm" ng-if="brand.searchWeight"><i class="fa fa-check"></i> 解除推广</button>
+                            <button ng-click="updateweight(brand)" class="btn btn-danger btn-sm" ng-if="brand.searchWeight"><i class="fa fa-check"></i> 修改推广</button>
+                            <input type="number" style="height: 30px"  ng-model="brand.inputWeight"/>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+            <!-- ng-tableEnd -->
+        </div>
+
+        <div class="box-content" ng-show="!isDisable">
+            <!-- ng-tableStart -->
+            <div class="fullscreen" style="padding: 10px;overflow-y:auto;">
+                <input  style="height: 30px"  ng-model="keyword"/>
+                <button ng-click="updateweight(brand)" class="btn btn-danger btn-sm" ng-if="brand.searchWeight"><i class="fa fa-check"></i> 修改推广</button>
+            </div>
+            <!-- ng-tableEnd -->
+        </div>
+    </div><!--/span-->
+
+</div><!--/row-->