github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/authorization/crud.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package authorization 4 5 // CRUD indicate all CRUD. 6 type CRUD uint8 7 8 // CRUD 9 const ( 10 CRUDNone CRUD = 0b00000000 // 0 11 CRUDCreate CRUD = 0b00000001 // 1 12 CRUDRead CRUD = 0b00000010 // 2 13 CRUDUpdate CRUD = 0b00000100 // 4 14 CRUDDelete CRUD = 0b00001000 // 8 15 CRUDAll CRUD = 0b11111111 // 255 16 17 // CRUDCreateRead CRUD = 0b00000011 // 3 18 // CRUDCreateUpdate CRUD = 0b00000101 // 5 19 // CRUDReadUpdate CRUD = 0b00000110 // 6 20 // CRUDCreateReadUpdate CRUD = 0b00000111 // 7 21 // CRUDCreateDelete CRUD = 0b00001001 // 9 22 // CRUDReadDelete CRUD = 0b00001010 // 10 23 // CRUDCreateReadDelete CRUD = 0b00001011 // 11 24 // CRUDUpdateDelete CRUD = 0b00001100 // 12 25 // CRUDCreateUpdateDelete CRUD = 0b00001101 // 13 26 // CRUDReadUpdateDelete CRUD = 0b00001110 // 14 27 ) 28 29 // Set given crud to given CRUD! 30 // e.g. c.Set(CRUDCreate|CRUDDelete) 31 func (c CRUD) Set(crud CRUD) { 32 c = crud 33 } 34 35 // Check check given crud exist in given CRUD! 36 func (c CRUD) Check(crud CRUD) (exist bool) { 37 if crud&c == crud { 38 return true 39 } 40 return false 41 }