| | |
| | | import com.vincent.rsf.server.system.entity.Fields; |
| | | import com.vincent.rsf.server.system.service.FieldsService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.*; |
| | | |
| | | @Api(tags = "动态扩展字段") |
| | | @RestController |
| | | public class FieldsController extends BaseController { |
| | | |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Fields, BaseParam> pageParam = new PageParam<>(baseParam, Fields.class); |
| | | return R.ok().add(fieldsService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(fieldsService.page(pageParam, pageParam.buildWrapper(true)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:list')") |
| | | @PostMapping("/fields/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(fieldsService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(fieldsService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:list')") |
| | | @GetMapping("/fields/enable/list") |
| | | @ApiOperation("获取已开启扩展字段") |
| | | public R getEnableList() { |
| | | return R.ok(fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getFlagEnable, 1))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:list')") |
| | | @PostMapping({"/fields/many/{ids}", "/fieldss/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(fieldsService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(fieldsService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:list')") |
| | | @GetMapping("/fields/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(fieldsService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(fieldsService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:save')") |
| | |
| | | if (!fieldsService.save(fields)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(fields); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(fields)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:update')") |
| | |
| | | if (!fieldsService.updateById(fields)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(fields); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(fields)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:fields:remove')") |
| | |
| | | if (!fieldsService.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:fields:list')") |
| | |
| | | fieldsService.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:fields:list')") |
| | | @PostMapping("/fields/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(fieldsService.list(), Fields.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(fieldsService.list()), Fields.class), response); |
| | | } |
| | | |
| | | } |
| | | |