package shop.alien.lawyer.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import shop.alien.entity.result.R;
import shop.alien.entity.store.LawyerServiceArea;
import shop.alien.lawyer.service.LawyerServiceAreaService;
import shop.alien.mapper.LawyerServiceAreaMapper;


/**
 * 律师服务领域关联 服务实现类
 *
 * @author system
 * @since 2025-01-XX
 */
@Slf4j
@Transactional
@Service
@RequiredArgsConstructor
public class LawyerServiceAreaServiceImpl extends ServiceImpl<LawyerServiceAreaMapper, LawyerServiceArea> implements LawyerServiceAreaService {

    @Override
    public R<LawyerServiceArea> addLawyerServiceArea(LawyerServiceArea lawyerServiceArea) {
        log.info("LawyerServiceAreaServiceImpl.addLawyerServiceArea?lawyerServiceArea={}", lawyerServiceArea);
        boolean result = this.save(lawyerServiceArea);
        if (result) {
            return R.data(lawyerServiceArea);
        }
        return R.fail("新增失败");
    }

    @Override
    public R<LawyerServiceArea> editLawyerServiceArea(LawyerServiceArea lawyerServiceArea) {
        log.info("LawyerServiceAreaServiceImpl.editLawyerServiceArea?lawyerServiceArea={}", lawyerServiceArea);
        boolean result = this.updateById(lawyerServiceArea);
        if (result) {
            return R.data(lawyerServiceArea);
        }
        return R.fail("修改失败");
    }

    @Override
    public R<Boolean> deleteLawyerServiceArea(Integer id) {
        log.info("LawyerServiceAreaServiceImpl.deleteLawyerServiceArea?id={}", id);
        boolean result = this.removeById(id);
        if (result) {
            return R.success("删除成功");
        }
        return R.fail("删除失败");
    }
}

