package com.ekexiu.portal.service;

import java.sql.Connection;
import java.sql.SQLException;

import org.jfw.apt.annotation.Autowrie;
import org.jfw.apt.web.annotation.Path;
import org.jfw.apt.web.annotation.operate.Get;
import org.jfw.apt.web.annotation.operate.Post;
import org.jfw.apt.web.annotation.operate.Put;
import org.jfw.apt.web.annotation.param.JdbcConn;
import org.jfw.apt.web.annotation.param.PathVar;
import org.jfw.apt.web.annotation.param.RequestBody;

import com.ekexiu.portal.dao.UserDao;
import com.ekexiu.portal.po.User;

@Path("/init")
public class InitUserService {
	@Autowrie
	private UserDao userDao;
	
	
	public UserDao getUserDao() {
		return userDao;
	}


	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}


	@Get
	@Path("/user/{id}")
	public User getUser(@JdbcConn Connection con,@PathVar String id) throws SQLException{
		return this.userDao.query(con, id);
	}
	@Post
	@Path("/user")
	public void modifyMobilePhone(@JdbcConn(true) Connection con,String id,String mobilePhone)throws SQLException
	{
		User user = new User();
		user.setId(id);
		user.setMobilePhone(mobilePhone);
		user.setPasswd(SysService.DEFAULT_PASS_WORD);
		user.setUserType("0");
		this.userDao.insert(con, user);		
	}
	@Put
	@Path("/user")
	public void modifyMobilePhone(@JdbcConn(true) Connection con ,@RequestBody User user)throws SQLException
	{
		this.userDao.updateMobilePhone(con, user.getMobilePhone(), user.getId())	;
	}
	

}
