123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 'use strict';
- /**
- * 客户信息数据模型
- *
- * @author CaiAoLin
- * @date 2017/11/14
- * @version
- */
- module.exports = app => {
- class Customer extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'customer';
- }
- /**
- * 查询过虑
- *
- * @param {Object} data - 筛选表单中的get数据
- * @return {void}
- */
- searchFilter(data) {
- this.initSqlBuilder();
- }
- /**
- * 新增SSO用户
- *
- * @param {Object} data - 接口返回的数据
- * @return {Number} - 返回新增数据的id
- */
- async addSSOUser(data) {
- let result = 0;
- if (Object.keys(data).length <= 0 || data.useremail === undefined) {
- return result;
- }
- // 先查找是否存在
- const customerData = await this.db.get(this.tableName, { email: data.useremail });
- if (customerData !== null) {
- // 存在则直接返回id
- return customerData.id;
- }
- const insertData = {
- email: data.useremail,
- mobile: data.mobile,
- name: data.username,
- };
- result = await this.db.insert(this.tableName, insertData);
- return result.insertId;
- }
- }
- return Customer;
- };
|