Bläddra i källkod

后台图书管理员跟小塾管理员分开

shenhao 4 år sedan
förälder
incheckning
961951bb4a

+ 10 - 0
src/main/java/com/ssj/bean/weixin/libmy/domain/TbLibReadManager.java

@@ -44,6 +44,8 @@ public class TbLibReadManager extends BaseEntity {
      */
     private Integer state;
 
+    private Date createTime;
+
     public String getLibId() {
         return libId;
     }
@@ -107,4 +109,12 @@ public class TbLibReadManager extends BaseEntity {
     public void setState(Integer state) {
         this.state = state;
     }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
 }

+ 1 - 1
src/main/java/com/ssj/dao/weixin/user/dao/impl/UserQueryImpl.java

@@ -74,7 +74,7 @@ public class UserQueryImpl implements  UserQueryDao {
 			queryParams.add(searchParams.get("type"));
 		}else if("0".equals(type)||"1".equals(type)){
 			//图书馆馆长以及馆长助理
-			selSQL.append("  from  tb_user  u  where not exists (select 1 from tb_lib_manager t where t.user_id = u.id and t.lib_id is not null and t.state=1 and (t.type BETWEEN 0 and 1))    ");
+			selSQL.append("  from  tb_user  u  where not exists (select 1 from tb_lib_read_manager t where t.user_id = u.id and t.lib_id is not null and t.state=1 and (t.type BETWEEN 0 and 1))    ");
 		}else{
 			selSQL.append("  from  tb_user  u  where not exists (select 1 from tb_lib_manager t where t.user_id = u.id and t.lib_id is not null and t.state=1 )   ");
 		}

+ 16 - 0
src/main/java/com/ssj/service/sys/manager/dao/ReadManagerDao.java

@@ -0,0 +1,16 @@
+package com.ssj.service.sys.manager.dao;
+
+import com.ssj.bean.weixin.libmy.domain.TbLibReadManager;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sh
+ * @className ReadManagerDao
+ * @description repository
+ * @date 2021/3/15
+ */
+@Repository
+public interface ReadManagerDao extends JpaRepository<TbLibReadManager,String> {
+}

+ 32 - 0
src/main/java/com/ssj/service/sys/manager/service/impl/ReadManagerServiceImpl.java

@@ -0,0 +1,32 @@
+package com.ssj.service.sys.manager.service.impl;
+
+import com.ssj.bean.weixin.libmy.domain.TbLibReadManager;
+import com.ssj.framework.core.common.service.BaseServiceImpl;
+import com.ssj.service.sys.manager.dao.ReadManagerDao;
+import com.ssj.service.sys.manager.service.IReadManagerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author sh
+ * @className ReadManagerServiceImpl
+ * @description
+ * @date 2021/3/15
+ */
+@Service
+public class ReadManagerServiceImpl extends BaseServiceImpl<TbLibReadManager,String> implements IReadManagerService {
+
+    @Autowired
+    private ReadManagerDao dao;
+
+
+    @Override
+    public PagingAndSortingRepository<TbLibReadManager, String> getDao() {
+        return dao;
+    }
+
+}

+ 52 - 28
src/main/java/com/ssj/service/weixin/library/service/impl/LibJoinServiceImpl.java

@@ -6,6 +6,7 @@ import com.ssj.bean.sys.imlibuser.TbClass;
 import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
 import com.ssj.bean.weixin.libmy.domain.TbLibManager;
 import com.ssj.bean.weixin.libmy.domain.TbLibManagerAudit;
+import com.ssj.bean.weixin.libmy.domain.TbLibReadManager;
 import com.ssj.dao.weixin.library.dao.ILibJoinDao;
 import com.ssj.dao.weixin.library.dao.ILibJoinQueryDao;
 import com.ssj.framework.basic.utils.DateHelper;
@@ -18,6 +19,7 @@ import com.ssj.framework.core.util.StringUtil;
 import com.ssj.framework.core.util.SystemResourceLocator;
 import com.ssj.framework.weixin.util.BarcodeFactory;
 import com.ssj.service.sys.imlibuser.service.TbClassService;
+import com.ssj.service.sys.manager.service.IReadManagerService;
 import com.ssj.service.weixin.library.service.IBookManagerService;
 import com.ssj.service.weixin.library.service.ILibJoinService;
 import com.ssj.service.weixin.library.service.LibManagerAuditService;
@@ -66,7 +68,10 @@ public class LibJoinServiceImpl extends BaseServiceImpl<TbLibJoin, String> imple
 
 	@Autowired
 	private LibManagerAuditService auditService;
-	 
+
+	@Autowired
+	private IReadManagerService readManagerService;
+
 	 
 	@Override
 	public PagingAndSortingRepository<TbLibJoin, String> getDao() {
@@ -101,21 +106,54 @@ public class LibJoinServiceImpl extends BaseServiceImpl<TbLibJoin, String> imple
 			Date now = new Date();
 			TbLibJoin join =  this.getById(libId);
 			for (int i = 0; i < ids.length; i++) {
+
 				String userId = ids[i];
-				libJoinDao.libManagerDeleteIn(libId, userId,type);
-				TbLibManager  tb = new  TbLibManager();
-				tb.setLibId(libId);
-				tb.setUserId(userId);
-				tb.setType(type);
-				tb.setName(names[i]==null?userService.getById(userId).getName():names[i]);
-				if(StringUtil.isNotEmpty(mobiles[i])){
-					tb.setTelephone(mobiles[i]);
+				if(type==0 || type ==1){
+					TbLibReadManager manager = new TbLibReadManager();
+					manager.setLibId(libId);
+					manager.setUserId(userId);
+					manager.setType(type);
+					manager.setName(names[i]==null?userService.getById(userId).getName():names[i]);
+					if(StringUtil.isNotEmpty(mobiles[i])){
+						manager.setTelephone(mobiles[i]);
+					}
+
+					manager.setCreateTime(now);
+					manager.setState(1);
+					readManagerService.save(manager);
+				}else{
+					libJoinDao.libManagerDeleteIn(libId, userId,type);
+					TbLibManager  tb = new  TbLibManager();
+					tb.setLibId(libId);
+					tb.setUserId(userId);
+					tb.setType(type);
+					tb.setName(names[i]==null?userService.getById(userId).getName():names[i]);
+					if(StringUtil.isNotEmpty(mobiles[i])){
+						tb.setTelephone(mobiles[i]);
+					}
+
+					tb.setCreateTime(now);
+					tb.setLibtype(join.getLibtype()>1?2:1);
+					tb.setState(1);
+					tb = managerService.save(tb);
+
+					if(type==4){
+						//校长,插入audit记录
+						TbLibManagerAudit  audit = new  TbLibManagerAudit();
+						audit.setStatus(1);
+						audit.setTelephone(tb.getTelephone());
+						audit.setLibManagerId(tb.getId());
+						audit.setLibId(tb.getLibId());
+						audit.setType(tb.getType());
+						audit.setCreateTime(now);
+						audit.setLastUpdateTime(now);
+						audit.setUserId(tb.getUserId());
+						audit.setName(tb.getName());
+						//BeanUtils.copyProperties(tb,audit);
+						auditService.save(audit);
+					}
 				}
 
-				tb.setCreateTime(now);
-				tb.setLibtype(join.getLibtype()>1?2:1);
-				tb.setState(1);
-				tb = managerService.save(tb);
 				if(type==1){
 					userId="JIEYUE"+userId;//图书借阅
 		         }else if(type==2){
@@ -125,21 +163,7 @@ public class LibJoinServiceImpl extends BaseServiceImpl<TbLibJoin, String> imple
 		         }else{
 		        	 userId ="CD"+userId;
 		         }
-				if(type==4){
-					//校长,插入audit记录
-					TbLibManagerAudit  audit = new  TbLibManagerAudit();
-					audit.setStatus(1);
-					audit.setTelephone(tb.getTelephone());
-					audit.setLibManagerId(tb.getId());
-					audit.setLibId(tb.getLibId());
-					audit.setType(tb.getType());
-					audit.setCreateTime(now);
-					audit.setLastUpdateTime(now);
-					audit.setUserId(tb.getUserId());
-					audit.setName(tb.getName());
-					//BeanUtils.copyProperties(tb,audit);
-					auditService.save(audit);
-				}
+
 				 tokenManager.createManageType(userId,libId);
 				 tokenManager.delToken(userId);
 			}

+ 34 - 0
src/main/java/com/ssj/sys/controller/SysLibController.java

@@ -19,6 +19,7 @@ import com.ssj.framework.core.util.PropertiesUtil;
 import com.ssj.framework.core.util.ResponseEntity;
 import com.ssj.framework.core.util.SystemResourceLocator;
 import com.ssj.framework.weixin.util.BarcodeFactory;
+import com.ssj.service.sys.manager.service.IReadManagerService;
 import com.ssj.service.sys.organization.service.OrganizationService;
 import com.ssj.service.sys.sort.service.SortService;
 import com.ssj.service.weixin.library.service.*;
@@ -106,6 +107,9 @@ public class SysLibController extends BaseController {
 
     @Autowired
 	 private ZuoybCourseService zuoybCourseService;
+
+    @Autowired
+	private IReadManagerService readManagerService;
     
 
     
@@ -1202,6 +1206,25 @@ public class SysLibController extends BaseController {
 		model.addAttribute("ws", lib);
 		return "sys/lib/libManagerEdit";
 	}
+	/**
+	 * 管理员修改资料
+	 *
+	 * @param model
+	 * @param id
+	 * @return
+	 * @throws Exception
+	 */
+	@RequestMapping("/libReadManagerEdit")
+	public String libReadManagerEdit(Model model, @RequestParam(defaultValue = "0") String id) throws Exception {
+		TbLibReadManager lib = readManagerService.getById(id);
+		if (lib == null) {
+			lib = new TbLibReadManager();
+			// lib.setOrgCode(orgCode());
+		}
+
+		model.addAttribute("ws", lib);
+		return "sys/lib/libReadManagerEdit";
+	}
 	@RequestMapping("/libManagerAdd4")
 	public String libManagerAdd4(Model model, @RequestParam(defaultValue = "0") String libId) throws Exception {
 
@@ -1224,6 +1247,17 @@ public class SysLibController extends BaseController {
 		response.success();
     	return response;
 	}
+	@RequestMapping(value = "/readManagerSave", method = RequestMethod.POST)
+	@ResponseBody
+	public Response readManagerSave(  TbLibManager tbLibManager){
+		Response response = new  Response();
+		TbLibReadManager tm = readManagerService.getById(tbLibManager.getId());
+		tm.setName(tbLibManager.getName());
+		readManagerService.save(tm);
+
+		response.success();
+    	return response;
+	}
 
 	@RequestMapping(value = "/managerAddSave", method = RequestMethod.POST)
 	@ResponseBody

+ 126 - 0
src/main/resources/templates/sys/lib/libReadManagerEdit.html

@@ -0,0 +1,126 @@
+<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/jquery.validate.min.js" th:src="@{/static/sys/js/jquery.validate.min.js}"></script>
+	<script src="sys/js/jquery-validation/messages_zh.js" th:src="@{/static/sys/js/jquery-validation/messages_zh.js}"></script>
+
+
+	<style>
+		body {
+			min-width: 180px;
+		}
+
+		.select1 {
+			width: 100%;
+			height: 32px;
+			line-height: 32px;
+			border-top: solid 1px #a7b5bc;
+			border-left: solid 1px #a7b5bc;
+			border-right: solid 1px #ced9df;
+			border-bottom: solid 1px #ced9df;
+			opacity: 1;
+			margin-bottom: 10px;
+		}
+		.selectg {
+			width: 100%;
+			height: 32px;
+			line-height: 32px;
+			border-top: solid 1px #a7b5bc;
+			border-left: solid 1px #a7b5bc;
+			border-right: solid 1px #ced9df;
+			border-bottom: solid 1px #ced9df;
+			opacity: 1;
+			margin-bottom: 10px;
+		}
+
+		.btn {
+			width: 100px;
+		}
+
+		label.control-label-error {
+			color: Red;
+		}
+
+		.forminfo li label {
+			width: 85px;
+			line-height: 34px;
+			display: block;
+			float: left;
+		}
+	</style>
+</head>
+
+<body>
+<div class="formbody">
+	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
+		<input type="hidden" name="id" th:if="${ws.id}" th:value="${ws.id}"/>
+		<ul class="forminfo">
+			<li class="clearfix">
+				<label>人员姓名:<b>*</b></label>
+				<input type="text" id="name" class="dfinput fl" name="name"  th:value="${ws.name}"/>
+			</li>
+			<li>
+				<label>&nbsp;</label>
+				<button type="submit" class="btn">保存</button>
+				<button type="button" class="btn" onclick="closeWin();">取消</button>
+			</li>
+		</ul>
+	</form>
+</div>
+</body>
+<script type="text/javascript">
+
+	$(function(){
+
+
+
+
+		$("#submitFrom").validate({
+			rules : {
+
+				name : {
+					required : true
+				}
+			},
+			messages: {
+				name : {
+					required : "名字不能为空"
+				},
+
+			},
+			errorPlacement : function(error, element) {
+				error.appendTo(element.parent());
+			},
+			submitHandler : function(form) {
+				roleFrom();
+			}
+		});
+
+	});
+	function roleFrom(){
+		var url="[[${sysUrl}]]/sys/lib/readManagerSave";
+		var params = $("#submitFrom").serialize();
+		$.post(url,params,function(data){
+			if(data != null){
+				if(data.meta.success){
+					parent.layer.msg("操作成功",{icon:1});
+					closeWin();
+				}else{
+					parent.layer.msg(data.meta.message,{icon:11});
+					closeWin();
+				}
+			}
+
+		});
+	}
+	function closeWin(){
+		parent.location.reload();
+		parent.layer.close(parent.layer.getFrameIndex(window.name));
+	}
+
+
+
+</script>
+</html>