@@ -23,17 +23,6 @@ const {
2323const idRegExp = / ^ [ 0 - 9 ] + $ / ; // Tips: 非必要情况下正则不要用g参数;如果必须使用,需要尽量限制使用范围,不要设为全局变量。
2424
2525module . exports = {
26- async find ( ctx ) {
27- const { list } = await findAllMaterial ( ctx . session . user , ctx . request . query , 'user-components' , 'user_components' , [
28- 'createdBy'
29- ] ) ;
30- return list . map ( ( item ) =>
31- sanitizeEntity (
32- { ...item , createdBy : filterUserField ( item . createdBy ) } ,
33- { model : strapi . models [ 'user-components' ] }
34- )
35- ) ;
36- } ,
3726
3827 async pagination ( ctx ) {
3928 const { list, total } = await findAllMaterial (
@@ -59,33 +48,7 @@ module.exports = {
5948 const { list } = await findAllMaterial ( ctx . session . user , ctx . request . query , 'user-components' , 'user_components' ) ;
6049 return list . length ;
6150 } ,
62-
63- async update ( ctx ) {
64- const { id } = ctx . params ;
65- const newData = { ...ctx . request . body } ;
66-
67- let currentPublicScope = newData . public ;
68- if ( ! isTruthy ( currentPublicScope ) ) {
69- currentPublicScope = ( await strapi . services [ 'user-components' ] . findOne ( { id } ) ) . public ;
70- }
71-
72- handlePublicScope ( currentPublicScope , newData ) ;
73- handleTinyReserved ( ctx . session . user , newData ) ;
74-
75- const component = await strapi . services [ 'user-components' ] . update ( { id } , newData ) ;
76- return sanitizeEntity ( component , { model : strapi . models [ 'user-components' ] } ) ;
77- } ,
78-
79- async create ( ctx ) {
80- const data = { ...ctx . request . body } ;
81-
82- handlePublicScope ( data . public , data ) ;
83- handleTinyReserved ( ctx . session . user , data , true ) ;
84-
85- const component = await strapi . services [ 'user-components' ] . create ( data ) ;
86- return sanitizeEntity ( component , { model : strapi . models [ 'user-components' ] } ) ;
87- } ,
88-
51+
8952 async associated ( ctx ) {
9053 const { id } = ctx . params ;
9154 if ( ! idRegExp . test ( id ) ) {
0 commit comments