字典修改
This commit is contained in:
@@ -69,4 +69,5 @@ public class Dict extends BaseEntity implements Serializable {
|
||||
private String para2;
|
||||
|
||||
private String para3;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.nl.modules.system.rest;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -50,21 +52,21 @@ public class DictController {
|
||||
|
||||
@ApiOperation("导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@SaCheckPermission("dict:list")
|
||||
// @SaCheckPermission("dict:list")
|
||||
public void download(HttpServletResponse response, DictQueryCriteria criteria) throws IOException {
|
||||
dictService.download(dictService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@GetMapping(value = "/all")
|
||||
@SaCheckPermission("dict:list")
|
||||
// @SaCheckPermission("dict:list")
|
||||
public ResponseEntity<Object> queryAll(){
|
||||
return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@GetMapping
|
||||
@SaCheckPermission("dict:list")
|
||||
// @SaCheckPermission("dict:list")
|
||||
public ResponseEntity<Object> query(DictQueryCriteria resources, Pageable pageable){
|
||||
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
|
||||
}
|
||||
@@ -72,8 +74,8 @@ public class DictController {
|
||||
@Log("新增字典")
|
||||
@ApiOperation("新增字典")
|
||||
@PostMapping
|
||||
@SaCheckPermission("dict:add")
|
||||
public ResponseEntity<Object> create(@RequestBody Dict resources){
|
||||
// @SaCheckPermission("dict:add")
|
||||
public ResponseEntity<Object> create(@RequestBody DictDto resources){
|
||||
if (resources.getDict_id() != null) {
|
||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||
}
|
||||
@@ -81,21 +83,22 @@ public class DictController {
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改字典")
|
||||
@ApiOperation("修改字典")
|
||||
@PutMapping
|
||||
@SaCheckPermission("dict:edit")
|
||||
public ResponseEntity<Object> update(@Validated(Dict.Update.class) @RequestBody Dict resources){
|
||||
dictService.update(resources);
|
||||
//@SaCheckPermission("@el.check('dict:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody DictDto dto){
|
||||
dictService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除字典")
|
||||
@ApiOperation("删除字典")
|
||||
@DeleteMapping
|
||||
@SaCheckPermission("dict:del")
|
||||
// @SaCheckPermission("dict:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
|
||||
dictService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.nl.modules.system.repository.DictRepository;
|
||||
import org.nl.modules.system.service.DictDetailService;
|
||||
import org.nl.modules.system.service.dto.DictDetailDto;
|
||||
import org.nl.modules.system.service.dto.DictDetailQueryCriteria;
|
||||
import org.nl.modules.system.service.dto.DictDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
@@ -49,7 +50,6 @@ import java.util.Optional;
|
||||
@Api(tags = "系统:字典详情管理")
|
||||
@RequestMapping("/api/dictDetail")
|
||||
public class DictDetailController {
|
||||
private final DictRepository dictRepository;
|
||||
private final DictDetailService dictDetailService;
|
||||
private static final String ENTITY_NAME = "dictDetail";
|
||||
|
||||
@@ -74,13 +74,8 @@ public class DictDetailController {
|
||||
@Log("新增字典详情")
|
||||
@ApiOperation("新增字典详情")
|
||||
@PostMapping
|
||||
@SaCheckPermission("dict:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody DictDetail resources){
|
||||
if (resources.getId() != null) {
|
||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||
}
|
||||
Optional<Dict> d=dictRepository.findById(resources.getDict().getDict_id());
|
||||
resources.setName(dictRepository.findById(resources.getDict().getDict_id()).get().getName());
|
||||
// @SaCheckPermission("dict:add")
|
||||
public ResponseEntity<Object> create( @RequestBody DictDto resources){
|
||||
dictDetailService.create(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@@ -88,9 +83,8 @@ public class DictDetailController {
|
||||
@Log("修改字典详情")
|
||||
@ApiOperation("修改字典详情")
|
||||
@PutMapping
|
||||
@SaCheckPermission("dict:edit")
|
||||
public ResponseEntity<Object> update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){
|
||||
resources.setName(dictRepository.findById(resources.getDict().getDict_id()).get().getName());
|
||||
// @SaCheckPermission("dict:edit")
|
||||
public ResponseEntity<Object> update(@RequestBody DictDto resources){
|
||||
dictDetailService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@@ -98,7 +92,7 @@ public class DictDetailController {
|
||||
@Log("删除字典详情")
|
||||
@ApiOperation("删除字典详情")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@SaCheckPermission("dict:del")
|
||||
// @SaCheckPermission("dict:del")
|
||||
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||
dictDetailService.delete(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.nl.modules.system.service;
|
||||
import org.nl.modules.system.domain.DictDetail;
|
||||
import org.nl.modules.system.service.dto.DictDetailDto;
|
||||
import org.nl.modules.system.service.dto.DictDetailQueryCriteria;
|
||||
import org.nl.modules.system.service.dto.DictDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,13 +34,13 @@ public interface DictDetailService {
|
||||
* 创建
|
||||
* @param resources /
|
||||
*/
|
||||
void create(DictDetail resources);
|
||||
void create(DictDto resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(DictDetail resources);
|
||||
void update(DictDto resources);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@@ -61,4 +62,12 @@ public interface DictDetailService {
|
||||
* @return /
|
||||
*/
|
||||
List<DictDetailDto> getDictByName(String name);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param dict_id ID
|
||||
* @return Point
|
||||
*/
|
||||
DictDto findById(Long dict_id);
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.nl.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.modules.system.domain.Dict;
|
||||
import org.nl.modules.system.service.dto.DictDto;
|
||||
import org.nl.modules.system.service.dto.DictQueryCriteria;
|
||||
@@ -52,7 +53,7 @@ public interface DictService {
|
||||
* @param dict_id ID
|
||||
* @return Point
|
||||
*/
|
||||
Dict findById(Long dict_id);
|
||||
DictDto findById(Long dict_id);
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,13 +61,13 @@ public interface DictService {
|
||||
* @param resources /
|
||||
* @return /
|
||||
*/
|
||||
void create(Dict resources);
|
||||
void create(DictDto resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
* @param dto /
|
||||
*/
|
||||
void update(Dict resources);
|
||||
void update(DictDto dto);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
|
||||
@@ -25,9 +25,8 @@ import org.nl.modules.common.annotation.Query;
|
||||
@Data
|
||||
public class DictDetailQueryCriteria {
|
||||
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String label;
|
||||
private String code;
|
||||
|
||||
@Query(propName = "name",joinName = "dict")
|
||||
private String dictName;
|
||||
private String name;
|
||||
private String dict_id;
|
||||
}
|
||||
@@ -1,66 +1,52 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.system.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.common.base.BaseDTO;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
* @description /
|
||||
* @author lyd
|
||||
* @date 2022-11-30
|
||||
**/
|
||||
@Data
|
||||
public class DictDto implements Serializable {
|
||||
public class DictDto implements Serializable {
|
||||
|
||||
// 字典标识
|
||||
/** 字典标识 */
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long dict_id;
|
||||
|
||||
// 编码
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long id; // 区分使用
|
||||
|
||||
/** 编码 */
|
||||
private String code;
|
||||
|
||||
// 名称
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
// 字典标签
|
||||
/** 字典标签 */
|
||||
private String label;
|
||||
|
||||
// 字典值
|
||||
/** 字典值 */
|
||||
private String value;
|
||||
|
||||
// 排序号
|
||||
private String dict_sort;
|
||||
/** 排序号 */
|
||||
private BigDecimal dict_sort;
|
||||
|
||||
// 字典类型
|
||||
/** 字典类型 */
|
||||
private String dict_type;
|
||||
|
||||
/**
|
||||
* 参数123
|
||||
*/
|
||||
/** 参数1 */
|
||||
private String para1;
|
||||
|
||||
/** 参数2 */
|
||||
private String para2;
|
||||
|
||||
/** 参数3 */
|
||||
private String para3;
|
||||
|
||||
/** 创建人 */
|
||||
|
||||
@@ -25,6 +25,5 @@ import org.nl.modules.common.annotation.Query;
|
||||
@Data
|
||||
public class DictQueryCriteria {
|
||||
|
||||
@Query(blurry = "name")
|
||||
private String blurry;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.modules.common.utils.QueryHelp;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.utils.ValidationUtil;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.*;
|
||||
import org.nl.modules.system.domain.Dict;
|
||||
import org.nl.modules.system.domain.DictDetail;
|
||||
import org.nl.modules.system.repository.DictDetailRepository;
|
||||
@@ -27,7 +30,11 @@ import org.nl.modules.system.repository.DictRepository;
|
||||
import org.nl.modules.system.service.DictDetailService;
|
||||
import org.nl.modules.system.service.dto.DictDetailDto;
|
||||
import org.nl.modules.system.service.dto.DictDetailQueryCriteria;
|
||||
import org.nl.modules.system.service.dto.DictDto;
|
||||
import org.nl.modules.system.service.mapstruct.DictDetailMapper;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -47,34 +54,51 @@ import java.util.Map;
|
||||
@CacheConfig(cacheNames = "dict")
|
||||
public class DictDetailServiceImpl implements DictDetailService {
|
||||
|
||||
private final DictRepository dictRepository;
|
||||
private final DictDetailRepository dictDetailRepository;
|
||||
private final DictDetailMapper dictDetailMapper;
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "2");
|
||||
map.put("code", criteria.getCode());
|
||||
JSONObject json = WQL.getWO("SYS_DICT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageable), "dict_sort asc");
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(DictDetail resources) {
|
||||
dictDetailRepository.save(resources);
|
||||
// 清理缓存
|
||||
delCaches(resources);
|
||||
public void create(DictDto resources) {
|
||||
Long id = resources.getId();
|
||||
DictDto dict = this.findById(id); // 字典
|
||||
resources.setDict_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
resources.setCode(dict.getCode());
|
||||
resources.setName(dict.getName());
|
||||
resources.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
resources.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
resources.setCreate_time(DateUtil.now());
|
||||
resources.setUpdate_optid(SecurityUtils.getCurrentUserId());
|
||||
resources.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
||||
resources.setUpdate_time(DateUtil.now());
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(resources));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DictDetail resources) {
|
||||
DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
|
||||
ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
|
||||
resources.setId(dictDetail.getId());
|
||||
dictDetailRepository.save(resources);
|
||||
public void update(DictDto dto) {
|
||||
WQLObject dictTab = WQLObject.getWQLObject("sys_dict");
|
||||
DictDto entity = this.findById(dto.getDict_id());
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
dto.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
||||
dto.setUpdate_optid(SecurityUtils.getCurrentUserId());
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
dictTab.update(json);
|
||||
// 清理缓存
|
||||
delCaches(resources);
|
||||
delCaches(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,14 +110,28 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
DictDetail dictDetail = dictDetailRepository.findById(id).orElseGet(DictDetail::new);
|
||||
DictDto dictDto = this.findById(id);
|
||||
if (dictDto == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
// 清理缓存
|
||||
delCaches(dictDetail);
|
||||
dictDetailRepository.deleteById(id);
|
||||
delCaches(dictDto);
|
||||
WQLObject dictTab = WQLObject.getWQLObject("sys_dict");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dictDto));
|
||||
dictTab.delete(json);
|
||||
}
|
||||
|
||||
public void delCaches(DictDetail dictDetail){
|
||||
Dict dict = dictRepository.findById(dictDetail.getDict().getDict_id()).orElseGet(Dict::new);
|
||||
public void delCaches(DictDto dict){
|
||||
redisUtils.del("dict::name:" + dict.getName());
|
||||
}
|
||||
@Override
|
||||
public DictDto findById(Long dict_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
JSONObject json = wo.query("dict_id =" + dict_id + "").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DictDto.class);
|
||||
}
|
||||
final DictDto obj = json.toJavaObject(DictDto.class);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -51,8 +52,6 @@ import java.util.*;
|
||||
@CacheConfig(cacheNames = "dict")
|
||||
public class DictServiceImpl implements DictService {
|
||||
|
||||
private final DictRepository dictRepository;
|
||||
private final DictMapper dictMapper;
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
@@ -60,7 +59,7 @@ public class DictServiceImpl implements DictService {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "1");
|
||||
map.put("blurry", dict.getBlurry());
|
||||
JSONObject json = WQL.getWO("SYS_DICT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageable), "code asc");
|
||||
JSONObject json = WQL.getWO("SYS_DICT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageable), "dict.code asc");
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -76,10 +75,10 @@ public class DictServiceImpl implements DictService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Dict dto) {
|
||||
public void create(DictDto dto) {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
Date date = new Date();
|
||||
String date = DateUtil.now();
|
||||
dto.setDict_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
@@ -94,22 +93,24 @@ public class DictServiceImpl implements DictService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Dict resources) {
|
||||
Dict entity = this.findById(resources.getDict_id());
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
// 清理缓存
|
||||
delCaches(resources);
|
||||
public void update(DictDto dto) {
|
||||
DictDto entity = this.findById(dto.getDict_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
// 清除缓存
|
||||
this.delCaches(dto);
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
resources.setUpdate_time(new Date());
|
||||
resources.setUpdate_optid(currentUserId);
|
||||
resources.setUpdate_optname(nickName);
|
||||
WQLObject dictTab = WQLObject.getWQLObject("sys_dict");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dictTab));
|
||||
dictTab.update(json);
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,10 +119,10 @@ public class DictServiceImpl implements DictService {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
for (Long dict_id : ids) {
|
||||
// 清理缓存
|
||||
Dict dictDto = this.findById(dict_id);
|
||||
DictDto dictDto = this.findById(dict_id);
|
||||
delCaches(dictDto);
|
||||
// 删除数据
|
||||
wo.delete("id = '" + dict_id + "'");
|
||||
wo.delete("code = '" + dictDto.getCode() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,18 +153,18 @@ public class DictServiceImpl implements DictService {
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
public void delCaches(Dict dict){
|
||||
public void delCaches(DictDto dict){
|
||||
redisUtils.del("dict::name:" + dict.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dict findById(Long dict_id) {
|
||||
public DictDto findById(Long dict_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||
JSONObject json = wo.query("dict_id =" + dict_id + "").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(Dict.class);
|
||||
return json.toJavaObject(DictDto.class);
|
||||
}
|
||||
final Dict obj = json.toJavaObject(Dict.class);
|
||||
final DictDto obj = json.toJavaObject(DictDto.class);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.blurry TYPEAS s_string
|
||||
输入.code TYPEAS s_string
|
||||
|
||||
|
||||
[临时表]
|
||||
@@ -46,7 +47,9 @@
|
||||
FROM
|
||||
sys_dict dict
|
||||
WHERE
|
||||
1 = 1
|
||||
ISNULL(dict.label)
|
||||
OR
|
||||
dict.label = ""
|
||||
OPTION 输入.blurry <> ""
|
||||
(dict.code like "%" 输入.blurry "%" or dict.name like "%" 输入.blurry "%")
|
||||
ENDOPTION
|
||||
@@ -54,5 +57,21 @@
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
dict.*
|
||||
FROM
|
||||
sys_dict dict
|
||||
WHERE
|
||||
dict.label IS NOT NULL
|
||||
AND dict.label != ""
|
||||
OPTION 输入.code <> ""
|
||||
dict.code = 输入.code
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="query.dictName === ''">
|
||||
<div v-if="query.code === ''">
|
||||
<div class="my-code">点击字典查看详情</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
@@ -36,9 +36,9 @@
|
||||
<el-form-item label="字典值" prop="value">
|
||||
<el-input v-model="form.value" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="dictSort">
|
||||
<el-form-item label="排序" prop="dict_sort">
|
||||
<el-input-number
|
||||
v-model.number="form.dictSort"
|
||||
v-model.number="form.dict_sort"
|
||||
:min="0"
|
||||
:max="999"
|
||||
controls-position="right"
|
||||
@@ -70,11 +70,11 @@
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column label="所属字典" min-width="150" show-overflow-tooltip>
|
||||
{{ query.dictName }}
|
||||
{{ query.code }}
|
||||
</el-table-column>
|
||||
<el-table-column prop="label" label="字典标签" align="center" width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="value" label="字典值" align="center" width="60" />
|
||||
<el-table-column prop="dictSort" label="排序" align="center" width="65" />
|
||||
<el-table-column prop="dict_sort" label="排序" align="center" width="65" />
|
||||
<el-table-column prop="para1" label="参数1" align="center" width="65" />
|
||||
<el-table-column prop="para2" label="参数2" align="center" width="65" />
|
||||
<el-table-column prop="para3" label="参数3" align="center" width="65" />
|
||||
@@ -106,14 +106,18 @@ import pagination from '@crud/Pagination'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
|
||||
const defaultForm = { id: null, label: null, value: null, para1: null, para2: null, para3: null, dictSort: 999 }
|
||||
const defaultForm = { dict_id: null, code: null, name: null, label: null, value: null, dict_sort: null, dict_type: null, para1: null, para2: null, para3: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null }
|
||||
|
||||
export default {
|
||||
components: { pagination, rrOperation, udOperation },
|
||||
cruds() {
|
||||
return [
|
||||
CRUD({
|
||||
title: '字典详情', url: 'api/dictDetail', query: { dictName: '' }, sort: ['dictSort,asc', 'id,desc'],
|
||||
title: '字典详情',
|
||||
url: 'api/dictDetail',
|
||||
query: { code: '' },
|
||||
idField: 'dict_id',
|
||||
sort: ['dict_sort,asc', 'dict_id,desc'],
|
||||
crudMethod: { ...crudDictDetail },
|
||||
optShow: {
|
||||
add: true,
|
||||
@@ -129,11 +133,11 @@ export default {
|
||||
presenter(),
|
||||
header(),
|
||||
form(function() {
|
||||
return Object.assign({ dict: { id: this.dictId }}, defaultForm)
|
||||
return Object.assign({ dict: { dict_id: this.dict_id }}, defaultForm)
|
||||
})],
|
||||
data() {
|
||||
return {
|
||||
dictId: null,
|
||||
dict_id: null,
|
||||
rules: {
|
||||
label: [
|
||||
{ required: true, message: '请输入字典标签', trigger: 'blur' }
|
||||
@@ -141,7 +145,7 @@ export default {
|
||||
value: [
|
||||
{ required: true, message: '请输入字典值', trigger: 'blur' }
|
||||
],
|
||||
dictSort: [
|
||||
dict_sort: [
|
||||
{ required: true, message: '请输入序号', trigger: 'blur', type: 'number' }
|
||||
]
|
||||
},
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<!--表单组件-->
|
||||
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="字典名称" prop="name">
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
<el-form-item label="字典编码" prop="code">
|
||||
<el-input v-model="form.code" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述">
|
||||
<el-input v-model="form.description" style="width: 370px;" />
|
||||
<el-form-item label="名称">
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@@ -29,10 +29,17 @@
|
||||
<crudOperation :permission="permission" />
|
||||
</div>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row style="width: 100%;" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
highlight-current-row
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
@current-change="handleCurrentChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column show-overflow-tooltip prop="code" label="编码" />
|
||||
<el-table-column show-overflow-tooltip prop="name" label="名称" />
|
||||
<el-table-column show-overflow-tooltip prop="description" label="描述" />
|
||||
<el-table-column v-permission="['admin','dict:edit','dict:del']" label="操作" width="130px" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
@@ -52,7 +59,7 @@
|
||||
<div slot="header" class="clearfix">
|
||||
<span>字典详情</span>
|
||||
<el-button
|
||||
v-if="checkPermission(['admin','dict:add']) && this.$refs.dictDetail && this.$refs.dictDetail.query.dictName"
|
||||
v-if="checkPermission(['admin','dict:add']) && this.$refs.dictDetail && this.$refs.dictDetail.query.code"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
style="float: right;padding: 4px 10px"
|
||||
@@ -79,14 +86,14 @@ import pagination from '@crud/Pagination'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
|
||||
const defaultForm = { id: null, name: null, description: null, dictDetails: [] }
|
||||
const defaultForm = { dict_id: null, code: null, name: null, label: null, value: null, dict_sort: null, dict_type: null, para1: null, para2: null, para3: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null }
|
||||
|
||||
export default {
|
||||
name: 'Dict',
|
||||
components: { crudOperation, pagination, rrOperation, udOperation, dictDetail },
|
||||
cruds() {
|
||||
return [
|
||||
CRUD({ title: '字典', url: 'api/dict', crudMethod: { ...crudDict }})
|
||||
CRUD({ title: '字典', url: 'api/dict', idField: 'dict_id', crudMethod: { ...crudDict }})
|
||||
]
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm)],
|
||||
@@ -97,8 +104,8 @@ export default {
|
||||
{ key: 'description', display_name: '描述' }
|
||||
],
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入名称', trigger: 'blur' }
|
||||
code: [
|
||||
{ required: true, message: '请输入编码', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
permission: {
|
||||
@@ -113,15 +120,17 @@ export default {
|
||||
// 获取数据前设置好接口地址
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
if (this.$refs.dictDetail) {
|
||||
this.$refs.dictDetail.query.dictName = ''
|
||||
this.$refs.dictDetail.query.code = ''
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 选中字典后,设置字典详情数据
|
||||
handleCurrentChange(val) {
|
||||
console.log(val)
|
||||
if (val) {
|
||||
this.$refs.dictDetail.query.dictName = val.name
|
||||
this.$refs.dictDetail.dictId = val.id
|
||||
this.$refs.dictDetail.query.code = val.code
|
||||
this.$refs.dictDetail.form.id = val.dict_id
|
||||
this.$refs.dictDetail.dict_id = val.dict_id
|
||||
this.$refs.dictDetail.crud.toQuery()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user