添加了商品下架的功能模块
This commit is contained in:
		| @@ -2,11 +2,13 @@ package com.xkrs.controller; | |||||||
|  |  | ||||||
| import com.xkrs.common.encapsulation.PromptMessageEnum; | import com.xkrs.common.encapsulation.PromptMessageEnum; | ||||||
| import com.xkrs.common.tool.TokenUtil; | import com.xkrs.common.tool.TokenUtil; | ||||||
|  | import com.xkrs.dao.ProductDao; | ||||||
| import com.xkrs.dao.SysUserDao; | import com.xkrs.dao.SysUserDao; | ||||||
| import com.xkrs.model.entity.SysUserEntity; | import com.xkrs.model.entity.SysUserEntity; | ||||||
| import com.xkrs.model.qo.ProductQo; | import com.xkrs.model.qo.ProductQo; | ||||||
| import com.xkrs.service.ProductService; | import com.xkrs.service.ProductService; | ||||||
| import org.springframework.context.i18n.LocaleContextHolder; | import org.springframework.context.i18n.LocaleContextHolder; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
| import org.springframework.web.bind.annotation.PostMapping; | import org.springframework.web.bind.annotation.PostMapping; | ||||||
| import org.springframework.web.bind.annotation.RequestBody; | import org.springframework.web.bind.annotation.RequestBody; | ||||||
| import org.springframework.web.bind.annotation.RequestHeader; | import org.springframework.web.bind.annotation.RequestHeader; | ||||||
| @@ -31,6 +33,9 @@ public class ProductController { | |||||||
|     @Resource |     @Resource | ||||||
|     private SysUserDao sysUserDao; |     private SysUserDao sysUserDao; | ||||||
|  |  | ||||||
|  |     @Resource | ||||||
|  |     private ProductDao productDao; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 添加商品信息 |      * 添加商品信息 | ||||||
|      * @param productQo |      * @param productQo | ||||||
| @@ -103,4 +108,18 @@ public class ProductController { | |||||||
|         String reviewType = (String) map.get("reviewType"); |         String reviewType = (String) map.get("reviewType"); | ||||||
|         return productService.updateReviewType(productId,reviewType); |         return productService.updateReviewType(productId,reviewType); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 商品下架 | ||||||
|  |      * @param map | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     @Transactional(rollbackFor=Exception.class) | ||||||
|  |     @PostMapping("/updateOffShelf") | ||||||
|  |     public String updateOffShelf(@RequestBody Map map){ | ||||||
|  |         Locale locale = LocaleContextHolder.getLocale(); | ||||||
|  |         Integer productId = (Integer) map.get("productId"); | ||||||
|  |         productDao.updateShelfTypeById(productId,"2"); | ||||||
|  |         return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"商品下架成功!",locale); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -46,4 +46,13 @@ public interface ProductDao extends JpaRepository<ProductEntity,Long>, JpaSpecif | |||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     ProductEntity findById(Integer id); |     ProductEntity findById(Integer id); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 商品下架 | ||||||
|  |      * @param productId | ||||||
|  |      * @param shelfType | ||||||
|  |      */ | ||||||
|  |     @Modifying(clearAutomatically=true) | ||||||
|  |     @Query(value = "update product set shelf_type = ?2 where id = ?1",nativeQuery = true) | ||||||
|  |     void updateShelfTypeById(Integer productId,String shelfType); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user