Merge remote-tracking branch 'origin/jdk17' into jdk17-dev

# Conflicts:
#	pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/controller/SysDictController.java
This commit is contained in:
冷冷 2024-07-15 23:19:01 +08:00
commit 212e1e3633
2 changed files with 196 additions and 164 deletions

View File

@ -3,6 +3,7 @@ package com.pig4cloud.pig.admin.api.feign;
import com.pig4cloud.pig.admin.api.entity.SysDictItem;
import com.pig4cloud.pig.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.feign.annotation.NoToken;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -23,7 +24,8 @@ public interface RemoteDictService {
* @param type 字典类型
* @return 同类型字典
*/
@GetMapping("/dict/type/{type}")
@NoToken
@GetMapping("/dict/remote/type/{type}")
R<List<SysDictItem>> getDictByType(@PathVariable("type") String type);
}

View File

@ -30,7 +30,7 @@ import com.pig4cloud.pig.admin.service.SysDictService;
import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import com.pig4cloud.pig.common.security.annotation.HasPermission;
import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -40,6 +40,7 @@ import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -65,6 +66,7 @@ public class SysDictController {
/**
* 通过ID查询字典信息
*
* @param id ID
* @return 字典信息
*/
@ -75,6 +77,7 @@ public class SysDictController {
/**
* 查询字典信息
*
* @param query 查询信息
* @return 字典信息
*/
@ -85,6 +88,7 @@ public class SysDictController {
/**
* 分页查询字典信息
*
* @param page 分页对象
* @return 分页对象
*/
@ -96,25 +100,16 @@ public class SysDictController {
.like(StrUtil.isNotBlank(sysDict.getDictType()), SysDict::getDictType, sysDict.getDictType())));
}
/**
* 通过字典类型查找字典
* @param type 类型
* @return 同类型字典
*/
@GetMapping("/type/{type}")
@Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.isEmpty()")
public R<List<SysDictItem>> getDictByType(@PathVariable String type) {
return R.ok(sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getDictType, type)));
}
/**
* 添加字典
*
* @param sysDict 字典信息
* @return successfalse
*/
@SysLog("添加字典")
@PostMapping
@HasPermission("sys_dict_add")
@PreAuthorize("@pms.hasPermission('sys_dict_add')")
public R save(@Valid @RequestBody SysDict sysDict) {
sysDictService.save(sysDict);
return R.ok(sysDict);
@ -122,12 +117,13 @@ public class SysDictController {
/**
* 删除字典并且清除字典缓存
*
* @param ids ID
* @return R
*/
@SysLog("删除字典")
@DeleteMapping
@HasPermission("sys_dict_del")
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysDictService.removeDictByIds(ids));
@ -135,18 +131,20 @@ public class SysDictController {
/**
* 修改字典
*
* @param sysDict 字典信息
* @return success/false
*/
@PutMapping
@SysLog("修改字典")
@HasPermission("sys_dict_edit")
@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
public R updateById(@Valid @RequestBody SysDict sysDict) {
return sysDictService.updateDict(sysDict);
}
/**
* 分页查询
*
* @param name 名称或者字典项
* @return
*/
@ -160,6 +158,7 @@ public class SysDictController {
/**
* 分页查询
*
* @param page 分页对象
* @param sysDictItem 字典项
* @return
@ -171,6 +170,7 @@ public class SysDictController {
/**
* 通过id查询字典项
*
* @param id id
* @return R
*/
@ -181,6 +181,7 @@ public class SysDictController {
/**
* 查询字典项详情
*
* @param query 查询条件
* @return R
*/
@ -191,6 +192,7 @@ public class SysDictController {
/**
* 新增字典项
*
* @param sysDictItem 字典项
* @return R
*/
@ -203,6 +205,7 @@ public class SysDictController {
/**
* 修改字典项
*
* @param sysDictItem 字典项
* @return R
*/
@ -214,6 +217,7 @@ public class SysDictController {
/**
* 通过id删除字典项
*
* @param id id
* @return R
*/
@ -225,6 +229,7 @@ public class SysDictController {
/**
* 同步缓存字典
*
* @return R
*/
@SysLog("同步字典")
@ -239,4 +244,29 @@ public class SysDictController {
return sysDictItemService.list(Wrappers.query(sysDictItem));
}
/**
* 通过字典类型查找字典
*
* @param type 类型
* @return 同类型字典
*/
@GetMapping("/type/{type}")
@Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.isEmpty()")
public R<List<SysDictItem>> getDictByType(@PathVariable String type) {
return R.ok(sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getDictType, type)));
}
/**
* 通过字典类型查找字典 (针对feign调用)
* TODO: 兼容性方案代码重复
* @param type 类型
* @return 同类型字典
*/
@Inner
@GetMapping("/remote/type/{type}")
@Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.isEmpty()")
public R<List<SysDictItem>> getRemoteDictByType(@PathVariable String type) {
return R.ok(sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getDictType, type)));
}
}