# AdjPmsAccountServiceImpl.java

    package cloud.wconnect.frontoffice.service.adjustment.impl;

    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.frontoffice.entity.adjustment.AdjPmsAccount;
    import cloud.wconnect.frontoffice.mapper.adjustment.AdjPmsAccountMapper;
    import cloud.wconnect.frontoffice.pojo.query.adjustment.PmsAccountQuery;
    import cloud.wconnect.frontoffice.service.adjustment.IAdjPmsAccountService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.apache.commons.lang3.StringUtils;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * adjustment功能pmsAccount表 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2023-12-02
     */
    @Service
    @DS("logbook")
    public class AdjPmsAccountServiceImpl extends ServiceImpl<AdjPmsAccountMapper, AdjPmsAccount> implements IAdjPmsAccountService {

        /**
         * 获取pmsAccount列表
         *
         * @param propertyId      资产id
         * @param pmsAccountQuery 查询对象
         * @return cloud.wconnect.commonlib.pojo.dto.ListPagedDTO<cloud.wconnect.frontoffice.entity.adjustment.AdjPmsAccount>
         * @author lichen
         * @date 2023/12/2
         */
        @Override
        public ListPagedDTO<AdjPmsAccount> pageList(int propertyId, PmsAccountQuery pmsAccountQuery) {
            long total;
            List<AdjPmsAccount> pmsAccountList;
            if (Objects.nonNull(pmsAccountQuery.getPage()) && Objects.nonNull(pmsAccountQuery.getSize())) {
                Page<AdjPmsAccount> resultPage = page(new Page<>(pmsAccountQuery.getPage(), pmsAccountQuery.getSize()),
                        new LambdaQueryWrapper<AdjPmsAccount>()
                                .eq(AdjPmsAccount::getPropertyId, propertyId)
                                .like(StringUtils.isNotBlank(pmsAccountQuery.getPmsAccount()), AdjPmsAccount::getPmsAccount, pmsAccountQuery.getPmsAccount())
                                .orderByDesc(AdjPmsAccount::getId));
                total = resultPage.getTotal();
                pmsAccountList = resultPage.getRecords();
            } else {
                pmsAccountList = list(new LambdaQueryWrapper<AdjPmsAccount>()
                        .eq(AdjPmsAccount::getPropertyId, propertyId)
                        .eq(StringUtils.isNotBlank(pmsAccountQuery.getPmsAccount()), AdjPmsAccount::getPmsAccount, pmsAccountQuery.getPmsAccount())
                        .orderByDesc(AdjPmsAccount::getId));
                total = pmsAccountList.size();
            }
            return new ListPagedDTO<>(total, pmsAccountList);
        }

        /**
         * 批量保存pmsAccount
         *
         * @param propertyDTO    资产DTO
         * @param pmsAccountList pmsAccount列表
         * @author lichen
         * @date 2023/12/2
         */
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void saveBatch(PropertyDTO propertyDTO, List<String> pmsAccountList) {
            baseMapper.insertOrUpdateByUnique(propertyDTO, pmsAccountList);
        }
    }