|
@@ -1,9 +1,17 @@
|
|
|
package com.example.xiaoshiweixinback.service;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.ToolUtil;
|
|
|
import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
|
|
|
|
|
|
+import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
|
|
|
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
|
import com.example.xiaoshiweixinback.mapper.AssoPersonProductMapper;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -12,8 +20,29 @@ import org.springframework.stereotype.Service;
|
|
|
* @createDate 2024-04-10 15:45:40
|
|
|
*/
|
|
|
@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
public class AssoPersonProductService extends ServiceImpl<AssoPersonProductMapper, AssoPersonProduct> {
|
|
|
-
|
|
|
+ private final CacheUtil cacheUtil;
|
|
|
+
|
|
|
+ public Integer add(AssoPersonProductDTO assoPersonProductDTO){
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
+ if (ToolUtil.isNotEmpty(personnelVO)) {
|
|
|
+ AssoPersonProduct assoPersonProduct = new AssoPersonProduct();
|
|
|
+ BeanUtils.copyProperties(assoPersonProductDTO, assoPersonProduct);
|
|
|
+ assoPersonProduct.setPersonUuid(personnelVO.getUuid());
|
|
|
+ assoPersonProduct.insert();
|
|
|
+ return assoPersonProduct.getProductId();
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Integer cancel(Integer productId){
|
|
|
+ LambdaQueryWrapper<AssoPersonProduct> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AssoPersonProduct::getProductId, productId);
|
|
|
+ this.remove(queryWrapper);
|
|
|
+ return productId;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|