Browse Source

优化jiekou

wangfeng 6 years ago
parent
commit
bc47584f49

+ 65 - 1
diagbotman-service/src/main/java/com/diagbot/facade/OpenedProductsFacade.java

@@ -4,21 +4,31 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import javax.validation.Valid;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import com.diagbot.dto.EnShowOptionDTO;
 import com.diagbot.dto.GetConsoleOnTrialDTO;
 import com.diagbot.dto.GetConsoleOpenedDTO;
 import com.diagbot.dto.OpenUpOnTrialDTO;
 import com.diagbot.dto.ProductServiceDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.OpenedProducts;
 import com.diagbot.entity.ProductService;
 import com.diagbot.entity.ServiceInfo;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.OpenedProductsServiceImpl;
+import com.diagbot.util.DateUtil;
 import com.diagbot.util.UserUtils;
+import com.diagbot.vo.ModifyOpeningTimeVO;
 import com.diagbot.vo.OpenUpOnTrialVO;
 import com.diagbot.vo.ProductServiceSaveVO;
+import com.diagbot.vo.StartAndendByUserIdVO;
 
 /**
  * @Description:已开通产品业务层
@@ -108,5 +118,59 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
     	
     	return enShowOptionDTO;
     }
-
+    /**
+     * 
+     * @param startAndendByUserIdVO
+     * @return 根据用户id和产品id,删除开通信息
+     */
+    public RespDTO<StartAndendByUserIdVO> startAndendByuserIds(StartAndendByUserIdVO startAndendByUserIdVO) {
+		OpenedProducts openedProducts = new OpenedProducts();
+		openedProducts.setUserId(startAndendByUserIdVO.getUserId());
+		openedProducts.setProductId(startAndendByUserIdVO.getProductId());
+		openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
+		openedProducts.setGmtCreate(DateUtil.now());
+		openedProducts.setServiceStatus(startAndendByUserIdVO.getServiceStatus());
+		boolean res =startAndendByuserId(openedProducts);
+		if (!res){
+			throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
+		}
+		return RespDTO.onSuc(res);
+	}
+    /**
+     * 
+     * @param userId
+     * @param productId
+     * @return 根据用户id和产品id,删除开通信息
+     */
+    public RespDTO delInformationAvailables(Long userId, Long productId) {
+		OpenedProducts openedProducts = new OpenedProducts();
+		openedProducts.setUserId(userId);
+		openedProducts.setProductId(productId);
+		openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
+		openedProducts.setGmtCreate(DateUtil.now());
+		boolean res =delInformationAvailable(openedProducts);
+		if (!res){
+			throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
+		}
+		return RespDTO.onSuc(res);
+	}
+    /**
+     * 
+     * @param modifyOpeningTimeVO
+     * @return 根据用户id和产品id,修改开通时间
+     */
+    public RespDTO<ModifyOpeningTimeVO> modifyOpeningTimes(ModifyOpeningTimeVO modifyOpeningTimeVO) {
+		OpenedProducts openedProducts = new OpenedProducts();
+		openedProducts.setUserId(modifyOpeningTimeVO.getUserId());
+		openedProducts.setProductId(modifyOpeningTimeVO.getProductId());
+		openedProducts.setStartTime(DateUtil.parseDate(modifyOpeningTimeVO.getStartTime()));
+		openedProducts.setEndTime(DateUtil.parseDate(modifyOpeningTimeVO.getEndTime()));
+		openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
+		openedProducts.setGmtCreate(DateUtil.now());
+		boolean res = modifyOpeningTime(openedProducts);
+		if (!res){
+			throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
+		}
+		return RespDTO.onSuc(res);
+	}
 }

+ 1 - 1
diagbotman-service/src/main/java/com/diagbot/mapper/OpenedProductsMapper.java

