@IocBean
public class UserModule extends BaseModule{
@Inject
protected userService userService;
@At
public int count(){
return dao.count(User.class);
}
@At
public Object query(@Param("name")String name){
Cnd cnd = Strings.isBlank(name)? null : Cnd.where("name", "like", "%"+name+"%");
User user = new User();
user = (User) dao.query(User.class, cnd);
return user;
}
protected User checkUser(User user) {
user.setId(user.getId());
user.setName(user.getName());
user.setDate(user.getDate());
user.setHf(user.getHf());
user.setCj(user.getCj());
user.setAddname(user.getAddname());
user.setDeletename(user.getDeletename());
return user;
}
@At
public Object add(@Param("..")User user) { // 两个点号是按对象属性一一设置
NutMap re = new NutMap();
/* User msg = checkUser(user);
System.out.println(msg.getName()+"===============");*/
System.out.println("+++++"+dao); //dao一直输出null
dao.insert(user);
if (user != null){
return re.setv("ok", false).setv("user", user);
}
// user = userService.add(user.getId(),user.getName(),user.getDate(),user.getHf(),user.getCj(),
// user.getAddname(),user.getDeletename());
return re.setv("ok", true).setv("data", user);
}