From d8088850424ce618bef81de2c6d23342f8e7009e Mon Sep 17 00:00:00 2001 From: aerain Date: Sat, 24 Aug 2019 16:21:15 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/jedaero/lib/dreamy.js | 40 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tool/jedaero/lib/dreamy.js b/tool/jedaero/lib/dreamy.js index eca40cc..4e49852 100644 --- a/tool/jedaero/lib/dreamy.js +++ b/tool/jedaero/lib/dreamy.js @@ -1,22 +1,29 @@ import encode64 from "./encode64"; import { Platform } from 'react-native'; import RNFetchBlob from "rn-fetch-blob"; + +const fetchData = async (uri, body) => RNFetchBlob.config({trusty: true}).fetch('POST', uri, {"Content-Type": "application/x-www-form-urlencoded"}, body) + /** * Dreamy Connection with fetch API. */ const Dreamy = { _openSession: async function (account, password) { const uri = 'https://dreamy.jejunu.ac.kr/frame/sysUser.do?next='; - const body = `tmpu=${encode64(account)}&tmpw=${encode64(password)}&mobile=&app=&z=N&userid=&password=` + const body = `tmpu=${encode64(account)}&tmpw=${encode64(password)}&mobile=y&app=null&z=Y&userid=&password=` // 세션 확보 - return this.fetchData(uri, body); + return fetchData(uri, body); }, _getBaseInfo: async function (account) { const uri = 'https://dreamy.jejunu.ac.kr/hjju/hj/sta_hj_1010q.jejunu'; const body = `mode=doValue&student_no=${account}&_=` + return (await fetchData(uri, body)).json(); + }, - return (await this.fetchData(uri, body)).json(); + _logout: async function() { + const uri = 'https://dreamy.jejunu.ac.kr/frame/sysUser.do?mode=logout'; + return RNFetchBlob.config({trusty: true}).fetch('GET', uri); }, getTimeTable: async function (account, year, month, day) { @@ -37,7 +44,7 @@ const Dreamy = { */ const uri = 'https://dreamy.jejunu.ac.kr/susj/su/sta_su_6170q.jejunu'; const body = `mode=doListTimetable&curri_year=${year}&term_gb=${semester}&su_dt=${year}${month <= 9 ? `0${month}` : month}${day <= 9 ? `0${day}` : day}&student_no=${account}&_=`; - return (await this.fetchData(uri, body)).json() + return (await fetchData(uri, body)).json() }, isValidAccount: async function(account = '', password = '') { @@ -56,27 +63,28 @@ const Dreamy = { getCredit: async function (account) { const uri = 'https://dreamy.jejunu.ac.kr/susj/sj/sta_sj_3230q.jejunu'; const body = `mode=doSearch&student_no=${account}&del_gb=&_=`; - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, getCreditDetail: async function (account, year, semester, outsideSeq, groupGb) { const uri = 'https://dreamy.jejunu.ac.kr/susj/sj/sta_sj_3220q.jejunu'; const body = `mode=doList&year=${year}&term_gb=${semester}&group_gb=${groupGb}&student_no=${account}&outside_seq=${outsideSeq}&del_gb=AND%20SJ_DEL_GB%20IS%20NULL&_=`; - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, getLectureBoard: async function(account, name, userGb, year, semester) { const uri = 'https://dreamy.jejunu.ac.kr/frame/doumi_1020e.jejunu'; const body = `mode=doListSugangBanNo&common_curri_year=${year}&common_term_gb=${semester}&common_student_no=${account}&common_subject_nm=${name}&common_prof_no=${account}&common_prof_nm=${name}&common_user_gb=${userGb}&mng_dept_cd=&_=`; - return (await this.fetchData(uri, body)).json(); + console.log(body); + return (await fetchData(uri, body)).json(); }, getLectureItemBoard: async function(year, semester, classCode) { const uri = 'https://dreamy.jejunu.ac.kr/frame/doumi_1020e.jejunu'; const body = `mode=doList&curri_year=${year}&term_gb=${semester}&ban_no=${classCode}&title&content&name&_=`; - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, getLecturePost: async function(year, semester, classCode, num, root) { const uri = 'https://dreamy.jejunu.ac.kr/frame/doumi_1020e.jejunu'; const body = `mode=doGetBoardDetail&curri_year=${year}&term_gb=${semester}&ban_no=${classCode}&num=${num}&root=${root}&prevnextyn=0&_=` - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, downloadLecurePostFile: async function ( account = '', @@ -122,17 +130,18 @@ const Dreamy = { isPassDormitory: async function (account) { const uri = 'https://dreamy.jejunu.ac.kr/stsv/ht/sts_ht_0509e.jejunu'; const body = `mode=doValue&campus_gb=A&student_no=${account}&_=`; - return (await this.fetchData(uri, body)).json(); + console.log(body); + return (await fetchData(uri, body)).json(); }, getLecturePlanList: async function ({year, semester, search: {classCode = '', professorName = '', lectureName = ''}}) { const uri = 'https://dreamy.jejunu.ac.kr/susj/su/sta_su_7020q.jejunu'; const body = `mode=doList&curri_year=${year}&term_gb=${semester}&ban_no=${classCode}&emp_nm=${professorName}&emp_no=&subject_nm=${lectureName}&_=`; - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, getLecturePlanSummary: async function ({year, semester, lecture: {classCode, lectureCode}}) { const uri = 'https://dreamy.jejunu.ac.kr/susj/su/sta_su_7020q.jejunu'; const body = `mode=doGetListDetail&curri_year=${year}&term_gb=${semester}&ban_no=${classCode}&subject_cd=${lectureCode}&_=` - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, /** @@ -141,14 +150,13 @@ const Dreamy = { getLecturePlanDetail: async function({mode, year, semester, classCode}) { const uri = 'https://dreamy.jejunu.ac.kr/susj/su/sta_su_7012e.jejunu'; const body = `mode=doSearch&curri_year=${year}&term_gb=${semester}&ban_no=${classCode}&_=` - return (await this.fetchData(uri, body)).json(); + return (await fetchData(uri, body)).json(); }, getLecturePlanDetailWeekList: async function ({year, semester, classCode}) { const uri = 'https://dreamy.jejunu.ac.kr/susj/su/sta_su_7012e.jejunu'; const body = `mode=doListMst&curri_year=${year}&term_gb=${semester}&ban_no=${classCode}&_=` - return (await this.fetchData(uri, body)).json(); - }, - fetchData: (uri, body) => RNFetchBlob.config({trusty: true}).fetch('POST', uri, {"Content-Type": "application/x-www-form-urlencoded"}, body) + return (await fetchData(uri, body)).json(); + } }; export default Dreamy; \ No newline at end of file