# ServiceRequestCenterPropertyServiceImpl.java

    package cloud.wconnect.it.service.servicerequestcenter.impl;

    import cloud.wconnect.commonlib.util.JsonUtils;
    import cloud.wconnect.it.entity.servicerequestcenter.ServiceRequestCenterProperty;
    import cloud.wconnect.it.mapper.servicerequestcenter.ServiceRequestCenterPropertyMapper;
    import cloud.wconnect.it.pojo.dto.servicerequestcenter.PropertyBasicDTO;
    import cloud.wconnect.it.service.servicerequestcenter.IServiceRequestCenterPropertyService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import java.util.List;

    /**
     * <p>
     *  服务实现类
     * </p>
     *
     * @author yyt
     * @since 2026-04-01
     */
    @Service
    @DS("it_manage")
    public class ServiceRequestCenterPropertyServiceImpl extends ServiceImpl<ServiceRequestCenterPropertyMapper, ServiceRequestCenterProperty> implements IServiceRequestCenterPropertyService {

        @Autowired
        private ObjectMapper objectMapper;

        /**
         * 保存资产
         *
         * @param requestId  request id
         * @param properties 资产
         * @author yyt
         * @date 2026/4/1
         **/
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void saveProperty(Integer requestId, String properties) {
            saveBatch(JsonUtils.convertStringToList(objectMapper, properties, PropertyBasicDTO.class)
                    .stream().map(property -> new ServiceRequestCenterProperty().setRequestId(requestId).setPropertyId(property.getId()))
                    .toList());
        }

        /**
         * 查询 request 绑定资产
         *
         * @param requestId request id
         * @return 资产 id
         * @author yyt
         * @date 2026/4/1
         **/
        @Override
        public List<Integer> listPropertyIds(Integer requestId) {
            return list(new LambdaQueryWrapper<ServiceRequestCenterProperty>()
                    .eq(ServiceRequestCenterProperty::getRequestId, requestId)
                    .select(ServiceRequestCenterProperty::getPropertyId))
                    .stream().map(ServiceRequestCenterProperty::getPropertyId).toList();
        }

        /**
         * 批量查询 request 绑定资产
         *
         * @param requestIds request id
         * @return 资产关系关系
         * @author yyt
         * @date 2026/4/1
         **/
        @Override
        public List<ServiceRequestCenterProperty> listPropertyIds(List<Integer> requestIds) {
            return list(new LambdaQueryWrapper<ServiceRequestCenterProperty>()
                    .in(ServiceRequestCenterProperty::getRequestId, requestIds));
        }

    }