Преглед изворни кода

编写品牌映射前端JS代码

hulh пре 8 година
родитељ
комит
e9372f59f0

+ 13 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandMapServiceImpl.java

@@ -109,6 +109,7 @@ public class BrandMapServiceImpl implements BrandMapService{
 
 	@Override
 	public BrandMap addOneMap(BrandMap map) {
+		validateMap(map);
 		User user = SystemSession.getUser();
 		map.setUserUU(user.getUserUU());
 		map.setOperateName(user.getUserName());
@@ -117,6 +118,18 @@ public class BrandMapServiceImpl implements BrandMapService{
 		return brandMapDao.save(map);
 	}
 
+	public void validateMap(BrandMap map){
+		if (StringUtils.isEmpty(map.getEnName())){
+			throw new IllegalOperatorException("请选择店铺信息");
+		}
+		if (StringUtils.isEmpty(map.getNameChildEn())){
+			throw new IllegalOperatorException("请完善要对应的品牌英文名");
+		}
+		if (StringUtils.isEmpty(map.getNameStandardCn()) || StringUtils.isEmpty(map.getNameStandardEn())){
+			throw new IllegalOperatorException("请选择对应标准库的品牌");
+		}
+	}
+
 	@Override
 	public Object deleteOneMap(Long id) {
 		return null;

+ 15 - 0
src/main/java/com/uas/platform/b2c/prod/store/controller/StoreInController.java

@@ -7,6 +7,7 @@ import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.b2c.prod.store.model.StoreStatus;
 import com.uas.platform.b2c.prod.store.model.StoreType;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
+import com.uas.platform.b2c.trade.presale.model.ValidTime;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
@@ -156,4 +157,18 @@ public class StoreInController {
 		PageInfo pageInfo = new PageInfo(params);
 		return	storeService.pageStoreInfoWhenAdminQuery(pageInfo, type, status, keyword);
 	}
+
+	/**
+	 * 分页获取店铺信息,根据店铺名过滤
+	 *
+	 * @param params
+	 * @param keyword
+	 * @param storeType
+	 * @return
+	 */
+	@RequestMapping(value = "/stores/page", method = RequestMethod.GET)
+	public Page<StoreIn> pageAllStore(PageParams params, String keyword, StoreType storeType){
+		PageInfo pageInfo = new PageInfo(params);
+		return storeService.getStorePage(pageInfo, keyword, storeType);
+	}
 }

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/store/service/StoreInService.java

@@ -145,6 +145,16 @@ public interface StoreInService {
 	 */
 	Page<StoreIn> pageStoreInfoWhenAdminQuery(PageInfo pageInfo, StoreType type, StoreStatus status, String keyword);
 
+	/**
+	 * 分页获取店铺信息,根据店铺名过滤
+	 *
+	 * @param pageInfo
+	 * @param keyword
+	 * @param storeType
+	 * @return
+	 */
+	Page<StoreIn> getStorePage(PageInfo pageInfo, String keyword, StoreType storeType);
+
 	/**
 	 * 当管理员推荐店铺的时候,保存店铺的广告信息
 	 *

+ 19 - 0
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreInServiceImpl.java

@@ -525,4 +525,23 @@ public class StoreInServiceImpl implements StoreInService {
 		List<String> typeList = Arrays.asList(typeArray);
 		return storeDao.findFiveStoresByType(num, typeList);
 	}
+
+	@Override
+	public Page<StoreIn> getStorePage(final PageInfo pageInfo, String keyword, StoreType storeType) {
+
+		if (StringUtils.hasText(keyword)){
+			pageInfo.expression(PredicateUtils.like("storeName", keyword, false));
+		}
+		if (storeType != null){
+			pageInfo.expression(PredicateUtils.eq("type", storeType, false));
+		}
+
+		return storeDao.findAll(new Specification<StoreIn>() {
+			@Override
+			public Predicate toPredicate(Root<StoreIn> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+				criteriaQuery.where(pageInfo.getPredicates(root, criteriaQuery, criteriaBuilder));
+				return null;
+			}
+		}, pageInfo);
+	}
 }

+ 95 - 1
src/main/webapp/resources/js/admin/controllers/product/brandMapCtrl.js

@@ -1,6 +1,100 @@
 define(['app/app'], function(app) {
 	'use strict';
-	app.register.controller('BrandMapCtrl', ['$scope', 'CrawlTask', 'ngTableParams', 'BaseService', function($scope, CrawlTask, ngTableParams, BaseService) {
+	app.register.controller('BrandMapCtrl', ['$scope', 'ngTableParams', 'BaseService', 'BrandMap', 'toaster', 'BrandActive', 'StoreInfo', function($scope, ngTableParams, BaseService, BrandMap, toaster, BrandActive, StoreInfo) {
+		$scope.$$map = {};
+		$scope.keyword = '';
+		$scope.storeType = 'AGENCY';
+		$scope.brandMap = {};
+
+		$scope.update = function () {
+			$scope.brandMapTableParams.reload();
+		};
+
+		$scope.addOneMap = function () {
+			if (!$scope.brandMap.nameChildEn){
+				toaster.pop("info", "请完善要对应的品牌英文名");
+				return ;
+			}
+			if (!$scope.brandMap.nameStandardEn || !$scope.brandMap.nameStandardCn){
+				toaster.pop("info", "请选择对应标准库的品牌");
+				return ;
+			}
+			BrandMap.addOneBrandMap({}, $scope.brandMap, function () {
+
+			}, function (error) {
+				toaster.pop("error", error.data);
+			})
+		};
+
+		$scope.brandMapTableParams = new ngTableParams({
+			page : 1,
+			count : 10,
+			sorting : {
+				operateTime : 'DESC'
+			}
+		},{
+			total : 0,
+			getData : function ($defer, params) {
+				var param = BaseService.parseParams(params.url());
+				if ($scope.keyword && $scope.keyword.length > 0){
+					param.keyword = $scope.keyword;
+				}
+				if ($scope.storeType && $scope.storeType != 'ALL'){
+					param.storeType = $scope.storeType;
+				}
+				BrandMap.getPageOfBrandMap(param, function (page){
+					$scope.$$map.totalElements = page.totalElements;
+					params.total(page.totalElements);
+					$defer.resolve(page.content);
+				},function () {
+					toaster.pop('error', '获取品牌映射关系失败');
+				} )
+			}
+		});
+
+		$scope.brandInfoTableParams = new ngTableParams({
+			page : 1,
+			count : 12
+		},{
+			total : 0,
+			getData : function ($defer, params) {
+				var param = BaseService.parseParams(params.url());
+				// if ($scope.keyword && $scope.keyword.length > 0){
+				// 	param.keyword = $scope.keyword;
+				// }
+				// if ($scope.storeType && $scope.storeType != 'ALL'){
+				// 	param.storeType = $scope.storeType;
+				// }
+				BrandActive.getSimpleInfoPage(param, function (page){
+					params.total(page.totalElements);
+					$defer.resolve(page.content);
+				},function () {
+					toaster.pop('error', '获取标准品牌错误');
+				} )
+			}
+		});
+
+		$scope.storeInfoTableParams = new ngTableParams({
+			page : 1,
+			count : 12
+		},{
+			total : 0,
+			getData : function ($defer, params) {
+				var param = BaseService.parseParams(params.url());
+				// if ($scope.keyword && $scope.keyword.length > 0){
+				// 	param.keyword = $scope.keyword;
+				// }
+				// if ($scope.storeType && $scope.storeType != 'ALL'){
+				// 	param.storeType = $scope.storeType;
+				// }
+				StoreInfo.findStoresPageByKeyword(param, function (page){
+					params.total(page.totalElements);
+					$defer.resolve(page.content);
+				},function () {
+					toaster.pop('error', '获取标准品牌错误');
+				} )
+			}
+		});
 
 	}]);
 });

+ 13 - 0
src/main/webapp/resources/js/common/query/brand.js

@@ -201,5 +201,18 @@ define([ 'ngResource' ], function() {
 				method: 'GET'
 			}
 		});
+	}]).factory('BrandMap', ['$resource', function ($resource) {
+		//品牌映射关系相关操作
+		return $resource('product/brandMap', {}, {
+			//分页获取品牌映射关系
+			getPageOfBrandMap : {
+				url: 'product/brandMap/page',
+				method: 'GET'
+			},
+			addOneBrandMap : {
+				url: 'product/brandMap/addOne',
+				method: 'POST'
+			}
+		});
 	}]);
 });

+ 5 - 0
src/main/webapp/resources/js/common/query/storeInfo.js

@@ -96,6 +96,11 @@ define([ 'ngResource' ], function() {
                     op : 'page'
                 }
             },
+			// 分页获取店铺信息,根据店铺名称过滤
+			findStoresPageByKeyword : {
+				url : 'store-service/stores/page',
+				method : 'GET'
+			},
             // 检测当前企业是否已开店铺
             existStore : {
                 url : 'store-service/stores',