curing.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. var option={
  27. where: {
  28. mobile: {
  29. [Op.or]: [mobile]
  30. }
  31. },
  32. raw:true,
  33. };
  34. if(hash.isExistence(compilation_id)){
  35. option.where={compilation_id: compilation_id};
  36. }
  37. if(mobile==undefined){
  38. return [];
  39. }
  40. var condition={
  41. raw:true,
  42. where: {
  43. mobile: mobile
  44. }};
  45. var curingList = await this.findOne(condition);
  46. return curingList;
  47. };
  48. /*
  49. * ����mobile����Ѱ������ư��û�
  50. * */
  51. curing.getCuringByMobile=async function(mobile){
  52. if(mobile==undefined){
  53. return [];
  54. }
  55. var condition={
  56. raw:true,
  57. where: {
  58. mobile: mobile
  59. }};
  60. var curingList = await this.findOne(condition);
  61. return curingList;
  62. };
  63. /*
  64. * ����ssoid����Ѱ������ư��û�
  65. * */
  66. curing.getCuringBySsoid=async function(ssoid){
  67. if(!hash.isExistence(ssoid)){
  68. return [];
  69. }
  70. var condition={
  71. raw:true,
  72. where: {
  73. sso_id: ssoid
  74. }};
  75. var detail = await this.findOne(condition);
  76. if(!hash.isExistence(detail)){
  77. return [];
  78. }
  79. detail.id=hash.hashEncode(detail.id.toString());
  80. return detail;
  81. };
  82. /*
  83. * ����id����Ѱ������ư��û�
  84. * */
  85. curing.getCuringById=async function(id){
  86. if(!hash.isExistence(id)){
  87. return [];
  88. }
  89. var condition={
  90. raw:true,
  91. where: {
  92. id: id
  93. }};
  94. var detail = await this.findOne(condition);
  95. return detail;
  96. };
  97. /*
  98. * ��ñ��ر��
  99. * */
  100. curing.getCuringCompilationList=async function(){
  101. return [];
  102. };
  103. return curing;
  104. };