| | |
| | | RequestContext.getCurrentInstance().execute("PF('dialog').show()"); |
| | | } |
| | | |
| | | public void btnPermissionClick() { |
| | | if (this.selectedList == null |
| | | || this.selectedList.size() == 0) { |
| | | FacesUtils.warn("请选择数据。"); |
| | | return; |
| | | } |
| | | if (this.selectedList.size() > 1) { |
| | | FacesUtils.warn("只能选择一个数据进行修改。"); |
| | | return; |
| | | } |
| | | this.baseRole = this.baseRoleService.getBaseRole(this.selectedList.get(0).getId()); |
| | | RequestContext.getCurrentInstance().execute("PF('btnDialog').show()"); |
| | | } |
| | | |
| | | public void userPermissionClick() { |
| | | if (this.selectedList == null |
| | | || this.selectedList.size() == 0) { |
| | | FacesUtils.warn("请选择数据。"); |
| | | return; |
| | | } |
| | | if (this.selectedList.size() > 1) { |
| | | FacesUtils.warn("只能选择一个数据进行修改。"); |
| | | return; |
| | | } |
| | | this.baseRole = this.baseRoleService.getBaseRole(this.selectedList.get(0).getId()); |
| | | RequestContext.getCurrentInstance().execute("PF('userDialog').show()"); |
| | | } |
| | | |
| | | public void onSaveBtnClick() { |
| | | try { |
| | | // 新建 |
| | |
| | | FacesUtils.warn("请选择角色权限。"); |
| | | return; |
| | | } |
| | | |
| | | baseRole.setUserPermission("自己"); |
| | | baseRole.setBtnPermission("新增,修改,删除,导入"); |
| | | this.baseRoleService.insertBaseRole(this.baseRole); |
| | | |
| | | FacesUtils.info("新建成功。"); |
| | |
| | | FacesUtils.warn("操作失败。"); |
| | | } |
| | | } |
| | | /** |
| | | * 人员管理按钮权限修改 |
| | | */ |
| | | public void onSaveBtnPermission() { |
| | | try { |
| | | if (this.baseRole == null) { |
| | | FacesUtils.warn("修改对象为空。"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (this.baseRole.getBtnPermissions() == null || this.baseRole.getBtnPermissions().size() == 0) { |
| | | FacesUtils.warn("请选择功能。"); |
| | | return; |
| | | } |
| | | |
| | | this.baseRoleService.updateUserMngPageBtn(this.baseRole); |
| | | |
| | | FacesUtils.info("修改成功。"); |
| | | RequestContext.getCurrentInstance().execute("PF('btnDialog').hide()"); |
| | | } catch (Exception e) { |
| | | logger.error("操作失败。", e); |
| | | FacesUtils.warn("操作失败。"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 人员管理人员可见权限修改 |
| | | */ |
| | | public void onSaveUserPermission() { |
| | | try { |
| | | if (this.baseRole == null) { |
| | | FacesUtils.warn("修改对象为空。"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (this.baseRole.getUserPermission() == null) { |
| | | FacesUtils.warn("请选择可见范围。"); |
| | | return; |
| | | } |
| | | |
| | | this.baseRoleService.updateUserMngPageBtn(this.baseRole); |
| | | |
| | | FacesUtils.info("修改成功。"); |
| | | RequestContext.getCurrentInstance().execute("PF('userDialog').hide()"); |
| | | } catch (Exception e) { |
| | | logger.error("操作失败。", e); |
| | | FacesUtils.warn("操作失败。"); |
| | | } |
| | | } |
| | | |
| | | public void onDeleteBtnClick() { |
| | | try { |
| | |
| | | private List<Waster> wasterSelectList; |
| | | private String project; |
| | | private String company; |
| | | private BaseRole role; |
| | | |
| | | public List<BaseRole> getRoleList() { |
| | | return roleList; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void initPage() { |
| | | sysUser = sysUserService.getSysUser(getUser().getId()); |
| | | role = baseRoleService.getRoleByUserId(sysUser.getId()); |
| | | } |
| | | public boolean isAccess(String info) { |
| | | String permission = role.getBtnPermission(); |
| | | return permission.contains(info); |
| | | } |
| | | |
| | | public LazyDataModel<SysUser> getDataModel() { |
| | | if (this.dataModel == null) { |
| | | this.dataModel = new LazyDataModel<SysUser>() { |
| | |
| | | public List<SysUser> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) { |
| | | List<SysUser> list = null; |
| | | try { |
| | | int count = sysUserService.getSysUserTotalCount(arp, name,departmentName,project,company); |
| | | this.setRowCount(count); |
| | | if (count > 0) { |
| | | list = sysUserService.getSysUserList(arp, name,departmentName,project,company, first, pageSize); |
| | | //做可见人员过滤 |
| | | String userPermission = role.getUserPermission(); |
| | | if (userPermission.contains("自己")) { |
| | | list = Collections.singletonList(sysUserService.getSysUser(UserMngController.this.sysUser.getId())); |
| | | this.setRowCount(1); |
| | | |
| | | }else if (userPermission.contains("课题组")){ |
| | | project = sysUser.getProject(); |
| | | int count = sysUserService.getUserCountInProject(arp, name,departmentName,project,company); |
| | | this.setRowCount(count); |
| | | if (count > 0) { |
| | | list = sysUserService.getUserInProject(arp, name,departmentName,project,company, first, pageSize); |
| | | } |
| | | |
| | | }else{ |
| | | int count = sysUserService.getSysUserTotalCount(arp, name,departmentName,project,company); |
| | | this.setRowCount(count); |
| | | if (count > 0) { |
| | | list = sysUserService.getSysUserList(arp, name,departmentName,project,company, first, pageSize); |
| | | } |
| | | } |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | |
| | | |
| | | public void insertBaseRole(BaseRole baseRole) throws DataAccessException; |
| | | public int updateBaseRole(BaseRole baseRole) throws DataAccessException; |
| | | public int updateBaseRoleInfo(BaseRole baseRole); |
| | | public int deleteBaseRoles(List<String> ids) throws DataAccessException; |
| | | |
| | | BaseRole getBaseRoleByUser(String id); |
| | | } |
| | |
| | | <id property="id" column="id"/> |
| | | <result property="name" column="name"></result> |
| | | <result property="memo" column="memo"></result> |
| | | <result property="userPermission" column="user_permission"></result> |
| | | <result property="btnPermission" column="btn_permission"></result> |
| | | <result property="createTime" column="create_time"></result> |
| | | <result property="updateTime" column="update_time"></result> |
| | | <result property="validFlag" column="valid_flag" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></result> |
| | |
| | | where valid_flag = 1 |
| | | <include refid="queryWhereSql"/> |
| | | </select> |
| | | <select id="getBaseRoleByUser" resultMap="BaseRole"> |
| | | SELECT br.* FROM base_role br |
| | | LEFT JOIN sys_user su on su.role_id = br.id |
| | | where su.id=#{0} |
| | | and br.valid_flag = 1 |
| | | </select> |
| | | |
| | | <insert id="insertBaseRole" parameterType="com.nanometer.smartlab.entity.BaseRole"> |
| | | insert into base_role(id, name, memo, valid_flag, create_time, update_time) |
| | | values (#{id}, #{name}, #{memo}, 1, now(), now()) |
| | | insert into base_role(id, name, memo, valid_flag, create_time, update_time |
| | | <if test="btnPermission !=null"> |
| | | ,btn_permission |
| | | </if> |
| | | <if test="userPermission !=null"> |
| | | ,user_permission |
| | | </if>) |
| | | values (#{id}, #{name}, #{memo}, 1, now(), now() |
| | | <if test="btnPermission !=null"> |
| | | ,#{btnPermission} |
| | | </if> |
| | | <if test="userPermission !=null"> |
| | | ,#{userPermission} |
| | | </if>) |
| | | </insert> |
| | | |
| | | <update id="updateBaseRole" parameterType="com.nanometer.smartlab.entity.BaseRole"> |
| | |
| | | where id=#{id} |
| | | </update> |
| | | |
| | | <update id="updateBaseRoleInfo" parameterType="com.nanometer.smartlab.entity.BaseRole"> |
| | | update base_role |
| | | <set> |
| | | <if test="btnPermission != null"> btn_permission=#{btnPermission},</if> |
| | | <if test="userPermission != null"> user_permission=#{userPermission},</if> |
| | | update_time=now() |
| | | </set> |
| | | |
| | | where id=#{id} |
| | | </update> |
| | | <update id="deleteBaseRoles" parameterType="java.util.List"> |
| | | update base_role set valid_flag=0, update_time=now() |
| | | where id in |
| | |
| | | List<LaboratoryVo.LaboratoryUser> getUserByProject(@Param("project") String project); |
| | | |
| | | List<SysUser> getUserByArp(String arp); |
| | | |
| | | int getUserCountInProject(Map params); |
| | | |
| | | List<SysUser> getUserInProject(Map params); |
| | | } |
| | |
| | | <if test="seeFlag != null"> |
| | | and su.see_flag = #{seeFlag} |
| | | </if> |
| | | <if test="seeFlag != null"> |
| | | and su.see_flag = #{seeFlag} |
| | | </if> |
| | | <if test="editId != null and editId != ''"> |
| | | and su.id != #{editId} |
| | | </if> |
| | |
| | | select * from sys_user |
| | | where arp = #{0} and valid_flag = 1 |
| | | </select> |
| | | <select id="getUserCountInProject" parameterType="java.util.Map" resultType="java.lang.Integer"> |
| | | select count(1) from sys_user as su |
| | | left join base_meta bm on su.department = bm.id |
| | | left join base_meta bm1 on bm1.id = su.company |
| | | where su.valid_flag = 1 |
| | | <if test="departmentNameLike != null and departmentNameLike != ''"> |
| | | and bm.meta_value like concat("%",#{departmentNameLike},"%") |
| | | </if> |
| | | <if test="arp != null and arp != ''"> |
| | | and su.arp like concat("%",#{arp},"%") |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | and su.name like concat("%",#{name},"%") |
| | | </if> |
| | | <if test="company != null and company != ''"> |
| | | and bm1.meta_value like concat("%",#{company},"%") |
| | | </if> |
| | | <if test="project != null and project != ''"> |
| | | and |
| | | <foreach item="item" index="index" collection="project.split(',')" open="(" separator="or" close=")"> |
| | | su.project like concat("%",#{item},"%") |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | <select id="getUserInProject" parameterType="java.util.Map" resultMap="SysUser"> |
| | | select su.*, br.name as roleName from sys_user as su |
| | | left join base_role as br on su.role_id = br.id |
| | | left join base_meta bm on su.department = bm.id |
| | | left join base_meta bm1 on bm1.id = su.company |
| | | where su.valid_flag = 1 |
| | | <if test="departmentNameLike != null and departmentNameLike != ''"> |
| | | and bm.meta_value like concat("%",#{departmentNameLike},"%") |
| | | </if> |
| | | <if test="arp != null and arp != ''"> |
| | | and su.arp like concat("%",#{arp},"%") |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | and su.name like concat("%",#{name},"%") |
| | | </if> |
| | | <if test="company != null and company != ''"> |
| | | and bm1.meta_value like concat("%",#{company},"%") |
| | | </if> |
| | | <if test="project != null and project != ''"> |
| | | and |
| | | <foreach item="item" index="index" collection="project.split(',')" open="(" separator="or" close=")"> |
| | | su.project like concat("%",#{item},"%") |
| | | </foreach> |
| | | </if> |
| | | order by su.arp ASC |
| | | <if test="first != null and pageSize != null"> |
| | | limit #{first}, #{pageSize} |
| | | </if> |
| | | </select> |
| | | <update id="updateUserPointBySelective" parameterType="java.util.Map"> |
| | | update sys_user set point=#{point} |
| | | <where> |
| | |
| | | package com.nanometer.smartlab.entity; |
| | | |
| | | import com.nanometer.smartlab.entity.enumtype.ValidFlag; |
| | | import org.apache.commons.lang.StringUtils; |
| | | |
| | | import java.io.Serializable; |
| | | import java.sql.Timestamp; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private ValidFlag validFlag; |
| | | private Timestamp createTime; |
| | | private Timestamp updateTime; |
| | | private String btnPermission; |
| | | private String userPermission; |
| | | private List<String> btnPermissions; |
| | | |
| | | private List<String> pageIdList; |
| | | |
| | |
| | | public void setPageIdList(List<String> pageIdList) { |
| | | this.pageIdList = pageIdList; |
| | | } |
| | | |
| | | public String getBtnPermission() { |
| | | return btnPermission; |
| | | } |
| | | |
| | | public void setBtnPermission(String btnPermission) { |
| | | if (StringUtils.isNotBlank(btnPermission)) { |
| | | btnPermissions = Arrays.asList(btnPermission.split(",")); |
| | | } |
| | | this.btnPermission = btnPermission; |
| | | } |
| | | |
| | | public String getUserPermission() { |
| | | return userPermission; |
| | | } |
| | | |
| | | public void setUserPermission(String userPermission) { |
| | | this.userPermission = userPermission; |
| | | } |
| | | |
| | | public List<String> getBtnPermissions() { |
| | | return btnPermissions; |
| | | } |
| | | |
| | | public void setBtnPermissions(List<String> btnPermissions) { |
| | | this.btnPermissions = btnPermissions; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public BaseRole insertBaseRole(BaseRole baseRole); |
| | | public boolean updateBaseRole(BaseRole baseRole); |
| | | public boolean deleteBaseRole(List<BaseRole> baseRoleList); |
| | | |
| | | public void updateUserMngPageBtn(BaseRole baseRole); |
| | | public void updateUserMngPageUser(BaseRole baseRole); |
| | | |
| | | BaseRole getRoleByUserId(String id); |
| | | } |
| | |
| | | throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), ex); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateUserMngPageBtn(BaseRole baseRole) { |
| | | |
| | | if (baseRole.getBtnPermissions() != null && baseRole.getBtnPermissions().size() > 0) { |
| | | List<String> btnPermissions = baseRole.getBtnPermissions(); |
| | | for (String btnPermission : btnPermissions) { |
| | | if (btnPermissions.indexOf(btnPermission) == 0) { |
| | | baseRole.setBtnPermission(btnPermission); |
| | | } else { |
| | | baseRole.setBtnPermission(baseRole.getBtnPermission() + "," + btnPermission); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //更新操作可见 |
| | | baseRoleDao.updateBaseRoleInfo(baseRole); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateUserMngPageUser(BaseRole baseRole) { |
| | | //更新人员可见 |
| | | baseRoleDao.updateBaseRoleInfo(baseRole); |
| | | } |
| | | |
| | | @Override |
| | | public BaseRole getRoleByUserId(String id) { |
| | | return baseRoleDao.getBaseRoleByUser(id); |
| | | } |
| | | } |
| | |
| | | |
| | | List<SysUser> getSysUserList(String arp, String name,String departmentName,String project,String company,Integer first, Integer pageSize); |
| | | int getSysUserTotalCount(String arp, String name,String departmentName,String project,String company); |
| | | int getUserCountInProject(String arp, String name,String departmentName,String project,String company); |
| | | List<SysUser> getUserInProject(String arp, String name,String departmentName,String project,String company,Integer first, Integer pageSize); |
| | | SysUser getSysUser(String id); |
| | | SysUser getSysUserForSuppllier(String id); |
| | | SysUser getSysUserByAccount(String account); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getUserCountInProject(String arp, String name, String departmentName, String project, String company) { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("arp", arp); |
| | | params.put("name", name); |
| | | params.put("departmentNameLike", departmentName); |
| | | params.put("project", project); |
| | | params.put("company", company); |
| | | return sysUserDao.getUserCountInProject(params); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUser> getUserInProject(String arp, String name, String departmentName, String project, String company, Integer first, Integer pageSize) { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("arp", arp); |
| | | params.put("name", name); |
| | | params.put("departmentNameLike", departmentName); |
| | | params.put("project", project); |
| | | params.put("company", company); |
| | | return sysUserDao.getUserInProject(params); |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public SysUser getSysUser(String id) { |
| | | try { |
| | |
| | | <property name="title" value="人员管理"></property> |
| | | <property name="page" value="user_mng"></property> |
| | | <property name="privilegeCode" value="user_mng"></property> |
| | | <property name="initClazz" value="userMngController"></property> |
| | | <property name="initMethod" value="initPage"></property> |
| | | </bean> |
| | | <bean class="com.nanometer.smartlab.model.MenuModel"> |
| | | <property name="id" value="role_mng"></property> |
| | |
| | | <p:outputLabel styleClass="title" value="角色管理"></p:outputLabel> |
| | | </p:panel> |
| | | <p:panel styleClass="center-body"> |
| | | <p:panelGrid columns="3" styleClass="btn"> |
| | | <p:panelGrid columns="5" styleClass="btn"> |
| | | <p:commandButton value="新建" styleClass="new-btn" |
| | | process="@this" |
| | | actionListener="#{roleMngController.onNewBtnClick}" |
| | |
| | | update="@form"> |
| | | <p:confirm header="确认" message="确认操作?"></p:confirm> |
| | | </p:commandButton> |
| | | |
| | | <p:commandButton value="按钮权限" styleClass="edit-btn" |
| | | process="@form" |
| | | actionListener="#{roleMngController.btnPermissionClick}" |
| | | update=":btnDialog,:btnDialogForm"/> |
| | | |
| | | <p:commandButton value="人员权限" styleClass="edit-btn" |
| | | process="@form" |
| | | actionListener="#{roleMngController.userPermissionClick}" |
| | | update=":userDialog,:userDialogForm"/> |
| | | </p:panelGrid> |
| | | |
| | | <p:dataTable id="roleMngDataTable" styleClass="data-table" |
| | |
| | | </p:panel> |
| | | </h:form> |
| | | </p:dialog> |
| | | |
| | | <p:dialog modal="true" header="修改" appendTo="@(body)" |
| | | id="btnDialog" widgetVar="btnDialog" resizable="false" width="420"> |
| | | <h:form id="btnDialogForm"> |
| | | <p:panelGrid columns="1" styleClass="content"> |
| | | <p:outputLabel value="角色名称"/> |
| | | <p:inputText value="#{roleMngController.baseRole.name}" readonly="true"/> |
| | | |
| | | <p:outputLabel value="人员管理页面:"/> |
| | | |
| | | <p:selectManyCheckbox value="#{roleMngController.baseRole.btnPermissions}" layout="grid" columns="2" style="width: 100%;"> |
| | | <f:selectItem itemLabel="新增功能" itemValue="新增"/> |
| | | <f:selectItem itemLabel="修改功能" itemValue="修改"/> |
| | | <f:selectItem itemLabel="删除功能" itemValue="删除"/> |
| | | <f:selectItem itemLabel="导入功能" itemValue="导入"/> |
| | | </p:selectManyCheckbox> |
| | | </p:panelGrid> |
| | | <p:panel styleClass="btn"> |
| | | <p:commandButton value="保存" actionListener="#{roleMngController.onSaveBtnPermission}" |
| | | process="@form" update=":roleMngForm:roleMngDataTable"> |
| | | <p:confirm header="确认" message="确认操作?"/> |
| | | </p:commandButton> |
| | | </p:panel> |
| | | </h:form> |
| | | </p:dialog> |
| | | |
| | | <p:dialog modal="true" header="修改" appendTo="@(body)" |
| | | id="userDialog" widgetVar="userDialog" resizable="false" width="420"> |
| | | <h:form id="userDialogForm"> |
| | | <p:panelGrid columns="1" styleClass="content"> |
| | | <p:outputLabel value="角色名称"/> |
| | | <p:inputText value="#{roleMngController.baseRole.name}" readonly="true"/> |
| | | |
| | | <p:outputLabel value="人员管理页面:"/> |
| | | |
| | | <p:selectOneRadio value="#{roleMngController.baseRole.userPermission}" layout="grid" columns="1" style="width: 100%;"> |
| | | <f:selectItem itemLabel="可见所有人员" itemValue="所有人员"/> |
| | | <f:selectItem itemLabel="只可见课题组成员" itemValue="课题组"/> |
| | | <f:selectItem itemLabel="只可见自己" itemValue="自己"/> |
| | | </p:selectOneRadio> |
| | | </p:panelGrid> |
| | | <p:panel styleClass="btn"> |
| | | <p:commandButton value="保存" actionListener="#{roleMngController.onSaveUserPermission}" |
| | | process="@form" update=":roleMngForm:roleMngDataTable"> |
| | | <p:confirm header="确认" message="确认操作?"/> |
| | | </p:commandButton> |
| | | </p:panel> |
| | | </h:form> |
| | | </p:dialog> |
| | | </ui:composition> |
| | | </html> |
| | |
| | | process="@this" |
| | | actionListener="#{userMngController.onNewBtnClick}" |
| | | oncomplete="PF('dialog').show();" |
| | | update=":dialog,:dialogForm"></p:commandButton> |
| | | update=":dialog,:dialogForm" |
| | | rendered="#{userMngController.isAccess('新增')}"></p:commandButton> |
| | | <p:commandButton value="修改" styleClass="edit-btn" |
| | | process="@form" |
| | | actionListener="#{userMngController.onEditBtnClick}" |
| | | update=":dialog,:dialogForm"></p:commandButton> |
| | | update=":dialog,:dialogForm" |
| | | rendered="#{userMngController.isAccess('修改')}"></p:commandButton> |
| | | <p:commandButton value="删除" styleClass="del-btn" |
| | | process="@form" |
| | | actionListener="#{userMngController.onDeleteBtnClick}" |
| | | update="@form"> |
| | | update="@form" |
| | | rendered="#{userMngController.isAccess('删除')}"> |
| | | <p:confirm header="确认" message="确认操作?"></p:confirm> |
| | | </p:commandButton> |
| | | <p:commandButton value="导入" styleClass="import-btn" onclick="importUser()" |
| | | rendered="#{userMngController.isAccess('导入')}" |
| | | ></p:commandButton> |
| | | <a href="resources/template/用户导入模板.xlsx" style="display: inline-block;"><img src="resources/images/xlsx.png" width="30px;" alt=""/></a> |
| | | <p:outputLabel rendered="#{userMngController.isAccess('导入')}"> |
| | | <a href="resources/template/用户导入模板.xlsx" style="display: inline-block;"><img src="resources/images/xlsx.png" width="30px;" alt=""/></a> |
| | | </p:outputLabel> |
| | | <script> |
| | | function importUser(){ |
| | | $("#userMngForm\\:importUserBtn_input").click(); |