org.jeecg.modules.system.entity.SysDict Java Examples

The following examples show how to use org.jeecg.modules.system.entity.SysDict. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysDictServiceImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
  @Transactional
  public Integer saveMain(SysDict sysDict, List<SysDictItem> sysDictItemList) {
int insert=0;
  	try{
	 insert = sysDictMapper.insert(sysDict);
	if (sysDictItemList != null) {
		for (SysDictItem entity : sysDictItemList) {
			entity.setDictId(sysDict.getId());
			entity.setStatus(1);
			sysDictItemMapper.insert(entity);
		}
	}
}catch(Exception e){
	return insert;
}
return insert;
  }
 
Example #2
Source File: SysDictController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * @功能:编辑
 * @param sysDict
 * @return
 */
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	SysDict sysdict = sysDictService.getById(sysDict.getId());
	if(sysdict==null) {
		result.error500("未找到对应实体");
	}else {
		sysDict.setUpdateTime(new Date());
		boolean ok = sysDictService.updateById(sysDict);
		//TODO 返回false说明什么?
		if(ok) {
			result.success("编辑成功!");
		}
	}
	return result;
}
 
Example #3
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:新增
 * @param sysDict
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysDict> add(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	try {
		sysDict.setCreateTime(new Date());
		sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
		sysDictService.save(sysDict);
		result.success("保存成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #4
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:编辑
 * @param sysDict
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	SysDict sysdict = sysDictService.getById(sysDict.getId());
	if(sysdict==null) {
		result.error500("未找到对应实体");
	}else {
		sysDict.setUpdateTime(new Date());
		boolean ok = sysDictService.updateById(sysDict);
		if(ok) {
			result.success("编辑成功!");
		}
	}
	return result;
}
 
Example #5
Source File: SysDictController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:编辑
 * @param sysDict
 * @return
 */
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	SysDict sysdict = sysDictService.getById(sysDict.getId());
	if(sysdict==null) {
		result.error500("未找到对应实体");
	}else {
		sysDict.setUpdateTime(new Date());
		boolean ok = sysDictService.updateById(sysDict);
		if(ok) {
			result.success("编辑成功!");
		}
	}
	return result;
}
 
Example #6
Source File: SysDictServiceImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
  @Transactional
  public Integer saveMain(SysDict sysDict, List<SysDictItem> sysDictItemList) {
int insert=0;
  	try{
	 insert = sysDictMapper.insert(sysDict);
	if (sysDictItemList != null) {
		for (SysDictItem entity : sysDictItemList) {
			entity.setDictId(sysDict.getId());
			entity.setStatus(1);
			sysDictItemMapper.insert(entity);
		}
	}
}catch(Exception e){
	return insert;
}
return insert;
  }
 
Example #7
Source File: SysDictServiceImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, List<DictModel>> queryAllDictItems() {
	Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
	List<SysDict> ls = sysDictMapper.selectList(null);
	LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
	queryWrapper.eq(SysDictItem::getStatus, 1);
	queryWrapper.orderByAsc(SysDictItem::getSortOrder);
	List<SysDictItem> sysDictItemList = sysDictItemMapper.selectList(queryWrapper);

	for (SysDict d : ls) {
		List<DictModel> dictModelList = sysDictItemList.stream().filter(s -> d.getId().equals(s.getDictId())).map(item -> {
			DictModel dictModel = new DictModel();
			dictModel.setText(item.getItemText());
			dictModel.setValue(item.getItemValue());
			return dictModel;
		}).collect(Collectors.toList());
		res.put(d.getDictCode(), dictModelList);
	}
	log.debug("-------登录加载系统字典-----" + res.toString());
	return res;
}
 
Example #8
Source File: SysDictServiceImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, List<DictModel>> queryAllDictItems() {
	Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
	List<SysDict> ls = sysDictMapper.selectList(null);
	LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
	queryWrapper.eq(SysDictItem::getStatus, 1);
	queryWrapper.orderByAsc(SysDictItem::getSortOrder);
	List<SysDictItem> sysDictItemList = sysDictItemMapper.selectList(queryWrapper);

	for (SysDict d : ls) {
		List<DictModel> dictModelList = sysDictItemList.stream().filter(s -> d.getId().equals(s.getDictId())).map(item -> {
			DictModel dictModel = new DictModel();
			dictModel.setText(item.getItemText());
			dictModel.setValue(item.getItemValue());
			return dictModel;
		}).collect(Collectors.toList());
		res.put(d.getDictCode(), dictModelList);
	}
	log.debug("-------登录加载系统字典-----" + res.toString());
	return res;
}
 
Example #9
Source File: SysDictController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:编辑
 * @param sysDict
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	SysDict sysdict = sysDictService.getById(sysDict.getId());
	if(sysdict==null) {
		result.error500("未找到对应实体");
	}else {
		sysDict.setUpdateTime(new Date());
		boolean ok = sysDictService.updateById(sysDict);
		if(ok) {
			result.success("编辑成功!");
		}
	}
	return result;
}
 
