|  |  | 
 |  |  | 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.commons.lang3.StringUtils; | 
 |  |  | import org.apache.shiro.SecurityUtils; | 
 |  |  | import org.checkerframework.checker.units.qual.C; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.util.CollectionUtils; | 
 |  |  | 
 |  |  |     public String create(BaseParam baseParam) { | 
 |  |  |  | 
 |  |  |         LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |  | 
 |  |  |         if (Objects.isNull(baseParam.getType()) || StringUtils.isEmpty(baseParam.getName())){ | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"参数错误"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(); | 
 |  |  |         wrapper.lambda() | 
 |  |  |                 .eq(BaseParam::getType,baseParam.getType()) | 
 |  |  |                 .eq(BaseParam::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(BaseParam::getType,baseParam.getName()); | 
 |  |  |                 .eq(BaseParam::getName,baseParam.getName()); | 
 |  |  |  | 
 |  |  |         Integer count = baseParamMapper.selectCount(wrapper); | 
 |  |  |         if (count > 0){ | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void deleteById(String id) { | 
 |  |  |         baseParamMapper.deleteById(id); | 
 |  |  |         BaseParam baseParam = new BaseParam(); | 
 |  |  |         baseParam.setId(id); | 
 |  |  |         baseParam.setEditDate(new Date()); | 
 |  |  |         baseParam.setIsdeleted(Constants.ONE); | 
 |  |  |         baseParamMapper.updateById(baseParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void delete(BaseParam baseParam) { | 
 |  |  |         UpdateWrapper<BaseParam> deleteWrapper = new UpdateWrapper<>(baseParam); | 
 |  |  |         baseParamMapper.delete(deleteWrapper); | 
 |  |  | //      UpdateWrapper<BaseParam> deleteWrapper = new UpdateWrapper<>(baseParam); | 
 |  |  |         baseParam.setIsdeleted(Constants.ONE); | 
 |  |  |         baseParamMapper.updateById(baseParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |         if (CollectionUtils.isEmpty(ids)) { | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         baseParamMapper.deleteBatchIds(ids); | 
 |  |  |        for(String id :ids){ | 
 |  |  |            deleteById(id); | 
 |  |  |        } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |         wrapper.lambda() | 
 |  |  |                 .eq(BaseParam::getType,baseParam.getType()) | 
 |  |  |                 .eq(BaseParam::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(BaseParam::getType,baseParam.getName()); | 
 |  |  |                 .eq(BaseParam::getName,baseParam.getName()); | 
 |  |  |  | 
 |  |  |         BaseParam baseParam1 = baseParamMapper.selectOne(wrapper.last(" limit 1")); | 
 |  |  |         if (Objects.nonNull(baseParam1) && !baseParam1.getId().equals(baseParam.getId())){ | 
 |  |  | 
 |  |  |         updateWrapper | 
 |  |  |                 .lambda() | 
 |  |  |                 .eq(BaseParam::getId,baseParam.getId()) | 
 |  |  |                 .set(BaseParam::getRequired,baseParam.getRequired()) | 
 |  |  |                 .set(BaseParam::getName,baseParam.getName()) | 
 |  |  |                 .set(BaseParam::getSortnum,baseParam.getSortnum()) | 
 |  |  |                 .set(BaseParam::getEditDate,new Date()) | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<BaseParam> findList(BaseParam baseParam) { | 
 |  |  |         QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam); | 
 |  |  |         baseParam.setIsdeleted(Constants.ZERO); | 
 |  |  |         wrapper.orderByAsc("sortnum"); | 
 |  |  |         return baseParamMapper.selectList(wrapper); | 
 |  |  |     } | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public long count(BaseParam baseParam) { | 
 |  |  |         QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam); | 
 |  |  |         baseParam.setIsdeleted(Constants.ZERO); | 
 |  |  |         return baseParamMapper.selectCount(wrapper); | 
 |  |  |     } | 
 |  |  | } |