|
@@ -0,0 +1,279 @@
|
|
|
+import { Injectable } from '@angular/core';
|
|
|
+import { Http } from '@angular/http';
|
|
|
+import { AppConfig } from '../../app.config';
|
|
|
+import { ResultMessage } from '../../../viewmodel/result';
|
|
|
+import { ServiceCommon } from "../service.common";
|
|
|
+
|
|
|
+import 'rxjs/add/operator/toPromise';
|
|
|
+import {StudentInfoView} from "../../../viewmodel/user/studentInfo";
|
|
|
+import {StudentView} from "../../../viewmodel/user/studentView";
|
|
|
+import {DictionaryItemView} from "../../../viewmodel/common/dictionaryItemView";
|
|
|
+import {RegistView} from "../../../viewmodel/user/registView";
|
|
|
+
|
|
|
+@Injectable()
|
|
|
+export class UserService {
|
|
|
+ constructor(private http: Http) { }
|
|
|
+
|
|
|
+ login(loginID: string, password: string): Promise<ResultMessage> {
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "UserServices/Login";
|
|
|
+ let openID: string = localStorage.openID;
|
|
|
+ if (!openID) openID = null;
|
|
|
+ return this.http.post(url, JSON.stringify({ loginID: loginID, password: password, openID: openID }), {headers: ServiceCommon.getHeader() })
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ var result = res.json();
|
|
|
+ return {
|
|
|
+ isSuccess: result.IsSuccess,
|
|
|
+ message: result.Message,
|
|
|
+ errorCode: result.ErrorCode,
|
|
|
+ data: result.Data
|
|
|
+ // isSuccess: res.json(),
|
|
|
+ // message: res.json() ? "" : "用户名或密码不正确",
|
|
|
+ // data: null
|
|
|
+ } as ResultMessage;
|
|
|
+ })
|
|
|
+ .catch(ServiceCommon.serviceErrorHandler);
|
|
|
+ }
|
|
|
+
|
|
|
+ getUserByLoginID(loginID: string): Promise<ResultMessage> {
|
|
|
+ let baseurl: string = AppConfig.getServiceUrl();
|
|
|
+ let studenturl = baseurl + "StudentServices/GetStudentViewByLoginID";
|
|
|
+
|
|
|
+ return this.http.post(studenturl, JSON.stringify({ loginID: loginID }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let student = res.json();
|
|
|
+ if (student) {
|
|
|
+ return {
|
|
|
+ isSuccess: true,
|
|
|
+ message: "",
|
|
|
+ data: {
|
|
|
+ UserID: student.UserID,
|
|
|
+ LoginID: loginID,
|
|
|
+ UserName: student.UserName,
|
|
|
+ classmajorID: student.ClassMajorID,
|
|
|
+ classmajorName: student.ClassMajorName
|
|
|
+ }
|
|
|
+ } as ResultMessage;
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ isSuccess: false,
|
|
|
+ message: "当前登录并非学生用户,请重新登录。",
|
|
|
+ data: null
|
|
|
+ } as ResultMessage;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(ServiceCommon.serviceErrorHandler);
|
|
|
+ }
|
|
|
+
|
|
|
+ getStudentByUserID(userID: string): Promise<ResultMessage> {
|
|
|
+ let baseurl: string = AppConfig.getServiceUrl();
|
|
|
+ let studenturl = baseurl + "StudentServices/GetStudentViewByUserID";
|
|
|
+
|
|
|
+ return this.http.post(studenturl, JSON.stringify({ userID: userID }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let student = res.json();
|
|
|
+ if (student) {
|
|
|
+ return {
|
|
|
+ isSuccess: true,
|
|
|
+ message: "",
|
|
|
+ data: {
|
|
|
+ UserID: student.UserID,
|
|
|
+ LoginID: student.LoginID,
|
|
|
+ Name: student.Name,
|
|
|
+ UserName:student.UserName,
|
|
|
+ UsedName: student.UsedName,
|
|
|
+ Sex: student.Sex,
|
|
|
+ SexName: student.SexName,
|
|
|
+ Nation:student.Nation,
|
|
|
+ NationName: student.NationName,
|
|
|
+ BirthDate: student.BirthDate == null ? null :new Date(parseInt(student.BirthDate.substring(6,19))+8*60*60*1000).toISOString(),
|
|
|
+ Politics:student.Politics,
|
|
|
+ PoliticsName: student.PoliticsName,
|
|
|
+ CertificatesType:student.CertificatesType,
|
|
|
+ CertificatesTypeName: student.CertificatesTypeName,
|
|
|
+ IDNumber: student.IDNumber,
|
|
|
+ ClassMajorID: student.ClassMajorID,
|
|
|
+ ClassMajorName: student.ClassMajorName,
|
|
|
+ EducationID:student.EducationID,
|
|
|
+ EducationName: student.EducationName,
|
|
|
+ StudentType:student.StudentType,
|
|
|
+ StudentTypeName: student.StudentTypeName,
|
|
|
+ PhotoUrl: student.PhotoUrl,//AppConfig.getServiceUrl() + student.PhotoUrl.replace(/(^[/]*)/g, ''),
|
|
|
+ StudentStatus: student.StudentStatus,
|
|
|
+ StudentStatusName: student.StudentStatusName,
|
|
|
+ InSchoolStatusID:student.InSchoolStatusID,
|
|
|
+ InSchoolStatusName: student.InSchoolStatusName,
|
|
|
+ EntranceDate: student.EntranceDate == null ? null :new Date(parseInt(student.EntranceDate.substring(6,19))+8*60*60*1000).toISOString(),
|
|
|
+ EntranceWay:student.EntranceWay,
|
|
|
+ EntranceWayName: student.EntranceWayName,
|
|
|
+ ExamineeNum: student.ExamineeNum,
|
|
|
+ ExamineeType:student.ExamineeType,
|
|
|
+ ExamineeTypeName: student.ExamineeTypeName,
|
|
|
+ Features:student.Features,
|
|
|
+ FeaturesName: student.FeaturesName,
|
|
|
+ Score: student.Score,
|
|
|
+ Territorial:student.Territorial,
|
|
|
+ TerritorialName: student.TerritorialName,
|
|
|
+ Area: student.Area,
|
|
|
+ Place: student.Place,
|
|
|
+ Healthy:student.Healthy,
|
|
|
+ HealthyName: student.HealthyName,
|
|
|
+ Specialty: student.Specialty,
|
|
|
+ Height: student.Height,
|
|
|
+ Weight: student.Weight,
|
|
|
+ Email: student.Email,
|
|
|
+ QQ: student.QQ,
|
|
|
+ Dormitory: student.Dormitory,
|
|
|
+ Telephone: student.Telephone,
|
|
|
+ Mobile: student.Mobile,
|
|
|
+ Address: student.Address,
|
|
|
+ WorkUnit: student.WorkUnit,
|
|
|
+ ZipCode: student.ZipCode,
|
|
|
+ Recipient: student.Recipient,
|
|
|
+ BankName: student.BankName,
|
|
|
+ CardNo: student.CardNo,
|
|
|
+ Remarks: student.Remarks
|
|
|
+ } as StudentInfoView
|
|
|
+ } as ResultMessage;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(ServiceCommon.serviceErrorHandler);
|
|
|
+ }
|
|
|
+
|
|
|
+ getStudentChangeFeilds(UserID:string) : Promise<ResultMessage> {
|
|
|
+ let baseurl: string = AppConfig.getServiceUrl();
|
|
|
+ let studenturl = baseurl + "StudentServices/GetStudentChangeFeilds";
|
|
|
+ return this.http.post(studenturl, JSON.stringify({ UserID: UserID }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let studentChangeFilds = res.json();
|
|
|
+ if (studentChangeFilds) {
|
|
|
+ return {
|
|
|
+ isSuccess: true,
|
|
|
+ message: "",
|
|
|
+ data:res.json()
|
|
|
+ }as ResultMessage;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ studentChangeSave(StudentView: StudentView, UserID: string): Promise<ResultMessage>{
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "StudentServices/GetStudentChangeSave";
|
|
|
+ return this.http.post(url, JSON.stringify({ Model: StudentView, UserID: UserID }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let IsSuccess = res.json();
|
|
|
+ if(IsSuccess.IsSuccess){
|
|
|
+ return{
|
|
|
+ isSuccess: true,
|
|
|
+ message: "保存成功",
|
|
|
+ data:null
|
|
|
+ } as ResultMessage
|
|
|
+ }else{
|
|
|
+ return{
|
|
|
+ isSuccess: false,
|
|
|
+ message: IsSuccess.Message,
|
|
|
+ data:null
|
|
|
+ } as ResultMessage
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ getSchoolYear(): Promise<ResultMessage>{
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "CommonServices/GetSchoolYearForDropdownList";
|
|
|
+ return this.http.post(url, JSON.stringify({ }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let schoolyearList = res.json();
|
|
|
+ if(schoolyearList)
|
|
|
+ {
|
|
|
+ return{
|
|
|
+ isSuccess: true,
|
|
|
+ message: "",
|
|
|
+ data: res.json()
|
|
|
+ }as ResultMessage;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ forgotPassword(loginID:string): Promise<ResultMessage>{
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "UserServices/ForgotPassword";
|
|
|
+ return this.http.post(url, JSON.stringify({LoginID:loginID}), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ return{
|
|
|
+ isSuccess: res.json().IsSuccess,
|
|
|
+ message: res.json().Message,
|
|
|
+ data: null
|
|
|
+ }as ResultMessage;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ regist(registView: RegistView): Promise<ResultMessage>{
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "UserServices/Regist";
|
|
|
+ let openID: string = localStorage.openID;
|
|
|
+ if (!openID) openID = null;
|
|
|
+ return this.http.post(url, JSON.stringify({ model: registView, openID: openID }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let resMessage = res.json();
|
|
|
+ return{
|
|
|
+ isSuccess: resMessage.IsSuccess,
|
|
|
+ message: resMessage.Message,
|
|
|
+ data: resMessage.Data
|
|
|
+ }as ResultMessage;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ unbind(): Promise<ResultMessage> {
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "UserServices/UnBind";
|
|
|
+ let openID: string = localStorage.openID;
|
|
|
+ if (!openID) openID = null;
|
|
|
+ return this.http.post(url, JSON.stringify({ openID: openID }), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let resMessage = res.json();
|
|
|
+ return{
|
|
|
+ isSuccess: resMessage.IsSuccess,
|
|
|
+ message: resMessage.Message,
|
|
|
+ data: resMessage.Data
|
|
|
+ }as ResultMessage;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ getDictionaryItemViewList(dictionaryCode:string): Promise<ResultMessage>{
|
|
|
+ let url: string = AppConfig.getServiceUrl();
|
|
|
+ url += "CommonServices/GetDictionaryViewList";
|
|
|
+ return this.http.post(url, JSON.stringify({ dictionaryCode:dictionaryCode}), {headers: ServiceCommon.getHeader()})
|
|
|
+ .toPromise()
|
|
|
+ .then(res => {
|
|
|
+ let dictionaryItemList = res.json();
|
|
|
+ if(dictionaryItemList)
|
|
|
+ {
|
|
|
+ return{
|
|
|
+ isSuccess: true,
|
|
|
+ message: "",
|
|
|
+ data: res.json().map(x => {
|
|
|
+ return {
|
|
|
+ dictionaryItemID:x.DictionaryItemID,
|
|
|
+ dictionaryCode:x.DictionaryCode,
|
|
|
+ dictionaryName:x.DictionaryName,
|
|
|
+ orderNo:x.OrderNo,
|
|
|
+ code:x.Code,
|
|
|
+ name:x.Name,
|
|
|
+ value:x.Value,
|
|
|
+ } as DictionaryItemView
|
|
|
+ })
|
|
|
+ }as ResultMessage;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|