添加了各级进行审核的功能模块

This commit is contained in:
XinYi Song 2021-12-16 17:59:15 +08:00
parent c1523b22ec
commit 1c1bc5b7d9
4 changed files with 67 additions and 3 deletions

View File

@ -91,4 +91,16 @@ public class ProductController {
} }
return productService.selectProductReviewType(sysUserEntity.getId(),productCity,productCounty,reviewType); return productService.selectProductReviewType(sysUserEntity.getId(),productCity,productCounty,reviewType);
} }
/**
* 各级进行审核的操作
* @param map
* @return
*/
@PostMapping("/updateReviewType")
public String updateReviewType(@RequestBody Map map){
Integer productId = (Integer) map.get("productId");
String reviewType = (String) map.get("reviewType");
return productService.updateReviewType(productId,reviewType);
}
} }

View File

@ -3,6 +3,8 @@ package com.xkrs.dao;
import com.xkrs.model.entity.ProductEntity; import com.xkrs.model.entity.ProductEntity;
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 java.util.List; import java.util.List;
@ -20,10 +22,28 @@ public interface ProductDao extends JpaRepository<ProductEntity,Long>, JpaSpecif
ProductEntity findByProductName(String productName); ProductEntity findByProductName(String productName);
/** /**
* 商家查看商品信息 * 修改审核状态
* @param businessId * @param productId
* @param reviewType
*/
@Modifying(clearAutomatically=true)
@Query(value = "update product set review_type = ?2 where id = ?1",nativeQuery = true)
void updateReviewType(Integer productId,String reviewType);
/**
* 修改上架的状态
* @param productId
* @param shelfType * @param shelfType
* @param productTime
*/
@Modifying(clearAutomatically=true)
@Query(value = "update product set shelf_type = ?2,product_time = ?3 where id = ?1",nativeQuery = true)
void updateShelfType(Integer productId,String shelfType,String productTime);
/**
* 根据id查询商品信息
* @param id
* @return * @return
*/ */
List<ProductEntity> findAllByBusinessIdAndAndShelfType(Integer businessId,String shelfType); ProductEntity findById(Integer id);
} }

View File

@ -34,4 +34,12 @@ public interface ProductService {
* @return * @return
*/ */
String selectProductReviewType(Integer businessId, String productCity, String productCounty, String reviewType); String selectProductReviewType(Integer businessId, String productCity, String productCounty, String reviewType);
/**
* 商品审核
* @param productId
* @param reviewType
* @return
*/
String updateReviewType(Integer productId,String reviewType);
} }

View File

@ -135,4 +135,28 @@ public class ProductServiceImpl implements ProductService {
} }
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,productEntities,locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,productEntities,locale);
} }
/**
* 商品审核
* @param productId
* @param reviewType
* @return
*/
@Override
public String updateReviewType(Integer productId, String reviewType) {
Locale locale = LocaleContextHolder.getLocale();
ProductEntity byId = productDao.findById(productId);
if(byId == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有该商品的信息!",locale);
}
if(reviewType.equals(byId.getReviewType()) || reviewType.compareTo(byId.getReviewType()) < 0){
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"操作错误!",locale);
}
if(reviewType.equals("3")){
String dateTimeToString = DateTimeUtil.dateTimeToString(LocalDateTime.now());
productDao.updateShelfType(productId,"1",dateTimeToString);
}
productDao.updateReviewType(productId,reviewType);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功!",locale);
}
} }