给接口增加openapi注解

master
李一帆 2024-01-24 17:14:06 +08:00
parent 7fa8ddc11f
commit c13a4ace55
3 changed files with 18 additions and 15 deletions

13
pom.xml
View File

@ -34,19 +34,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-lib</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -8,6 +8,7 @@ import com.gunshi.project.xyt.service.ProtocolInfoService;
import com.gunshi.project.xyt.so.BzProtocolInfoSo; import com.gunshi.project.xyt.so.BzProtocolInfoSo;
import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Insert;
import com.gunshi.project.xyt.validate.markers.Update; import com.gunshi.project.xyt.validate.markers.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -24,7 +25,7 @@ import java.util.Date;
*/ */
@RestController @RestController
@RequestMapping("/protocolInfo") @RequestMapping("/protocolInfo")
@Tag(name = "协议信息") @Tag(name = "系统管理-统一接收-协议管理")
public class BzProtocolInfoController { public class BzProtocolInfoController {
@Autowired @Autowired
private BzProtocolInfoAutoDao dao; private BzProtocolInfoAutoDao dao;
@ -32,6 +33,7 @@ public class BzProtocolInfoController {
@Autowired @Autowired
private ProtocolInfoService service; private ProtocolInfoService service;
@Operation(summary = "新增协议信息")
@PostMapping("/save") @PostMapping("/save")
public R<Boolean> save(@Validated({Insert.class}) @RequestBody BzProtocolInfo entity) { public R<Boolean> save(@Validated({Insert.class}) @RequestBody BzProtocolInfo entity) {
// todo 无论是数据库设置默认值为GETDATE()还是使用注解fill = FieldFill.INSERT都不能自动插入当前时间 // todo 无论是数据库设置默认值为GETDATE()还是使用注解fill = FieldFill.INSERT都不能自动插入当前时间
@ -40,21 +42,25 @@ public class BzProtocolInfoController {
return R.ok(dao.save(entity)); return R.ok(dao.save(entity));
} }
@Operation(summary = "更新协议信息")
@PostMapping("/update") @PostMapping("/update")
public R<Boolean> update(@Validated({Update.class}) @RequestBody BzProtocolInfo entity) { public R<Boolean> update(@Validated({Update.class}) @RequestBody BzProtocolInfo entity) {
return R.ok(dao.updateById(entity)); return R.ok(dao.updateById(entity));
} }
@Operation(summary = "删除协议信息")
@GetMapping("/delete/{id}") @GetMapping("/delete/{id}")
public R<Boolean> delete(@PathVariable String id) { public R<Boolean> delete(@PathVariable String id) {
return R.ok(dao.removeById(id)); return R.ok(dao.removeById(id));
} }
@Operation(summary = "按id查询接口")
@GetMapping("/get/{id}") @GetMapping("/get/{id}")
public R<BzProtocolInfo> getById(@PathVariable("id") String id) { public R<BzProtocolInfo> getById(@PathVariable("id") String id) {
return R.ok(dao.getById(id)); return R.ok(dao.getById(id));
} }
@Operation(summary = "分页查询接口")
@PostMapping("/page") @PostMapping("/page")
public R<Page<BzProtocolInfo>> page(@Validated @RequestBody BzProtocolInfoSo so) { public R<Page<BzProtocolInfo>> page(@Validated @RequestBody BzProtocolInfoSo so) {
return R.ok(service.page(so)); return R.ok(service.page(so));

View File

@ -16,6 +16,7 @@ import com.gunshi.project.xyt.validate.markers.QueryPage;
import com.gunshi.project.xyt.validate.markers.QueryTimeRange; import com.gunshi.project.xyt.validate.markers.QueryTimeRange;
import com.gunshi.project.xyt.validate.markers.Update; import com.gunshi.project.xyt.validate.markers.Update;
import com.gunshi.project.xyt.vo.BzServiceResourceMonitorVo; import com.gunshi.project.xyt.vo.BzServiceResourceMonitorVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -33,7 +34,7 @@ import java.util.Date;
*/ */
@RestController @RestController
@RequestMapping("/serviceResource") @RequestMapping("/serviceResource")
@Tag(name = "服务资源及监控") @Tag(name = "系统管理-数据共享服务-服务资源及监控")
public class BzServiceResourceController { public class BzServiceResourceController {
@Autowired @Autowired
@ -45,6 +46,7 @@ public class BzServiceResourceController {
@Autowired @Autowired
private BzServiceResourceTypeAutoDao serviceTypeDao; private BzServiceResourceTypeAutoDao serviceTypeDao;
@Operation(summary = "新增服务资源")
@PostMapping("/save") @PostMapping("/save")
public R<Boolean> save(@Validated(Insert.class) @RequestBody BzServiceResource entity) { public R<Boolean> save(@Validated(Insert.class) @RequestBody BzServiceResource entity) {
entity.setId(IdWorker.getIdStr()); entity.setId(IdWorker.getIdStr());
@ -53,6 +55,7 @@ public class BzServiceResourceController {
return R.ok(serviceResourceDao.save(entity)); return R.ok(serviceResourceDao.save(entity));
} }
@Operation(summary = "更新服务资源")
@PostMapping("/update") @PostMapping("/update")
public R<Boolean> update(@Validated(Update.class) @RequestBody BzServiceResource entity) { public R<Boolean> update(@Validated(Update.class) @RequestBody BzServiceResource entity) {
BzServiceResource byId = serviceResourceDao.getById(entity.getId()); BzServiceResource byId = serviceResourceDao.getById(entity.getId());
@ -64,11 +67,13 @@ public class BzServiceResourceController {
return R.ok(serviceResourceDao.updateById(entity)); return R.ok(serviceResourceDao.updateById(entity));
} }
@Operation(summary = "删除服务资源")
@GetMapping("/delete/{id}") @GetMapping("/delete/{id}")
public R<Boolean> delete(@PathVariable("id") String id) { public R<Boolean> delete(@PathVariable("id") String id) {
return R.ok(serviceMonitorService.removeById(id)); return R.ok(serviceMonitorService.removeById(id));
} }
@Operation(summary = "分页查询服务资源")
@PostMapping("/page") @PostMapping("/page")
public R<Page<BzServiceResource>> page( public R<Page<BzServiceResource>> page(
@Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody BzServiceResourceSo so @Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody BzServiceResourceSo so
@ -86,6 +91,7 @@ public class BzServiceResourceController {
return R.ok(page); return R.ok(page);
} }
@Operation(summary = "分页查询服务资源监控")
@PostMapping("/monitor/page") @PostMapping("/monitor/page")
public R<Page<BzServiceResourceMonitorVo>> pageMonitorR( public R<Page<BzServiceResourceMonitorVo>> pageMonitorR(
@Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody BzServiceResourceSo so @Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody BzServiceResourceSo so
@ -94,22 +100,26 @@ public class BzServiceResourceController {
return R.ok(page); return R.ok(page);
} }
@Operation(summary = "新增服务资源类型")
@PostMapping("/type/save") @PostMapping("/type/save")
public R<Boolean> saveType(@Validated(Insert.class) @RequestBody BzServiceResourceType entity) { public R<Boolean> saveType(@Validated(Insert.class) @RequestBody BzServiceResourceType entity) {
entity.setId(IdWorker.getIdStr()); entity.setId(IdWorker.getIdStr());
return R.ok(serviceTypeDao.save(entity)); return R.ok(serviceTypeDao.save(entity));
} }
@Operation(summary = "更新服务资源类型")
@PostMapping("/type/update") @PostMapping("/type/update")
public R<Boolean> updateType(@Validated(Update.class) @RequestBody BzServiceResourceType entity) { public R<Boolean> updateType(@Validated(Update.class) @RequestBody BzServiceResourceType entity) {
return R.ok(serviceTypeDao.updateById(entity)); return R.ok(serviceTypeDao.updateById(entity));
} }
@Operation(summary = "删除服务资源类型")
@GetMapping("/type/delete/{id}") @GetMapping("/type/delete/{id}")
public R<Boolean> deleteType(@PathVariable("id") String id) { public R<Boolean> deleteType(@PathVariable("id") String id) {
return R.ok(serviceTypeDao.removeById(id)); return R.ok(serviceTypeDao.removeById(id));
} }
@Operation(summary = "分页查询服务资源类型")
@PostMapping("/type/page") @PostMapping("/type/page")
public R<Page<BzServiceResourceType>> pageType( public R<Page<BzServiceResourceType>> pageType(
@Validated({QueryPage.class}) @RequestBody BzServiceResourceTypeSo so @Validated({QueryPage.class}) @RequestBody BzServiceResourceTypeSo so