package scripts.dict


import cn.lihongjie.coal.common.Ctx
import com.fasterxml.jackson.databind.JsonNode
import jakarta.persistence.EntityManager
import org.springframework.context.ApplicationContext

ApplicationContext ioc = ioc


EntityManager em = ioc.getBean(EntityManager.class)


return em.createQuery("select distinct pzUser from WeightDeviceDataEntity where pzUser like :q and organizationId = :organizationId order by pzUser limit 10")
        .setParameter("q", "%${(params as JsonNode).get("q")?.asText('') ?: ''}%" as String)
        .setParameter("organizationId", Ctx.currentUser().organizationId)
        .resultList
        .collect { it as String }
        .sort()


