[重磅更新] 重写项目整体结构 数据处理下沉至 Mapper 符合 MVC 规范 减少循环依赖
| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpException; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | @PutMapping("/changePreviewListResource") |
| | | public AjaxResult<Void> changePreviewListResource(@RequestBody String body) { |
| | | Map<String, Boolean> map = JsonUtils.parseMap(body); |
| | | SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, OssConstant.PEREVIEW_LIST_RESOURCE_KEY)); |
| | | SysConfig config = iSysConfigService.getOne(new SysConfig().setConfigKey(OssConstant.PEREVIEW_LIST_RESOURCE_KEY)); |
| | | config.setConfigValue(map.get("previewListResource").toString()); |
| | | return toAjax(iSysConfigService.updateConfig(config)); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.mapper; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.enums.SqlMethod; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; |
| | | import com.baomidou.mybatisplus.core.toolkit.*; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.ruoyi.common.utils.BeanCopyUtils; |
| | | import org.apache.ibatis.binding.MapperMethod; |
| | | import org.apache.ibatis.logging.Log; |
| | | import org.apache.ibatis.logging.LogFactory; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * èªå®ä¹ Mapper æ¥å£, å®ç° èªå®ä¹æ©å± |
| | | * |
| | | * @param <M> mapper æ³å |
| | | * @param <T> table æ³å |
| | | * @param <V> vo æ³å |
| | | * @author Lion Li |
| | | * @since 2021-05-13 |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> { |
| | | |
| | | Log log = LogFactory.getLog(BaseMapperPlus.class); |
| | | |
| | | int DEFAULT_BATCH_SIZE = 1000; |
| | | |
| | | default Class<V> currentVoClass() { |
| | | return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 2); |
| | | } |
| | | |
| | | default Class<T> currentModelClass() { |
| | | return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 1); |
| | | } |
| | | |
| | | default Class<M> currentMapperClass() { |
| | | return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 0); |
| | | } |
| | | |
| | | default List<T> selectList() { |
| | | return this.selectList(new QueryWrapper<>()); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæå
¥ |
| | | */ |
| | | default boolean insertBatch(Collection<T> entityList) { |
| | | return insertBatch(entityList, DEFAULT_BATCH_SIZE); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ´æ° |
| | | */ |
| | | default boolean updateBatchById(Collection<T> entityList) { |
| | | return updateBatchById(entityList, DEFAULT_BATCH_SIZE); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæå
¥ææ´æ° |
| | | */ |
| | | default boolean insertOrUpdateBatch(Collection<T> entityList) { |
| | | return insertOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæå
¥(å
å«éå¶æ¡æ°) |
| | | */ |
| | | default boolean insertBatch(Collection<T> entityList, int batchSize) { |
| | | String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.INSERT_ONE); |
| | | return SqlHelper.executeBatch(this.currentModelClass(), log, entityList, batchSize, |
| | | (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity)); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ´æ°(å
å«éå¶æ¡æ°) |
| | | */ |
| | | default boolean updateBatchById(Collection<T> entityList, int batchSize) { |
| | | String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.UPDATE_BY_ID); |
| | | return SqlHelper.executeBatch(this.currentModelClass(), log, entityList, batchSize, |
| | | (sqlSession, entity) -> { |
| | | MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>(); |
| | | param.put(Constants.ENTITY, entity); |
| | | sqlSession.update(sqlStatement, param); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæå
¥ææ´æ°(å
å«éå¶æ¡æ°) |
| | | */ |
| | | default boolean insertOrUpdateBatch(Collection<T> entityList, int batchSize) { |
| | | TableInfo tableInfo = TableInfoHelper.getTableInfo(this.currentModelClass()); |
| | | Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); |
| | | String keyProperty = tableInfo.getKeyProperty(); |
| | | Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); |
| | | return SqlHelper.saveOrUpdateBatch(this.currentModelClass(), getClass(), log, entityList, batchSize, (sqlSession, entity) -> { |
| | | Object idVal = tableInfo.getPropertyValue(entity, keyProperty); |
| | | String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.INSERT_ONE); |
| | | return StringUtils.checkValNull(idVal) |
| | | || CollectionUtils.isEmpty(sqlSession.selectList(sqlStatement, entity)); |
| | | }, (sqlSession, entity) -> { |
| | | MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>(); |
| | | param.put(Constants.ENTITY, entity); |
| | | String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.UPDATE_BY_ID); |
| | | sqlSession.update(sqlStatement, param); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æå
¥ææ´æ°(å
å«éå¶æ¡æ°) |
| | | */ |
| | | default boolean insertOrUpdate(T entity) { |
| | | if (null != entity) { |
| | | TableInfo tableInfo = TableInfoHelper.getTableInfo(this.currentModelClass()); |
| | | Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); |
| | | String keyProperty = tableInfo.getKeyProperty(); |
| | | Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); |
| | | Object idVal = tableInfo.getPropertyValue(entity, tableInfo.getKeyProperty()); |
| | | return StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal)) ? insert(entity) > 0 : updateById(entity) > 0; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | default V selectVoById(Serializable id) { |
| | | return selectVoById(id, this.currentVoClass()); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® ID æ¥è¯¢ |
| | | */ |
| | | default <C> C selectVoById(Serializable id, Class<C> voClass) { |
| | | T obj = this.selectById(id); |
| | | if (ObjectUtil.isNull(obj)) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.copy(obj, voClass); |
| | | } |
| | | |
| | | default List<V> selectVoById(Collection<? extends Serializable> idList) { |
| | | return selectVoBatchIds(idList, this.currentVoClass()); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ®ID æ¹éæ¥è¯¢ï¼ |
| | | */ |
| | | default <C> List<C> selectVoBatchIds(Collection<? extends Serializable> idList, Class<C> voClass) { |
| | | List<T> list = this.selectBatchIds(idList); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return BeanCopyUtils.copyList(list, voClass); |
| | | } |
| | | |
| | | default List<V> selectVoByMap(Map<String, Object> map) { |
| | | return selectVoByMap(map, this.currentVoClass()); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ® columnMap æ¡ä»¶ï¼ |
| | | */ |
| | | default <C> List<C> selectVoByMap(Map<String, Object> map, Class<C> voClass) { |
| | | List<T> list = this.selectByMap(map); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return BeanCopyUtils.copyList(list, voClass); |
| | | } |
| | | |
| | | default V selectVoOne(Wrapper<T> wrapper) { |
| | | return selectVoOne(wrapper, this.currentVoClass()); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® entity æ¡ä»¶ï¼æ¥è¯¢ä¸æ¡è®°å½ |
| | | */ |
| | | default <C> C selectVoOne(Wrapper<T> wrapper, Class<C> voClass) { |
| | | T obj = this.selectOne(wrapper); |
| | | if (ObjectUtil.isNull(obj)) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.copy(obj, voClass); |
| | | } |
| | | |
| | | default List<V> selectVoList(Wrapper<T> wrapper) { |
| | | return selectVoList(wrapper, this.currentVoClass()); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® entity æ¡ä»¶ï¼æ¥è¯¢å
¨é¨è®°å½ |
| | | */ |
| | | default <C> List<C> selectVoList(Wrapper<T> wrapper, Class<C> voClass) { |
| | | List<T> list = this.selectList(wrapper); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return BeanCopyUtils.copyList(list, voClass); |
| | | } |
| | | |
| | | default <P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper) { |
| | | return selectVoPage(page, wrapper, this.currentVoClass()); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢VO |
| | | */ |
| | | default <C, P extends IPage<C>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<C> voClass) { |
| | | IPage<T> pageData = this.selectPage(page, wrapper); |
| | | IPage<C> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal()); |
| | | if (CollUtil.isEmpty(pageData.getRecords())) { |
| | | return (P) voPage; |
| | | } |
| | | voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass)); |
| | | return (P) voPage; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import com.ruoyi.demo.mapper.TestDemoMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | @RequestMapping("/demo/batch") |
| | | public class TestBatchController extends BaseController { |
| | | |
| | | private final ITestDemoService iTestDemoService; |
| | | /** |
| | | * 为äºä¾¿äºæµè¯ ç´æ¥å¼å
¥mapper |
| | | */ |
| | | private final TestDemoMapper testDemoMapper; |
| | | |
| | | /** |
| | | * æ°å¢æ¹éæ¹æ³ å¯å®ç¾æ¿ä»£ saveBatch ç§çº§æå
¥ä¸ä¸æ°æ® (对mysqlè´è·è¾å¤§) |
| | |
| | | for (int i = 0; i < 1000; i++) { |
| | | list.add(new TestDemo().setOrderNum(-1L).setTestKey("æ¹éæ°å¢").setValue("æµè¯æ°å¢")); |
| | | } |
| | | return toAjax(iTestDemoService.saveAll(list) ? 1 : 0); |
| | | return toAjax(testDemoMapper.insertBatch(list) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (int i = 0; i < 1000; i++) { |
| | | list.add(new TestDemo().setOrderNum(-1L).setTestKey("æ¹éæ°å¢").setValue("æµè¯æ°å¢")); |
| | | } |
| | | iTestDemoService.saveAll(list); |
| | | testDemoMapper.insertBatch(list); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TestDemo testDemo = list.get(i); |
| | | testDemo.setTestKey("æ¹éæ°å¢æä¿®æ¹").setValue("æ¹éæ°å¢æä¿®æ¹"); |
| | |
| | | testDemo.setId(null); |
| | | } |
| | | } |
| | | return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0); |
| | | return toAjax(testDemoMapper.insertOrUpdateBatch(list) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | @DeleteMapping() |
| | | // @DS("slave") |
| | | public AjaxResult<Void> remove() { |
| | | return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>() |
| | | .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0); |
| | | return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>() |
| | | .eq(TestDemo::getOrderNum, -1L))); |
| | | } |
| | | |
| | | } |
| | |
| | | ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true); |
| | | List<TestDemoImportVo> volist = excelResult.getList(); |
| | | List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class); |
| | | iTestDemoService.saveAll(list); |
| | | iTestDemoService.saveBatch(list); |
| | | return AjaxResult.success(excelResult.getAnalysis()); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | public interface TestDemoMapper extends BaseMapperPlus<TestDemo> { |
| | | public interface TestDemoMapper extends BaseMapperPlus<TestDemoMapper, TestDemo, TestDemoVo> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | |
| | | |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | |
| | | /** |
| | | * æµè¯æ 表Mapperæ¥å£ |
| | |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | public interface TestTreeMapper extends BaseMapperPlus<TestTree> { |
| | | public interface TestTreeMapper extends BaseMapperPlus<TestTreeMapper, TestTree, TestTreeVo> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.service; |
| | | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | public interface ITestDemoService extends IServicePlus<TestDemo, TestDemoVo> { |
| | | public interface ITestDemoService { |
| | | |
| | | /** |
| | | * æ¥è¯¢å个 |
| | |
| | | * @return |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | /** |
| | | * æ¹éä¿å |
| | | */ |
| | | Boolean saveBatch(List<TestDemo> list); |
| | | } |
| | |
| | | package com.ruoyi.demo.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | |
| | |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | public interface ITestTreeService extends IServicePlus<TestTree, TestTreeVo> { |
| | | public interface ITestTreeService { |
| | | /** |
| | | * æ¥è¯¢å个 |
| | | * |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.mapper.TestDemoMapper; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collection; |
| | |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDemo, TestDemoVo> implements ITestDemoService { |
| | | public class TestDemoServiceImpl implements ITestDemoService { |
| | | |
| | | private final TestDemoMapper baseMapper; |
| | | |
| | | @Override |
| | | public TestDemoVo queryById(Long id) { |
| | | return getVoById(id); |
| | | return baseMapper.selectVoById(id); |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); |
| | | Page<TestDemoVo> result = pageVo(pageQuery.build(), lqw); |
| | | Page<TestDemoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<TestDemoVo> queryList(TestDemoBo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | | return baseMapper.selectVoList(buildQueryWrapper(bo)); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) { |
| | |
| | | public Boolean insertByBo(TestDemoBo bo) { |
| | | TestDemo add = BeanUtil.toBean(bo, TestDemo.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = save(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setId(add.getId()); |
| | | } |
| | |
| | | public Boolean updateByBo(TestDemoBo bo) { |
| | | TestDemo update = BeanUtil.toBean(bo, TestDemo.class); |
| | | validEntityBeforeSave(update); |
| | | return updateById(update); |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | if (isValid) { |
| | | //TODO åä¸äºä¸å¡ä¸çæ ¡éª,夿æ¯å¦éè¦æ ¡éª |
| | | } |
| | | return removeByIds(ids); |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean saveBatch(List<TestDemo> list) { |
| | | return baseMapper.insertBatch(list); |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | import com.ruoyi.demo.mapper.TestTreeMapper; |
| | | import com.ruoyi.demo.service.ITestTreeService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collection; |
| | |
| | | * @date 2021-07-26 |
| | | */ |
| | | // @DS("slave") // 忢ä»åºæ¥è¯¢ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService { |
| | | public class TestTreeServiceImpl implements ITestTreeService { |
| | | |
| | | private final TestTreeMapper baseMapper; |
| | | |
| | | @Override |
| | | public TestTreeVo queryById(Long id) { |
| | | return getVoById(id); |
| | | return baseMapper.selectVoById(id); |
| | | } |
| | | |
| | | // @DS("slave") // 忢ä»åºæ¥è¯¢ |
| | | @Override |
| | | public List<TestTreeVo> queryList(TestTreeBo bo) { |
| | | LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo); |
| | | return listVo(lqw); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) { |
| | |
| | | public Boolean insertByBo(TestTreeBo bo) { |
| | | TestTree add = BeanUtil.toBean(bo, TestTree.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = save(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setId(add.getId()); |
| | | } |
| | |
| | | public Boolean updateByBo(TestTreeBo bo) { |
| | | TestTree update = BeanUtil.toBean(bo, TestTree.class); |
| | | validEntityBeforeSave(update); |
| | | return updateById(update); |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | if (isValid) { |
| | | //TODO åä¸äºä¸å¡ä¸çæ ¡éª,夿æ¯å¦éè¦æ ¡éª |
| | | } |
| | | return removeByIds(ids); |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; |
| | | import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; |
| | | import com.baomidou.mybatisplus.core.injector.ISqlInjector; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.ruoyi.common.core.mybatisplus.methods.InsertAll; |
| | | import com.ruoyi.framework.handler.CreateAndUpdateMetaObjectHandler; |
| | | import com.ruoyi.framework.interceptor.PlusDataPermissionInterceptor; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * mybatis-plusé
置类(䏿¹æ³¨éææä»¶ä»ç») |
| | |
| | | @Bean |
| | | public MetaObjectHandler metaObjectHandler() { |
| | | return new CreateAndUpdateMetaObjectHandler(); |
| | | } |
| | | |
| | | /** |
| | | * sql注å
¥å¨é
ç½® |
| | | */ |
| | | @Bean |
| | | public ISqlInjector sqlInjector() { |
| | | return new DefaultSqlInjector() { |
| | | @Override |
| | | public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) { |
| | | List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo); |
| | | methodList.add(new InsertAll()); |
| | | return methodList; |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.generator.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | | import java.util.List; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @InterceptorIgnore(dataPermission = "true") |
| | | public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn> { |
| | | public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumnMapper, GenTableColumn, GenTableColumn> { |
| | | /** |
| | | * æ ¹æ®è¡¨åç§°æ¥è¯¢åä¿¡æ¯ |
| | | * |
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @InterceptorIgnore(dataPermission = "true") |
| | | public interface GenTableMapper extends BaseMapperPlus<GenTable> { |
| | | public interface GenTableMapper extends BaseMapperPlus<GenTableMapper, GenTable, GenTable> { |
| | | |
| | | |
| | | Page<GenTable> selectPageGenTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable); |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | import com.ruoyi.generator.mapper.GenTableColumnMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMapper, GenTableColumn, GenTableColumn> implements IGenTableColumnService { |
| | | public class GenTableColumnServiceImpl implements IGenTableColumnService { |
| | | |
| | | private final GenTableColumnMapper baseMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | |
| | | */ |
| | | @Override |
| | | public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) { |
| | | return list(new LambdaQueryWrapper<GenTableColumn>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<GenTableColumn>() |
| | | .eq(GenTableColumn::getTableId, tableId) |
| | | .orderByAsc(GenTableColumn::getSort)); |
| | | } |
| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | |
| | | import com.ruoyi.generator.util.GenUtils; |
| | | import com.ruoyi.generator.util.VelocityInitializer; |
| | | import com.ruoyi.generator.util.VelocityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.util.IOUtils; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.apache.velocity.app.Velocity; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTable, GenTable> implements IGenTableService { |
| | | public class GenTableServiceImpl implements IGenTableService { |
| | | |
| | | @Autowired |
| | | private GenTableColumnMapper genTableColumnMapper; |
| | | private final GenTableMapper baseMapper; |
| | | private final GenTableColumnMapper genTableColumnMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡ä¿¡æ¯ |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteGenTableByIds(Long[] tableIds) { |
| | | List<Long> ids = Arrays.asList(tableIds); |
| | | removeByIds(ids); |
| | | baseMapper.deleteBatchIds(ids); |
| | | genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids)); |
| | | } |
| | | |
| | |
| | | saveColumns.add(column); |
| | | } |
| | | if (CollUtil.isNotEmpty(saveColumns)) { |
| | | genTableColumnMapper.insertAll(saveColumns); |
| | | genTableColumnMapper.insertBatch(saveColumns); |
| | | } |
| | | } |
| | | } |
| | |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | generatorCode(tableName, zip); |
| | | IOUtils.closeQuietly(zip); |
| | | IoUtil.close(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | |
| | | } |
| | | }); |
| | | if (CollUtil.isNotEmpty(saveColumns)) { |
| | | genTableColumnMapper.insertAll(saveColumns); |
| | | genTableColumnMapper.insertBatch(saveColumns); |
| | | } |
| | | |
| | | List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); |
| | |
| | | for (String tableName : tableNames) { |
| | | generatorCode(tableName, zip); |
| | | } |
| | | IOUtils.closeQuietly(zip); |
| | | IoUtil.close(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface IGenTableColumnService extends IService<GenTableColumn> { |
| | | public interface IGenTableColumnService { |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | | * |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface IGenTableService extends IService<GenTable> { |
| | | public interface IGenTableService { |
| | | |
| | | |
| | | TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery); |
| | |
| | | package ${packageName}.mapper; |
| | | |
| | | import ${packageName}.domain.${ClassName}; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | |
| | | /** |
| | | * ${functionName}Mapperæ¥å£ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysConfigMapper extends BaseMapperPlus<SysConfig> { |
| | | public interface SysConfigMapper extends BaseMapperPlus<SysConfigMapper, SysConfig, SysConfig> { |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDeptMapper extends BaseMapperPlus<SysDept> { |
| | | public interface SysDeptMapper extends BaseMapperPlus<SysDeptMapper, SysDept, SysDept> { |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDictDataMapper extends BaseMapperPlus<SysDictData> { |
| | | public interface SysDictDataMapper extends BaseMapperPlus<SysDictDataMapper, SysDictData, SysDictData> { |
| | | |
| | | default List<SysDictData> selectDictDataByType(String dictType) { |
| | | return selectList( |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | |
| | | /** |
| | | * åå
¸è¡¨ æ°æ®å± |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDictTypeMapper extends BaseMapperPlus<SysDictType> { |
| | | public interface SysDictTypeMapper extends BaseMapperPlus<SysDictTypeMapper, SysDictType, SysDictType> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysLogininforMapper extends BaseMapperPlus<SysLogininfor> { |
| | | public interface SysLogininforMapper extends BaseMapperPlus<SysLogininforMapper, SysLogininfor, SysLogininfor> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysMenuMapper extends BaseMapperPlus<SysMenu> { |
| | | public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, SysMenu> { |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æææé |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysNoticeMapper extends BaseMapperPlus<SysNotice> { |
| | | public interface SysNoticeMapper extends BaseMapperPlus<SysNoticeMapper, SysNotice, SysNotice> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysOperLogMapper extends BaseMapperPlus<SysOperLog> { |
| | | public interface SysOperLogMapper extends BaseMapperPlus<SysOperLogMapper, SysOperLog, SysOperLog> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | |
| | | /** |
| | | * 对象åå¨é
ç½®Mapperæ¥å£ |
| | |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfig> { |
| | | public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ æ°æ®å± |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysOssMapper extends BaseMapperPlus<SysOss> { |
| | | public interface SysOssMapper extends BaseMapperPlus<SysOssMapper, SysOss, SysOssVo> { |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysPostMapper extends BaseMapperPlus<SysPost> { |
| | | public interface SysPostMapper extends BaseMapperPlus<SysPostMapper, SysPost, SysPost> { |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDè·åå²ä½éæ©æ¡å表 |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDept> { |
| | | public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDeptMapper, SysRoleDept, SysRoleDept> { |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysRoleMapper extends BaseMapperPlus<SysRole> { |
| | | public interface SysRoleMapper extends BaseMapperPlus<SysRoleMapper, SysRole, SysRole> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id") |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu> { |
| | | public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenuMapper, SysRoleMenu, SysRoleMenu> { |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.DataColumn; |
| | | import com.ruoyi.common.annotation.DataPermission; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysUserMapper extends BaseMapperPlus<SysUser> { |
| | | public interface SysUserMapper extends BaseMapperPlus<SysUserMapper, SysUser, SysUser> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysUserPostMapper extends BaseMapperPlus<SysUserPost> { |
| | | public interface SysUserPostMapper extends BaseMapperPlus<SysUserPostMapper, SysUserPost, SysUserPost> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.common.core.mapper.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole> { |
| | | public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRoleMapper, SysUserRole, SysUserRole> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysConfigService extends IService<SysConfig> { |
| | | public interface ISysConfigService { |
| | | |
| | | |
| | | TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery); |
| | |
| | | * @return ç»æ |
| | | */ |
| | | String checkConfigKeyUnique(SysConfig config); |
| | | |
| | | SysConfig getOne(SysConfig config); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysDeptService extends IService<SysDept> { |
| | | public interface ISysDeptService { |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | | * |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysDictDataService extends IService<SysDictData> { |
| | | public interface ISysDictDataService { |
| | | |
| | | |
| | | TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery); |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysDictTypeService extends IService<SysDictType> { |
| | | public interface ISysDictTypeService { |
| | | |
| | | |
| | | TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysLogininforService extends IService<SysLogininfor> { |
| | | public interface ISysLogininforService { |
| | | |
| | | |
| | | TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor, PageQuery pageQuery); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysMenuService extends IService<SysMenu> { |
| | | public interface ISysMenuService { |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢ç³»ç»èåå表 |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysNoticeService extends IService<SysNotice> { |
| | | public interface ISysNoticeService { |
| | | |
| | | |
| | | TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery); |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysOperLogService extends IService<SysOperLog> { |
| | | public interface ISysOperLogService { |
| | | |
| | | TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog, PageQuery pageQuery); |
| | | |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | |
| | |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | public interface ISysOssConfigService extends IServicePlus<SysOssConfig, SysOssConfigVo> { |
| | | public interface ISysOssConfigService { |
| | | |
| | | /** |
| | | * åå§åOSSé
ç½® |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysOssService extends IServicePlus<SysOss, SysOssVo> { |
| | | public interface ISysOssService { |
| | | |
| | | TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery); |
| | | |
| | | SysOss getById(Long ossId); |
| | | |
| | | SysOss upload(MultipartFile file); |
| | | |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | } |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysPostService extends IService<SysPost> { |
| | | public interface ISysPostService { |
| | | |
| | | |
| | | TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysRoleService extends IService<SysRole> { |
| | | public interface ISysRoleService { |
| | | |
| | | |
| | | TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysUserService extends IService<SysUser>, UserService { |
| | | public interface ISysUserService extends UserService { |
| | | |
| | | |
| | | TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery); |
| | |
| | | import com.ruoyi.common.exception.user.UserException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysLoginService { |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private AuthenticationManager authenticationManager; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private LogininforService asyncService; |
| | | private final TokenService tokenService; |
| | | private final AuthenticationManager authenticationManager; |
| | | private final ISysUserService userService; |
| | | private final ISysConfigService configService; |
| | | private final LogininforService asyncService; |
| | | |
| | | /** |
| | | * ç»å½éªè¯ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashSet; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysPermissionService { |
| | | |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | private final ISysRoleService roleService; |
| | | private final ISysMenuService menuService; |
| | | |
| | | /** |
| | | * è·åè§è²æ°æ®æé |
| | |
| | | import com.ruoyi.common.core.service.LogininforService; |
| | | import com.ruoyi.common.exception.user.CaptchaException; |
| | | import com.ruoyi.common.exception.user.CaptchaExpireException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysRegisterService { |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private LogininforService asyncService; |
| | | private final ISysUserService userService; |
| | | private final ISysConfigService configService; |
| | | private final LogininforService asyncService; |
| | | |
| | | /** |
| | | * 注å |
| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.ConfigService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig, SysConfig> implements ISysConfigService, ConfigService { |
| | | public class SysConfigServiceImpl implements ISysConfigService, ConfigService { |
| | | |
| | | private final SysConfigMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery) { |
| | |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | Page<SysConfig> page = page(pageQuery.build(), lqw); |
| | | Page<SysConfig> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | @Override |
| | | public SysConfig getOne(SysConfig config) { |
| | | return baseMapper.selectOne(new LambdaQueryWrapper<>(config)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åæ° key è·ååæ°å¼ |
| | | * |
| | |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleDeptMapper; |
| | | import com.ruoyi.system.service.SysDataScopeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RequiredArgsConstructor |
| | | @Service("sdss") |
| | | public class SysDataScopeServiceImpl implements SysDataScopeService { |
| | | |
| | | @Autowired |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | @Autowired |
| | | private SysDeptMapper deptMapper; |
| | | private final SysRoleDeptMapper roleDeptMapper; |
| | | private final SysDeptMapper deptMapper; |
| | | |
| | | @Override |
| | | public String getRoleCustom(Long roleId) { |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept, SysDept> implements ISysDeptService { |
| | | public class SysDeptServiceImpl implements ISysDeptService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | | |
| | | @Autowired |
| | | private SysUserMapper userMapper; |
| | | private final SysDeptMapper baseMapper; |
| | | private final SysRoleMapper roleMapper; |
| | | private final SysUserMapper userMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | |
| | | */ |
| | | @Override |
| | | public List<SysDept> selectDeptList(SysDept dept) { |
| | | // return baseMapper.selectList(); |
| | | // return baseMapper.selectList(new LambdaQueryWrapper<>()); |
| | | return baseMapper.selectDeptList(dept); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public SysDept selectDeptById(Long deptId) { |
| | | return getById(deptId); |
| | | return baseMapper.selectById(deptId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public long selectNormalChildrenDeptById(Long deptId) { |
| | | return count(new LambdaQueryWrapper<SysDept>() |
| | | return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getStatus, 0) |
| | | .apply("find_in_set({0}, ancestors)", deptId)); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public boolean hasChildByDeptId(Long deptId) { |
| | | long result = count(new LambdaQueryWrapper<SysDept>() |
| | | return baseMapper.exists(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getParentId, deptId)); |
| | | return result > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean checkDeptExistUser(Long deptId) { |
| | | long result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>() |
| | | return userMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getDeptId, deptId)); |
| | | return result > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkDeptNameUnique(SysDept dept) { |
| | | Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
| | | long count = count(new LambdaQueryWrapper<SysDept>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getDeptName, dept.getDeptName()) |
| | | .eq(SysDept::getParentId, dept.getParentId()) |
| | | .ne(SysDept::getDeptId, deptId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | */ |
| | | @Override |
| | | public int insertDept(SysDept dept) { |
| | | SysDept info = getById(dept.getParentId()); |
| | | SysDept info = baseMapper.selectById(dept.getParentId()); |
| | | // 妿ç¶èç¹ä¸ä¸ºæ£å¸¸ç¶æ,åä¸å
许æ°å¢åèç¹ |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { |
| | | throw new ServiceException("é¨é¨åç¨ï¼ä¸å
许æ°å¢"); |
| | |
| | | */ |
| | | @Override |
| | | public int updateDept(SysDept dept) { |
| | | SysDept newParentDept = getById(dept.getParentId()); |
| | | SysDept oldDept = getById(dept.getDeptId()); |
| | | SysDept newParentDept = baseMapper.selectById(dept.getParentId()); |
| | | SysDept oldDept = baseMapper.selectById(dept.getDeptId()); |
| | | if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { |
| | | String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); |
| | | String oldAncestors = oldDept.getAncestors(); |
| | |
| | | private void updateParentDeptStatusNormal(SysDept dept) { |
| | | String ancestors = dept.getAncestors(); |
| | | Long[] deptIds = Convert.toLongArray(ancestors); |
| | | update(null, new LambdaUpdateWrapper<SysDept>() |
| | | baseMapper.update(null, new LambdaUpdateWrapper<SysDept>() |
| | | .set(SysDept::getStatus, "0") |
| | | .in(SysDept::getDeptId, Arrays.asList(deptIds))); |
| | | } |
| | |
| | | * @param oldAncestors æ§çç¶IDéå |
| | | */ |
| | | public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { |
| | | List<SysDept> children = list(new LambdaQueryWrapper<SysDept>() |
| | | List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>() |
| | | .apply("find_in_set({0},ancestors)", deptId)); |
| | | for (SysDept child : children) { |
| | | child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); |
| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, SysDictData, SysDictData> implements ISysDictDataService { |
| | | public class SysDictDataServiceImpl implements ISysDictDataService { |
| | | |
| | | private final SysDictDataMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) { |
| | |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort); |
| | | Page<SysDictData> page = page(pageQuery.build(), lqw); |
| | | Page<SysDictData> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData) { |
| | | return list(new LambdaQueryWrapper<SysDictData>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysDictData>() |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | |
| | | */ |
| | | @Override |
| | | public String selectDictLabel(String dictType, String dictValue) { |
| | | return getOne(new LambdaQueryWrapper<SysDictData>() |
| | | return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>() |
| | | .select(SysDictData::getDictLabel) |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .eq(SysDictData::getDictValue, dictValue)) |
| | |
| | | */ |
| | | @Override |
| | | public SysDictData selectDictDataById(Long dictCode) { |
| | | return getById(dictCode); |
| | | return baseMapper.selectById(dictCode); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void deleteDictDataByIds(Long[] dictCodes) { |
| | | for (Long dictCode : dictCodes) { |
| | | SysDictData data = selectDictDataById(dictCode); |
| | | removeById(dictCode); |
| | | baseMapper.deleteById(dictCode); |
| | | List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); |
| | | RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas); |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.DictService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import com.ruoyi.system.mapper.SysDictTypeMapper; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, SysDictType, SysDictType> implements ISysDictTypeService, DictService { |
| | | public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService { |
| | | |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | | private final SysDictTypeMapper baseMapper; |
| | | private final SysDictDataMapper dictDataMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery) { |
| | |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | Page<SysDictType> page = page(pageQuery.build(), lqw); |
| | | Page<SysDictType> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | return list(new LambdaQueryWrapper<SysDictType>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysDictType>() |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | |
| | | */ |
| | | @Override |
| | | public List<SysDictType> selectDictTypeAll() { |
| | | return list(); |
| | | return baseMapper.selectList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public SysDictType selectDictTypeById(Long dictId) { |
| | | return getById(dictId); |
| | | return baseMapper.selectById(dictId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public SysDictType selectDictTypeByType(String dictType) { |
| | | return getOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType)); |
| | | return baseMapper.selectById(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void loadingDictCache() { |
| | | List<SysDictType> dictTypeList = list(); |
| | | List<SysDictType> dictTypeList = baseMapper.selectList(); |
| | | for (SysDictType dictType : dictTypeList) { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); |
| | | RedisUtils.setCacheObject(getCacheKey(dictType.getDictType()), dictDatas); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateDictType(SysDictType dict) { |
| | | SysDictType oldDict = getById(dict.getDictId()); |
| | | SysDictType oldDict = baseMapper.selectById(dict.getDictId()); |
| | | dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() |
| | | .set(SysDictData::getDictType, dict.getDictType()) |
| | | .eq(SysDictData::getDictType, oldDict.getDictType())); |
| | |
| | | @Override |
| | | public String checkDictTypeUnique(SysDictType dict) { |
| | | Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); |
| | | long count = count(new LambdaQueryWrapper<SysDictType>() |
| | | long count = baseMapper.selectCount(new LambdaQueryWrapper<SysDictType>() |
| | | .eq(SysDictType::getDictType, dict.getDictType()) |
| | | .ne(SysDictType::getDictId, dictId)); |
| | | if (count > 0) { |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.LogininforService; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | import com.ruoyi.system.mapper.SysLogininforMapper; |
| | | import com.ruoyi.system.service.ISysLogininforService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | @Service |
| | | public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMapper, SysLogininfor, SysLogininfor> implements ISysLogininforService, LogininforService { |
| | | public class SysLogininforServiceImpl implements ISysLogininforService, LogininforService { |
| | | |
| | | private final SysLogininforMapper baseMapper; |
| | | |
| | | /** |
| | | * è®°å½ç»å½ä¿¡æ¯ |
| | |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("info_id").setIsAsc("desc"); |
| | | } |
| | | Page<SysLogininfor> page = page(pageQuery.build(), lqw); |
| | | Page<SysLogininfor> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void insertLogininfor(SysLogininfor logininfor) { |
| | | logininfor.setLoginTime(new Date()); |
| | | save(logininfor); |
| | | baseMapper.insert(logininfor); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | return list(new LambdaQueryWrapper<SysLogininfor>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | |
| | | */ |
| | | @Override |
| | | public void cleanLogininfor() { |
| | | remove(new LambdaQueryWrapper<>()); |
| | | baseMapper.delete(new LambdaQueryWrapper<>()); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.TreeBuildUtils; |
| | |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu, SysMenu> implements ISysMenuService { |
| | | public class SysMenuServiceImpl implements ISysMenuService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | | |
| | | @Autowired |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | | private final SysMenuMapper baseMapper; |
| | | private final SysRoleMapper roleMapper; |
| | | private final SysRoleMenuMapper roleMenuMapper; |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢ç³»ç»èåå表 |
| | |
| | | List<SysMenu> menuList = null; |
| | | // 管çåæ¾ç¤ºææèåä¿¡æ¯ |
| | | if (SysUser.isAdmin(userId)) { |
| | | menuList = list(new LambdaQueryWrapper<SysMenu>() |
| | | menuList = baseMapper.selectList(new LambdaQueryWrapper<SysMenu>() |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus()) |
| | |
| | | */ |
| | | @Override |
| | | public SysMenu selectMenuById(Long menuId) { |
| | | return getById(menuId); |
| | | return baseMapper.selectById(menuId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean hasChildByMenuId(Long menuId) { |
| | | long result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId)); |
| | | return result > 0; |
| | | return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean checkMenuExistRole(Long menuId) { |
| | | long result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId)); |
| | | return result > 0; |
| | | return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkMenuNameUnique(SysMenu menu) { |
| | | Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); |
| | | long count = count(new LambdaQueryWrapper<SysMenu>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(SysMenu::getParentId, menu.getParentId()) |
| | | .ne(SysMenu::getMenuId, menuId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | import com.ruoyi.system.mapper.SysNoticeMapper; |
| | | import com.ruoyi.system.service.ISysNoticeService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNotice, SysNotice> implements ISysNoticeService { |
| | | public class SysNoticeServiceImpl implements ISysNoticeService { |
| | | |
| | | private final SysNoticeMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) { |
| | |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); |
| | | Page<SysNotice> page = page(pageQuery.build(), lqw); |
| | | Page<SysNotice> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public SysNotice selectNoticeById(Long noticeId) { |
| | | return getById(noticeId); |
| | | return baseMapper.selectById(noticeId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<SysNotice> selectNoticeList(SysNotice notice) { |
| | | return list(new LambdaQueryWrapper<SysNotice>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysNotice>() |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy())); |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.dto.OperLogDTO; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.OperLogService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | import com.ruoyi.system.mapper.SysOperLogMapper; |
| | | import com.ruoyi.system.service.ISysOperLogService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, SysOperLog, SysOperLog> implements ISysOperLogService, OperLogService { |
| | | public class SysOperLogServiceImpl implements ISysOperLogService, OperLogService { |
| | | |
| | | private final SysOperLogMapper baseMapper; |
| | | |
| | | /** |
| | | * æä½æ¥å¿è®°å½ |
| | |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("oper_id").setIsAsc("desc"); |
| | | } |
| | | Page<SysOperLog> page = page(pageQuery.build(), lqw); |
| | | Page<SysOperLog> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void insertOperlog(SysOperLog operLog) { |
| | | operLog.setOperTime(new Date()); |
| | | save(operLog); |
| | | baseMapper.insert(operLog); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<SysOperLog> selectOperLogList(SysOperLog operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | return list(new LambdaQueryWrapper<SysOperLog>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | |
| | | */ |
| | | @Override |
| | | public SysOperLog selectOperLogById(Long operId) { |
| | | return getById(operId); |
| | | return baseMapper.selectById(operId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void cleanOperLog() { |
| | | remove(new LambdaQueryWrapper<>()); |
| | | baseMapper.delete(new LambdaQueryWrapper<>()); |
| | | } |
| | | } |
| | |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> implements ISysOssConfigService { |
| | | public class SysOssConfigServiceImpl implements ISysOssConfigService { |
| | | |
| | | private final SysOssConfigMapper baseMapper; |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååæ°å°ç¼åï¼å è½½é
置类 |
| | | */ |
| | | @Override |
| | | public void init() { |
| | | List<SysOssConfig> list = list(); |
| | | List<SysOssConfig> list = baseMapper.selectList(); |
| | | // å è½½OSSåå§åé
ç½® |
| | | for (SysOssConfig config : list) { |
| | | String configKey = config.getConfigKey(); |
| | |
| | | |
| | | @Override |
| | | public SysOssConfigVo queryById(Integer ossConfigId) { |
| | | return getVoById(ossConfigId); |
| | | return baseMapper.selectVoById(ossConfigId); |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysOssConfig> lqw = buildQueryWrapper(bo); |
| | | Page<SysOssConfigVo> result = pageVo(pageQuery.build(), lqw); |
| | | Page<SysOssConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | |
| | | public Boolean insertByBo(SysOssConfigBo bo) { |
| | | SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | validEntityBeforeSave(config); |
| | | return setConfigCache(save(config), config); |
| | | return setConfigCache(baseMapper.insert(config) > 0, config); |
| | | } |
| | | |
| | | @Override |
| | |
| | | luw.set(StringUtils.isBlank(config.getRegion()), SysOssConfig::getRegion, ""); |
| | | luw.set(StringUtils.isBlank(config.getExt1()), SysOssConfig::getExt1, ""); |
| | | luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId()); |
| | | return setConfigCache(update(config, luw), config); |
| | | return setConfigCache(baseMapper.update(config, luw) > 0, config); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | List<SysOssConfig> list = Lists.newArrayList(); |
| | | for (Long configId : ids) { |
| | | SysOssConfig config = getById(configId); |
| | | SysOssConfig config = baseMapper.selectById(configId); |
| | | list.add(config); |
| | | } |
| | | boolean flag = removeByIds(ids); |
| | | boolean flag = baseMapper.deleteBatchIds(ids) > 0; |
| | | if (flag) { |
| | | list.stream().forEach(sysOssConfig -> { |
| | | RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey())); |
| | |
| | | */ |
| | | private String checkConfigKeyUnique(SysOssConfig sysOssConfig) { |
| | | long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId(); |
| | | SysOssConfig info = getOne(new LambdaQueryWrapper<SysOssConfig>() |
| | | SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>() |
| | | .select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey) |
| | | .eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())); |
| | | if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) { |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.mapper.SysOssMapper; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, SysOssVo> implements ISysOssService { |
| | | public class SysOssServiceImpl implements ISysOssService { |
| | | |
| | | private final SysOssMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo); |
| | | Page<SysOssVo> result = pageVo(pageQuery.build(), lqw); |
| | | Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | |
| | | lqw.eq(StringUtils.isNotBlank(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService()); |
| | | return lqw; |
| | | } |
| | | |
| | | @Override |
| | | public SysOss getById(Long ossId) { |
| | | return baseMapper.selectById(ossId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .setFileName(uploadResult.getFilename()) |
| | | .setOriginalName(originalfileName) |
| | | .setService(storage.getServiceType()); |
| | | save(oss); |
| | | baseMapper.insert(oss); |
| | | return oss; |
| | | } |
| | | |
| | |
| | | if (isValid) { |
| | | // åä¸äºä¸å¡ä¸çæ ¡éª,夿æ¯å¦éè¦æ ¡éª |
| | | } |
| | | List<SysOss> list = listByIds(ids); |
| | | List<SysOss> list = baseMapper.selectBatchIds(ids); |
| | | for (SysOss sysOss : list) { |
| | | IOssStrategy storage = OssFactory.instance(sysOss.getService()); |
| | | storage.delete(sysOss.getUrl()); |
| | | } |
| | | return removeByIds(ids); |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.ruoyi.system.mapper.SysPostMapper; |
| | | import com.ruoyi.system.mapper.SysUserPostMapper; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost, SysPost> implements ISysPostService { |
| | | public class SysPostServiceImpl implements ISysPostService { |
| | | |
| | | @Autowired |
| | | private SysUserPostMapper userPostMapper; |
| | | private final SysPostMapper baseMapper; |
| | | private final SysUserPostMapper userPostMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) { |
| | |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); |
| | | Page<SysPost> page = page(pageQuery.build(), lqw); |
| | | Page<SysPost> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public List<SysPost> selectPostList(SysPost post) { |
| | | return list(new LambdaQueryWrapper<SysPost>() |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysPost>() |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName())); |
| | |
| | | */ |
| | | @Override |
| | | public List<SysPost> selectPostAll() { |
| | | return list(); |
| | | return baseMapper.selectList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public SysPost selectPostById(Long postId) { |
| | | return getById(postId); |
| | | return baseMapper.selectById(postId); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkPostNameUnique(SysPost post) { |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | long count = count(new LambdaQueryWrapper<SysPost>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostName, post.getPostName()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkPostCodeUnique(SysPost post) { |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | long count = count(new LambdaQueryWrapper<SysPost>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostCode, post.getPostCode()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.mapper.SysUserRoleMapper; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole, SysRole> implements ISysRoleService { |
| | | public class SysRoleServiceImpl implements ISysRoleService { |
| | | |
| | | @Autowired |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | | |
| | | @Autowired |
| | | private SysUserRoleMapper userRoleMapper; |
| | | |
| | | @Autowired |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | private final SysRoleMapper baseMapper; |
| | | private final SysRoleMenuMapper roleMenuMapper; |
| | | private final SysUserRoleMapper userRoleMapper; |
| | | private final SysRoleDeptMapper roleDeptMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery) { |
| | |
| | | */ |
| | | @Override |
| | | public SysRole selectRoleById(Long roleId) { |
| | | return getById(roleId); |
| | | return baseMapper.selectById(roleId); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkRoleNameUnique(SysRole role) { |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | long count = count(new LambdaQueryWrapper<SysRole>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkRoleKeyUnique(SysRole role) { |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | long count = count(new LambdaQueryWrapper<SysRole>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | list.add(rm); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = roleMenuMapper.insertAll(list); |
| | | rows = roleMenuMapper.insertBatch(list) ? list.size() : 0; |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | list.add(rd); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = roleDeptMapper.insertAll(list); |
| | | rows = roleDeptMapper.insertBatch(list) ? list.size() : 0; |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | list.add(ur); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = userRoleMapper.insertAll(list); |
| | | rows = userRoleMapper.insertBatch(list) ? list.size() : 0; |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysUserOnline; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.service.ISysUserOnlineService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysUserOnlineServiceImpl implements ISysUserOnlineService { |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | private final SysUserMapper userMapper; |
| | | |
| | | /** |
| | | * éè¿ç»å½å°åæ¥è¯¢ä¿¡æ¯ |
| | |
| | | if (StringUtils.isNull(user)) { |
| | | return null; |
| | | } |
| | | SysUser sysUser = userService.selectUserById(user.getUserId()); |
| | | SysUser sysUser = userMapper.selectUserById(user.getUserId()); |
| | | SysUserOnline sysUserOnline = new SysUserOnline(); |
| | | sysUserOnline.setTokenId(user.getToken()); |
| | | sysUserOnline.setUserName(user.getUsername()); |
| | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.service.UserService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser, SysUser> implements ISysUserService, UserService { |
| | | public class SysUserServiceImpl implements ISysUserService, UserService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | | |
| | | @Autowired |
| | | private SysPostMapper postMapper; |
| | | |
| | | @Autowired |
| | | private SysUserRoleMapper userRoleMapper; |
| | | |
| | | @Autowired |
| | | private SysUserPostMapper userPostMapper; |
| | | private final SysUserMapper baseMapper; |
| | | private final SysRoleMapper roleMapper; |
| | | private final SysPostMapper postMapper; |
| | | private final SysUserRoleMapper userRoleMapper; |
| | | private final SysUserPostMapper userPostMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) { |
| | |
| | | */ |
| | | @Override |
| | | public String checkUserNameUnique(String userName) { |
| | | long count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName)); |
| | | long count = baseMapper.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public String checkPhoneUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | long count = count(new LambdaQueryWrapper<SysUser>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkEmailUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | long count = count(new LambdaQueryWrapper<SysUser>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getEmail, user.getEmail()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | list.add(ur); |
| | | } |
| | | if (list.size() > 0) { |
| | | userRoleMapper.insertAll(list); |
| | | userRoleMapper.insertBatch(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | list.add(up); |
| | | } |
| | | if (list.size() > 0) { |
| | | userPostMapper.insertAll(list); |
| | | userPostMapper.insertBatch(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | list.add(ur); |
| | | } |
| | | if (list.size() > 0) { |
| | | userRoleMapper.insertAll(list); |
| | | userRoleMapper.insertBatch(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.service.TokenService; |
| | | import com.ruoyi.common.properties.TokenProperties; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class TokenServiceImpl implements TokenService { |
| | | |
| | |
| | | |
| | | private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L; |
| | | |
| | | @Autowired |
| | | private TokenProperties tokenProperties; |
| | | private final TokenProperties tokenProperties; |
| | | |
| | | /** |
| | | * è·åç¨æ·èº«ä»½ä¿¡æ¯ |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.SysPermissionService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class UserDetailsServiceImpl implements UserDetailsService { |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | private final ISysUserService userService; |
| | | private final SysPermissionService permissionService; |
| | | |
| | | @Override |
| | | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |