Commit cd163d2240abba19e0d5bb4b28c1c337564ba618

Authored by maliang
1 parent 05fe6b8508
Exists in master

创建controller 添加基础测试类

Showing 3 changed files with 35 additions and 7 deletions

center.manager/src/main/java/com/lyms/cm/controller/sys/SysUsersController.java View file @ cd163d2
1 1 package com.lyms.cm.controller.sys;
2 2  
  3 +import org.springframework.beans.factory.annotation.Autowired;
3 4 import org.springframework.stereotype.Controller;
4 5 import org.springframework.web.bind.annotation.RequestMapping;
  6 +import org.springframework.web.bind.annotation.RequestMethod;
5 7  
  8 +import com.lyms.cm.entity.sys.SysUsers;
  9 +import com.lyms.cm.service.sys.ISysUsersService;
6 10 import com.lyms.web.controller.BaseController;
7 11  
8 12 /**
... ... @@ -16,6 +20,23 @@
16 20 @Controller
17 21 @RequestMapping("/sysUsers")
18 22 public class SysUsersController extends BaseController {
  23 +
  24 + @Autowired
  25 + private ISysUsersService userService;
  26 +
  27 + /**
  28 + * 创建用户
  29 + * <p>
  30 + * TODO
  31 + *
  32 + * @param user
  33 + * @return
  34 + */
  35 + @RequestMapping(value = "/create", method = RequestMethod.POST)
  36 + public String create(SysUsers user) {
  37 + boolean tag = userService.addUser(user);
  38 + return null;
  39 + }
19 40  
20 41 }
center.manager/src/test/java/center/manager/test/user/BaseTest.java View file @ cd163d2
  1 +package center.manager.test.user;
  2 +
  3 +import org.junit.runner.RunWith;
  4 +import org.springframework.test.context.ContextConfiguration;
  5 +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  6 +import org.springframework.transaction.annotation.Transactional;
  7 +
  8 +@Transactional
  9 +@RunWith(SpringJUnit4ClassRunner.class)
  10 +@ContextConfiguration(locations = { "classpath:app-context.xml" })
  11 +public class BaseTest {
  12 +
  13 +}
center.manager/src/test/java/center/manager/test/user/UserTest.java View file @ cd163d2
... ... @@ -5,18 +5,12 @@
5 5 import org.junit.Assert;
6 6 import org.junit.Before;
7 7 import org.junit.Test;
8   -import org.junit.runner.RunWith;
9 8 import org.springframework.beans.factory.annotation.Autowired;
10   -import org.springframework.test.context.ContextConfiguration;
11   -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12 9  
13 10 import com.lyms.cm.entity.sys.SysUsers;
14 11 import com.lyms.cm.service.sys.ISysUsersService;
15 12  
16   -//@Transactional
17   -@RunWith(SpringJUnit4ClassRunner.class)
18   -@ContextConfiguration(locations = { "classpath:app-context.xml" })
19   -public class UserTest {
  13 +public class UserTest extends BaseTest {
20 14  
21 15 @Autowired
22 16 private ISysUsersService userService;