@@ -75,7 +75,7 @@ public interface OpenedProductsMapper extends BaseMapper<OpenedProducts> {
     int getConsoleOnTrialCount(Long userId);
 
     //根据用户id查询已开通的功能
-    public List<UserAndProdutDTO> getInformationAvailableByUserId(Long userId);
+    public List<UserAndProdutDTO> getInformationAvailableByUserId(OpenedProducts openedProducts);
     //根据用户id和产品id,启用和停用功能
     public boolean startAndendByuserId(OpenedProducts openedProducts);
 	  //根据用户id和产品id,删除开通信息", notes = "删除开通信息")

+ 1 - 1
diagbotman-service/src/main/java/com/diagbot/service/OpenedProductsService.java

@@ -43,7 +43,7 @@ public interface OpenedProductsService extends IService<OpenedProducts> {
     List<OpenedProducts> getByAppkeyAndSecret(Map<String,Object> map);
     
     //根据用户id查询已开通的功能
-    public List<UserAndProdutDTO> getInformationAvailableByUserId(Long userId);
+    public List<UserAndProdutDTO> getInformationAvailableByUserId(OpenedProducts openedProducts);
     //根据用户id和产品id,启用和停用功能
     public boolean startAndendByuserId(OpenedProducts openedProducts);
 	  //根据用户id和产品id,删除开通信息", notes = "删除开通信息")

+ 2 - 2
diagbotman-service/src/main/java/com/diagbot/service/impl/OpenedProductsServiceImpl.java

@@ -49,9 +49,9 @@ public class OpenedProductsServiceImpl extends ServiceImpl<OpenedProductsMapper,
     }
 
 	@Override
-	public List<UserAndProdutDTO> getInformationAvailableByUserId(Long userId) {
+	public List<UserAndProdutDTO> getInformationAvailableByUserId(OpenedProducts openedProducts) {
 		// TODO Auto-generated method stub
-		return openedProductsMapper.getInformationAvailableByUserId(userId);
+		return openedProductsMapper.getInformationAvailableByUserId(openedProducts);
 	}
 
 	@Override

+ 11 - 35
diagbotman-service/src/main/java/com/diagbot/web/ProductOrderController.java

@@ -99,8 +99,10 @@ public class ProductOrderController {
 	@ApiOperation(value = "根据用户id查询已开通的功能[by:wangfeng]", notes = "已开通信息")
     @PostMapping("/getInformationAvailableByUserId")
     @SysLogger("getInformationAvailableByUserId")
-    public RespDTO  getInformationAvailableByUserId(@RequestParam Long userId){
-    	List<UserAndProdutDTO> UserAndProdutData = openedProductsFacade.getInformationAvailableByUserId(userId);
+    public RespDTO  getInformationAvailableByUserId(Long userId){
+		OpenedProducts openedProducts =new OpenedProducts();
+		openedProducts.setUserId(userId);
+    	List<UserAndProdutDTO> UserAndProdutData = openedProductsFacade.getInformationAvailableByUserId(openedProducts);
     	return RespDTO.onSuc(UserAndProdutData);
     }
 
@@ -109,17 +111,9 @@ public class ProductOrderController {
 	@SysLogger("startAndendByuserId")
 	@Transactional
 	public RespDTO<StartAndendByUserIdVO> startAndendByuserId(@RequestBody @Valid StartAndendByUserIdVO startAndendByUserIdVO) {
-		OpenedProducts openedProducts = new OpenedProducts();
-		openedProducts.setUserId(startAndendByUserIdVO.getUserId());
-		openedProducts.setProductId(startAndendByUserIdVO.getProductId());
-		openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
-		openedProducts.setGmtCreate(DateUtil.now());
-		openedProducts.setServiceStatus(startAndendByUserIdVO.getServiceStatus());
-		boolean res =openedProductsFacade.startAndendByuserId(openedProducts);
-		if (!res){
-			throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
-		}
-		return RespDTO.onSuc(res);
+		
+		return openedProductsFacade.startAndendByuserIds(startAndendByUserIdVO);
+		
 	}
 
 	@ApiOperation(value = "根据用户id和产品id,删除开通信息[by:wangfeng]", notes = "删除开通信息")
@@ -127,16 +121,8 @@ public class ProductOrderController {
 	@SysLogger("delInformationAvailable")
 	@Transactional
 	public RespDTO delInformationAvailable(@RequestParam Long userId, Long productId) {
-		OpenedProducts openedProducts = new OpenedProducts();
-		openedProducts.setUserId(userId);
-		openedProducts.setProductId(productId);
-		openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
-		openedProducts.setGmtCreate(DateUtil.now());
-		boolean res =openedProductsFacade.delInformationAvailable(openedProducts);
-		if (!res){
-			throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
-		}
-		return RespDTO.onSuc(res);
+
+		return openedProductsFacade.delInformationAvailables(userId,productId);
 	}
 
 	@ApiOperation(value = "根据用户id和产品id,修改开通时间[by:wangfeng]", notes = "修改开通时间")
@@ -144,18 +130,8 @@ public class ProductOrderController {
 	@SysLogger("modifyOpeningTime")
 	@Transactional
 	public RespDTO<ModifyOpeningTimeVO> modifyOpeningTime(@RequestBody @Valid ModifyOpeningTimeVO modifyOpeningTimeVO) {
-		OpenedProducts openedProducts = new OpenedProducts();
-		openedProducts.setUserId(modifyOpeningTimeVO.getUserId());
-		openedProducts.setProductId(modifyOpeningTimeVO.getProductId());
-		openedProducts.setStartTime(DateUtil.parseDate(modifyOpeningTimeVO.getStartTime()));
-		openedProducts.setEndTime(DateUtil.parseDate(modifyOpeningTimeVO.getEndTime()));
-		//TODO wangfeng openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
-		openedProducts.setGmtCreate(DateUtil.now());
-		boolean res = openedProductsFacade.modifyOpeningTime(openedProducts);
-		if (!res){
-			throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL);
-		}
-		return RespDTO.onSuc(res);
+		 
+		return openedProductsFacade.modifyOpeningTimes(modifyOpeningTimeVO);
 	}
 	@ApiOperation(value = "产品申请——显示所有订单[by:wangyu]",
 			notes =

+ 1 - 1
diagbotman-service/src/main/resources/mapper/OpenedProductsMapper.xml

@@ -110,7 +110,7 @@
 		and c.user_id=#{userId}
 		and a.id not in (SELECT product_id FROM diag_opened_products where user_id=#{userId})
     </select>
-<select id="getInformationAvailableByUserId" parameterType = "long" resultType = "com.diagbot.dto.UserAndProdutDTO">
+<select id="getInformationAvailableByUserId"  parameterType="com.diagbot.entity.OpenedProducts" resultType = "com.diagbot.dto.UserAndProdutDTO">
 
 	SELECT
 	a.id as Id,