X Tutup
The Wayback Machine - https://web.archive.org/web/20201015014158/https://github.com/APIJSON/APIJSON/issues/122
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增自定义接口的问题,是否需要手工在Access表中插入数据? #122

Closed
kevin01222 opened this issue Mar 3, 2020 · 3 comments

Comments

@kevin01222
Copy link

@kevin01222 kevin01222 commented Mar 3, 2020

环境信息

  • 系统: Windows 7
  • JDK: 1.8.0_66
  • 数据库: MySQL 5.7.14
  • APIJSON: 3.9.0

问题描述

  1. 修改DemoSQLConfig.java中的数据库配置。登录测试账号成功。
  2. 新增自定义接口的问题,我的操作步骤:
    2.1 新建一个 空类
    @MethodAccess
    public class EyeShop {}
    2.2 修改DemoSQLConfig.java中的配置
    TABLE_KEY_MAP.put(EyeShop.class.getSimpleName(),"eye_shop");
    ACCESS_MAP.put(EyeShop.class.getSimpleName(),getAccessMap(EyeShop.class.getAnnotation(MethodAccess.class)));
    2.3 自定义主键名:修改 getIdKey()方法:
    return StringUtil.toLowerCase(table).substring(3) + "_id"; //把表的前缀Eye去掉。主键用的shop_id
    2.4 配置Request表新增一条数据(貌似没用)
    39 ,1, GET, EyeShop, {}, 无

错误信息

{"EyeShop":{"shop_id":1},"code":401,"msg":"EyeShop 不允许 LOGIN 用户的 GET 请求!","sql:generate|cache|execute|maxExecute":"0|0|0|200","depth:count|max":"1|5","time:start|duration|end":"1583248775224|9|1583248775233"}

解决
只有在数据库表Access中插入一条语句才可以在apijson.org/auto中通过{"EyeShop":{"shop_id":1}}查到正确结果。
INSERT INTO apijson.access (id, debug, name, alias, get, head, gets, heads, post, put, delete, date) VALUES ('20', '0', 'eye_shop', 'EyeShop', '["UNKNOWN", "LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["UNKNOWN", "LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["OWNER", "ADMIN"]', '["OWNER", "ADMIN"]', '["OWNER", "ADMIN"]', '2020-03-02 18:23:48');

疑问

  1. access表中是否需要这条记录?
  2. 如果access表需要有记录,那这条insert语句是否需要自己去插入?
  3. 如果access数据表需要这条语句,且不用手工插入,那是根据TABLE_KEY_MAP.put(EyeShop.class.getSimpleName(),"eye_shop");
    ACCESS_MAP.put(EyeShop.class.getSimpleName(),getAccessMap(EyeShop.class.getAnnotation(MethodAccess.class)));
    这两句和@MethodAccess来插入到Access表的么?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup