From 1695c8356c17395139bc806ead0596a929518707 Mon Sep 17 00:00:00 2001 From: feige <feige@qq.com> Date: 星期二, 16 一月 2024 21:25:47 +0800 Subject: [PATCH] 增加内容 --- ruoyi-system/pom.xml | 11 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 18 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfFamilyController.java | 45 +++ zhang-content/src/main/java/com/ruoyi/domain/ZfFamily.java | 13 zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java | 4 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/sysUserInfo.java | 356 +++++++++++++++++++++++ zhang-content/src/main/java/com/ruoyi/service/impl/ZfFamilyServiceImpl.java | 34 ++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 76 ++++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZAuthorityController.java | 29 + zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java | 80 ++++- zhang-content/src/main/java/com/ruoyi/service/ZfFamilyService.java | 7 zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java | 70 ++++ ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java | 8 zhang-content/src/main/java/com/ruoyi/service/ZAuthorityService.java | 6 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java | 15 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java | 2 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java | 56 +++ zhang-content/src/main/java/com/ruoyi/domain/dto/EmpowerDto.java | 14 ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml | 2 19 files changed, 806 insertions(+), 40 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 2cb0e8f..ca39bd6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,10 +1,17 @@ package com.ruoyi.web.controller.system; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.core.domain.entity.sysUserInfo; +import com.ruoyi.domain.ZInfoUser; +import com.ruoyi.domain.ZfFamily; +import com.ruoyi.service.ZInfoUserService; +import com.ruoyi.service.ZfFamilyService; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -54,7 +61,10 @@ @Autowired private ISysPostService postService; - + @Resource + private ZInfoUserService zInfoUserService; + @Resource + private ZfFamilyService zfFamilyService; /** * 鑾峰彇鐢ㄦ埛鍒楄〃 */ @@ -125,8 +135,23 @@ @PreAuthorize("@ss.hasPermi('system:user:add')") @Log(title = "鐢ㄦ埛绠$悊", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@Validated @RequestBody SysUser user) + public AjaxResult add(@Validated @RequestBody sysUserInfo userAll) { + SysUser user = new SysUser(); + user.setUserId(userAll.getUserId()); + user.setAvatar(userAll.getAvatar()); + user.setPassword(userAll.getPassword()); + user.setNickName(userAll.getNickName()); + user.setUserName(userAll.getUserName()); + user.setPhonenumber(userAll.getPhonenumber()); + user.setRoleId(userAll.getRoleId()); + user.setRoleIds(userAll.getRoleIds()); + user.setStatus(userAll.getStatus()); + user.setSex(userAll.getSex()); + user.setRemark(userAll.getRemark()); + user.setUpdateBy(userAll.getUpdateBy()); + user.setPostIds(userAll.getPostIds()); + // user.set if (!userService.checkUserNameUnique(user)) { return error("鏂板鐢ㄦ埛'" + user.getUserName() + "'澶辫触锛岀櫥褰曡处鍙峰凡瀛樺湪"); @@ -141,6 +166,32 @@ } user.setCreateBy(getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + //鍐欏叆鍒� 鏂板缓绔嬬殑淇℃伅琛ㄩ噷闈� + ZfFamily zfFamily = zfFamilyService.getByFamId(userAll.getFamilyId()); + ZInfoUser infoUser = new ZInfoUser(); + infoUser.setUserId(user.getUserId()); + infoUser.setNickName(user.getNickName()); + infoUser.setPhoneNumber(user.getPhonenumber()); + infoUser.setSex(user.getSex()=="鐢�"?1:0); + infoUser.setFamilyId(userAll.getFamilyId()); + if(zfFamily!=null) { + infoUser.setFatherId(zfFamily.getFid()); + // infoUser.setMomId(zfFamily.getMid()); + } + System.out.println("-----"); + System.out.println(userAll.getIsMyFamily()); + infoUser.setIsMyFamily(userAll.getIsMyFamily()); + if(userAll.getSpouseId()==0) + infoUser.setSpouseId(null); + else + infoUser.setSpouseId(userAll.getSpouseId()); + //鍓嶇淇濊瘉浜嗚鑹蹭笉涓虹┖ + if(user.getRoleIds()[0]==102) + infoUser.setRoleId(3L); + // infoUser.setRoleName(user.g); + if(userAll.getFamilyId()!=-1) { + zInfoUserService.saveOrUpdate(infoUser); + } return toAjax(userService.insertUser(user)); } @@ -182,6 +233,7 @@ { return error("褰撳墠鐢ㄦ埛涓嶈兘鍒犻櫎"); } + zInfoUserService.removeByUserName( userService.findUserNames(userIds)); return toAjax(userService.deleteUserByIds(userIds)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZAuthorityController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZAuthorityController.java index 2974de9..21e9123 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZAuthorityController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZAuthorityController.java @@ -6,6 +6,7 @@ import com.ruoyi.domain.ZAuthority; import com.ruoyi.domain.dto.AuthorityDto; import com.ruoyi.domain.dto.AuthorityDto2; +import com.ruoyi.domain.dto.EmpowerDto; import com.ruoyi.service.ZAuthorityService; import org.springframework.web.bind.annotation.*; @@ -64,13 +65,27 @@ return zAuthorityService.getOtherAuthority(authorityDto); } -// /** -// * 鎺堟潈(鍙湁瀹跺涵绠$悊鍛樻墠鑳借皟鐢ㄨ繖涓帴鍙�) -// */ -// @PostMapping("/empower") -// public AjaxResult empower(){ -// -// } + /** + * 鎺堟潈(鍙湁瀹跺涵绠$悊鍛樻墠鑳借皟鐢ㄨ繖涓帴鍙�) + */ + @PostMapping("/empower") + public AjaxResult empower(@RequestBody EmpowerDto zAuthority){ + return zAuthorityService.saveZa(zAuthority); + } + /** + * 鏍规嵁authorityId鍜屽搴璱d鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉 + */ + @PostMapping("/getInfoByAidFid") + public AjaxResult empowerGetInfo(@RequestBody ZAuthority zAuthority){ + return zAuthorityService.listByFidAid(zAuthority); + } + /** + * 鏍规嵁authorityId鍜屽搴璱d鏀跺洖宸茬粡鎺堟潈缁欓偅浜涗汉 + */ + @PostMapping("/deleteInfoByAidFid") + public AjaxResult deleteEmpower(@RequestBody EmpowerDto zAuthority){ + return zAuthorityService.deleteZa(zAuthority); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java index b9de3a2..88c310d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java @@ -116,6 +116,12 @@ Long userId = user.getUserId(); return AjaxResult.success(zInfoUserService.getInfoById(userId)); } + @GetMapping("/{id}") + public AjaxResult getInfoById(@PathVariable("id") Long id) { + // SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = id; + return AjaxResult.success(zInfoUserService.getInfoById(userId)); + } // /** @@ -200,7 +206,14 @@ public AjaxResult listAllPeopleWithTree(@PathParam("depth") Integer depth){ return zInfoUserService.listWithTree(depth); } - + /** + * 鏍规嵁瀹跺涵鎴愬憳鎵惧埌鎵�鏈変汉 + */ + @GetMapping("/allFamInfo") + public AjaxResult listAllFamilyPeople() + { + return zInfoUserService.listAllFamilyPeople(); + } /** * 鎵惧埌鎵�鏈夌殑鎴愬憳 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfFamilyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfFamilyController.java index cd24e07..6cae23e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfFamilyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfFamilyController.java @@ -1,6 +1,10 @@ package com.ruoyi.web.controller.zhang; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.domain.ZfEvent; import com.ruoyi.domain.ZfFamily; import com.ruoyi.domain.dto.UserInfoDto; import com.ruoyi.service.ZfFamilyService; @@ -8,6 +12,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * @Author Jinquan_Ou @@ -34,6 +40,15 @@ public AjaxResult getByFamilyId(@PathVariable Long fid){ return AjaxResult.success(zfFamilyService.getByFamilyId(fid)); } + @GetMapping("/findByfid/{fid}") + public AjaxResult getByFId(@PathVariable("fid") Long fid){ + return AjaxResult.success(zfFamilyService.getByFid(fid)); + } + @GetMapping("/findByFname/{name}") + public AjaxResult getByFName(@PathVariable("name") String name){ + return AjaxResult.success(zfFamilyService.getByName(name)); + } + /** * 鏌ョ湅褰撳墠鐢ㄦ埛褰撳墠瀹跺涵鐨勫搴垚鍛� @@ -55,6 +70,25 @@ } /** + * 瀵煎嚭瀹跺涵澶т簨浠惰褰曞垪琛� + */ +// @PreAuthorize("@ss.hasPermi('system:property:export')") + @Log(title = "瀹跺涵澶т簨浠惰褰�", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response) { + List<ZfFamily> list = zfFamilyService.list(); + System.out.println("------------------"); + ExcelUtil<ZfFamily> util = new ExcelUtil<>(ZfFamily.class); + util.exportExcel(response, list, "瀹跺涵澶т簨浠惰褰曟暟鎹�"); + + } + + @Log(title = "瀹跺涵澶т簨浠惰褰�", businessType = BusinessType.DELETE) + @DeleteMapping("/deleteFam/{ids}") + public AjaxResult deleteFamily(@PathVariable Long[] ids) { + return zfFamilyService.deleteFam(ids); + } + /** * * @param zfFamily * @return @@ -70,6 +104,17 @@ * @param zfFamily * @return */ + @PostMapping("/findInfo") + public AjaxResult findFamilyMember(@RequestBody ZfFamily zfFamily){ + + return AjaxResult.success(zfFamilyService.getByNameAndUser(zfFamily)); + + } + /** + * + * @param zfFamily + * @return + */ @PostMapping("/updateFam") public AjaxResult updateFamily(@RequestBody ZfFamily zfFamily){ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/sysUserInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/sysUserInfo.java new file mode 100644 index 0000000..6376a54 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/sysUserInfo.java @@ -0,0 +1,356 @@ +package com.ruoyi.common.core.domain.entity; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.xss.Xss; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Date; +import java.util.List; + +public class sysUserInfo extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 鐢ㄦ埛ID */ + @Excel(name = "鐢ㄦ埛搴忓彿", cellType = Excel.ColumnType.NUMERIC, prompt = "鐢ㄦ埛缂栧彿") + private Long userId; + + /** 閮ㄩ棬ID */ + @Excel(name = "閮ㄩ棬缂栧彿", type = Excel.Type.IMPORT) + private Long deptId; + + /** 鐢ㄦ埛璐﹀彿 */ + @Excel(name = "鐧诲綍鍚嶇О") + private String userName; + + /** 鐢ㄦ埛鏄电О */ + @Excel(name = "鐢ㄦ埛鍚嶇О") + private String nickName; + + /** 鐢ㄦ埛閭 */ + @Excel(name = "鐢ㄦ埛閭") + private String email; + + /** 鎵嬫満鍙风爜 */ + @Excel(name = "鎵嬫満鍙风爜") + private String phonenumber; + + /** 鐢ㄦ埛鎬у埆 */ + @Excel(name = "鐢ㄦ埛鎬у埆", readConverterExp = "0=鐢�,1=濂�,2=鏈煡") + private String sex; + + /** 鐢ㄦ埛澶村儚 */ + private String avatar; + + /** 瀵嗙爜 */ + private String password; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public long getFamilyId() { + return familyId; + } + + public void setFamilyId(long familyId) { + this.familyId = familyId; + } + + public long getSpouseId() { + return spouseId; + } + + public void setSpouseId(long spouseId) { + this.spouseId = spouseId; + } + + public int getIsMyFamily() { + return isMyFamily; + } + + public void setIsMyFamily(int isMyFamily) { + this.isMyFamily = isMyFamily; + } + + public long getFatherId() { + return fatherId; + } + + public void setFatherId(long fatherId) { + this.fatherId = fatherId; + } + + public long getMomId() { + return momId; + } + + public void setMomId(long momId) { + this.momId = momId; + } + + private long familyId; + + private long spouseId; + + private int isMyFamily; + + public long getFid() { + return fid; + } + + public void setFid(long fid) { + this.fid = fid; + } + + private long fatherId; + + private long momId; + + private long fid; + /** 甯愬彿鐘舵�侊紙0姝e父 1鍋滅敤锛� */ + @Excel(name = "甯愬彿鐘舵��", readConverterExp = "0=姝e父,1=鍋滅敤") + private String status; + + /** 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛� */ + private String delFlag; + + /** 鏈�鍚庣櫥褰旾P */ + @Excel(name = "鏈�鍚庣櫥褰旾P", type = Excel.Type.EXPORT) + private String loginIp; + + /** 鏈�鍚庣櫥褰曟椂闂� */ + @Excel(name = "鏈�鍚庣櫥褰曟椂闂�", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT) + private Date loginDate; + + /** 閮ㄩ棬瀵硅薄 */ + @Excels({ + @Excel(name = "閮ㄩ棬鍚嶇О", targetAttr = "deptName", type = Excel.Type.EXPORT), + @Excel(name = "閮ㄩ棬璐熻矗浜�", targetAttr = "leader", type = Excel.Type.EXPORT) + }) + private SysDept dept; + + /** 瑙掕壊瀵硅薄 */ + private List<SysRole> roles; + + /** 瑙掕壊缁� */ + private Long[] roleIds; + + /** 宀椾綅缁� */ + private Long[] postIds; + + /** 瑙掕壊ID */ + private Long roleId; + + public sysUserInfo() + { + + } + + public sysUserInfo(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public boolean isAdmin() + { + return isAdmin(this.userId); + } + + public static boolean isAdmin(Long userId) + { + //1鍙风敤鎴峰氨鏄鐞嗗憳 + return userId != null && 1L == userId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + @Xss(message = "鐢ㄦ埛鏄电О涓嶈兘鍖呭惈鑴氭湰瀛楃") + @Size(min = 0, max = 30, message = "鐢ㄦ埛鏄电О闀垮害涓嶈兘瓒呰繃30涓瓧绗�") + public String getNickName() + { + return nickName; + } + + public void setNickName(String nickName) + { + this.nickName = nickName; + } + + @Xss(message = "鐢ㄦ埛璐﹀彿涓嶈兘鍖呭惈鑴氭湰瀛楃") + @NotBlank(message = "鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖") + @Size(min = 0, max = 30, message = "鐢ㄦ埛璐﹀彿闀垮害涓嶈兘瓒呰繃30涓瓧绗�") + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + @Email(message = "閭鏍煎紡涓嶆纭�") + @Size(min = 0, max = 50, message = "閭闀垮害涓嶈兘瓒呰繃50涓瓧绗�") + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + @Size(min = 0, max = 11, message = "鎵嬫満鍙风爜闀垮害涓嶈兘瓒呰繃11涓瓧绗�") + public String getPhonenumber() + { + return phonenumber; + } + + public void setPhonenumber(String phonenumber) + { + this.phonenumber = phonenumber; + } + + public String getSex() + { + return sex; + } + + public void setSex(String sex) + { + this.sex = sex; + } + + public String getAvatar() + { + return avatar; + } + + public void setAvatar(String avatar) + { + this.avatar = avatar; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getLoginIp() + { + return loginIp; + } + + public void setLoginIp(String loginIp) + { + this.loginIp = loginIp; + } + + public Date getLoginDate() + { + return loginDate; + } + + public void setLoginDate(Date loginDate) + { + this.loginDate = loginDate; + } + + public SysDept getDept() + { + return dept; + } + + public void setDept(SysDept dept) + { + this.dept = dept; + } + + public List<SysRole> getRoles() + { + return roles; + } + + public void setRoles(List<SysRole> roles) + { + this.roles = roles; + } + + public Long[] getRoleIds() + { + return roleIds; + } + + public void setRoleIds(Long[] roleIds) + { + this.roleIds = roleIds; + } + + public Long[] getPostIds() + { + return postIds; + } + + public void setPostIds(Long[] postIds) + { + this.postIds = postIds; + } + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } +} diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index ef656a0..11f84cc 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,6 +22,17 @@ <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common</artifactId> </dependency> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>zhang-content</artifactId> + <version>1.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-extension</artifactId> + <version>3.5.2</version> + </dependency> </dependencies> diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 76e1c79..98f9674 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -1,5 +1,6 @@ package com.ruoyi.system.mapper; +import java.util.ArrayList; import java.util.List; import org.apache.ibatis.annotations.Param; import com.ruoyi.common.core.domain.entity.SysUser; @@ -11,6 +12,7 @@ */ public interface SysUserMapper { + public List<String> findUserNames(Long[] ids); /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 10bc2ab..b4bb6e3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -1,6 +1,9 @@ package com.ruoyi.system.service; +import java.util.ArrayList; import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.entity.SysUser; /** @@ -8,8 +11,11 @@ * * @author ruoyi */ -public interface ISysUserService +public interface ISysUserService extends IService<SysUser> { + + + public List<String> findUserNames(Long [] ids); /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 638966a..3f4c384 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -1,9 +1,17 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; +import javax.annotation.Resource; import javax.validation.Validator; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.domain.ZInfoUser; +import com.ruoyi.service.ZInfoUserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +44,7 @@ * @author ruoyi */ @Service -public class SysUserServiceImpl implements ISysUserService -{ +public class SysUserServiceImpl implements ISysUserService { private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); @Autowired @@ -60,6 +67,17 @@ @Autowired protected Validator validator; + + @Resource + private ZInfoUserService zInfoUserService; + + @Override + public List<String> findUserNames(Long[] ids) { + List<String> usNames = userMapper.findUserNames(ids); + System.out.println(usNames); + //.stream().map(SysUser::getUserName).collect(Collectors.toList()); + return usNames; + } /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃 @@ -262,6 +280,8 @@ insertUserPost(user); // 鏂板鐢ㄦ埛涓庤鑹茬鐞� insertUserRole(user); + + return rows; } @@ -296,6 +316,9 @@ userPostMapper.deleteUserPostByUserId(userId); // 鏂板鐢ㄦ埛涓庡矖浣嶇鐞� insertUserPost(user); + + //鏇存柊鐢ㄦ埛淇℃伅琛� + return userMapper.updateUser(user); } @@ -541,4 +564,49 @@ } return successMsg.toString(); } + + @Override + public boolean saveBatch(Collection<SysUser> entityList, int batchSize) { + return false; + } + + @Override + public boolean saveOrUpdateBatch(Collection<SysUser> entityList, int batchSize) { + return false; + } + + @Override + public boolean updateBatchById(Collection<SysUser> entityList, int batchSize) { + return false; + } + + @Override + public boolean saveOrUpdate(SysUser entity) { + return false; + } + + @Override + public SysUser getOne(Wrapper<SysUser> queryWrapper, boolean throwEx) { + return null; + } + + @Override + public Map<String, Object> getMap(Wrapper<SysUser> queryWrapper) { + return null; + } + + @Override + public <V> V getObj(Wrapper<SysUser> queryWrapper, Function<? super Object, V> mapper) { + return null; + } + + @Override + public BaseMapper<SysUser> getBaseMapper() { + return null; + } + + @Override + public Class<SysUser> getEntityClass() { + return null; + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index 61d401d..e295da0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -50,7 +50,7 @@ <select id="selectMenuTreeAll" resultMap="SysMenuResult"> select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time - from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 and m.menu_id in (1, 100,101, 118) + from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 and m.menu_id in (1, 100, 118) order by m.parent_id, m.order_num </select> diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index d86c444..b42a4d4 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -26,7 +26,7 @@ <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" /> <collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> </resultMap> - + <resultMap id="deptResult" type="SysDept"> <id property="deptId" column="dept_id" /> <result property="parentId" column="parent_id" /> @@ -45,9 +45,9 @@ <result property="dataScope" column="data_scope" /> <result property="status" column="role_status" /> </resultMap> - + <sql id="selectUserVo"> - select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, + select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status from sys_user u @@ -55,7 +55,15 @@ left join sys_user_role ur on u.user_id = ur.user_id left join sys_role r on r.role_id = ur.role_id </sql> - + <select id="findUserNames" parameterType="Long" resultMap="SysUserResult"> + SELECT + user_name + from sys_user + WHERE user_id IN + <foreach collection="array" item="id" index="index" open="(" close=")" separator=","> + #{id} + </foreach> + </select> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u left join sys_dept d on u.dept_id = d.dept_id @@ -141,7 +149,7 @@ <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 </select> - + <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> insert into sys_user( <if test="userId != null and userId != 0">user_id,</if> diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfFamily.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfFamily.java index 7c4175d..0f0cdc2 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZfFamily.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfFamily.java @@ -27,5 +27,18 @@ /** * 瀹跺涵鍚嶇О */ + @Excel(name="瀹跺涵鍙�") + private String name; + + + /** + * 瀹跺涵鍚嶇О + */ + @Excel(name="鐖朵翰id") + + private Long fid; + + + } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/dto/EmpowerDto.java b/zhang-content/src/main/java/com/ruoyi/domain/dto/EmpowerDto.java index 735d325..7d19989 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/dto/EmpowerDto.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/dto/EmpowerDto.java @@ -15,5 +15,19 @@ public class EmpowerDto implements Serializable { private static final long serialVersionUID = 1L; + /** + * 鐢ㄦ埛id + */ + private Long [] uids; + + /** + * 瀹跺涵id + */ + private Long fid; + + /** + * 鏉冮檺鐮� + */ + private Long[] authoritys; } diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZAuthorityService.java b/zhang-content/src/main/java/com/ruoyi/service/ZAuthorityService.java index 183a8df..af33434 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/ZAuthorityService.java +++ b/zhang-content/src/main/java/com/ruoyi/service/ZAuthorityService.java @@ -5,6 +5,7 @@ import com.ruoyi.domain.ZAuthority; import com.ruoyi.domain.dto.AuthorityDto; import com.ruoyi.domain.dto.AuthorityDto2; +import com.ruoyi.domain.dto.EmpowerDto; import java.util.List; @@ -24,4 +25,9 @@ AjaxResult managerAuthority(AuthorityDto2 authorityDto); AjaxResult getOtherAuthority(AuthorityDto authorityDto); + + AjaxResult saveZa(EmpowerDto zAuthority); + + AjaxResult deleteZa(EmpowerDto empowerDto); + AjaxResult listByFidAid(ZAuthority zAuthority); } diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java b/zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java index 67ef1bc..4612fa9 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java +++ b/zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java @@ -24,6 +24,8 @@ List<ZInfoUser> selectByCondition(ZInfoUser zInfoUser); + AjaxResult removeByUserName(List userName); + List<ZInfoUser> selectByFamId(long fid); AjaxResult searchMyRelation(); AjaxResult addRelation(ZfRelation zfRelation); @@ -39,7 +41,7 @@ AjaxResult addParent(Long fatherId, Long motherId); AjaxResult listAllExceptAdmin(); - + AjaxResult listAllFamilyPeople(); AjaxResult listMySelfAndSpouse(Long id); AjaxResult listGenealogy(Genealogy genealogy,Integer pageNum,Integer pageSize); diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfFamilyService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfFamilyService.java index 89f16d0..967eadb 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/ZfFamilyService.java +++ b/zhang-content/src/main/java/com/ruoyi/service/ZfFamilyService.java @@ -18,12 +18,13 @@ @Service public interface ZfFamilyService extends IService<ZfFamily> { + ZfFamily getByNameAndUser(ZfFamily zfFamily); /** * 鏍规嵁瀹跺涵鍚嶅瓧鏌ヨ瀹跺涵 */ ZfFamily getByName(String familyName); - - + ZfFamily getByFid(Long fid); + ZfFamily getByFamId(Long fid); List<UserInfoDto> getByFamilyId(Long fid); List<UserInfoDto> getNowMember(); @@ -36,4 +37,6 @@ AjaxResult addFamily(ZfFamily zfFamily); AjaxResult updateFam(ZfFamily zfFamily); + + AjaxResult deleteFam(Long []ids); } diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java index bb31f3b..91bd22b 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java @@ -12,6 +12,7 @@ import com.ruoyi.domain.dto.AuthorityDto; import com.ruoyi.domain.dto.AuthorityDto2; import com.ruoyi.domain.dto.AuthorityDtoWithName; +import com.ruoyi.domain.dto.EmpowerDto; import com.ruoyi.mapper.ZAuthorityMapper; import com.ruoyi.service.ZAuthorityService; import com.ruoyi.service.ZInfoUserService; @@ -275,4 +276,73 @@ } + public void addData(ZAuthority za) + { + //鍒ゆ柇鏄惁閲嶅鎺堟潈 + + // + zAuthorityService.save(za); + + } + public AjaxResult saveZa(EmpowerDto zAuthority) + { + // boolean bl = zAuthorityService.saveOrUpdate(zAuthority); + Long [] uids = zAuthority.getUids(); + Long [] authoritys = zAuthority.getAuthoritys(); + for(Long uid : uids) + for(Long auri: authoritys) + { + ZAuthority za = new ZAuthority(); + za.setAuthority(auri); + za.setFid(zAuthority.getFid()); + za.setUid(uid); + addData(za); + } + // Long [] + // if(bl) + return AjaxResult.success("鏉冮檺鏂板鎴愬姛!"); + // else + // return AjaxResult.error("鏉冮檺鏂板澶辫触锛�"); + + } + + @Override + public AjaxResult deleteZa(EmpowerDto empowerDto) { + Long [] uids = empowerDto.getUids(); + Long [] authoritys = empowerDto.getAuthoritys(); + for(Long uid : uids) + for(Long auri: authoritys) + { + + LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZAuthority::getFid,empowerDto.getFid()) + .eq(ZAuthority::getAuthority, auri) + .eq(ZAuthority::getUid, uid); + + zAuthorityService.remove(lqw); + // addData(za); + } + return AjaxResult.success("鏉冮檺鏀跺洖鎴愬姛!"); + + } + + @Override + public AjaxResult listByFidAid(ZAuthority zAuthority) { + //鎵惧埌瀵瑰簲瀹跺涵浠ュ強鏉冮檺妯″潡瀵瑰簲鐨勭敤鎴� + LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZAuthority::getFid,zAuthority.getFid()) + .eq(ZAuthority::getAuthority, zAuthority.getAuthority()); + + List<ZAuthority> authorityList = list(lqw); + + List<Long> allUserListId = authorityList.stream().map(ZAuthority::getUid).collect(Collectors.toList());//鎺堟潈鐢ㄦ埛鏁扮粍鏁扮粍 + + + LambdaQueryWrapper<ZInfoUser> lq = new LambdaQueryWrapper<>(); + lq.in(ZInfoUser::getUserId, allUserListId); + + List<ZInfoUser> userInfo = zInfoUserService.list(lq); + // Map<Long, String> usi = userInfo.stream().collect(Collectors.toMap(ZInfoUser::getUserId,ZInfoUser::getNickName)); + return AjaxResult.success(userInfo); + } } diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java index 8da6d16..64af105 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java @@ -14,6 +14,7 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.domain.ZInfoUser; import com.ruoyi.domain.ZfEvent; +import com.ruoyi.domain.ZfFamily; import com.ruoyi.domain.ZfRelation; import com.ruoyi.domain.dto.*; import com.ruoyi.mapper.ZInfoUserMapper; @@ -100,6 +101,27 @@ log.info("杩斿洖鐨勬暟鎹负:{}", list); return list; + } + + @Override + public AjaxResult removeByUserName(List userName) { + LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); + lqw.in(ZInfoUser::getNickName, userName); + List<Long> ids = list(lqw).stream().map(ZInfoUser::getUserId).collect(Collectors.toList()); + removeByIds(ids); + return AjaxResult.success("鍒犻櫎鎴愬姛"); + } + + @Override + public List<ZInfoUser> selectByFamId(long fid) { + LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfFamily::getId, fid); + ZfFamily zfFamily = zfFamilyService.list(lqw).get(0); + LambdaQueryWrapper<ZInfoUser> lqws = new LambdaQueryWrapper<>(); + lqws.eq(ZInfoUser::getFatherId, zfFamily.getFid()); + // lqws.eq(ZInfoUser::getMomId, zfFamily.getMid()); + List<ZInfoUser> list = list(lqws); + return list; } @Override @@ -299,22 +321,29 @@ List<ZInfoUser> myFamilyPeopleList = allPeopleList.stream().filter(people -> people.getUserId() != 1 && people.getIsMyFamily() == 1).collect(Collectors.toList()); - - result = allPeopleList.stream().filter(people -> people.getUserId() != 1 && (people.getFatherId() == 0 || people.getMomId() == 0) && people.getIsMyFamily() == 1) +result = allPeopleList.stream().filter(people -> people!=null && people.getUserId() != 1 && ((people.getFatherId()!=null &&people.getFatherId() == 0 )|| (people.getMomId()!=null&&people.getMomId() == 0)) && people.getIsMyFamily() == 1) .map(people -> { +// System.out.println("======================================="); +// System.out.println(people); if (depth > 1) { - people.setIdentity(1); - //鏍规嵁閰嶅伓id鏌ヨ閰嶅伓鐨勬暟鎹紝灏佽濂戒竴璧疯繑鍥� - Long spouseId = people.getSpouseId(); - ZInfoUser spouse = zInfoUserService.getById(spouseId); - spouse.setIdentity(1); - people.setSpouse(spouse); - people.setChildList(fillChildren(people, myFamilyPeopleList, depth - 1)); + if(people!=null) { + people.setIdentity(1); + //鏍规嵁閰嶅伓id鏌ヨ閰嶅伓鐨勬暟鎹紝灏佽濂戒竴璧疯繑鍥� + Long spouseId = people.getSpouseId(); + if (spouseId != null) { + ZInfoUser spouse = zInfoUserService.getById(spouseId); + spouse.setIdentity(1); + people.setSpouse(spouse); + } + people.setChildList(fillChildren(people, myFamilyPeopleList, depth - 1)); + } } +// System.out.println("+++++++++++++++++++++++++++++"); +// System.out.println(people); return people; }).collect(Collectors.toList()); - +//System.out.println("--------------++++++++++++++++--------------"); return AjaxResult.success(result); } @@ -576,11 +605,24 @@ @Override public ZInfoUser getInfoById(Long userId) { ZInfoUser user = getById(userId); - Long familyId = user.getFamilyId(); - String familyName = zfFamilyService.getById(familyId).getName(); - String roleName = zfRoleService.getById(user.getRoleId()).getName(); - user.setFamilyName(familyName); - user.setRoleName(roleName); + + + if(user!=null) + { + Long familyId = user.getFamilyId(); + // System.out.println("dddddddddddddddddddd"); + + String roleName = zfRoleService.getById(user.getRoleId()).getName(); + + user.setRoleName(roleName); + System.out.println("dddddddddddddddddddd"); + System.out.println(familyId); + if(familyId!=-1) + { + String familyName = zfFamilyService.getById(familyId).getName(); + user.setFamilyName(familyName); + } + } return user; } @@ -671,6 +713,12 @@ } @Override + public AjaxResult listAllFamilyPeople() { + List<ZInfoUser> collect = list().stream().filter(zInfoUser -> zInfoUser.getRoleId()== 3).collect(Collectors.toList()); + return AjaxResult.success(collect); + } + + @Override public AjaxResult listMySelfAndSpouse(Long id) { LambdaQueryWrapper<ZInfoUser> lqw1 = new LambdaQueryWrapper<>(); lqw1.eq(ZInfoUser::getUserId, id); @@ -709,7 +757,7 @@ // ).collect(Collectors.toList()); List<ZInfoUser> collect = allPeopleList.stream().filter( - one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1) + one -> ((one.getFamilyId()!=null && one.getFatherId() == people.getUserId()) || (one.getMomId()!=null&&one.getMomId() == people.getUserId())) && (people.getIsMyFamily() == 1) ).map( one -> { if (depth == 1) { diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfFamilyServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfFamilyServiceImpl.java index 9111359..0ef749d 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfFamilyServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfFamilyServiceImpl.java @@ -20,6 +20,7 @@ import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -36,11 +37,33 @@ @Resource ZfFamilyMapper zfFamilyMapper; + @Resource + ZfFamilyService zfFamilyService; + + @Override + public ZfFamily getByNameAndUser(ZfFamily zfFamily) { + LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfFamily::getName,zfFamily.getName()).or().eq(ZfFamily::getFid, zfFamily.getFid()); + return getOne(lqw); + } @Override public ZfFamily getByName(String familyName) { LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfFamily::getName,familyName); + return getOne(lqw); + } + + @Override + public ZfFamily getByFid(Long fid) { + LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfFamily::getFid,fid); + return getOne(lqw); } + + @Override + public ZfFamily getByFamId(Long fid) { + LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfFamily::getId,fid); return getOne(lqw); } @@ -133,4 +156,15 @@ }else return AjaxResult.error("淇敼澶辫触,瀹跺涵鍙蜂笉鑳介噸澶�"); } + + @Override + public AjaxResult deleteFam(Long[] ids) { + if (zfFamilyService.removeByIds(Arrays.asList(ids))) { + return AjaxResult.success(); + } + else + return AjaxResult.error(); + + + } } -- Gitblit v1.9.1