更新删除
parent
e98f19362d
commit
e0f77d32c1
|
@ -83,4 +83,20 @@ public class ProductUpdReq {
|
|||
* 重要路径
|
||||
*/
|
||||
private String apiRouter;
|
||||
/**
|
||||
* 按次查询
|
||||
*/
|
||||
private BigDecimal timemoney;
|
||||
/**
|
||||
* 包日
|
||||
*/
|
||||
private BigDecimal daymoney;
|
||||
/**
|
||||
* 包月
|
||||
*/
|
||||
private BigDecimal monthmoney;
|
||||
/**
|
||||
* 包年
|
||||
*/
|
||||
private BigDecimal yearmoney;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,33 @@ public class ApiManageController {
|
|||
@Schema(title = "产品ID", type = "Integer", defaultValue = "1", description = "修改产品信息需要依据的唯一条件")
|
||||
@RequestBody @Validated ProductUpdReq productUpdReq) {
|
||||
apiManageService.updateById(Product.updProductList(productUpdReq,()-> productUpdReq.getProductId()));
|
||||
List<Specification> specificationList = apiManageService.findspecification();
|
||||
for (Specification specification : specificationList) {
|
||||
Integer specificationId = specification.getProductSpecificationId();
|
||||
BigDecimal middlePrice;
|
||||
switch (specificationId) {
|
||||
case 1:
|
||||
middlePrice = productUpdReq.getTimemoney();
|
||||
break;
|
||||
case 2:
|
||||
middlePrice = productUpdReq.getDaymoney();
|
||||
break;
|
||||
case 3:
|
||||
middlePrice = productUpdReq.getMonthmoney();
|
||||
break;
|
||||
case 4:
|
||||
middlePrice = productUpdReq.getYearmoney();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + specificationId);
|
||||
}
|
||||
MiddleTableEntity middleEntity = new MiddleTableEntity();
|
||||
middleEntity.setMiddleProduct(productUpdReq.getProductId());
|
||||
middleEntity.setMiddleSpecification(specificationId);
|
||||
middleEntity.setMiddlePrice(middlePrice);
|
||||
apiManageService.updmiddlemoney(middleEntity);
|
||||
}
|
||||
|
||||
return Result.success(null, "操作成功");
|
||||
}
|
||||
|
||||
|
@ -156,6 +183,7 @@ public class ApiManageController {
|
|||
@Operation(summary = "接口信息删除",description = "通过Id删除接口信息")
|
||||
public Result<String> delete(@PathVariable("productId") Integer productId){
|
||||
apiManageService.removeById(productId);
|
||||
apiManageService.delmiddle(productId);
|
||||
return Result.success(null, "操作成功");
|
||||
}
|
||||
|
||||
|
|
|
@ -44,4 +44,8 @@ public interface ApiManageMapper extends BaseMapper<Product> {
|
|||
|
||||
|
||||
List<MiddleTableEntity> getprice(@Param("productId") Integer productId);
|
||||
|
||||
void updmiddlemoney(MiddleTableEntity middleEntity);
|
||||
|
||||
void deletemiddle(@Param("productId") Integer productId);
|
||||
}
|
||||
|
|
|
@ -62,4 +62,8 @@ public interface ApiManageService extends IService<Product> {
|
|||
* @return
|
||||
*/
|
||||
List<MiddleTableEntity> getprice(Integer productId);
|
||||
|
||||
void updmiddlemoney(MiddleTableEntity middleEntity);
|
||||
|
||||
void delmiddle(Integer productId);
|
||||
}
|
||||
|
|
|
@ -111,5 +111,15 @@ public class ApiManageServiceImpl extends ServiceImpl<ApiManageMapper, Product>
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updmiddlemoney(MiddleTableEntity middleEntity) {
|
||||
apiManageMapper.updmiddlemoney(middleEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delmiddle(Integer productId) {
|
||||
apiManageMapper.deletemiddle(productId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
<mapper namespace="com.muyu.cloud.background.mapper.ApiManageMapper">
|
||||
|
||||
|
||||
<select id="getprice" resultType="com.muyu.cloud.background.domin.MiddleTableEntity">
|
||||
SELECT * from middle_specification_product where middle_product=#{productId}
|
||||
</select>
|
||||
|
@ -22,5 +23,14 @@
|
|||
update product set product_state=#{productState} where product_id=#{productId}
|
||||
</update>
|
||||
|
||||
<update id="updmiddlemoney">
|
||||
UPDATE `h6_cloud_server`.`middle_specification_product` SET
|
||||
`middle_price`=#{middlePrice} WHERE `middle_product` = #{middleProduct} and `middle_specification` = #{middleSpecification}
|
||||
</update>
|
||||
|
||||
<delete id="deletemiddle">
|
||||
delete from middle_specification_product where middle_product=#{productId}
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue