| | |
| | | import com.moon.server.annotation.SysLog; |
| | | import com.moon.server.controller.all.BaseController; |
| | | import com.moon.server.entity.all.ResponseMsg; |
| | | import com.moon.server.entity.all.SettingData; |
| | | import com.moon.server.entity.all.StaticData; |
| | | import com.moon.server.entity.sys.TokenEntity; |
| | | import com.moon.server.entity.sys.UserEntity; |
| | | import com.moon.server.helper.StringHelper; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 令牌表 |
| | | * @author WWW |
| | | * @date 2022-09-28 |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | @Api(tags = "运维管理\\令牌管理") |
| | | @RestController |
| | | @RequestMapping("/token") |
| | |
| | | } |
| | | |
| | | @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") |
| | | }) |
| | | @GetMapping(value = "/insertNewToken") |
| | | public ResponseMsg<Object> insertNewToken(Integer type, Integer min, HttpServletRequest req) { |
| | | try { |
| | | if (null == type || type > 1) { |
| | | type = 0; |
| | | } |
| | | if (null == min || min < StaticData.I10) { |
| | | min = SettingData.TOKEN_EXPIRE; |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | TokenEntity te = tokenService.getNewToken(type, min, ue, req); |
| | | int rows = tokenService.insertToken(te); |
| | | if (0 == rows) { |
| | | return fail("创建令牌失败", null); |
| | | } |
| | | |
| | | return success(te); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "删除一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |