@@ -12,7 +12,7 @@ type ApprHandler struct {
1212 Error func (context.Context , string )
1313 ApprService ApprService
1414 ModelType reflect.Type
15- IdNames []string
15+ Keys []string
1616 Indexes map [string ]int
1717 Offset int
1818 Log func (ctx context.Context , resource string , action string , success bool , desc string ) error
@@ -26,24 +26,24 @@ func NewApprHandler(apprService ApprService, modelType reflect.Type, logError fu
2626 if len (option ) > 0 && option [0 ] >= 0 {
2727 offset = option [0 ]
2828 }
29- return NewApprHandlerWithKeysAndLog (apprService , modelType , offset , logError , nil , nil )
29+ return NewApprHandlerWithKeysAndLog (apprService , nil , modelType , offset , logError , nil )
3030}
3131func NewApprHandlerWithLogs (apprService ApprService , modelType reflect.Type , offset int , logError func (context.Context , string ), writeLog func (context.Context , string , string , bool , string ) error , options ... string ) * ApprHandler {
32- return NewApprHandlerWithKeysAndLog (apprService , modelType , offset , logError , nil , writeLog , options ... )
32+ return NewApprHandlerWithKeysAndLog (apprService , nil , modelType , offset , logError , writeLog , options ... )
3333}
3434func NewApprHandlerWithKeys (apprService ApprService , modelType reflect.Type , logError func (context.Context , string ), idNames []string , option ... int ) * ApprHandler {
3535 offset := 1
3636 if len (option ) > 0 && option [0 ] >= 0 {
3737 offset = option [0 ]
3838 }
39- return NewApprHandlerWithKeysAndLog (apprService , modelType , offset , logError , idNames , nil )
39+ return NewApprHandlerWithKeysAndLog (apprService , idNames , modelType , offset , logError , nil )
4040}
41- func NewApprHandlerWithKeysAndLog (apprService ApprService , modelType reflect.Type , offset int , logError func (context.Context , string ), idNames [] string , writeLog func (context.Context , string , string , bool , string ) error , options ... string ) * ApprHandler {
41+ func NewApprHandlerWithKeysAndLog (apprService ApprService , keys [] string , modelType reflect.Type , offset int , logError func (context.Context , string ), writeLog func (context.Context , string , string , bool , string ) error , options ... string ) * ApprHandler {
4242 if offset < 0 {
4343 offset = 1
4444 }
45- if idNames == nil || len (idNames ) == 0 {
46- idNames = getJsonPrimaryKeys (modelType )
45+ if keys == nil || len (keys ) == 0 {
46+ keys = getJsonPrimaryKeys (modelType )
4747 }
4848 indexes := getIndexes (modelType )
4949 var resource , action1 , action2 string
@@ -62,7 +62,7 @@ func NewApprHandlerWithKeysAndLog(apprService ApprService, modelType reflect.Typ
6262 } else {
6363 resource = buildResourceName (modelType .Name ())
6464 }
65- return & ApprHandler {Log : writeLog , ApprService : apprService , ModelType : modelType , IdNames : idNames , Indexes : indexes , Offset : offset , Error : logError , Resource : resource , Action1 : action1 , Action2 : action2 }
65+ return & ApprHandler {Log : writeLog , ApprService : apprService , ModelType : modelType , Keys : keys , Indexes : indexes , Offset : offset , Error : logError , Resource : resource , Action1 : action1 , Action2 : action2 }
6666}
6767
6868func (c * ApprHandler ) newModel (body interface {}) (out interface {}) {
@@ -81,7 +81,7 @@ func (c *ApprHandler) newModel(body interface{}) (out interface{}) {
8181}
8282
8383func (c * ApprHandler ) Approve (w http.ResponseWriter , r * http.Request ) {
84- id , err := buildId (r , c .ModelType , c .IdNames , c .Indexes , c .Offset )
84+ id , err := buildId (r , c .ModelType , c .Keys , c .Indexes , c .Offset )
8585 if err != nil {
8686 http .Error (w , err .Error (), http .StatusBadRequest )
8787 } else {
@@ -95,7 +95,7 @@ func (c *ApprHandler) Approve(w http.ResponseWriter, r *http.Request) {
9595}
9696
9797func (c * ApprHandler ) Reject (w http.ResponseWriter , r * http.Request ) {
98- id , err := buildId (r , c .ModelType , c .IdNames , c .Indexes , c .Offset )
98+ id , err := buildId (r , c .ModelType , c .Keys , c .Indexes , c .Offset )
9999 if err != nil {
100100 http .Error (w , err .Error (), http .StatusBadRequest )
101101 } else {
0 commit comments