mysql/oracle操作

mysql/oracle查询

案例:http://dev.manateeai.com/interface?mode=edit&id=221

  1. {
  2. "name" : "mysqlQuery",//组件名称
  3. "db" : "oracle",//多数据源时查询指定数据源,单数据源时不需要配置
  4. "table" : "student",//表名
  5. "columns" : "id,name",//要查询的列
  6. "queryParams" : { //设置查询条件
  7. },
  8. "selectOne":true,// 默认查询出list
  9. "selectTotalCount":true,//查询list的时候返回totalCount
  10. "camelCase":false,// 默认驼峰
  11. "condition":"name like ${name} and id >{id}", //sql 表达式
  12. "sort":{ // 排序
  13. "gmt_modified":"desc",
  14. "id":"asc"
  15. },
  16. "in":{ // in查询
  17. "key" : "'id'", //要in查询的key
  18. "value" : "studentList", //in查询的集合
  19. "valueKey" : "id" //in查询集合中映射的key
  20. },
  21. "page":{ // 分页
  22. "pageNum":1,//第几页
  23. "pagesize":10//每页多少条
  24. },
  25. "join":[ //join关联查询
  26. {
  27. "table" : "project",
  28. "columns" : "id,name",
  29. "joinKey" : "project_id",
  30. "beJoinedKey" : "id",
  31. "joinType":"left join",//不填默认为 inner join
  32. "queryParams" : {
  33. "id":35,
  34. "condition" : "name = ${projectName}"//sql 表达式
  35. }
  36. }
  37. ],
  38. "dataHandleBatch" : { //拿到的结果数据批量处理
  39. "phone" : "phone",
  40. "userId" : "user_id"
  41. },
  42. // "dataHandle" : { //拿到的结果数据单个处理
  43. // "phone" : "phone",
  44. // "userId" : "user_id"
  45. // },
  46. "mergeFields":true,//是否将dataHandle后的字段与处理前的字段合并,默认不合并
  47. "valueTo" : "request", //放入上下文request,默认为response
  48. "returnkey" : "studentList" //数据处理完后选择输出到对象中
  49. }

mysql/oracle更新

案例:http://dev.manateeai.com/interface?mode=edit&id=223

  1. {
  2. "name":"mysqlUpdate",
  3. "db" : "oracle",//多数据源时查询指定数据源,单数据源时不需要配置
  4. "table":"student",//表名
  5. "queryParams":{//查询参数
  6. "id":"id"
  7. },
  8. "updateParams":{//更新参数
  9. "name":"name",
  10. "gender":"gender"
  11. }
  12. }

mysql/oracle新增

单个新增案例:http://dev.manateeai.com/interface?mode=edit&id=269
批量新增案例:http://dev.manateeai.com/interface?mode=edit&id=222

  1. //单个插入:
  2. {
  3. "name":"mysqlInsert",
  4. "db" : "oracle",//多数据源时查询指定数据源,单数据源时不需要配置
  5. "table":"student",//表名
  6. "insertParams":{//单个插入参数处理
  7. "name":"name",
  8. "gender":"gender"
  9. }
  10. }
  11. //批量插入:
  12. {
  13. "name" : "mysqlInsert",
  14. "table" : "test_case",
  15. "paramsKey":"caseList",
  16. "insertParamsBatch" : {//批量插入参数处理
  17. "name":"strUpperCase(name)",
  18. "description":"description"
  19. }
  20. }

mysql/oracle SQL 查询

案例:http://dev.manateeai.com/interface?mode=edit&id=266

  1. {
  2. "name":"mysqlSql",
  3. "db" : "oracle",//多数据源时查询指定数据源,单数据源时不需要配置
  4. "sql":"select nick,user_id from uic_user where city='${city}'",
  5. "dataHandleBatch" : { //拿到的结果数据批量处理
  6. "phone" : "phone",
  7. "userId" : "user_id"
  8. },
  9. // "dataHandle" : { //拿到的结果数据单个处理
  10. // "phone" : "phone",
  11. // "userId" : "user_id"
  12. // },
  13. "mergeFields":true,//是否将dataHandle后的字段与处理前的字段合并,默认不合并
  14. "returnkey" : "studentList", //数据处理完后选择输出到对象中
  15. "valueTo" : "request" //放入上下文request,默认为response
  16. }

mongo操作

mongoDB添加

  1. {
  2. "name" : "mongoAdd",
  3. "db" : "testLowCode",
  4. "table" : "mongo_test",
  5. "input" : {
  6. "c":"add(a,b)"
  7. }
  8. }

先执行mapping计算或者数据映射,得到的结果插入mongo中

