package com.feiyangedu.springcloud.petstore.account.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feiyangedu.springcloud.petstore.account.bean.UserBean;
import com.feiyangedu.springcloud.petstore.account.domain.User;
import com.feiyangedu.springcloud.petstore.account.repository.UserRepository;
import com.feiyangedu.springcloud.petstore.common.service.AbstractService;
import com.feiyangedu.springcloud.petstore.common.util.BeanUtil;

@RestController
public class AccountService extends AbstractService {

	@Autowired
	UserRepository userRepository;

	@GetMapping("/api/test")
	public String test() {
		return "TIME: " + System.currentTimeMillis();
	}

	@GetMapping("/api/users")
	public Page<User> getUsers(@RequestParam(value = "page", defaultValue = "0") int pageIndex) {
		return userRepository.findAll(new PageRequest(pageIndex, DEFAULT_PAGE_SIZE,
				new Sort(new Sort.Order(Sort.Direction.DESC, "createdAt"))));
	}

	@GetMapping("/api/users/{id}")
	public User getUser(@PathVariable("id") String id) {
		return checkNonNull(userRepository.findOne(id));
	}

	@PostMapping("/api/users")
	public User createUser(@RequestBody UserBean bean) {
		User user = new User();
		BeanUtil.copyPublicFields(bean, user);
		userRepository.save(user);
		return user;
	}
}

@@ -1095,108 +1095,61 @@
 ;%0A%0A%09
-@GetMapping(%22/api/test%22)%0A%09public String test() %7B%0A%09%09return %22TIME: %22 + System.currentTimeMillis();%0A%09%7D%0A
+/**%0A%09 * Get all users.%0A%09 * %0A%09 * @param pageIndex%0A%09 */
 %0A%09@G
@@ -1556,16 +1556,263 @@
 ));%0A%09%7D%0A%0A
+%09@PostMapping(%22/api/users2%22)%0A%09public User createUser2(@RequestParam(%22aa%22) java.time.LocalDateTime aa, @RequestBody UserBean bean) %7B%0A%09%09User user = new User();%0A%09%09BeanUtil.copyPublicFields(bean, user);%0A%09%09userRepository.save(user);%0A%09%09return user;%0A%09%7D%0A%0A
 %09@PostMa

fix account service