Example #10
Source File: SysDictController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:新增
 * @param sysDict
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysDict> add(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	try {
		sysDict.setCreateTime(new Date());
		sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
		sysDictService.save(sysDict);
		result.success("保存成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #11
Source File: SysDictController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * @功能:删除
 * @param id
 * @return
 */
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysDict> result = new Result<SysDict>();
	boolean ok = sysDictService.removeById(id);
	if(ok) {
		result.success("删除成功!");
	}else{
		result.error500("删除失败!");
	}
	return result;
}
 
Example #12
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
	QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
	Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
	IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
	log.debug("查询当前页:"+pageList.getCurrent());
	log.debug("查询当前页数量:"+pageList.getSize());
	log.debug("查询结果数量:"+pageList.getRecords().size());
	log.debug("数据总数:"+pageList.getTotal());
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example #13
Source File: SysDictTree.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
public SysDictTree(SysDict node) {
   	this.id = node.getId();
	this.key = node.getId();
	this.title = node.getDictName();
	this.dictCode = node.getDictCode();
	this.description = node.getDescription();
	this.delFlag = node.getDelFlag();
	this.type = node.getType();
}
 
Example #14
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:新增
 * @param sysDict
 * @return
 */
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysDict> add(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	try {
		sysDict.setCreateTime(new Date());
		sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
		sysDictService.save(sysDict);
		result.success("保存成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #15
Source File: SysDictController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
	QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
	Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
	IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
	log.debug("查询当前页:"+pageList.getCurrent());
	log.debug("查询当前页数量:"+pageList.getSize());
	log.debug("查询结果数量:"+pageList.getRecords().size());
	log.debug("数据总数:"+pageList.getTotal());
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example #16
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:删除
 * @param id
 * @return
 */
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysDict> result = new Result<SysDict>();
	boolean ok = sysDictService.removeById(id);
	if(ok) {
		result.success("删除成功!");
	}else{
		result.error500("删除失败!");
	}
	return result;
}
 
Example #17
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:批量删除
 * @param ids
 * @return
 */
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
	Result<SysDict> result = new Result<SysDict>();
	if(oConvertUtils.isEmpty(ids)) {
		result.error500("参数不识别!");
	}else {
		sysDictService.removeByIds(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}
 
Example #18
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:刷新缓存
 * @return
 */
@RequestMapping(value = "/refleshCache")
public Result<?> refleshCache() {
	Result<?> result = new Result<SysDict>();
	//清空字典缓存
	Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
	Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
	Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
	Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
	redisTemplate.delete(keys);
	redisTemplate.delete(keys2);
	redisTemplate.delete(keys3);
	redisTemplate.delete(keys4);
	return result;
}
 
Example #19
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDict sysDict,HttpServletRequest request) {
	// Step.1 组装查询条件
	QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
	//Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<SysDictPage> pageList = new ArrayList<SysDictPage>();

	List<SysDict> sysDictList = sysDictService.list(queryWrapper);
	for (SysDict dictMain : sysDictList) {
		SysDictPage vo = new SysDictPage();
		BeanUtils.copyProperties(dictMain, vo);
		// 查询机票
		List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByMainId(dictMain.getId());
		vo.setSysDictItemList(sysDictItemList);
		pageList.add(vo);
	}

	// 导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME, "数据字典");
	// 注解对象Class
	mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
	// 自定义表格参数
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:"+user.getRealname(), "数据字典"));
	// 导出数据列表
	mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
	return mv;
}
 
Example #20
Source File: SysDictController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * @功能:新增
 * @param sysDict
 * @return
 */
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysDict> add(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	try {
		sysDict.setCreateTime(new Date());
		sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
		sysDictService.save(sysDict);
		result.success("保存成功!");
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #21
Source File: SysDictController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 查询被删除的列表
 * @return
 */
@RequestMapping(value = "/deleteList", method = RequestMethod.GET)
public Result<List<SysDict>> deleteList() {
	Result<List<SysDict>> result = new Result<List<SysDict>>();
	List<SysDict> list = this.sysDictService.queryDeleteList();
	result.setSuccess(true);
	result.setResult(list);
	return result;
}
 
Example #22
Source File: SysDictTree.java    From teaching with Apache License 2.0 5 votes vote down vote up
public SysDictTree(SysDict node) {
   	this.id = node.getId();
	this.key = node.getId();
	this.title = node.getDictName();
	this.dictCode = node.getDictCode();
	this.description = node.getDescription();
	this.delFlag = node.getDelFlag();
	this.type = node.getType();
}
 
Example #23
Source File: SysDictServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
public void saveMain(SysDict sysDict, List<SysDictItem> sysDictItemList) {

    sysDictMapper.insert(sysDict);
    if (sysDictItemList != null) {
        for (SysDictItem entity : sysDictItemList) {
            entity.setDictId(sysDict.getId());
            sysDictItemMapper.insert(entity);
        }
    }
}
 
Example #24
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
	Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
	QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
	Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
	IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
	log.debug("查询当前页:"+pageList.getCurrent());
	log.debug("查询当前页数量:"+pageList.getSize());
	log.debug("查询结果数量:"+pageList.getRecords().size());
	log.debug("数据总数:"+pageList.getTotal());
	result.setSuccess(true);
	result.setResult(pageList);
	return result;
}
 
Example #25
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:删除
 * @param id
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
	Result<SysDict> result = new Result<SysDict>();
	boolean ok = sysDictService.removeById(id);
	if(ok) {
		result.success("删除成功!");
	}else{
		result.error500("删除失败!");
	}
	return result;
}
 
Example #26
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:批量删除
 * @param ids
 * @return
 */
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
	Result<SysDict> result = new Result<SysDict>();
	if(oConvertUtils.isEmpty(ids)) {
		result.error500("参数不识别!");
	}else {
		sysDictService.removeByIds(Arrays.asList(ids.split(",")));
		result.success("删除成功!");
	}
	return result;
}
 
Example #27
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * @功能:刷新缓存
 * @return
 */
@RequestMapping(value = "/refleshCache")
public Result<?> refleshCache() {
	Result<?> result = new Result<SysDict>();
	//清空字典缓存
	Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
	Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
	Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
	Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
	redisTemplate.delete(keys);
	redisTemplate.delete(keys2);
	redisTemplate.delete(keys3);
	redisTemplate.delete(keys4);
	return result;
}
 
Example #28
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDict sysDict,HttpServletRequest request) {
	// Step.1 组装查询条件
	QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
	//Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<SysDictPage> pageList = new ArrayList<SysDictPage>();

	List<SysDict> sysDictList = sysDictService.list(queryWrapper);
	for (SysDict dictMain : sysDictList) {
		SysDictPage vo = new SysDictPage();
		BeanUtils.copyProperties(dictMain, vo);
		// 查询机票
		List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByMainId(dictMain.getId());
		vo.setSysDictItemList(sysDictItemList);
		pageList.add(vo);
	}

	// 导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME, "数据字典");
	// 注解对象Class
	mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
	// 自定义表格参数
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:"+user.getRealname(), "数据字典"));
	// 导出数据列表
	mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
	return mv;
}
 
Example #29
Source File: SysDictController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 查询被删除的列表
 * @return
 */
@RequestMapping(value = "/deleteList", method = RequestMethod.GET)
public Result<List<SysDict>> deleteList() {
	Result<List<SysDict>> result = new Result<List<SysDict>>();
	List<SysDict> list = this.sysDictService.queryDeleteList();
	result.setSuccess(true);
	result.setResult(list);
	return result;
}
 
Example #30
Source File: SysDictTree.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
public SysDictTree(SysDict node) {
   	this.id = node.getId();
	this.key = node.getId();
	this.title = node.getDictName();
	this.dictCode = node.getDictCode();
	this.description = node.getDescription();
	this.delFlag = node.getDelFlag();
	this.type = node.getType();
}