Browse Source

培训添加用户

wuwen 5 years ago
parent
commit
a6a2ba952a

+ 12 - 43
src/main/java/com/ssj/api/controller/ApiTrainController.java

@@ -7,7 +7,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -25,20 +24,18 @@ import com.ssj.api.domain.vo.train.TrainVideoFileVo;
 import com.ssj.api.domain.vo.train.TrainVideoVo;
 import com.ssj.api.security.annotation.IgnoreSecurity;
 import com.ssj.bean.sys.train.bean.ExamInfo;
+import com.ssj.bean.sys.train.bean.TrainUser;
 import com.ssj.bean.sys.train.bean.VideoInfo;
 import com.ssj.bean.sys.train.bean.VideoUser;
-import com.ssj.bean.weixin.libmy.domain.TbLibManager;
-import com.ssj.bean.weixin.user.domain.User;
 import com.ssj.framework.core.common.controller.BaseController;
 import com.ssj.framework.core.util.CodecUtil;
 import com.ssj.framework.core.util.ResponseConstant;
 import com.ssj.framework.core.util.ResponseEntity;
 import com.ssj.service.sys.train.service.ExamInfoService;
+import com.ssj.service.sys.train.service.TrainUserService;
 import com.ssj.service.sys.train.service.VideoFileService;
 import com.ssj.service.sys.train.service.VideoInfoService;
 import com.ssj.service.sys.train.service.VideoUserService;
