1+ 'use strict' ;
2+ /**
3+ * model
4+ */
5+ export default class extends think . model . base {
6+
7+ // 添加新用户
8+ addUser ( data ) {
9+ return this . model ( 'user' ) . add ( data ) ;
10+ }
11+ //保存用户信息
12+ saveUserInfo ( data , where ) {
13+ return this . model ( 'user' ) . where ( where ) . update ( data ) ;
14+ }
15+
16+ //查找用户
17+ findUser ( where ) {
18+ return this . model ( 'user' ) . where ( where ) . select ( ) ;
19+ }
20+
21+ //返回全部列表
22+ findAll ( db , where ) {
23+ return this . model ( db ) . where ( where ) . select ( ) ;
24+ }
25+ //返回特定记录
26+ findOne ( db , where ) {
27+ return this . model ( db ) . where ( where ) . find ( ) ;
28+ }
29+ //更新数据
30+ updateRecord ( db , where , data ) {
31+ return this . model ( db ) . where ( where ) . update ( data ) ;
32+ }
33+ //添加数据
34+ addRecord ( db , data ) {
35+ return this . model ( db ) . add ( data ) ;
36+ }
37+ //返回文章列表
38+ getArticleList ( where ) {
39+ return this . model ( "article" ) . where ( where ) . order ( "createtime DESC" ) . limit ( 5 ) . select ( ) ;
40+ }
41+ //返回点击排行列表
42+ getPopularList ( where ) {
43+ return this . model ( "article" ) . where ( where ) . order ( "view DESC" ) . limit ( 5 ) . select ( ) ;
44+ }
45+ //返回点击排行列表
46+ addViewCount ( where ) {
47+ return this . model ( "article" ) . where ( where ) . increment ( 'view' , 1 ) ;
48+ }
49+ //分页初始数据
50+ getPageSelect ( where , page , pagesize ) {
51+ return this . model ( "article" ) . where ( where ) . order ( "createtime DESC" ) . page ( page , pagesize ) . select ( ) ;
52+ }
53+ //分页thinkjs分页数据
54+ getPageCountSelect ( where , page , pagesize ) {
55+ return this . model ( "article" ) . where ( where ) . order ( "createtime DESC" ) . page ( page , pagesize ) . countSelect ( ) ;
56+ }
57+ //获取排序后的列表
58+ getOrderList ( db , where ) {
59+ return this . model ( db ) . where ( where ) . order ( "orders" ) . select ( ) ;
60+ }
61+ }
0 commit comments