| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | 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; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 系统基础配置表Service实现 |
| | |
| | | |
| | | @Override |
| | | public String create(BaseParam baseParam) { |
| | | baseParamMapper.insert(baseParam); |
| | | return baseParam.getId(); |
| | | |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(BaseParam::getType,baseParam.getType()) |
| | | .eq(BaseParam::getType,baseParam.getName()); |
| | | |
| | | Integer count = baseParamMapper.selectCount(wrapper); |
| | | if (count > 0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"车辆问题已存在"); |
| | | } |
| | | BaseParam insert = new BaseParam(); |
| | | insert.setCreateDate(new Date()); |
| | | insert.setCreator(principal.getId()); |
| | | insert.setEditDate(new Date()); |
| | | insert.setEditor(principal.getId()); |
| | | insert.setIsdeleted(Constants.ZERO); |
| | | insert.setName(baseParam.getName()); |
| | | insert.setSortnum(baseParam.getSortnum()); |
| | | insert.setType(baseParam.getType()); |
| | | insert.setStatus(Constants.ZERO); |
| | | insert.setInfo(baseParam.getInfo()); |
| | | insert.setRequired(baseParam.getRequired()); |
| | | baseParamMapper.insert(insert); |
| | | return insert.getId(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<String> ids) { |
| | | |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void updateById(BaseParam baseParam) { |
| | | baseParamMapper.updateById(baseParam); |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(BaseParam::getType,baseParam.getType()) |
| | | .eq(BaseParam::getType,baseParam.getName()); |
| | | |
| | | BaseParam baseParam1 = baseParamMapper.selectOne(wrapper); |
| | | if (Objects.nonNull(baseParam1) && !baseParam1.getId().equals(baseParam.getId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"车辆问题已存在"); |
| | | } |
| | | UpdateWrapper<BaseParam> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper |
| | | .lambda() |
| | | .eq(BaseParam::getId,baseParam.getId()) |
| | | .set(BaseParam::getName,baseParam.getName()) |
| | | .set(BaseParam::getSortnum,baseParam.getSortnum()) |
| | | .set(BaseParam::getEditDate,new Date()) |
| | | .set(BaseParam::getEditor,principal.getId()); |
| | | baseParamMapper.update(null,updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public List<BaseParam> findList(BaseParam baseParam) { |
| | | QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam); |
| | | wrapper.orderByAsc("sortnum"); |
| | | return baseParamMapper.selectList(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageData<BaseParam> findPage(PageWrap<BaseParam> pageWrap) { |
| | | IPage<BaseParam> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |