Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
87c4a9fd
Commit
87c4a9fd
authored
Sep 17, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
1e89629d
Pipeline
#13845
passed with stage
in 35 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
343 additions
and
1 deletion
+343
-1
institution.js
app/controller/course/institution.js
+19
-0
option.js
app/controller/course/option.js
+20
-0
course_cat.js
app/model/prometheus/course_cat.js
+105
-0
course_institution_to_cat.js
app/model/prometheus/course_institution_to_cat.js
+102
-0
course.js
app/router/course.js
+1
-1
institution.js
app/service/course/institution.js
+24
-0
option.js
app/service/course/option.js
+72
-0
No files found.
app/controller/course/institution.js
0 → 100644
View file @
87c4a9fd
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
InstitutionController
extends
Controller
{
/**
* 机构列表
*/
async
list
()
{
const
{
ctx
}
=
this
;
let
ret
=
await
ctx
.
service
.
credit
.
home
.
home
();
ctx
.
success
(
ret
);
}
}
module
.
exports
=
InstitutionController
;
app/controller/course/option.js
0 → 100644
View file @
87c4a9fd
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
OptionController
extends
Controller
{
/**
* 筛选项
*/
async
getOptions
()
{
const
{
ctx
}
=
this
;
const
results
=
await
ctx
.
service
.
course
.
option
.
getOptions
();
ctx
.
success
({
results
});
}
}
module
.
exports
=
OptionController
;
app/model/prometheus/course_cat.js
0 → 100644
View file @
87c4a9fd
'use strict'
;
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseCat
=
app
.
prometheusModel
.
define
(
'course_cat'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
first_id
:
INTEGER
,
parent_id
:
INTEGER
,
level
:
INTEGER
,
name
:
STRING
,
tips
:
STRING
,
status
:
ENUM
(
'offline'
,
'online'
),
is_deleted
:
INTEGER
,
created_at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_cat'
,
});
CourseCat
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseCat
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
CourseCat
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseCat
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
CourseCat
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
CourseCat
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
CourseCat
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
CourseCat
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
CourseCat
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseCat
.
update
(
params
,
{
where
:
where
})
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
}
return
CourseCat
;
};
\ No newline at end of file
app/model/prometheus/course_institution_to_cat.js
0 → 100644
View file @
87c4a9fd
'use strict'
;
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseInstitutionToCat
=
app
.
prometheusModel
.
define
(
'course_institution_to_cat'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
institution_id
:
INTEGER
,
cat_id
:
INTEGER
,
status
:
ENUM
(
'offline'
,
'online'
),
is_deleted
:
INTEGER
,
created_at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_at
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_institution_to_cat'
,
});
CourseInstitutionToCat
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseInstitutionToCat
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
CourseInstitutionToCat
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseInstitutionToCat
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
CourseInstitutionToCat
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
CourseInstitutionToCat
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
CourseInstitutionToCat
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
CourseInstitutionToCat
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
CourseInstitutionToCat
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseInstitutionToCat
.
update
(
params
,
{
where
:
where
})
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
}
return
CourseInstitutionToCat
;
};
\ No newline at end of file
app/router/course.js
View file @
87c4a9fd
...
...
@@ -4,7 +4,7 @@ module.exports = app => {
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/course'
);
const
loginAuth
=
app
.
middleware
.
loginAuth
({
type
:
'new'
});
//登录中间件
// router.get('/history/:type', 'credit.order.getRecord
');
router
.
get
(
'/option'
,
'course.option.getOptions
'
);
};
app/service/course/institution.js
0 → 100644
View file @
87c4a9fd
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
InstitutionService
extends
Service
{
/**
* 我的信用首页
*/
async
home
()
{
}
}
module
.
exports
=
InstitutionService
;
app/service/course/option.js
0 → 100644
View file @
87c4a9fd
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
AGE_CATS
=
[
{
id
:
-
2
,
name
:
'全部'
,
value
:
0
},
{
id
:
-
3
,
name
:
'3岁以下'
,
value
:
3
},
{
id
:
-
4
,
name
:
'4岁'
,
value
:
4
},
{
id
:
-
5
,
name
:
'5岁'
,
value
:
5
},
{
id
:
-
6
,
name
:
'6岁'
,
value
:
6
},
{
id
:
-
7
,
name
:
'7岁'
,
value
:
7
},
{
id
:
-
8
,
name
:
'8岁'
,
value
:
8
},
{
id
:
-
9
,
name
:
'9岁'
,
value
:
9
},
{
id
:
-
10
,
name
:
'10岁'
,
value
:
10
},
{
id
:
-
11
,
name
:
'11岁'
,
value
:
11
},
{
id
:
-
12
,
name
:
'12岁'
,
value
:
12
},
{
id
:
-
13
,
name
:
'12岁以上'
,
value
:
13
},
];
const
INSTITUTION_TYPE
=
[
{
id
:
-
14
,
name
:
'全部'
,
value
:
''
},
{
id
:
-
15
,
name
:
'品牌'
,
value
:
'品牌'
},
];
class
OptionService
extends
Service
{
/**
* 我的信用首页
*/
async
getOptions
()
{
const
{
ctx
}
=
this
;
const
cats
=
await
ctx
.
prometheusModel
.
CourseCat
.
all
({
where
:
{
status
:
1
,
is_deleted
:
0
}
});
const
tree_cats
=
this
.
getTrees
(
cats
,
0
);
const
options
=
{
cats
:
tree_cats
,
ages
:
AGE_CATS
,
institutions
:
INSTITUTION_TYPE
,
}
return
options
;
}
getTrees
(
data
,
rootId
)
{
const
ret
=
[];
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
node
=
data
[
i
];
if
(
node
.
parent_id
==
rootId
)
{
const
newNode
=
{};
ret
.
push
({
id
:
0
,
name
:
'全部'
,
value
:
''
});
newNode
.
id
=
node
.
id
;
newNode
.
name
=
node
.
name
;
newNode
.
tips
=
node
.
tips
;
newNode
.
level
=
node
.
level
;
newNode
.
value
=
node
.
id
;
newNode
.
_child
=
this
.
getTrees
(
data
,
node
.
id
);
ret
.
push
(
newNode
);
}
}
return
ret
;
}
}
module
.
exports
=
OptionService
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment