TenantController.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package com.fjhx.controller;
  18. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  19. import com.fjhx.base.Condition;
  20. import com.fjhx.params.TenantVo;
  21. import com.fjhx.service.ITenantService;
  22. import lombok.AllArgsConstructor;
  23. import org.springblade.core.boot.ctrl.BladeController;
  24. import org.springblade.core.secure.annotation.PreAuth;
  25. import org.springblade.core.tenant.annotation.NonDS;
  26. import org.springblade.core.tool.api.R;
  27. import org.springblade.core.tool.constant.RoleConstant;
  28. import org.springblade.system.entity.Tenant;
  29. import org.springframework.web.bind.annotation.PostMapping;
  30. import org.springframework.web.bind.annotation.RequestBody;
  31. import org.springframework.web.bind.annotation.RequestMapping;
  32. import org.springframework.web.bind.annotation.RestController;
  33. import javax.validation.Valid;
  34. import java.util.Map;
  35. /**
  36. * 控制器
  37. *
  38. * @author Chill
  39. */
  40. @NonDS
  41. @RestController
  42. @AllArgsConstructor
  43. @RequestMapping("/tenant")
  44. public class TenantController extends BladeController {
  45. private final ITenantService tenantService;
  46. /**
  47. * 新增或修改
  48. */
  49. @PostMapping("/submit")
  50. @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
  51. public R submit(@Valid @RequestBody Tenant tenant) {
  52. tenantService.submitTenant(tenant);
  53. return R.success();
  54. }
  55. /**
  56. * 分页
  57. */
  58. @PostMapping("/page")
  59. @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
  60. public R page(@RequestBody Condition condition) {
  61. Page<Map<String, Object>> page = tenantService.getPage(condition);
  62. return R.success(page);
  63. }
  64. /**
  65. * 第三方创建租户
  66. */
  67. @PostMapping("/thirdPartyCreate")
  68. public R thirdPartyCreate(@RequestBody Condition condition) {
  69. TenantVo token = tenantService.thirdPartyCreate(condition.getStr("token"));
  70. return R.success(token);
  71. }
  72. }