| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | import com.ruoyi.domain.dto.AuthorityDto; |
| | | import com.ruoyi.domain.dto.AuthorityDto2; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | return AjaxResult.success(zAuthorityService.getByCondition(authorityDto)); |
| | | } |
| | | |
| | | /** |
| | | * 权限管理(管理员端) |
| | | */ |
| | | @PostMapping() |
| | | public AjaxResult authorityManager(@RequestBody AuthorityDto2 authorityDto){ |
| | | return zAuthorityService.managerAuthority(authorityDto); |
| | | } |
| | | |
| | | // /** |
| | | // * 授权(只有家庭管理员才能调用这个接口) |
| | | // */ |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出保洁收纳记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "保洁收纳记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfClean zfClean) |
| | | // { |
| | | // List<ZfClean> list = zfCleanService.selectByCondition(zfClean); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.class); |
| | | // util.exportExcel(response, list, "保洁收纳记录数据"); |
| | | // } |
| | | /** |
| | | * 导出保洁收纳记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfClean zfClean) |
| | | { |
| | | List<ZfClean> list = zfCleanService.selectByCondition(zfClean); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.class); |
| | | util.exportExcel(response, list, "保洁收纳记录数据"); |
| | | } |
| | | /** |
| | | * 导出保洁收纳记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfClean> list = zfCleanService.selectByIds(ids); |
| | |
| | | util.exportExcel(response,list,"收藏荣誉导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出收藏和荣誉记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "收藏和荣誉记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfCollection zfCollection) |
| | | // { |
| | | // List<ZfCollection> list = zfCollectionService.selectByCondition(zfCollection); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfCollection> util = new ExcelUtil<>(ZfCollection.class); |
| | | // util.exportExcel(response, list, "收藏和荣誉记录数据"); |
| | | // } |
| | | /** |
| | | * 导出收藏和荣誉记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "收藏和荣誉记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfCollection zfCollection) |
| | | { |
| | | List<ZfCollection> list = zfCollectionService.selectByCondition(zfCollection); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfCollection> util = new ExcelUtil<>(ZfCollection.class); |
| | | util.exportExcel(response, list, "收藏和荣誉记录数据"); |
| | | } |
| | | /** |
| | | * 导出收藏和荣誉记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "收藏和荣誉记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfCollection> list = zfCollectionService.selectByIds(ids); |
| | |
| | | util.exportExcel(response,list,"通讯录导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出通讯录记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "通讯录记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfContact zfContact) |
| | | // { |
| | | // List<ZfContact> list = zfContactService.selectByCondition(zfContact); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | // util.exportExcel(response, list, "通讯录记录数据"); |
| | | // } |
| | | /** |
| | | * 导出通讯录记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "通讯录记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfContact zfContact) |
| | | { |
| | | List<ZfContact> list = zfContactService.selectByCondition(zfContact); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | util.exportExcel(response, list, "通讯录记录数据"); |
| | | } |
| | | |
| | | /** |
| | | * 导出通讯录记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "通讯录记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfContact> list = zfContactService.selectByIds(ids); |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出家庭小医生记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfDoctor zfDoctor) |
| | | // { |
| | | // List<ZfDoctor> list = zfDoctorService.selectByCondition(zfDoctor); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | // util.exportExcel(response, list, "家庭小医生记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭小医生记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfDoctor zfDoctor) |
| | | { |
| | | List<ZfDoctor> list = zfDoctorService.selectByCondition(zfDoctor); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | util.exportExcel(response, list, "家庭小医生记录数据"); |
| | | } |
| | | /** |
| | | * 导出家庭小医生记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfDoctor> list = zfDoctorService.selectByIds(ids); |
| | |
| | | util.exportExcel(response,list,"家庭收支台账导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出家庭收支台账记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭收支台账记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfEconomy zfEconomy) |
| | | // { |
| | | // List<ZfEconomy> list = zfEconomyService.selectByCondition(zfEconomy); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.class); |
| | | // util.exportExcel(response, list, "家庭收支台账记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭收支台账记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfEconomy zfEconomy) |
| | | { |
| | | List<ZfEconomy> list = zfEconomyService.selectByCondition(zfEconomy); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.class); |
| | | util.exportExcel(response, list, "家庭收支台账记录数据"); |
| | | } |
| | | /** |
| | | * 导出家庭收支台账记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfEconomy> list = zfEconomyService.selectByIds(ids); |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出家庭设备记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:equipment:export')") |
| | | // @Log(title = "家庭设备记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfEquipment zfEquipment) |
| | | // { |
| | | // List<ZfEquipment> list = zfEquipmentService.selectByCondition(zfEquipment); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfEquipment> util = new ExcelUtil<ZfEquipment>(ZfEquipment.class); |
| | | // util.exportExcel(response, list, "家庭设备记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭设备记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:equipment:export')") |
| | | @Log(title = "家庭设备记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfEquipment zfEquipment) |
| | | { |
| | | List<ZfEquipment> list = zfEquipmentService.selectByCondition(zfEquipment); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfEquipment> util = new ExcelUtil<ZfEquipment>(ZfEquipment.class); |
| | | util.exportExcel(response, list, "家庭设备记录数据"); |
| | | } |
| | | /** |
| | | * 导出家庭设备记录列表 |
| | | */ |
| | | @Log(title = "家庭设备记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | List<ZfEquipment> list = zfEquipmentService.selectByIds(ids); |
| | | log.info("导出记录为:{}", list); |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出家庭大事件记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfEvent zfEvent) { |
| | | // List<ZfEvent> list = new ArrayList<>(); |
| | | // |
| | | // list = zfEventService.selectByCondition(zfEvent); |
| | | // log.info("导出记录为:{}", list); |
| | | // ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | | // util.exportExcel(response, list, "家庭大事件记录数据"); |
| | | // |
| | | // } |
| | | /** |
| | | * 导出家庭大事件记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfEvent zfEvent) { |
| | | List<ZfEvent> list = new ArrayList<>(); |
| | | |
| | | list = zfEventService.selectByCondition(zfEvent); |
| | | log.info("导出记录为:{}", list); |
| | | ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | | util.exportExcel(response, list, "家庭大事件记录数据"); |
| | | |
| | | } |
| | | /** |
| | | * 导出家庭大事件记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | List<ZfEvent> list = zfEventService.selectByIds(ids); |
| | | log.info("导出记录为:{}", list); |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.dto.UserInfoDto; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | return AjaxResult.success(zfFamilyService.list()); |
| | | } |
| | | |
| | | /** |
| | | * 根据家庭id查询家庭成员 |
| | | */ |
| | | @GetMapping("/{fid}") |
| | | public AjaxResult getByFamilyId(@PathVariable Long fid){ |
| | | return AjaxResult.success(zfFamilyService.getByFamilyId(fid)); |
| | | } |
| | | |
| | | /** |
| | | * 查看当前用户当前家庭的家庭成员 |
| | | */ |
| | | |
| | | @GetMapping("/now") |
| | | public AjaxResult getNowMember(){ |
| | | return AjaxResult.success(zfFamilyService.getNowMember()); |
| | | } |
| | | |
| | | /** |
| | | * 新增家庭成员 |
| | | */ |
| | | @PostMapping() |
| | | public AjaxResult addFamilyMember(@RequestBody UserInfoDto userInfoDto){ |
| | | return zfFamilyService.addMember(userInfoDto); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 删除家庭成员 |
| | | */ |
| | | |
| | | @DeleteMapping() |
| | | public AjaxResult removeFamilyMember(@RequestBody UserInfoDto userInfoDto){ |
| | | return zfFamilyService.removeMember(userInfoDto); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | util.exportExcel(response,list,"魅宠记录导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出魅宠记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "魅宠记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfPet zfPet) |
| | | // { |
| | | // List<ZfPet> list = zfPetService.selectByCondition(zfPet); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class); |
| | | // util.exportExcel(response, list, "魅宠记录数据"); |
| | | // } |
| | | /** |
| | | * 导出魅宠记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "魅宠记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfPet zfPet) |
| | | { |
| | | List<ZfPet> list = zfPetService.selectByCondition(zfPet); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class); |
| | | util.exportExcel(response, list, "魅宠记录数据"); |
| | | } |
| | | |
| | | /** |
| | | * 导出魅宠记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "魅宠记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfPet> list = zfPetService.selectByIds(ids); |
| | |
| | | util.exportExcel(response,list,"家庭资产导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出家庭资产记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭资产记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response,ZfProperty zfProperty) |
| | | // { |
| | | // List<ZfProperty> list = zfPropertyService.selectByCondition(zfProperty); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); |
| | | // util.exportExcel(response, list, "家庭资产记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭资产记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭资产记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response,ZfProperty zfProperty) |
| | | { |
| | | List<ZfProperty> list = zfPropertyService.selectByCondition(zfProperty); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); |
| | | util.exportExcel(response, list, "家庭资产记录数据"); |
| | | } |
| | | /** |
| | | * 导出家庭资产记录列表 |
| | | */ |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export/{ids}") |
| | | @PostMapping("/export1/{ids}") |
| | | public void export1(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | List<ZfProperty> list = zfPropertyService.selectByIds(ids); |
| | | log.info("导出记录为:{}", list); |
New file |
| | |
| | | package com.ruoyi.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-21 20:07 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | public class AuthorityDto2 extends AuthorityDto{ |
| | | private Long uid; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-21 19:58 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | public class UserInfoDto { |
| | | private Long id; |
| | | private Long familyId; |
| | | private String familyName; |
| | | private String name; |
| | | } |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | import com.ruoyi.domain.dto.AuthorityDto; |
| | | import com.ruoyi.domain.dto.AuthorityDto2; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | List<String> getAuthorityFamilyName(); |
| | | |
| | | AjaxResult managerAuthority(AuthorityDto2 authorityDto); |
| | | } |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import com.ruoyi.domain.dto.UserInfoDto; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | |
| | | ZfFamily getByName(String familyName); |
| | | |
| | | |
| | | List<UserInfoDto> getByFamilyId(Long fid); |
| | | |
| | | List<UserInfoDto> getNowMember(); |
| | | |
| | | AjaxResult addMember(UserInfoDto userInfoDto); |
| | | |
| | | AjaxResult removeMember(UserInfoDto userInfoDto); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfCode; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import com.ruoyi.domain.dto.AuthorityDto; |
| | | import com.ruoyi.domain.dto.AuthorityDto2; |
| | | import com.ruoyi.mapper.ZAuthorityMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfCodeService; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private ZfCodeService zfCodeService; |
| | | |
| | | @Resource |
| | | private ZAuthorityService zAuthorityService; |
| | | |
| | | @Resource |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | /** |
| | | * 查询当前用户的权限 |
| | |
| | | return familyList.stream().map(ZfFamily::getName).distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param authorityDto 传入了用户id、modelName |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult managerAuthority(AuthorityDto2 authorityDto) { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | ZInfoUser myself = zInfoUserService.getById(userId); |
| | | |
| | | //查看当前用户是不是管理员 |
| | | if(myself.getRoleId()!=1 && myself.getRoleId()!=2){ |
| | | throw new RuntimeException("你不是家庭管理员,没有权限操作"); |
| | | } |
| | | |
| | | |
| | | Long uid = authorityDto.getUid(); |
| | | Long fid = myself.getFamilyId(); |
| | | String modelName = authorityDto.getModelName(); |
| | | |
| | | //根据模块的名字查出对应的权限码 |
| | | List<ZfCode> zfCodeList = zfCodeService.likeGetByName(modelName); |
| | | List<Long> allCodeList = zfCodeList.stream().map(ZfCode::getCode).collect(Collectors.toList());//权限码数组 |
| | | |
| | | //找到对应家庭对应模块的权限数组 |
| | | LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZAuthority::getFid,fid) |
| | | .eq(ZAuthority::getUid,uid) |
| | | .in(ZAuthority::getAuthority,allCodeList); |
| | | List<ZAuthority> authorityList = list(lqw); |
| | | |
| | | //先删掉现在所有的权限 |
| | | List<Long> idList = authorityList.stream().map(ZAuthority::getId).collect(Collectors.toList()); |
| | | zAuthorityService.removeBatchByIds(idList); |
| | | |
| | | //再添加新设置的权限 |
| | | if(authorityDto.getSearch() == 1){ |
| | | //根据模块的名字查到权限码,只会有一个结果 |
| | | List<ZfCode> zfcode = zfCodeService.likeGetByName(modelName + "查看"); |
| | | ZAuthority zAuthority = new ZAuthority(); |
| | | zAuthority.setFid(fid); |
| | | zAuthority.setUid(uid); |
| | | zAuthority.setAuthority(zfcode.get(0).getCode()); |
| | | zAuthorityService.save(zAuthority); |
| | | } |
| | | |
| | | if(authorityDto.getInsert() == 1){ |
| | | //根据模块的名字查到权限码,只会有一个结果 |
| | | List<ZfCode> zfcode = zfCodeService.likeGetByName(modelName + "添加"); |
| | | ZAuthority zAuthority = new ZAuthority(); |
| | | zAuthority.setFid(fid); |
| | | zAuthority.setUid(uid); |
| | | zAuthority.setAuthority(zfcode.get(0).getCode()); |
| | | zAuthorityService.save(zAuthority); |
| | | } |
| | | |
| | | if(authorityDto.getUpdate() == 1){ |
| | | //根据模块的名字查到权限码,只会有一个结果 |
| | | List<ZfCode> zfcode = zfCodeService.likeGetByName(modelName + "修改"); |
| | | ZAuthority zAuthority = new ZAuthority(); |
| | | zAuthority.setFid(fid); |
| | | zAuthority.setUid(uid); |
| | | zAuthority.setAuthority(zfcode.get(0).getCode()); |
| | | zAuthorityService.save(zAuthority); |
| | | } |
| | | |
| | | if(authorityDto.getDelete() == 1){ |
| | | //根据模块的名字查到权限码,只会有一个结果 |
| | | List<ZfCode> zfcode = zfCodeService.likeGetByName(modelName + "删除"); |
| | | ZAuthority zAuthority = new ZAuthority(); |
| | | zAuthority.setFid(fid); |
| | | zAuthority.setUid(uid); |
| | | zAuthority.setAuthority(zfcode.get(0).getCode()); |
| | | zAuthorityService.save(zAuthority); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import com.ruoyi.domain.dto.UserInfoDto; |
| | | import com.ruoyi.mapper.ZfEventMapper; |
| | | import com.ruoyi.mapper.ZfFamilyMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEventService; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | |
| | | **/ |
| | | @Service |
| | | public class ZfFamilyServiceImpl extends ServiceImpl<ZfFamilyMapper, ZfFamily> implements ZfFamilyService { |
| | | @Autowired |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | |
| | | @Override |
| | | public ZfFamily getByName(String familyName) { |
| | | LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfFamily::getName,familyName); |
| | | return getOne(lqw); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserInfoDto> getByFamilyId(Long fid) { |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getFamilyId,fid); |
| | | List<ZInfoUser> list = zInfoUserService.list(lqw); |
| | | return list.stream().map( |
| | | zInfoUser -> { |
| | | UserInfoDto userInfoDto = new UserInfoDto(); |
| | | userInfoDto.setId(zInfoUser.getUserId()); |
| | | userInfoDto.setFamilyId(zInfoUser.getFamilyId()); |
| | | userInfoDto.setName(zInfoUser.getNickName()); |
| | | userInfoDto.setFamilyName(getById(zInfoUser.getFamilyId()).getName()); |
| | | return userInfoDto; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<UserInfoDto> getNowMember() { |
| | | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | ZInfoUser myself = zInfoUserService.getById(userId); |
| | | return getByFamilyId(myself.getFamilyId()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addMember(UserInfoDto userInfoDto) { |
| | | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | ZInfoUser myself = zInfoUserService.getById(userId); |
| | | |
| | | //查看当前用户是不是管理员 |
| | | if(myself.getRoleId()!=1 && myself.getRoleId()!=2){ |
| | | throw new RuntimeException("你不是家庭管理员,没有权限操作"); |
| | | } |
| | | |
| | | Long uid = userInfoDto.getId(); |
| | | // Long targetFamilyId = zInfoUserService.getById(uid).getFamilyId(); |
| | | UpdateWrapper<ZInfoUser> luw = new UpdateWrapper<>(); |
| | | luw.eq("user_id",uid); |
| | | //update from z_info_user set family_id = #{targetFamilyId where user_id = #{uid} |
| | | luw.setSql("family_id = "+myself.getFamilyId()); |
| | | |
| | | zInfoUserService.update(luw); |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult removeMember(UserInfoDto userInfoDto) { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | ZInfoUser myself = zInfoUserService.getById(userId); |
| | | |
| | | //查看当前用户是不是管理员 |
| | | if(myself.getRoleId()!=1 && myself.getRoleId()!=2){ |
| | | throw new RuntimeException("你不是家庭管理员,没有权限操作"); |
| | | } |
| | | |
| | | Long uid = userInfoDto.getId(); |
| | | // Long targetFamilyId = zInfoUserService.getById(uid).getFamilyId(); |
| | | UpdateWrapper<ZInfoUser> luw = new UpdateWrapper<>(); |
| | | luw.eq("user_id",uid); |
| | | //update from z_info_user set family_id = #{targetFamilyId where user_id = #{uid} |
| | | luw.setSql("family_id = "+null); |
| | | |
| | | zInfoUserService.update(luw); |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | } |