Thursday, 14 April 2016

abstract class BaseController {
def springSecurityService
def loggedInUser
def baseSetupService

//maintain loggedInUser AccountId
def getLoggedInUser(){
this.loggedInUser = session?.loggedInUser
return loggedInUser
}
}


package com.gb.md.common

abstract class BaseEntity {

static dynamicProperties = true

Long createdBy
Date createdOn

transient springSecurityService

static transients = ['springSecurityService']
def storage = [:]

static constraints = { }

def beforeValidate(){
initDefaults()
}

def beforeInsert() {
initDefaults()
}

def beforeUpdate() {
initDefaults()
}

def initDefaults(){
if(!createdBy){
createdBy = springSecurityService?.currentUser ? springSecurityService.currentUser.id : 0
}
if(!createdOn){
createdOn = new Date()
}
}

def propertyMissing(String name, value) {
storage[name] = value
}

def propertyMissing(String name) {
storage[name]
}
}

No comments:

Post a Comment