AccessTokenMapper.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package cn.escheduler.dao.mapper;
  18. import cn.escheduler.common.enums.UserType;
  19. import cn.escheduler.dao.model.AccessToken;
  20. import cn.escheduler.dao.model.User;
  21. import org.apache.ibatis.annotations.*;
  22. import org.apache.ibatis.type.EnumOrdinalTypeHandler;
  23. import org.apache.ibatis.type.JdbcType;
  24. import java.sql.Timestamp;
  25. import java.util.List;
  26. public interface AccessTokenMapper {
  27. /**
  28. * insert accessToken
  29. * @param accessToken
  30. * @return
  31. */
  32. @InsertProvider(type = AccessTokenMapperProvider.class, method = "insert")
  33. @Options(useGeneratedKeys = true,keyProperty = "accessToken.id")
  34. @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "accessToken.id", before = false, resultType = int.class)
  35. int insert(@Param("accessToken") AccessToken accessToken);
  36. /**
  37. * delete accessToken
  38. * @param accessTokenId
  39. * @return
  40. */
  41. @DeleteProvider(type = AccessTokenMapperProvider.class, method = "delete")
  42. int delete(@Param("accessTokenId") int accessTokenId);
  43. /**
  44. * update accessToken
  45. *
  46. * @param accessToken
  47. * @return
  48. */
  49. @UpdateProvider(type = AccessTokenMapperProvider.class, method = "update")
  50. int update(@Param("accessToken") AccessToken accessToken);
  51. /**
  52. * query access token list paging
  53. * @param searchVal
  54. * @param offset
  55. * @param pageSize
  56. * @return
  57. */
  58. @Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
  59. @Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
  60. @Result(property = "token", column = "token", javaType = String.class, jdbcType = JdbcType.VARCHAR),
  61. @Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
  62. @Result(property = "expireTime", column = "expire_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
  63. @Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
  64. @Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
  65. })
  66. @SelectProvider(type = AccessTokenMapperProvider.class, method = "queryAccessTokenPaging")
  67. List<AccessToken> queryAccessTokenPaging(@Param("userId") Integer userId,
  68. @Param("searchVal") String searchVal,
  69. @Param("offset") Integer offset,
  70. @Param("pageSize") Integer pageSize);
  71. /**
  72. * count access token by search value
  73. * @param searchVal
  74. * @return
  75. */
  76. @SelectProvider(type = AccessTokenMapperProvider.class, method = "countAccessTokenPaging")
  77. Integer countAccessTokenPaging(@Param("userId") Integer userId
  78. ,@Param("searchVal") String searchVal);
  79. }