| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | |
| | | @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 |
| | |
| | | } |
| | | 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) { |
| | |
| | | @Override |
| | | public PricingParam findOne(PricingParam pricingParam) { |
| | | QueryWrapper<PricingParam> wrapper = new QueryWrapper<>(pricingParam); |
| | | return pricingParamMapper.selectOne(wrapper); |
| | | return pricingParamMapper.selectOne(wrapper.last(" limit 1")); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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()); |
| | |
| | | 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())); |
| | |
| | | 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)); |
| | | } |
| | | |