mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
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:
commit
212e1e3633
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
@ -59,184 +60,213 @@ import java.util.List;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SysDictController {
|
||||
|
||||
private final SysDictService sysDictService;
|
||||
private final SysDictService sysDictService;
|
||||
|
||||
private final SysDictItemService sysDictItemService;
|
||||
private final SysDictItemService sysDictItemService;
|
||||
|
||||
/**
|
||||
* 通过ID查询字典信息
|
||||
* @param id ID
|
||||
* @return 字典信息
|
||||
*/
|
||||
@GetMapping("/details/{id}")
|
||||
public R getById(@PathVariable Long id) {
|
||||
return R.ok(sysDictService.getById(id));
|
||||
}
|
||||
/**
|
||||
* 通过ID查询字典信息
|
||||
*
|
||||
* @param id ID
|
||||
* @return 字典信息
|
||||
*/
|
||||
@GetMapping("/details/{id}")
|
||||
public R getById(@PathVariable Long id) {
|
||||
return R.ok(sysDictService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典信息
|
||||
* @param query 查询信息
|
||||
* @return 字典信息
|
||||
*/
|
||||
@GetMapping("/details")
|
||||
public R getDetails(@ParameterObject SysDict query) {
|
||||
return R.ok(sysDictService.getOne(Wrappers.query(query), false));
|
||||
}
|
||||
/**
|
||||
* 查询字典信息
|
||||
*
|
||||
* @param query 查询信息
|
||||
* @return 字典信息
|
||||
*/
|
||||
@GetMapping("/details")
|
||||
public R getDetails(@ParameterObject SysDict query) {
|
||||
return R.ok(sysDictService.getOne(Wrappers.query(query), false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询字典信息
|
||||
* @param page 分页对象
|
||||
* @return 分页对象
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R<IPage> getDictPage(@ParameterObject Page page, @ParameterObject SysDict sysDict) {
|
||||
return R.ok(sysDictService.page(page,
|
||||
Wrappers.<SysDict>lambdaQuery()
|
||||
.eq(StrUtil.isNotBlank(sysDict.getSystemFlag()), SysDict::getSystemFlag, sysDict.getSystemFlag())
|
||||
.like(StrUtil.isNotBlank(sysDict.getDictType()), SysDict::getDictType, sysDict.getDictType())));
|
||||
}
|
||||
/**
|
||||
* 分页查询字典信息
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @return 分页对象
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R<IPage> getDictPage(@ParameterObject Page page, @ParameterObject SysDict sysDict) {
|
||||
return R.ok(sysDictService.page(page,
|
||||
Wrappers.<SysDict>lambdaQuery()
|
||||
.eq(StrUtil.isNotBlank(sysDict.getSystemFlag()), SysDict::getSystemFlag, sysDict.getSystemFlag())
|
||||
.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 success、false
|
||||
*/
|
||||
@SysLog("添加字典")
|
||||
@PostMapping
|
||||
@HasPermission("sys_dict_add")
|
||||
public R save(@Valid @RequestBody SysDict sysDict) {
|
||||
sysDictService.save(sysDict);
|
||||
return R.ok(sysDict);
|
||||
}
|
||||
/**
|
||||
* 添加字典
|
||||
*
|
||||
* @param sysDict 字典信息
|
||||
* @return success、false
|
||||
*/
|
||||
@SysLog("添加字典")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_dict_add')")
|
||||
public R save(@Valid @RequestBody SysDict sysDict) {
|
||||
sysDictService.save(sysDict);
|
||||
return R.ok(sysDict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典,并且清除字典缓存
|
||||
* @param ids ID
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除字典")
|
||||
@DeleteMapping
|
||||
@HasPermission("sys_dict_del")
|
||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(sysDictService.removeDictByIds(ids));
|
||||
}
|
||||
/**
|
||||
* 删除字典,并且清除字典缓存
|
||||
*
|
||||
* @param ids ID
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除字典")
|
||||
@DeleteMapping
|
||||
@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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典
|
||||
* @param sysDict 字典信息
|
||||
* @return success/false
|
||||
*/
|
||||
@PutMapping
|
||||
@SysLog("修改字典")
|
||||
@HasPermission("sys_dict_edit")
|
||||
public R updateById(@Valid @RequestBody SysDict sysDict) {
|
||||
return sysDictService.updateDict(sysDict);
|
||||
}
|
||||
/**
|
||||
* 修改字典
|
||||
*
|
||||
* @param sysDict 字典信息
|
||||
* @return success/false
|
||||
*/
|
||||
@PutMapping
|
||||
@SysLog("修改字典")
|
||||
@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
|
||||
public R updateById(@Valid @RequestBody SysDict sysDict) {
|
||||
return sysDictService.updateDict(sysDict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param name 名称或者字典项
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R getDictList(String name) {
|
||||
return R.ok(sysDictService.list(Wrappers.<SysDict>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(name), SysDict::getDictType, name)
|
||||
.or()
|
||||
.like(StrUtil.isNotBlank(name), SysDict::getDescription, name)));
|
||||
}
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param name 名称或者字典项
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R getDictList(String name) {
|
||||
return R.ok(sysDictService.list(Wrappers.<SysDict>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(name), SysDict::getDictType, name)
|
||||
.or()
|
||||
.like(StrUtil.isNotBlank(name), SysDict::getDescription, name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param sysDictItem 字典项
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/item/page")
|
||||
public R getSysDictItemPage(Page page, SysDictItem sysDictItem) {
|
||||
return R.ok(sysDictItemService.page(page, Wrappers.query(sysDictItem)));
|
||||
}
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param sysDictItem 字典项
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/item/page")
|
||||
public R getSysDictItemPage(Page page, SysDictItem sysDictItem) {
|
||||
return R.ok(sysDictItemService.page(page, Wrappers.query(sysDictItem)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询字典项
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/item/details/{id}")
|
||||
public R getDictItemById(@PathVariable("id") Long id) {
|
||||
return R.ok(sysDictItemService.getById(id));
|
||||
}
|
||||
/**
|
||||
* 通过id查询字典项
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/item/details/{id}")
|
||||
public R getDictItemById(@PathVariable("id") Long id) {
|
||||
return R.ok(sysDictItemService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典项详情
|
||||
* @param query 查询条件
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/item/details")
|
||||
public R getDictItemDetails(SysDictItem query) {
|
||||
return R.ok(sysDictItemService.getOne(Wrappers.query(query), false));
|
||||
}
|
||||
/**
|
||||
* 查询字典项详情
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/item/details")
|
||||
public R getDictItemDetails(SysDictItem query) {
|
||||
return R.ok(sysDictItemService.getOne(Wrappers.query(query), false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典项
|
||||
* @param sysDictItem 字典项
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增字典项")
|
||||
@PostMapping("/item")
|
||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||
public R save(@RequestBody SysDictItem sysDictItem) {
|
||||
return R.ok(sysDictItemService.save(sysDictItem));
|
||||
}
|
||||
/**
|
||||
* 新增字典项
|
||||
*
|
||||
* @param sysDictItem 字典项
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增字典项")
|
||||
@PostMapping("/item")
|
||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||
public R save(@RequestBody SysDictItem sysDictItem) {
|
||||
return R.ok(sysDictItemService.save(sysDictItem));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典项
|
||||
* @param sysDictItem 字典项
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改字典项")
|
||||
@PutMapping("/item")
|
||||
public R updateById(@RequestBody SysDictItem sysDictItem) {
|
||||
return sysDictItemService.updateDictItem(sysDictItem);
|
||||
}
|
||||
/**
|
||||
* 修改字典项
|
||||
*
|
||||
* @param sysDictItem 字典项
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改字典项")
|
||||
@PutMapping("/item")
|
||||
public R updateById(@RequestBody SysDictItem sysDictItem) {
|
||||
return sysDictItemService.updateDictItem(sysDictItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除字典项
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除字典项")
|
||||
@DeleteMapping("/item/{id}")
|
||||
public R removeDictItemById(@PathVariable Long id) {
|
||||
return sysDictItemService.removeDictItem(id);
|
||||
}
|
||||
/**
|
||||
* 通过id删除字典项
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除字典项")
|
||||
@DeleteMapping("/item/{id}")
|
||||
public R removeDictItemById(@PathVariable Long id) {
|
||||
return sysDictItemService.removeDictItem(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步缓存字典
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("同步字典")
|
||||
@PutMapping("/sync")
|
||||
public R sync() {
|
||||
return sysDictService.syncDictCache();
|
||||
}
|
||||
/**
|
||||
* 同步缓存字典
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("同步字典")
|
||||
@PutMapping("/sync")
|
||||
public R sync() {
|
||||
return sysDictService.syncDictCache();
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<SysDictItem> export(SysDictItem sysDictItem) {
|
||||
return sysDictItemService.list(Wrappers.query(sysDictItem));
|
||||
}
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<SysDictItem> export(SysDictItem sysDictItem) {
|
||||
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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user