-import com.ssj.service.weixin.library.service.IBookManagerService;
-import com.ssj.service.weixin.user.service.UserService;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -54,12 +51,6 @@ import io.swagger.annotations.ApiOperation;
 public class ApiTrainController extends BaseController {
 	
 	@Autowired
-    private UserService userService;
-	
-    @Autowired
-    private IBookManagerService bookManagerService;
-    
-	@Autowired
     private VideoUserService videoUserService;
 	
 	@Autowired
@@ -71,6 +62,9 @@ public class ApiTrainController extends BaseController {
 	@Autowired
     private ExamInfoService examInfoService;
 	
+	@Autowired
+    private TrainUserService trainUserService;
+	
 
 	private static List<RoleTypeModel> defaultRoleTypeModels=new ArrayList<RoleTypeModel>();
 	private static List<String> defaultRoleTypeNames=new ArrayList<String>();
@@ -116,24 +110,6 @@ public class ApiTrainController extends BaseController {
 	}
 	
 	
-	//查询出校长,老师的身份
-	private TbLibManager getTbLibManagerUserId(String userId) {
-		List<TbLibManager> teacherLists = bookManagerService.findAllManagerByTeacherId(userId);
-        if(CollectionUtils.isEmpty(teacherLists)) {
-        	return null;
-        }
-        TbLibManager tbLibManager=teacherLists.get(0);
-        for (TbLibManager libManager : teacherLists) {
-        	//有校长身份的,优先显示校长身份的数据
-			if(libManager.getType()==6) {
-				tbLibManager=libManager;
-				break;
-			}
-		}
-        return tbLibManager;
-	}
-	
-	
 	private Map<String, Object> getTrainVideoUserMap(Integer roleType,List<Map<String,Object>> list){
 		for (Map<String, Object> map : list) {
 			if(roleType==(int)map.get("role_type")) {
@@ -152,28 +128,21 @@ public class ApiTrainController extends BaseController {
         ResponseEntity responseEntity = new ResponseEntity();
         Map<String, Object> data=new HashMap<String, Object>();
         try {
-            User phoneUser = userService.findByMobile(requestVO.getLoginName());
+            TrainUser phoneUser = trainUserService.getTrainUserByMobile(requestVO.getLoginName());
             if (phoneUser == null) {
                 responseEntity.failure(ResponseConstant.CODE_000, "账号无效");
                 return responseEntity;
             }
-            User user = userService.getUserByPassword(requestVO.getLoginName(), requestVO.getPassword());
+            TrainUser user = trainUserService.login(requestVO.getLoginName(), requestVO.getPassword());
             if (user == null) {
             	responseEntity.failure("密码错误");
                 return responseEntity;
             }
-            //查询该老师拥有的角色
-            TbLibManager tbLibManager = getTbLibManagerUserId(user.getId());
-            if(tbLibManager==null) {
-            	responseEntity.failure("账号无身份权限");
-                return responseEntity;
-            }
 
             data.put("userId", user.getId());
-            data.put("name", StringUtils.isNotEmpty(tbLibManager.getName())? tbLibManager.getName(): "");
+            data.put("name", StringUtils.isNotEmpty(user.getName())? user.getName(): "");
             data.put("photo", StringUtils.isNotEmpty(user.getPhoto())? user.getPhoto(): "");
             data.put("accessToken", getAccessToken(user.getId(),CodecUtil.createUUID()));
-            //data.put("roleTypes", defaultRoleTypeModels);
             responseEntity.success(data, "账号密码登录成功");
         } catch (Exception e) {
             logger.error("账号密码登录接口", e);
@@ -191,14 +160,14 @@ public class ApiTrainController extends BaseController {
         Map<String, Object> data=new HashMap<String, Object>();
         try {
             String userId = tokenManager.getUserId(accessToken);
-            TbLibManager tbLibManager = getTbLibManagerUserId(userId);
+            TrainUser tbLibManager = trainUserService.getById(userId);
             if(tbLibManager==null) {
             	responseEntity.failure("账号无身份权限");
                 return responseEntity;
             }
             List<Map<String,Object>> list=videoUserService.findTrainVideoUserByUserId(userId);
             //是校长
-            if(tbLibManager.getType()==6) {
+            if(tbLibManager.getRoleType()==1) {
             	defaultRoleTypeModels.get(0).setUnlock(1);
             	
             	Map<String, Object> dataMap1=getTrainVideoUserMap(1, list);
@@ -247,7 +216,7 @@ public class ApiTrainController extends BaseController {
         List<Map<String, Object>> data=new ArrayList<Map<String,Object>>();
         try {
             String userId = tokenManager.getUserId(accessToken);
-            TbLibManager tbLibManager = getTbLibManagerUserId(userId);
+            TrainUser tbLibManager = trainUserService.getById(userId);
             if(tbLibManager==null) {
             	responseEntity.failure("账号无身份权限");
                 return responseEntity;
@@ -259,7 +228,7 @@ public class ApiTrainController extends BaseController {
             map1.put("roleType", 1);
             map1.put("roleName", defaultRoleTypeNames.get(0));
             //校长才显示校长端
-            if(tbLibManager.getType()==6) {
+            if(tbLibManager.getRoleType()==1) {
             	map1.put("successNum", dataMap1!=null ? Integer.parseInt(dataMap1.get("success_num").toString()):0);
             	map1.put("countNum", dataMap1!=null ? Integer.parseInt(dataMap1.get("count_num").toString()):0);
             	map1.put("unlock", 1);

+ 105 - 0
src/main/java/com/ssj/bean/sys/train/bean/TrainUser.java

@@ -0,0 +1,105 @@
+package com.ssj.bean.sys.train.bean;
+
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.ssj.bean.common.framework.core.domain.BaseEntity;
+
+@Entity
+@Table(name = "tr_train_user")
+public class TrainUser extends BaseEntity {
+	
+	private static final long serialVersionUID = 890135943022798129L;
+ 
+	private String id;
+	
+	private Integer roleType;
+	
+	private String mobile;
+	
+	private String password;
+	
+	private String name;
+	
+	private String photo;
+	
+	private String libId;
+	
+	private Integer status;
+	
+	private Date createTime;
+
+	
+	
+	public Integer getRoleType() {
+		return roleType;
+	}
+	public void setRoleType(Integer roleType) {
+		this.roleType = roleType;
+	}
+	public String getId() {
+		return id;
+	}
+	public String getMobile() {
+		return mobile;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public String getPhoto() {
+		return photo;
+	}
+
+	public String getLibId() {
+		return libId;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public void setPhoto(String photo) {
+		this.photo = photo;
+	}
+
+	public void setLibId(String libId) {
+		this.libId = libId;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+}	

+ 2 - 0
src/main/java/com/ssj/dao/sys/train/dao/TrainQueryDao.java

@@ -26,4 +26,6 @@ public interface TrainQueryDao {
 	
 	public Page<Map<String, Object>> findVideoFileByPage(Map<String, Object> params, Pageable pageable);
 
+	
+	public Page<Map<String, Object>> findTrainUserBySysPage(Map<String, Object> params, Pageable pageable);
 }

+ 15 - 0
src/main/java/com/ssj/dao/sys/train/dao/TrainUserDao.java

@@ -0,0 +1,15 @@
+package com.ssj.dao.sys.train.dao;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import com.ssj.bean.sys.train.bean.TrainUser;
+
+@Repository
+public interface TrainUserDao extends JpaRepository<TrainUser, String> {
+		
+	@Query(nativeQuery = true,value = "SELECT * from tr_train_user t WHERE  t.mobile=?1 AND t.`status`=1 LIMIT 1 ")
+	public TrainUser getTrainUserByMobile(String mobile);
+	
+}

+ 34 - 9
src/main/java/com/ssj/dao/sys/train/dao/impl/TrainQueryDaoImpl.java

@@ -54,8 +54,8 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
         sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_video_info m WHERE m.role_type=2 AND m.`status`=1 ) as role_num_2, ");
         sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_video_info m WHERE m.role_type=3 AND m.`status`=1 ) as role_num_3, ");
         sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_video_info m WHERE m.role_type=4 AND m.`status`=1 ) as role_num_4, ");
-        sb.append(" (SELECT COUNT(DISTINCT m.user_id) from tb_lib_manager m WHERE m.type=6 AND m.lib_id=t.lib_id) as pal_num, ");
-        sb.append(" (SELECT COUNT(DISTINCT m.user_id) from tb_lib_manager m WHERE m.lib_id=t.lib_id) as tea_num ");
+        sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_train_user m WHERE m.role_type=1 AND m.lib_id=t.lib_id) as pal_num, ");
+        sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_train_user m WHERE m.lib_id=t.lib_id) as tea_num ");
         sb.append(" from fx_merchant t WHERE 1=1 AND t.lib_id is not null ");
         if(params.get("unitName")!=null && StringUtils.isNotEmpty(params.get("unitName").toString())) {
        	 	sb.append(" AND t.unit_name like concat('%',?,'%') ");
@@ -84,19 +84,19 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
         sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_video_info m WHERE m.role_type=3 AND m.`status`=1) as role_num_3, ");
         sb.append(" (SELECT COUNT(DISTINCT m.id) from tr_video_info m WHERE m.role_type=4 AND m.`status`=1) as role_num_4  ");
         
-        sb.append(" from tb_lib_manager t WHERE 1=1 ");
+        sb.append(" from tr_train_user t WHERE 1=1 ");
         sb.append(" AND t.lib_id=?   ");
         param.add(params.get("libId"));
        
         if(params.get("type")!=null && StringUtils.isNotEmpty(params.get("type").toString())) {
-        	 sb.append(" AND t.type=? ");
+        	 sb.append(" AND t.role_type=? ");
         	 param.add(params.get("type"));
         }
         if(params.get("name")!=null && StringUtils.isNotEmpty(params.get("name").toString())) {
         	sb.append(" AND t.name like concat('%',?,'%') ");
        	 	param.add(params.get("name"));
         }
-        sb.append(" GROUP BY t.user_id ");
+        sb.append(" GROUP BY t.id ");
         sb.append(" ORDER BY t.create_time desc ");
         return dao.findPage(sb.toString(),param.toArray(),pageable);
 	}
@@ -111,7 +111,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
 		sb.append(" 	(SELECT COUNT(*)  from ( ");
 		sb.append(" 		SELECT  u.user_id,COUNT(DISTINCT u.video_id) AS count from tr_video_user u");
 		sb.append(" 		LEFT JOIN tr_video_info i ON u.video_id=i.id");
-		sb.append(" 		LEFT JOIN tb_lib_manager m ON u.user_id=m.user_id");
+		sb.append(" 		LEFT JOIN tr_train_user m ON u.user_id=m.id");
 		sb.append(" 		WHERE i.`status`=1 AND u.`status`=1 AND u.role_type=1 AND m.lib_id=? ");
 		sb.append(" 		GROUP BY u.user_id ");
 		sb.append(" 		HAVING count>=? ");
@@ -122,7 +122,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
 		sb.append(" 	(SELECT COUNT(*)  from ( ");
 		sb.append(" 		SELECT  u.user_id,COUNT(DISTINCT u.video_id) AS count from tr_video_user u");
 		sb.append(" 		LEFT JOIN tr_video_info i ON u.video_id=i.id");
-		sb.append(" 		LEFT JOIN tb_lib_manager m ON u.user_id=m.user_id");
+		sb.append(" 		LEFT JOIN tr_train_user m ON u.user_id=m.id");
 		sb.append(" 		WHERE i.`status`=1 AND u.`status`=1 AND u.role_type=2 AND m.lib_id=? ");
 		sb.append(" 		GROUP BY u.user_id ");
 		sb.append(" 		HAVING count>=? ");
@@ -134,7 +134,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
 	    sb.append(" 	(SELECT COUNT(*)  from ( ");
 		sb.append(" 		SELECT  u.user_id,COUNT(DISTINCT u.video_id) AS count from tr_video_user u");
 		sb.append(" 		LEFT JOIN tr_video_info i ON u.video_id=i.id");
-		sb.append(" 		LEFT JOIN tb_lib_manager m ON u.user_id=m.user_id");
+		sb.append(" 		LEFT JOIN tr_train_user m ON u.user_id=m.id");
 		sb.append(" 		WHERE i.`status`=1 AND u.`status`=1 AND u.role_type=3 AND m.lib_id=? ");
 		sb.append(" 		GROUP BY u.user_id ");
 		sb.append(" 		HAVING count>=? ");
@@ -145,7 +145,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
 	    sb.append(" 	(SELECT COUNT(*)  from ( ");
   		sb.append(" 		SELECT  u.user_id,COUNT(DISTINCT u.video_id) AS count from tr_video_user u");
   		sb.append(" 		LEFT JOIN tr_video_info i ON u.video_id=i.id");
-  		sb.append(" 		LEFT JOIN tb_lib_manager m ON u.user_id=m.user_id");
+  		sb.append(" 		LEFT JOIN tr_train_user m ON u.user_id=m.id");
   		sb.append(" 		WHERE i.`status`=1 AND u.`status`=1 AND u.role_type=4 AND m.lib_id=? ");
   		sb.append(" 		GROUP BY u.user_id ");
   		sb.append(" 		HAVING count>=? ");
@@ -256,6 +256,31 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
         return dao.findPage(sb.toString(),param.toArray(),pageable);
 	}
 
+	@Override
+	public Page<Map<String, Object>> findTrainUserBySysPage(Map<String, Object> params, Pageable pageable) {
+		StringBuilder sb = new StringBuilder();
+		List<Object> param = new ArrayList<>();
+        sb.append(" SELECT * from tr_train_user t WHERE 1=1   ");
+        if(params.get("roleType")!=null && StringUtils.isNotEmpty(params.get("roleType").toString())) {
+       	 	sb.append(" and t.role_type=?  ");
+       	 	param.add(params.get("roleType"));
+        }
+        if(params.get("mobile")!=null && StringUtils.isNotEmpty(params.get("mobile").toString())) {
+        	sb.append(" and t.mobile like concat('%',?,'%')  ");
+        	param.add(params.get("mobile"));
+        }
+        if(params.get("name")!=null && StringUtils.isNotEmpty(params.get("name").toString())) {
+       	  	sb.append(" and t.`name` like concat('%',?,'%')  ");
+       	  	param.add(params.get("name"));
+        }
+        if(params.get("libId")!=null && StringUtils.isNotEmpty(params.get("libId").toString())) {
+       	  	sb.append(" and t.libId =? ");
+       	  	param.add(params.get("libId"));
+        }
+        sb.append(" ORDER BY t.create_time DESC ");
+        return dao.findPage(sb.toString(),param.toArray(),pageable);
+	}
+
 
 	
 	

+ 21 - 0
src/main/java/com/ssj/service/sys/train/service/TrainUserService.java

@@ -0,0 +1,21 @@
+package com.ssj.service.sys.train.service;
+
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import com.ssj.bean.sys.train.bean.TrainUser;
+import com.ssj.framework.core.common.service.BaseService;
+
+
+public interface TrainUserService extends BaseService<TrainUser, String> {
+
+	public Page<Map<String, Object>> findTrainUserBySysPage(Map<String, Object> params, Pageable pageable);
+	
+	public TrainUser getTrainUserByMobile(String mobile);
+	
+	public TrainUser login(String mobile,String password);
+	
+	
+}

+ 58 - 0
src/main/java/com/ssj/service/sys/train/service/impl/TrainUserServiceImpl.java

@@ -0,0 +1,58 @@
+package com.ssj.service.sys.train.service.impl;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ssj.bean.sys.train.bean.TrainUser;
+import com.ssj.dao.sys.train.dao.TrainQueryDao;
+import com.ssj.dao.sys.train.dao.TrainUserDao;
+import com.ssj.framework.core.common.service.BaseServiceImpl;
+import com.ssj.service.sys.train.service.TrainUserService;
+
+@Service
+@Transactional
+public class TrainUserServiceImpl extends BaseServiceImpl<TrainUser, String> implements TrainUserService {
+
+    @Autowired
+    private TrainUserDao trainUserDao;
+    
+    @Autowired
+    private TrainQueryDao trainQueryDao;
+
+    @Override
+	public PagingAndSortingRepository<TrainUser, String> getDao() {
+		return trainUserDao;
+	}
+
+	@Override
+	public Page<Map<String, Object>> findTrainUserBySysPage(Map<String, Object> params, Pageable pageable) {
+		return trainQueryDao.findTrainUserBySysPage(params, pageable);
+	}
+
+	@Override
+	public TrainUser getTrainUserByMobile(String mobile) {
+		return trainUserDao.getTrainUserByMobile(mobile);
+	}
+
+	
+	@Override
+	public TrainUser login(String mobile,String password) {
+		TrainUser trainUser=this.getTrainUserByMobile(mobile);
+		if(trainUser!=null) {
+			if(trainUser.getPassword().equals(password)) {
+				return trainUser;
+			}
+		}
+		return null;
+	}
+    
+    
+	
+
+}

+ 106 - 0
src/main/java/com/ssj/sys/controller/TrainController.java

@@ -12,6 +12,7 @@ import javax.servlet.http.HttpSession;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort.Direction;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -23,15 +24,19 @@ import com.ssj.bean.common.framework.core.domain.Response;
 import com.ssj.bean.sys.fx.domain.Merchant;
 import com.ssj.bean.sys.role.domain.Admin;
 import com.ssj.bean.sys.train.bean.ExamInfo;
+import com.ssj.bean.sys.train.bean.TrainUser;
 import com.ssj.bean.sys.train.bean.VideoFile;
 import com.ssj.bean.sys.train.bean.VideoInfo;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
 import com.ssj.framework.basic.common.bean.SplitPage;
 import com.ssj.framework.core.common.controller.BaseController;
 import com.ssj.service.sys.fx.service.MerchantService;
 import com.ssj.service.sys.train.service.ExamInfoService;
+import com.ssj.service.sys.train.service.TrainUserService;
 import com.ssj.service.sys.train.service.VideoFileService;
 import com.ssj.service.sys.train.service.VideoInfoService;
 import com.ssj.service.sys.train.service.VideoUserService;
+import com.ssj.service.weixin.library.service.ILibJoinService;
 
 @RequestMapping("sys/train")
 @Controller
@@ -52,6 +57,105 @@ public class TrainController extends BaseController {
 	@Autowired
 	private MerchantService merchantService;
 	
+	@Autowired
+	private TrainUserService trainUserService;
+	
+	@Autowired
+	private ILibJoinService libJoinService;
+	
+	
+	
+	
+	@RequestMapping("/user/list")
+	public String userList(Model model,
+			@RequestParam(required = false, defaultValue = "10") int pageSize,
+			@RequestParam(required = false, defaultValue = "1") int pageNo)
+			throws Exception {
+		
+		Map<String, Object> params = new HashMap<String, Object>();
+		params.put("roleType", request.getParameter("roleType")==null?"1":request.getParameter("roleType"));
+		params.put("mobile", request.getParameter("mobile")==null?"":request.getParameter("mobile"));
+		params.put("name", request.getParameter("name")==null?"":request.getParameter("name"));
+		params.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
+		
+		SplitPage sp = new SplitPage();
+        sp.setAction(request.getRequestURI());
+        sp.setPageNo(pageNo);
+        sp.setPageSize(pageSize);
+        sp.setParams(params);
+        Page<Map<String,Object>> page = trainUserService.findTrainUserBySysPage(params, initPage(pageNo, pageSize));
+        List<Map<String,Object>> list=page.getContent();
+       
+        sp.setRowCnt((int) page.getTotalElements());
+        model.addAttribute("list",list);
+        model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
+        model.addAttribute("page", sp);
+        model.addAttribute("search", params);
+		return "sys/train/user_list";
+	}
+	
+	
+	@RequestMapping("/user/edit")
+	public String userEdit(Model model,String id)
+			throws Exception {
+		TrainUser trainUser=new TrainUser();
+		if(StringUtils.isNotEmpty(id)) {
+			trainUser=trainUserService.getById(id);
+		}
+		Map<String, Object> params = new HashMap<String, Object>();
+		params.put("GTE_type", "1");
+	    Page<TbLibJoin> page= libJoinService.findByPage(params, initPage(1,10000,Direction.DESC, new String[] { "type" }));
+		
+		model.addAttribute("libJoins", page.getContent());
+		model.addAttribute("trainUser",trainUser);
+		return "sys/train/user_edit";
+	}
+	
+	
+	@RequestMapping("/user/save")
+	@ResponseBody
+	public Response userSave(TrainUser param) throws Exception{
+	   	Response response = new  Response();
+	   	if(StringUtils.isNotEmpty(param.getId())) {
+	   		TrainUser trainUser=trainUserService.getById(param.getId());
+	   		trainUser.setRoleType(param.getRoleType());
+	   		trainUser.setPassword(param.getPassword());
+	   		trainUser.setName(param.getName());
+	   		trainUser.setLibId(param.getLibId());
+	   		trainUser.setCreateTime(new Date());
+	   		trainUserService.save(trainUser);
+	   	}else {
+	   		TrainUser trainUser=trainUserService.getTrainUserByMobile(param.getMobile());
+	   		if(trainUser!=null) {
+	   			response.failure("此手机号码已存在。");
+	   		   	return response;
+	   		}
+	   		param.setStatus(1);
+	   		param.setCreateTime(new Date());
+	   		trainUserService.save(param);
+	   	}
+	   	response.success();
+	   	return response;
+	 }
+	
+	
+	@RequestMapping("/user/delete")
+	@ResponseBody
+	public Response userDelete(String id) throws Exception{
+	   	Response response = new  Response();
+	   	if(StringUtils.isNotEmpty(id)) {
+	   		TrainUser trainUser=trainUserService.getById(id);
+	   		trainUser.setStatus(2);
+	   		trainUser.setCreateTime(new Date());
+	   		trainUserService.save(trainUser);
+	   	}
+	   	response.success();
+	   	return response;
+	 }
+	
+	
+	
+	
 	@RequestMapping("/video/list")
 	public String videoList(Model model,
 			@RequestParam(required = false, defaultValue = "10") int pageSize,
@@ -92,6 +196,8 @@ public class TrainController extends BaseController {
 		return "sys/train/video_edit";
 	}
 	
+	
+
 
 	 @RequestMapping("/video/save")
 	 @ResponseBody

+ 104 - 0
src/main/resources/templates/sys/train/user_edit.html

@@ -0,0 +1,104 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
+<link rel="stylesheet" href="https://www.17sucai.com/preview/1528155/2019-03-29/v/css/jsmodern.min.css">
+<script src="https://www.17sucai.com/preview/1528155/2019-03-29/v/js/jsmodern.min.js"></script>
+
+<script type="text/javascript" src="https://www.sharingschool.com/dcui/tools/ueditor/ueditor.config.js?version=1811271348"></script>
+<script type="text/javascript" src="https://www.sharingschool.com/dcui/tools/ueditor/ueditor.all.min.js?version=1812061808"></script>
+<script type="text/javascript" src="https://www.sharingschool.com/dcui/tools/ueditor/lang/zh-cn/zh-cn.js?version=1811271348"></script>
+
+</head>
+<style>
+	.tablelink{margin-right:10px;}
+	.stylecss{
+	      color: red;
+	}
+	.select_width{
+	     width: 220px;
+	}
+	.date_width{
+	     width: 150px;
+	}
+	
+	.tablelist th,td{
+		white-space: nowrap;
+		text-overflow: ellipsis;
+		overflow: hidden;
+	}
+	.tablelist td a{
+    	text-decoration: underline;
+	}
+	
+</style>
+
+
+
+
+<body style="min-width: 100%;margin-top: 20px">
+<div class="formbody">
+	<form id="submitFrom" method="post" class="form-horizontal form-validate">
+		<input type="hidden" name="id" id="id"  th:value="${trainUser.id}"/>
+		<ul class="forminfo">
+			 <li class="clearfix" >
+				<label>权限:<b>*</b></label>
+				<select class="scinput select_width"  name="roleType"  style="width: 345px;"  >
+					<option value="1"  th:selected="${trainUser.roleType==1 ? true : false}">校长端</option>
+					<option value="2"  th:selected="${trainUser.roleType==2 ? true : false}">老师端</option>
+				</select>
+		    </li>
+			<li class="clearfix" >
+				<label>手机号码:<b>*</b></label>
+				<input type="text"  name="mobile" disabled="disabled" class="dfinput fl" th:value="${trainUser.mobile}"/>
+			</li>
+			<li class="clearfix" >
+				<label>密码:<b>*</b></label>
+				<input type="password" name="password"  autocomplete="off" class="dfinput fl" id="password" />
+			</li>
+			<li class="clearfix" >
+				<label>姓名:<b>*</b></label>
+				<input type="text" name="name" class="dfinput fl" id="name" th:value="${trainUser.name}"/>
+			</li>
+			<li class="clearfix" >
+				<label>校区:<b>*</b></label>
+				<select class="scinput select_width"  name="libId"  style="width: 345px;"  >
+					<option th:each="item:${libJoins}" th:value="${item.id}"  th:selected="${trainUser.libId eq item.id ? true : false}">[[${item.leagueName}]]</option>
+				</select>
+			</li>
+			<li>
+				<label>&nbsp;</label>
+				<button type="button" class="btn" onclick="saveFrom()">保存</button>
+				<button type="button" class="btn" onclick="window.history.go(-1);">取消</button>
+			</li>
+		</ul>
+	</form>
+</div>
+</body>
+
+<script type="text/javascript">
+$(function () {
+
+})
+
+function saveFrom(){
+	var url="[[${sysUrl}]]/sys/train/user/save";
+	var params = $("#submitFrom").serialize();
+	$.post(url,params,function(data){
+		if(data.meta.success){
+			parent.layer.msg("保存成功",{icon:1});
+			parent.location.reload();
+			parent.layer.close(parent.layer.getFrameIndex(window.name));
+		}else{
+			parent.layer.msg(data.meta.message,{icon:11});
+		}
+	});
+}
+
+
+</script>
+
+
+</html>

+ 165 - 0
src/main/resources/templates/sys/train/user_list.html

@@ -0,0 +1,165 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
+</head>
+<style>
+	.tablelink{margin-right:10px;}
+	.stylecss{
+	      color: red;
+	}
+	.select_width{
+	     width: 220px;
+	}
+	.date_width{
+	     width: 150px;
+	}
+	
+	.tablelist th,td{
+		white-space: nowrap;
+		text-overflow: ellipsis;
+		overflow: hidden;
+	}
+	.tablelist td a{
+    	text-decoration: underline;
+	}
+	
+</style>
+<body>
+<div class="place">
+	<span>位置:</span>
+	<ul class="placeul">
+		<li><a href="#">视频培训系统</a></li>
+		<li><a href="#">培训视频管理</a></li>
+	</ul>
+</div>
+<div class="rightinfo">
+	<form id="seachform" th:action="@{/sys/train/video/list.html}" method="post">
+	<input type="hidden" name="pageSize" id="pageSize" value="10" />
+	<ul class="seachform">
+		<li>
+			<label>权限:</label>
+			<select class="scinput select_width"  name="roleType"   style="width: 150px;" >
+				<option value="">全部</option>
+				<option value="1" th:selected="${search.get('roleType') eq '1'}" >校长端</option>
+				<option value="2" th:selected="${search.get('roleType') eq '2'}">老师端</option>
+			</select>
+	    </li>
+	    <li>
+			 <label>手机号码:</label>
+			 <input name="mobile" type="text" class="scinput" th:value="${search.mobile}"   />
+		</li>
+		<li>
+			 <label>姓名:</label>
+			 <input name="name" type="text" class="scinput" th:value="${search.name}"   />
+		</li>
+		<li>
+			<input type="button" class="scbtn" value="查询" />
+		</li>
+		<li>
+			<ul class="toolbar">
+				<a  href="javascript:;" th:onclick="'userEdit(\'\')'"  >
+					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>添加老师</li>
+				</a>
+			</ul>
+		</li>
+	</ul>
+	
+<!-- 	<ul class="toolbar" style="margin-bottom: 10px;"> -->
+<!-- 		<li class="click"> -->
+<!-- 			<a th:href="@{/static/sys/excel/exam_info.xlsx}"> -->
+<!-- 				<span><img th:src="@{/static/sys/images/t02.png}"></span>下载导入模板 -->
+<!-- 			</a> -->
+<!-- 		</li> -->
+<!-- 	</ul> -->
+	
+	</form> 
+	
+	
+	
+
+	<table class="tablelist">
+		<thead>
+		    <tr>
+		    	<th >序号</th>
+		    	<th >权限 </th>
+		    	<th >手机号 </th>
+		    	<th >姓名</th>
+		    	<th >创建时间</th>
+		    	<th >操作 </th>
+		    </tr> 
+		</thead>
+		<tbody>
+			<tr th:each="item:${list}" >
+				<td th:text="${itemStat.count}"></td>
+				<td  th:switch="${item.role_type}">
+				   <span th:case="1" style="color:red">校长端</span>
+				   <span th:case="2" style="color:red">老师端</span>
+				</td>
+				<td th:text="${item.mobile}"></td>
+				<td th:text="${item.name}"></td>
+				<td th:text="${item.create_time}"></td>
+				<td >
+					<a href="javascript:;" th:onclick="'userEdit(\''+${item.id}+'\')'" class="tablelink">编辑</a>
+					<a href="javascript:;" th:onclick="'userDelete(\''+${item.id}+'\')'" class="tablelink">删除</a>
+				</td>
+			</tr>
+		</tbody>
+	</table>
+
+	<!-- 分页 -->
+	<div class="pagin">
+    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录,当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
+    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
+   	</div>
+   	
+</div>
+</body>
+
+<script type="text/javascript">
+$(function () {
+	
+})	
+	
+function userEdit(id){
+	var title="编辑老师";
+	parent.layer.open({
+	    type: 2,
+	    title: title,
+	    closeBtn: 1, //不显示关闭按钮
+	    shift: 0.8,
+	    offset: '100px',
+	    area: ['40%', '40%'],
+	    content: '[[${sysUrl}]]/sys/train/user/edit.html?id='+id
+	});
+}
+	
+
+function userDelete(id){
+	parent.layer.confirm("确定删除此老师?", {
+		icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
+	}, function(){
+		var url="[[${sysUrl}]]/sys/train/user/delete";
+		var params ={
+	        'id':id
+	    };
+		$.post(url,params,function(data){
+			if(data.meta.success){
+				parent.layer.msg("删除成功",{icon:1});
+				parent.location.reload();
+			}else{
+				parent.layer.msg(data.meta.message,{icon:11});
+			}
+		});
+	});
+}
+	
+	
+
+
+
+</script>
+
+</html>