From 1c366262ad99f66e2c5ea0d6c9e9cc121a19d7c6 Mon Sep 17 00:00:00 2001 From: qiaowei Date: Thu, 16 May 2019 11:46:40 +0800 Subject: [PATCH] =?utf8?q?=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../supwisdom/dlpay/api/dao/PersonDao.java | 4 + .../dlpay/framework/dao/RoleFunctionDao.java | 6 +- .../dlpay/framework/data/NodeData.java | 2 +- .../dlpay/system/bean/PersonParamBean.java | 13 ++ .../system/controller/UserController.java | 44 +++++ .../dlpay/system/service/UserDataService.java | 13 ++ .../system/service/impl/RoleServiceImpl.java | 2 +- .../service/impl/UserDataServiceImpl.java | 29 ++++ .../templates/system/function/subform.html | 2 +- .../templates/system/user/index.html | 162 ++++++++++++++++++ 10 files changed, 271 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/supwisdom/dlpay/system/bean/PersonParamBean.java create mode 100644 src/main/java/com/supwisdom/dlpay/system/controller/UserController.java create mode 100644 src/main/java/com/supwisdom/dlpay/system/service/UserDataService.java create mode 100644 src/main/java/com/supwisdom/dlpay/system/service/impl/UserDataServiceImpl.java create mode 100644 src/main/resources/templates/system/user/index.html diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java index 9b036615..988afaaa 100644 --- a/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java +++ b/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java @@ -1,6 +1,8 @@ package com.supwisdom.dlpay.api.dao; import com.supwisdom.dlpay.api.domain.TPerson; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @@ -15,4 +17,6 @@ public interface PersonDao extends JpaRepository { TPerson findByIdentity(String idtype, String idno); TPerson findByUserid(String userid); + + Page findAllByNameContaining(String name, Pageable pageable); } diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/RoleFunctionDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/RoleFunctionDao.java index 565ebe63..a8381a1d 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/dao/RoleFunctionDao.java +++ b/src/main/java/com/supwisdom/dlpay/framework/dao/RoleFunctionDao.java @@ -18,10 +18,10 @@ public interface RoleFunctionDao extends JpaRepository { List findByRoleId(String roleId); - @Query(value = " select f.id||'' as id ,f.parentid||'' as pid,f.name,case when rf.id is null then 0 else 1 end as checked from tb_function f " + - " left join tb_role_function rf on rf.functionid = f.id and rf.roleid=?1 " + + @Query(value = " select f.id||'' as id ,f.parentid||'' as pid,f.name,case when rf.id is null then 0 else 1 end as checked,case when rf.id is null then 1 else 0 end as open from tb_function f " + + " left join tb_role_function rf on rf.functionid = f.id and rf.roleid=?1 " + " union all " + - " select r.id||'_res' as id,r.function_id||'' as pid,r.name,case when p.id is null then 0 else 1 end as checked from tb_resource r " + + " select r.id||'_res' as id,r.function_id||'' as pid,r.name,case when p.id is null then 0 else 1 end as checked,0 as open from tb_resource r " + " left join tb_permission p on p.resid = r.id and p.roleid=?1 " , nativeQuery = true) List findByRoleIdNative(String roleId); diff --git a/src/main/java/com/supwisdom/dlpay/framework/data/NodeData.java b/src/main/java/com/supwisdom/dlpay/framework/data/NodeData.java index 19197d38..8f4975a2 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/data/NodeData.java +++ b/src/main/java/com/supwisdom/dlpay/framework/data/NodeData.java @@ -7,7 +7,7 @@ public interface NodeData { String getName(); - boolean getOpen(); + Integer getOpen(); Integer getChecked(); } diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/PersonParamBean.java b/src/main/java/com/supwisdom/dlpay/system/bean/PersonParamBean.java new file mode 100644 index 00000000..591bb04b --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/bean/PersonParamBean.java @@ -0,0 +1,13 @@ +package com.supwisdom.dlpay.system.bean; + +public class PersonParamBean extends PageBean { + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java b/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java new file mode 100644 index 00000000..087e71c4 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/controller/UserController.java @@ -0,0 +1,44 @@ +package com.supwisdom.dlpay.system.controller; + +import com.supwisdom.dlpay.api.domain.TPerson; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.framework.util.WebConstant; +import com.supwisdom.dlpay.system.bean.PersonParamBean; +import com.supwisdom.dlpay.system.service.UserDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class UserController { + @Autowired + private UserDataService userDataService; + + + @GetMapping("/user/index") + public String sysparaView() { + return "system/user/index"; + } + @GetMapping("/user/list") + @PreAuthorize("hasPermission('/user/list','')") + @ResponseBody + public PageResult getDataList(@RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize, + @RequestParam(value = "searchkey", required = false) String searchKey) { + try { + if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; + if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; + PersonParamBean searchBean = new PersonParamBean(); + searchBean.setPageNo(pageNo); + searchBean.setName(searchKey); + searchBean.setPageSize(pageSize); + return userDataService.getPersonsByKey(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); + } + } +} diff --git a/src/main/java/com/supwisdom/dlpay/system/service/UserDataService.java b/src/main/java/com/supwisdom/dlpay/system/service/UserDataService.java new file mode 100644 index 00000000..d5a614e0 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/service/UserDataService.java @@ -0,0 +1,13 @@ +package com.supwisdom.dlpay.system.service; + +import com.supwisdom.dlpay.api.domain.TPerson; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.system.bean.PersonParamBean; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +public interface UserDataService { + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true) + PageResult getPersonsByKey(PersonParamBean param); + +} diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/RoleServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/RoleServiceImpl.java index ea049e3c..c96485cb 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/impl/RoleServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/RoleServiceImpl.java @@ -154,7 +154,7 @@ public class RoleServiceImpl implements RoleService { zTreeNode.setId(data.getId()); zTreeNode.setName(data.getName()); zTreeNode.setChecked(data.getChecked() == 0 ? false : true); - zTreeNode.setOpen(true); + zTreeNode.setOpen(data.getOpen() == 0 ? false : true); ret.add(zTreeNode); } return ret; diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/UserDataServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/UserDataServiceImpl.java new file mode 100644 index 00000000..aab27cf5 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/UserDataServiceImpl.java @@ -0,0 +1,29 @@ +package com.supwisdom.dlpay.system.service.impl; + +import com.supwisdom.dlpay.api.dao.PersonDao; +import com.supwisdom.dlpay.api.domain.TPerson; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.framework.util.StringUtil; +import com.supwisdom.dlpay.system.bean.PersonParamBean; +import com.supwisdom.dlpay.system.service.UserDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; + +@Service +public class UserDataServiceImpl implements UserDataService { + @Autowired + private PersonDao personDao; + + @Override + public PageResult getPersonsByKey(PersonParamBean param) { + Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize() + , Sort.by("id")); + if (!StringUtil.isEmpty(param.getName())) { + return new PageResult<>(personDao.findAllByNameContaining(param.getName(), pageable)); + } + return new PageResult<>(personDao.findAll(pageable)); + } +} diff --git a/src/main/resources/templates/system/function/subform.html b/src/main/resources/templates/system/function/subform.html index def716f3..479452c5 100755 --- a/src/main/resources/templates/system/function/subform.html +++ b/src/main/resources/templates/system/function/subform.html @@ -63,7 +63,7 @@ } let parentId = admin.getTempData("parentId"); if(parentId){ - form.val('form', {"parentId":parentId}); + form.val('subform', {"parentId":parentId}); } // 表单提交事件 form.on('submit(subform-submit)', function (data) { diff --git a/src/main/resources/templates/system/user/index.html b/src/main/resources/templates/system/user/index.html new file mode 100644 index 00000000..8035a583 --- /dev/null +++ b/src/main/resources/templates/system/user/index.html @@ -0,0 +1,162 @@ +
+
+

用户管理

+ + 用户中心 + 用户管理 + +
+
+
+ 搜索: +   + + +
+
+
+
+ \ No newline at end of file -- 2.17.1