curing.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Created by MyPC on 2019/11/5.
  3. */
  4. 'use strict';
  5. const hash= require('../class/hash');
  6. const Sequelize = require('sequelize');
  7. const Op = Sequelize.Op;
  8. module.exports = (sequelize, DataTypes) => {
  9. const curing = sequelize.define('cloud_curing', {
  10. mobile: DataTypes.STRING,
  11. sso_id: DataTypes.STRING,
  12. compilation_id: DataTypes.STRING,
  13. curingCompany: DataTypes.STRING,
  14. sid: DataTypes.INTEGER,
  15. cid: DataTypes.INTEGER,
  16. status: DataTypes.INTEGER,
  17. client_id: DataTypes.INTEGER,
  18. addtime: DataTypes.STRING,
  19. updateTotal:DataTypes.INTEGER,
  20. upgradeDescribe: DataTypes.STRING,
  21. }, {});
  22. curing.associate = function(models) {
  23. // associations can be defined here
  24. };
  25. curing.getCuringInMobile=async function(mobile,compilation_id){
  26. if(!hash.isExistence(mobile)){
  27. return [];
  28. }
  29. var option={
  30. where: {
  31. mobile: {
  32. [Op.or]: [mobile]
  33. }
  34. },
  35. raw:true,
  36. };
  37. if(hash.isExistence(compilation_id)){
  38. option.where={compilation_id: compilation_id};
  39. }
  40. var curingList = await this.findAll(option);
  41. return curingList;
  42. };
  43. /*
  44. * ����mobile����Ѱ������ư��û�
  45. * */
  46. curing.getCuringByMobile=async function(mobile){
  47. if(mobile==undefined){
  48. return [];
  49. }
  50. var condition={
  51. raw:true,
  52. where: {
  53. mobile: mobile
  54. }};
  55. var curingList = await this.findOne(condition);
  56. return curingList;
  57. };
  58. /*
  59. * ����ssoid����Ѱ������ư��û�
  60. * */
  61. curing.getCuringBySsoid=async function(ssoid){
  62. if(!hash.isExistence(ssoid)){
  63. return [];
  64. }
  65. var condition={
  66. raw:true,
  67. where: {
  68. sso_id: ssoid
  69. }};
  70. var detail = await this.findOne(condition);
  71. if(!hash.isExistence(detail)){
  72. return [];
  73. }
  74. detail.id=hash.hashEncode(detail.id.toString());
  75. return detail;
  76. };
  77. /*
  78. * ����id����Ѱ������ư��û�
  79. * */
  80. curing.getCuringById=async function(id){
  81. if(!hash.isExistence(id)){
  82. return [];
  83. }
  84. var condition={
  85. raw:true,
  86. where: {
  87. id: id
  88. }};
  89. var detail = await this.findOne(condition);
  90. return detail;
  91. };
  92. /*
  93. * ��ñ��ر��
  94. * */
  95. curing.getCuringCompilationList=async function(){
  96. return [];
  97. };
  98. return curing;
  99. };