mongoDB查询

  1. {
  2. "name":"mongoQuery",
  3. "table":"mongo_test",
  4. "db":"testLowCode",
  5. "input":{
  6. "userId":"60112006b4286d1057775394"
  7. },
  8. "mergeInput":"true",
  9. "outputPackage":"data",
  10. "output":{
  11. "d":"json(b)",
  12. "c":"add(a,b)"
  13. }
  14. }

先从mongo中查询数据,然后通过output或者outputBatch进行数据处理(非必选)

  1. {
  2. "name":"mongoQuery",
  3. "table":"room",
  4. "db":"warehouse",
  5. "input":{
  6. "parkId":"60112006b4286d1057775394"
  7. },
  8. "join":[
  9. {
  10. "joinKey":"parkId",
  11. "beJoinedKey":"id",
  12. "table":"park",
  13. "cache":"memoryCache",
  14. "input":{
  15. "valid":true
  16. }
  17. }
  18. ]
  19. }

当涉及到数据join进行如上配置

mongoDB更新

  1. {
  2. "name" : "mongoUpdate",
  3. "input" : "id,b",
  4. "table" : "mongo_test",
  5. "db" : "testLowCode"
  6. }

mongoDB统计数量

  1. {
  2. "name" : "mongoQueryCount",
  3. "input" : "a,b",
  4. "table" : "mongo_test",
  5. "db" : "testLowCode"
  6. }

mongo累加器

  1. {
  2. "name" : "mongoIncrease",
  3. "table" : "seller",
  4. "db" : "supply_chain",
  5. "input" : {
  6. "biz" : "duoduo",
  7. "userId" : 101
  8. },
  9. "output" : {
  10. "c":"add(d,h)",
  11. "score":"cal('a+b*5+c*3')"
  12. }
  13. }

在进行累计之前通过output中计算,最后一条配置如果为数字类型作为结果,写入mongo,param作为mongo的筛选项。


redis操作

单个查询 hash

  1. {
  2. "name" : "redisHashFieldsQuery",
  3. "mergeInput" : true,
  4. "key" : "testRedisHashFieldsAdd",
  5. "input" : "a,b,c",
  6. "output" : {
  7. "f":"arrayToList(a)"
  8. },
  9. "db" : 0
  10. }

单个模糊查询hash

  1. {
  2. "name" : "redisHashFieldsFuzzyQuery",
  3. "pattern" : "*",
  4. "mergeInput" : true,
  5. "key" : "testRedisHashFieldsAdd",
  6. "output" : {
  7. "z":"add(a,b)"
  8. },
  9. "db" : 0
  10. }

插入 hash

  1. {
  2. "name" : "redisHashFieldsAdd",
  3. "key" : "warehouse:banner",
  4. "input" : {
  5. "c":"add(a,b)"
  6. },
  7. "db" : 0
  8. }

删除 hash

  1. {
  2. "name" : "redisHashFieldsRemove",
  3. "key" : "warehouse:banner",
  4. "input" : "bannerName",
  5. "db" : 0
  6. }

判断 key 是否存在

  1. {
  2. "name" : "redisKeyIsExists",
  3. "key" : "demoRedisStrKey",
  4. "db" : 0
  5. }

模糊查询key

  1. {
  2. "db" : 0,
  3. "name" : "redisKeysFuzzyQuery",
  4. "pattern" : "test*"
  5. }

新增 key value

  1. {
  2. "key" : "demoRedisStrKey",
  3. "input" : "strValue",
  4. "name" : "redisKeyValueAdd",
  5. "db" : 0
  6. }

查询 key value

  1. {
  2. "key" : "demoRedisStrKey",
  3. "name" : "redisKeyValueQuery",
  4. "db" : 0
  5. }

删除 key value

  1. {
  2. "key" : "demoRedisStrKey",
  3. "name" : "redisKeyValueRemove",
  4. "db" : 0
  5. }

新增 list value

  1. {
  2. "key" : "testRedisList",
  3. "input" : "test",
  4. "name" : "redisListValueAdd",
  5. "db" : 0
  6. }

查询 list value

  1. {
  2. "key" : "testRedisList",
  3. "name" : "redisListQuery",
  4. "db" : 0
  5. }

新增 set value

  1. {"key" : "testRedisSet",
  2. "input" : "test",
  3. "name" : "redisSetValueAdd",
  4. "db" : 0
  5. }

查询 set value

  1. {
  2. "key" : "testRedisSet",
  3. "name" : "redisSetQuery",
  4. "db" : 0
  5. }

累加

  1. {
  2. "name" : "redisValueIncrease",
  3. "key" : "foo",
  4. "db" : 0
  5. }