| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<DictData, BaseParam> pageParam = new PageParam<>(baseParam, DictData.class); |
| | | return R.ok().add(dictDataService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(dictDataService.page(pageParam, pageParam.buildWrapper(true)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:list')") |
| | | @PostMapping("/dictData/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(dictDataService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(dictDataService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:list')") |
| | | @PostMapping({"/dictData/many/{ids}", "/dictDatas/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(dictDataService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(dictDataService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:list')") |
| | | @GetMapping("/dictData/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(dictDataService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(dictDataService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:save')") |
| | |
| | | if (!dictDataService.save(dictData)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(dictData); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(dictData)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:update')") |
| | |
| | | if (!dictDataService.updateById(dictData)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(dictData); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(dictData)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:remove')") |
| | |
| | | if (!dictDataService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:list')") |
| | |
| | | dictDataService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getId())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dictData:list')") |
| | | @PostMapping("/dictData/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(dictDataService.list(), DictData.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(dictDataService.list()), DictData.class), response); |
| | | } |
| | | |
| | | } |
| | | |