| | |
| | | import com.terra.system.entity.sys.UserEntity; |
| | | import com.terra.system.helper.StringHelper; |
| | | import com.terra.system.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import javax.annotation.Resource; |
| | | |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | |
| | | * @author WWW |
| | | * @date 2022-09-28 |
| | | */ |
| | | @Api(tags = "运维管理\\令牌管理") |
| | | @Tag(name = "运维管理\\令牌管理") |
| | | @RestController |
| | | @RequestMapping("/token") |
| | | public class TokenController extends BaseController { |
| | |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "令牌", dataType = "String", paramType = "query", example = "ec101de8-1403-4d8f-ad13-edab8358399b"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "0"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | @Operation(summary = "分页查询并返回记录数") |
| | | @Parameters({ |
| | | @Parameter(name = "name", description = "令牌", in = ParameterIn.QUERY, example = "ec101de8-1403-4d8f-ad13-edab8358399b"), |
| | | @Parameter(name = "type", description = "类型", in = ParameterIn.QUERY, example = "0"), |
| | | @Parameter(name = "pageSize", description = "每页条数", in = ParameterIn.QUERY, example = "10"), |
| | | @Parameter(name = "pageIndex", description = "分页数(从1开始)", in = ParameterIn.QUERY, example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageAndCount") |
| | | public ResponseMsg<List<TokenEntity>> selectByPageAndCount(String name, Integer type, Integer pageSize, Integer pageIndex) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "TokenEntity", paramType = "body", example = "") |
| | | @Operation(summary = "插入一条") |
| | | @Parameters({ |
| | | @Parameter(name = "entity", description = "实体类", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertToken", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertToken(@RequestBody TokenEntity entity, HttpServletRequest req) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "创建新令牌") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "type", value = "令牌类别:0-临时,1-固定", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "min", value = "分钟数:默认1个月", dataType = "Integer", paramType = "query", example = "43200") |
| | | @Operation(summary = "创建新令牌") |
| | | @Parameters({ |
| | | @Parameter(name = "type", description = "令牌类别:0-临时,1-固定", in = ParameterIn.QUERY, example = "1"), |
| | | @Parameter(name = "min", description = "分钟数:默认1个月", in = ParameterIn.QUERY, example = "43200") |
| | | }) |
| | | @GetMapping(value = "/insertNewToken") |
| | | public ResponseMsg<Object> insertNewToken(Integer type, Integer min, HttpServletRequest req) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "删除一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | @Operation(summary = "删除一条") |
| | | @Parameters({ |
| | | @Parameter(name = "id", description = "ID", in = ParameterIn.QUERY, example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteToken") |
| | | public ResponseMsg<Integer> deleteToken(int id) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "删除多条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "List<Integer>", paramType = "query", example = "1,2") |
| | | @Operation(summary = "删除多条") |
| | | @Parameters({ |
| | | @Parameter(name = "ids", description = "ID数组", schema = @Schema(type = "array"), in = ParameterIn.QUERY, example = "1,2") |
| | | }) |
| | | @GetMapping(value = "/deleteTokens") |
| | | public ResponseMsg<Integer> deleteTokens(@RequestParam List<Integer> ids) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "更新一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "TokenEntity", paramType = "body", example = "") |
| | | @Operation(summary = "更新一条") |
| | | @Parameters({ |
| | | @Parameter(name = "entity", description = "实体类", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updateToken", produces = "application/json; charset=UTF-8") |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID更新令牌为失效") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "令牌ID", dataType = "Integer", paramType = "query", example = "6563") |
| | | @Operation(summary = "根据ID更新令牌为失效") |
| | | @Parameters({ |
| | | @Parameter(name = "id", description = "令牌ID", in = ParameterIn.QUERY, example = "6563") |
| | | }) |
| | | @GetMapping(value = "/updateExpireById") |
| | | public ResponseMsg<Integer> updateExpireById(Integer id, HttpServletRequest req) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据Token更新令牌为失效") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "tk", value = "令牌", dataType = "String", paramType = "query", example = "2edea2a2-e307-4baa-992c-b477ce0566dd") |
| | | @Operation(summary = "根据Token更新令牌为失效") |
| | | @Parameters({ |
| | | @Parameter(name = "tk", description = "令牌", in = ParameterIn.QUERY, example = "2edea2a2-e307-4baa-992c-b477ce0566dd") |
| | | }) |
| | | @GetMapping(value = "/updateExpireByToken") |
| | | public ResponseMsg<Integer> updateExpireByToken(String tk, HttpServletRequest req) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1658") |
| | | @Operation(summary = "根据ID查询") |
| | | @Parameters({ |
| | | @Parameter(name = "id", description = "ID", in = ParameterIn.QUERY, example = "1658") |
| | | }) |
| | | @GetMapping(value = "/selectToken") |
| | | public ResponseMsg<TokenEntity> selectToken(int id) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询(有效期内的)") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "6563") |
| | | @Operation(summary = "根据ID查询(有效期内的)") |
| | | @Parameters({ |
| | | @Parameter(name = "id", description = "ID", in = ParameterIn.QUERY, example = "6563") |
| | | }) |
| | | @GetMapping(value = "/selectOneById") |
| | | public ResponseMsg<TokenEntity> selectOneById(Integer id) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据token查询(有效期内的)") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "tk", value = "令牌", dataType = "String", paramType = "query", example = "2edea2a2-e307-4baa-992c-b477ce0566dd") |
| | | @Operation(summary = "根据token查询(有效期内的)") |
| | | @Parameters({ |
| | | @Parameter(name = "tk", description = "令牌", in = ParameterIn.QUERY, example = "2edea2a2-e307-4baa-992c-b477ce0566dd") |
| | | }) |
| | | @GetMapping(value = "/selectOneByToken") |
| | | public ResponseMsg<TokenEntity> selectOneByToken(String tk) { |