jiaosong
2023-10-18 99f77c0fd2ee8ed8840be5e5f99309b184a09e9f
server/services/src/main/java/com/doumee/service/business/impl/PricingParamServiceImpl.java
@@ -1,5 +1,7 @@
package com.doumee.service.business.impl;
import com.doumee.core.constants.Constants;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Utils;
@@ -10,10 +12,12 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
/**
@@ -29,8 +33,22 @@
    @Override
    public String create(PricingParam pricingParam) {
        pricingParamMapper.insert(pricingParam);
        return pricingParam.getId();
        LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        PricingParam insert = new PricingParam();
        insert.setCreateDate(new Date());
        insert.setCreator(principal.getId());
//        insert.setEditDate(new Date());
//        insert.setEditor(principal.getId());
        insert.setIsdeleted(Constants.ZERO);
        insert.setName(pricingParam.getName());
        insert.setStartDate(pricingParam.getStartDate());
        insert.setEndDate(pricingParam.getEndDate());
        insert.setSortnum(pricingParam.getSortnum());
        insert.setStatus(Constants.ZERO);
        insert.setInfo(pricingParam.getInfo());
        pricingParamMapper.insert(insert);
        return insert.getId();
    }
    @Override
@@ -51,6 +69,23 @@
        }
        pricingParamMapper.deleteBatchIds(ids);
    }
    @Override
    public void update(PricingParam pricingParam) {
        LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        UpdateWrapper<PricingParam> wrapper = new UpdateWrapper<>();
        wrapper.lambda()
                .eq(PricingParam::getId,pricingParam.getId())
                .set(PricingParam::getEditor,principal.getId())
                .set(PricingParam::getName,pricingParam.getName())
                .set(PricingParam::getStatus,pricingParam.getStatus())
                .set(PricingParam::getStartDate,pricingParam.getStartDate())
                .set(PricingParam::getEndDate,pricingParam.getEndDate())
                .set(PricingParam::getSortnum,pricingParam.getSortnum());
        pricingParamMapper.update(null,wrapper);
    }
    @Override
    public void updateById(PricingParam pricingParam) {
@@ -75,7 +110,7 @@
    @Override
    public PricingParam findOne(PricingParam pricingParam) {
        QueryWrapper<PricingParam> wrapper = new QueryWrapper<>(pricingParam);
        return pricingParamMapper.selectOne(wrapper);
        return pricingParamMapper.selectOne(wrapper.last(" limit 1"));
    }
    @Override
@@ -83,7 +118,7 @@
        QueryWrapper<PricingParam> wrapper = new QueryWrapper<>(pricingParam);
        return pricingParamMapper.selectList(wrapper);
    }
    @Override
    public PageData<PricingParam> findPage(PageWrap<PricingParam> pageWrap) {
        IPage<PricingParam> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
@@ -110,7 +145,7 @@
            queryWrapper.lambda().eq(PricingParam::getIsdeleted, pageWrap.getModel().getIsdeleted());
        }
        if (pageWrap.getModel().getName() != null) {
            queryWrapper.lambda().eq(PricingParam::getName, pageWrap.getModel().getName());
            queryWrapper.lambda().like(PricingParam::getName, pageWrap.getModel().getName());
        }
        if (pageWrap.getModel().getStartDate() != null) {
            queryWrapper.lambda().ge(PricingParam::getStartDate, Utils.Date.getStart(pageWrap.getModel().getStartDate()));
@@ -129,13 +164,8 @@
        if (pageWrap.getModel().getInfo() != null) {
            queryWrapper.lambda().eq(PricingParam::getInfo, pageWrap.getModel().getInfo());
        }
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        queryWrapper.lambda().orderByAsc(PricingParam::getSortnum);
        queryWrapper.lambda().orderByAsc(PricingParam::getStatus);
        return PageData.from(pricingParamMapper.selectPage(page, queryWrapper));
    }