ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/MarrySelfController.java
New file @@ -0,0 +1,48 @@ package com.ruoyi.web.controller.zhang; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.domain.ZfDoctor; import com.ruoyi.domain.dto.MarryInfoDto; import com.ruoyi.service.MarrySelfService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:26 * @Version 1.0.0 **/ @RestController @RequestMapping("/marrySelf") public class MarrySelfController { @Resource MarrySelfService marrySelfService; //获取所有信息 @GetMapping() public AjaxResult getInfo(){ return marrySelfService.getInfo(); } //新增或修改基本信息 @PostMapping() public AjaxResult updateData(@RequestBody MarryInfoDto marryInfoDto){ return marrySelfService.updateData(marryInfoDto); } //导出 @PostMapping("/export") public void export(HttpServletResponse response){ MarryInfoDto data = (MarryInfoDto)marrySelfService.getInfo().get("data"); List<MarryInfoDto> marryInfoDtos = new ArrayList<>(); marryInfoDtos.add(data); ExcelUtil<MarryInfoDto> util = new ExcelUtil<>(MarryInfoDto.class); util.exportExcel(response, marryInfoDtos, "个人婚姻数据"); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/MarryUserController.java
New file @@ -0,0 +1,51 @@ package com.ruoyi.web.controller.zhang; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.MarryUser; import com.ruoyi.service.MarrySelfService; import com.ruoyi.service.MarryUserService; import org.omg.CORBA.PUBLIC_MEMBER; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.websocket.server.PathParam; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:30 * @Version 1.0.0 **/ @RestController @RequestMapping("/marryUser") public class MarryUserController { @Resource MarryUserService marryUserService; //获取前任信息 @GetMapping() public AjaxResult getInfo(){ return marryUserService.getInfo(); } //新增前任 @PostMapping() public AjaxResult addData(@RequestBody MarryUser marryUser){ return marryUserService.addData(marryUser); } //修改前任 @PutMapping() public AjaxResult updateData(@RequestBody MarryUser marryUser){ return marryUserService.updateData(marryUser); } //删除前任 @DeleteMapping() public AjaxResult delete(@PathParam("id") Long id){ marryUserService.removeById(id); return AjaxResult.success(); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZMarryController.java
@@ -35,90 +35,90 @@ @RequestMapping("/zMarry") @Slf4j public class ZMarryController extends BaseController { @Autowired private ZMarryService zMarryService; /** * 查询当前婚姻状况 */ @GetMapping("/list") public AjaxResult getMarryStatus(){ return zMarryService.getNow(); } /** * 新增婚姻状况记录 */ // @PreAuthorize("@ss.hasPermi('system:property:add')") @Log(title = "婚姻状况记录", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody MarryInfoDto marryInfoDto) { return zMarryService.addInfo(marryInfoDto); } /** * 修改婚姻状况记录 */ // @PreAuthorize("@ss.hasPermi('system:property:edit')") @Log(title = "婚姻状况记录", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody MarryInfoDto marryInfoDto) { return zMarryService.updateInfo(marryInfoDto); } // @Autowired // private ZMarryService zMarryService; // /** * 批量删除婚姻状况记录 */ // @PreAuthorize("@ss.hasPermi('system:property:remove')") @Log(title = "婚姻状况记录", businessType = BusinessType.DELETE) @DeleteMapping("/{id}") public AjaxResult remove(@PathVariable String id) { return zMarryService.deleteOld(id); } // // /** // * 导出婚姻状况 // * 查询当前婚姻状况 // */ // @GetMapping("/list") // public AjaxResult getMarryStatus(){ // return zMarryService.getNow(); // } // // /** // * 新增婚姻状况记录 // */ //// @PreAuthorize("@ss.hasPermi('system:property:add')") // @Log(title = "婚姻状况记录", businessType = BusinessType.INSERT) // @PostMapping // public AjaxResult add(@RequestBody MarryInfoDto marryInfoDto) // { // return zMarryService.addInfo(marryInfoDto); // } // // /** // * 修改婚姻状况记录 // */ //// @PreAuthorize("@ss.hasPermi('system:property:edit')") // @Log(title = "婚姻状况记录", businessType = BusinessType.UPDATE) // @PutMapping // public AjaxResult edit(@RequestBody MarryInfoDto marryInfoDto) // { // return zMarryService.updateInfo(marryInfoDto); // } //// // /** // * 批量删除婚姻状况记录 // */ //// @PreAuthorize("@ss.hasPermi('system:property:remove')") // @Log(title = "婚姻状况记录", businessType = BusinessType.DELETE) // @DeleteMapping("/{id}") // public AjaxResult remove(@PathVariable String id) // { // return zMarryService.deleteOld(id); // } // // //// /** //// * 导出婚姻状况 //// */ //// @PostMapping("/export") //// public void export(HttpServletResponse response) //// { //// AjaxResult marryStatus = getMarryStatus(); //// HashMap data = (HashMap) marryStatus.get("data"); //// //// List<MarryUser> myInfoList = Arrays.asList((MarryUser) data.get("myInfo")); //// ExcelUtil<MarryUser> util1 = new ExcelUtil<>(MarryUser.class); //// util1.exportEasyExcel(response,myInfoList,"个人信息"); //// //// List<MarryUser> spouseInfoList = Arrays.asList((MarryUser) data.get("spouseInfo")); //// ExcelUtil<MarryUser> util2 = new ExcelUtil<>(MarryUser.class); //// util2.exportEasyExcel(response,spouseInfoList,"配偶信息"); //// //// List<ZMarry> marryInfoList = Arrays.asList((ZMarry) data.get("marryInfo")); //// ExcelUtil<ZMarry> util3 = new ExcelUtil<>(ZMarry.class); //// util3.exportEasyExcel(response,marryInfoList,"婚姻信息"); //// //// List<MarryUser> oldSpouseInfoList = (List<MarryUser>) data.get("oldSpouseInfo"); //// ExcelUtil<MarryUser> util4 = new ExcelUtil<>(MarryUser.class); //// util4.exportEasyExcel(response,oldSpouseInfoList,"前任信息"); //// } // // // /** // * 导出 // */ // @PostMapping("/export") // public void export(HttpServletResponse response) // { // public void export(HttpServletResponse response){ // AjaxResult marryStatus = getMarryStatus(); // HashMap data = (HashMap) marryStatus.get("data"); // // List<MarryUser> myInfoList = Arrays.asList((MarryUser) data.get("myInfo")); // ExcelUtil<MarryUser> util1 = new ExcelUtil<>(MarryUser.class); // util1.exportEasyExcel(response,myInfoList,"个人信息"); // // List<MarryUser> spouseInfoList = Arrays.asList((MarryUser) data.get("spouseInfo")); // ExcelUtil<MarryUser> util2 = new ExcelUtil<>(MarryUser.class); // util2.exportEasyExcel(response,spouseInfoList,"配偶信息"); // // List<ZMarry> marryInfoList = Arrays.asList((ZMarry) data.get("marryInfo")); // ExcelUtil<ZMarry> util3 = new ExcelUtil<>(ZMarry.class); // util3.exportEasyExcel(response,marryInfoList,"婚姻信息"); // // List<MarryUser> oldSpouseInfoList = (List<MarryUser>) data.get("oldSpouseInfo"); // ExcelUtil<MarryUser> util4 = new ExcelUtil<>(MarryUser.class); // util4.exportEasyExcel(response,oldSpouseInfoList,"前任信息"); // MarryInfoDto data = (MarryInfoDto) marryStatus.get("data"); // List<MarryInfoDto> list = Arrays.asList(data); // ExcelUtil<MarryInfoDto> util1 = new ExcelUtil<>(MarryInfoDto.class); // util1.exportExcel(response,list,"婚姻信息"); // } /** * 导出 */ @PostMapping("/export") public void export(HttpServletResponse response){ AjaxResult marryStatus = getMarryStatus(); MarryInfoDto data = (MarryInfoDto) marryStatus.get("data"); List<MarryInfoDto> list = Arrays.asList(data); ExcelUtil<MarryInfoDto> util1 = new ExcelUtil<>(MarryInfoDto.class); util1.exportExcel(response,list,"婚姻信息"); } } zhang-content/src/main/java/com/ruoyi/domain/MarrySelf.java
New file @@ -0,0 +1,108 @@ package com.ruoyi.domain; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import lombok.Data; import java.io.Serializable; import java.util.Date; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:20 * @Version 1.0.0 **/ @Data public class MarrySelf implements Serializable { private static final long serialVersionUID = 1L; private Long id; @Excel(name = "姓名") private String name; @Excel(name = "性别") private String sex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "生日", dateFormat = "yyyy-MM-dd") private Date birthday; @Excel(name = "民族") private String nation; @Excel(name = "身份证") private String idNo; @Excel(name = "手机号码") private String phone; @Excel(name = "婚姻状况",readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚") private Integer marryStatus; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "结婚时间", dateFormat = "yyyy-MM-dd") private Date marryTime; @Excel(name = "户籍地址") private String address; /** * 生育情况,0:未生育、1:在孕、2:已生育 */ // @Excel(name = "生育情况",readConverterExp = "0=未生育,1=在孕,2=已生育") private Integer bearStatus; // @Excel(name = "是否领取计划生育服务手册",readConverterExp = "0=否,1=是") private Integer handbookStatus; @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") // @Excel(name = "领取计划生育服务手册时间", dateFormat = "yyyy-MM-dd") private Date handbookTime; // @Excel(name = "是否领取独生子女证", readConverterExp = "0=否,1=是") private Integer oneBorn; @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") // @Excel(name = "领取独生子女证时间", dateFormat = "yyyy-MM-dd") private Date oneBornTime; // @Excel(name = "需声明的情况") private String notion; // @Excel(name = "备注") private String remark; private Long uid; @Excel(name = "姓名") private String spouseName; @Excel(name = "性别") private String spouseSex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "生日", dateFormat = "yyyy-MM-dd") private Date spouseBirthday; @Excel(name = "民族") private String spouseNation; @Excel(name = "身份证") private String spouseIdNo; @Excel(name = "手机号码") private String spousePhone; @Excel(name = "婚姻状况",readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚") private Integer spouseMarryStatus; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "结婚时间", dateFormat = "yyyy-MM-dd") private Date spouseMarryTime; @Excel(name = "户籍地址") private String spouseAddress; } zhang-content/src/main/java/com/ruoyi/domain/MarryUser.java
@@ -25,41 +25,37 @@ public class MarryUser implements Serializable { private static final long serialVersionUID = 1L; private String id; private Long myId; private Long id; @Excel(name = "姓名") // @ExcelProperty({"姓名"}) private String name; @Excel(name = "性别") private String sex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "生日", dateFormat = "yyyy-MM-dd") // @ExcelProperty({"生日"}) // @DateTimeFormat("yyyy-MM-dd") private Date birthday; @Excel(name = "户籍地址") // @ExcelProperty({"户籍地址"}) private String address; @Excel(name = "身份证") // @ExcelProperty({"工作地址"}) private String idNo; @Excel(name = "婚姻状况",readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚") // @ExcelProperty(value = {"婚姻状况"},converter = BearStatusConverter.class) private Integer marryStatus; @Excel(name = "性别",readConverterExp = "0=女,1=男") // @ExcelProperty({"性别"}) private Integer sex; @Excel(name = "民族") // @ExcelProperty({"民族"}) private String nation; @Excel(name = "身份证") private String idNo; @Excel(name = "户籍地址") private String address; @Excel(name = "手机号码") // @ExcelProperty({"手机号码"}) private String phone; @Excel(name = "婚姻状况",readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚") private Integer marryStatus; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "结婚时间", dateFormat = "yyyy-MM-dd") private Date marryTime; private Long uid; } zhang-content/src/main/java/com/ruoyi/domain/dto/MarryInfoDto.java
@@ -24,71 +24,116 @@ private static final long serialVersionUID = 1L; //我个人的数据 private String id; private Long id; // @ExcelProperty({"个人数据","姓名"}) @Excel(name = "个人姓名",headerBackgroundColor = IndexedColors.YELLOW) private String name; // @ExcelProperty(value = {"个人信息","性别"}) @Excel(name = "个人性别",headerBackgroundColor = IndexedColors.YELLOW) private String sex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") // @ExcelProperty({"个人信息","生日"}) // @DateTimeFormat("yyyy-MM-dd") @Excel(name = "个人生日", dateFormat = "yyyy-MM-dd",headerBackgroundColor = IndexedColors.YELLOW) private Date birthday; // @ExcelProperty({"个人信息","户籍地址"}) @Excel(name = "个人户籍地址",headerBackgroundColor = IndexedColors.YELLOW) private String address; // @ExcelProperty({"个人信息","工作地址"}) @Excel(name = "个人身份证",headerBackgroundColor = IndexedColors.YELLOW) private String idNo; // @ExcelProperty(value = {"个人信息","婚姻状况"},converter = BearStatusConverter.class) @Excel(name = "个人婚姻状况", readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚",headerBackgroundColor = IndexedColors.YELLOW) private Integer marryStatus; // @ExcelProperty(value = {"个人信息","性别"}) @Excel(name = "个人性别", readConverterExp = "0=女,1=男",headerBackgroundColor = IndexedColors.YELLOW) private Integer sex; // @ExcelProperty(value = {"个人信息","民族"}) @Excel(name = "个人民族",headerBackgroundColor = IndexedColors.YELLOW) private String nation; @Excel(name = "个人身份证",headerBackgroundColor = IndexedColors.YELLOW) private String idNo; // @ExcelProperty(value = {"个人信息","手机号码"}) @Excel(name = "个人电话号码",headerBackgroundColor = IndexedColors.YELLOW) private String phone; //配偶的数据 private String spouseId; // @ExcelProperty(value = {"配偶信息","姓名"}) @Excel(name = "配偶姓名",headerBackgroundColor = IndexedColors.GREEN) private String spouseName; // @ExcelProperty(value = {"个人信息","婚姻状况"},converter = BearStatusConverter.class) @Excel(name = "个人婚姻状况", readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚",headerBackgroundColor = IndexedColors.YELLOW) private Integer marryStatus; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") // @ExcelProperty(value = {"配偶信息","生日"}) // @DateTimeFormat("yyyy-MM-dd") @Excel(name = "配偶生日", dateFormat = "yyyy-MM-dd",headerBackgroundColor = IndexedColors.GREEN) @Excel(name = "结婚时间", dateFormat = "yyyy-MM-dd",headerBackgroundColor = IndexedColors.YELLOW) private Date marryTime; // @ExcelProperty({"个人信息","户籍地址"}) @Excel(name = "个人户籍地址",headerBackgroundColor = IndexedColors.YELLOW) private String address; @Excel(name = "配偶姓名") private String spouseName; @Excel(name = "配偶性别") private String spouseSex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "配偶生日", dateFormat = "yyyy-MM-dd") private Date spouseBirthday; // @ExcelProperty(value = {"配偶信息","户籍地址"}) @Excel(name = "配偶户籍地址",headerBackgroundColor = IndexedColors.GREEN) private String spouseAddress; // @ExcelProperty(value = {"配偶信息","工作地址"}) @Excel(name = "配偶身份证",headerBackgroundColor = IndexedColors.GREEN) private String spouseIdNo; // @ExcelProperty(value = {"配偶信息","婚姻状况"},converter = BearStatusConverter.class) @Excel(name = "配偶婚姻状况", readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚",headerBackgroundColor = IndexedColors.GREEN) private Integer spouseMarryStatus; // @ExcelProperty(value = {"配偶信息","性别"}) @Excel(name = "配偶性别", readConverterExp = "0=女,1=男",headerBackgroundColor = IndexedColors.GREEN) private Integer spouseSex; // @ExcelProperty(value = {"配偶信息","民族"}) @Excel(name = "配偶民族",headerBackgroundColor = IndexedColors.GREEN) @Excel(name = "配偶民族") private String spouseNation; @Excel(name = "配偶手机号码",headerBackgroundColor = IndexedColors.GREEN) @Excel(name = "配偶身份证") private String spouseIdNo; @Excel(name = "配偶手机号码") private String spousePhone; @Excel(name = "配偶婚姻状况",readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚") private Integer spouseMarryStatus; //生育情况(中间表) private Long marryId; /** * 结婚时间 */ @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "结婚时间", dateFormat = "yyyy-MM-dd") private Date marryTime; @Excel(name = "配偶结婚时间", dateFormat = "yyyy-MM-dd") private Date spouseMarryTime; @Excel(name = "配偶户籍地址") private String spouseAddress; // //配偶的数据 // private Long spouseId; // // @ExcelProperty(value = {"配偶信息","姓名"}) // @Excel(name = "配偶姓名",headerBackgroundColor = IndexedColors.GREEN) // private String spouseName; // @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") // // // @ExcelProperty(value = {"配偶信息","性别"}) // @Excel(name = "配偶性别", readConverterExp = "0=女,1=男",headerBackgroundColor = IndexedColors.GREEN) // private Integer spouseSex; // //// @ExcelProperty(value = {"配偶信息","生日"}) //// @DateTimeFormat("yyyy-MM-dd") // @Excel(name = "配偶生日", dateFormat = "yyyy-MM-dd",headerBackgroundColor = IndexedColors.GREEN) // private Date spouseBirthday; // // // @ExcelProperty(value = {"配偶信息","民族"}) // @Excel(name = "配偶民族",headerBackgroundColor = IndexedColors.GREEN) // private String spouseNation; // // @Excel(name = "配偶身份证",headerBackgroundColor = IndexedColors.GREEN) // private String spouseIdNo; // // // @ExcelProperty(value = {"配偶信息","户籍地址"}) // @Excel(name = "配偶户籍地址",headerBackgroundColor = IndexedColors.GREEN) // private String spouseAddress; // // @Excel(name = "配偶手机号码",headerBackgroundColor = IndexedColors.GREEN) // private String spousePhone; // // // @ExcelProperty(value = {"配偶信息","工作地址"}) // // // @ExcelProperty(value = {"配偶信息","婚姻状况"},converter = BearStatusConverter.class) // @Excel(name = "配偶婚姻状况", readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚",headerBackgroundColor = IndexedColors.GREEN) // private Integer spouseMarryStatus; // // @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") // @Excel(name = "配偶结婚时间", dateFormat = "yyyy-MM-dd",headerBackgroundColor = IndexedColors.GREEN) // private Date spouseMarryTime; //生育情况 /** * 生育情况,0:未生育、1:在孕、2:已生育 @@ -106,7 +151,7 @@ @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date oneBornTime; @Excel(name = "需声明的情况") private String content; private String notion; @Excel(name = "备注") private String remark; @@ -114,6 +159,6 @@ * 前任信息的List */ @Excel(name = "前任信息",headerBackgroundColor= IndexedColors.RED) private List<MarryUser> oldSpouseList; private List<MarryUserDto> oldSpouseList; } zhang-content/src/main/java/com/ruoyi/domain/dto/MarryUserDto.java
New file @@ -0,0 +1,50 @@ package com.ruoyi.domain.dto; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import lombok.Data; import java.io.Serializable; import java.util.Date; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:38 * @Version 1.0.0 **/ @Data public class MarryUserDto implements Serializable { private static final long serialVersionUID = 1L; private Long id; @Excel(name = "姓名") private String name; @Excel(name = "性别") private String sex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "生日", dateFormat = "yyyy-MM-dd") private Date birthday; @Excel(name = "民族") private String nation; @Excel(name = "身份证") private String idNo; @Excel(name = "户籍地址") private String address; @Excel(name = "手机号码") private String phone; @Excel(name = "婚姻状况",readConverterExp = "0=未婚,1=初婚,2=离婚,3=再婚") private Integer marryStatus; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "结婚时间", dateFormat = "yyyy-MM-dd") private Date marryTime; } zhang-content/src/main/java/com/ruoyi/mapper/MarrySelfMapper.java
New file @@ -0,0 +1,15 @@ package com.ruoyi.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.domain.MarrySelf; import org.apache.ibatis.annotations.Mapper; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:23 * @Version 1.0.0 **/ @Mapper public interface MarrySelfMapper extends BaseMapper<MarrySelf> { } zhang-content/src/main/java/com/ruoyi/service/MarrySelfService.java
New file @@ -0,0 +1,18 @@ package com.ruoyi.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.MarrySelf; import com.ruoyi.domain.dto.MarryInfoDto; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:24 * @Version 1.0.0 **/ public interface MarrySelfService extends IService<MarrySelf> { AjaxResult getInfo(); AjaxResult updateData(MarryInfoDto marryInfoDto); } zhang-content/src/main/java/com/ruoyi/service/MarryUserService.java
@@ -1,6 +1,7 @@ package com.ruoyi.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.MarryUser; /** @@ -10,4 +11,9 @@ * @Version 1.0.0 **/ public interface MarryUserService extends IService<MarryUser> { AjaxResult getInfo(); AjaxResult addData(MarryUser marryUser); AjaxResult updateData(MarryUser marryUser); } zhang-content/src/main/java/com/ruoyi/service/ZMarryService.java
@@ -16,10 +16,10 @@ */ public interface ZMarryService extends IService<ZMarry> { AjaxResult getNow(); AjaxResult addInfo(MarryInfoDto marryInfoDto); AjaxResult updateInfo(MarryInfoDto marryInfoDto); AjaxResult deleteOld(String spouseId); // AjaxResult getNow(); // // AjaxResult addInfo(MarryInfoDto marryInfoDto); // // AjaxResult updateInfo(MarryInfoDto marryInfoDto); // AjaxResult deleteOld(String spouseId); } zhang-content/src/main/java/com/ruoyi/service/impl/MarrySelfServiceImpl.java
New file @@ -0,0 +1,98 @@ package com.ruoyi.service.impl; 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.common.utils.bean.BeanUtils; import com.ruoyi.domain.MarrySelf; import com.ruoyi.domain.MarryUser; import com.ruoyi.domain.dto.MarryInfoDto; import com.ruoyi.domain.dto.MarryUserDto; import com.ruoyi.mapper.MarrySelfMapper; import com.ruoyi.service.MarrySelfService; import com.ruoyi.service.MarryUserService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; /** * @Author Jinquan_Ou * @Description * @Date 2023-08-07 21:25 * @Version 1.0.0 **/ @Service public class MarrySelfServiceImpl extends ServiceImpl<MarrySelfMapper, MarrySelf> implements MarrySelfService { @Resource MarryUserService marryUserService; // @Resource // MarrySelfService marrySelfService; @Override public AjaxResult getInfo() { //先查询自己的信息 SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<MarrySelf> marrySelfLQW = new LambdaQueryWrapper<>(); marrySelfLQW.eq(MarrySelf::getUid,userId); MarrySelf myself = getOne(marrySelfLQW); if(myself == null){ throw new RuntimeException("请先编辑信息"); } //再查询前任的信息 LambdaQueryWrapper<MarryUser> marryUserLQW = new LambdaQueryWrapper<>(); marryUserLQW.eq(MarryUser::getUid,userId); List<MarryUser> spouseList = marryUserService.list(marryUserLQW); List<MarryUserDto> frontList = spouseList.stream().map(s -> { MarryUserDto marryUserDto = new MarryUserDto(); BeanUtils.copyProperties(s, marryUserDto); return marryUserDto; }).collect(Collectors.toList()); //最终返回数据模型 MarryInfoDto result = new MarryInfoDto(); BeanUtils.copyProperties(myself,result); result.setOldSpouseList(frontList); return AjaxResult.success(result); } @Override public AjaxResult updateData(MarryInfoDto marryInfoDto) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); MarrySelf marrySelf = new MarrySelf(); BeanUtils.copyProperties(marryInfoDto,marrySelf); marrySelf.setUid(userId); //先查询数据库中有没有本用户的数据 LambdaQueryWrapper<MarrySelf> lqw = new LambdaQueryWrapper<>(); lqw.eq(MarrySelf::getUid,userId); List<MarrySelf> list = list(lqw); if(list.isEmpty()){ //如果是空的,那就是新增 save(marrySelf); }else { //否则就是修改 marrySelf.setId(list.get(0).getId()); updateById(marrySelf); } return AjaxResult.success(); } } zhang-content/src/main/java/com/ruoyi/service/impl/MarryUserServiceImpl.java
@@ -1,10 +1,16 @@ package com.ruoyi.service.impl; 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.MarryUser; import com.ruoyi.mapper.MarryUserMapper; import com.ruoyi.service.MarryUserService; import org.springframework.stereotype.Service; import java.util.List; /** * @Author Jinquan_Ou @@ -14,4 +20,39 @@ **/ @Service public class MarryUserServiceImpl extends ServiceImpl<MarryUserMapper, MarryUser> implements MarryUserService { @Override public AjaxResult getInfo() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<MarryUser> lqw = new LambdaQueryWrapper<>(); lqw.eq(MarryUser::getUid,userId); List<MarryUser> frontList = list(lqw); return AjaxResult.success(frontList); } @Override public AjaxResult addData(MarryUser marryUser) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); marryUser.setUid(userId); save(marryUser); return AjaxResult.success(); } @Override public AjaxResult updateData(MarryUser marryUser) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); marryUser.setUid(userId); updateById(marryUser); return AjaxResult.success(); } } zhang-content/src/main/java/com/ruoyi/service/impl/ZMarryServiceImpl.java
@@ -33,294 +33,294 @@ @Service public class ZMarryServiceImpl extends ServiceImpl<ZMarryMapper, ZMarry> implements ZMarryService { @Resource MarryUserService marryUserService; @Autowired ZMarryServiceImpl zMarryService; @Override public AjaxResult getNow() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); //先查询个人信息 LambdaQueryWrapper<MarryUser> marryUserLambdaQueryWrapper1 = new LambdaQueryWrapper<>(); marryUserLambdaQueryWrapper1.eq(MarryUser::getMyId, userId); MarryUser myself = marryUserService.getOne(marryUserLambdaQueryWrapper1); //再查询中间表信息 if (myself == null) { throw new RuntimeException("您暂时还未在婚姻表中添加个人信息"); } LambdaQueryWrapper<ZMarry> zMarryLambdaQueryWrapper = new LambdaQueryWrapper<>(); zMarryLambdaQueryWrapper.eq(ZMarry::getUserId, myself.getMyId()) .eq(ZMarry::getDeleteStatus, 0); ZMarry myMarryInfo = getOne(zMarryLambdaQueryWrapper);//只能有一个配偶 //根据中间表信息查询配偶信息 if (myMarryInfo == null) { throw new RuntimeException("您暂时还未在婚姻表中添加婚姻信息"); } String spouseId = myMarryInfo.getSpouseId(); LambdaQueryWrapper<MarryUser> marryUserLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); marryUserLambdaQueryWrapper2.eq(MarryUser::getId, spouseId); MarryUser spouse = marryUserService.getOne(marryUserLambdaQueryWrapper2); if (spouse == null) { throw new RuntimeException("您暂时还未在婚姻表中添加配偶信息"); } //根据中间表信息查询前任信息 LambdaQueryWrapper<ZMarry> zMarryOldLQW = new LambdaQueryWrapper<>(); zMarryOldLQW.eq(ZMarry::getUserId,myself.getMyId()) .eq(ZMarry::getDeleteStatus,1); List<ZMarry> oldList = list(zMarryOldLQW); //前任信息表 List<MarryUser> oldSpouseList = new ArrayList<>(); for (ZMarry zMarry : oldList) { String spouseId1 = zMarry.getSpouseId(); MarryUser oldSpouse = marryUserService.getById(spouseId1); oldSpouseList.add(oldSpouse); } // //统一封装返回 // HashMap<String, Object> resultMap = new HashMap<>(); // resultMap.put("myInfo",myself); // resultMap.put("spouseInfo",spouse); // resultMap.put("marryInfo",myMarryInfo); // resultMap.put("oldSpouseInfo",oldSpouseList); //转成DTO返回 MarryInfoDto marryInfoDto = MarryInfoToDto(myMarryInfo, oldSpouseList, myself, spouse); return AjaxResult.success(marryInfoDto); } private MarryInfoDto MarryInfoToDto(ZMarry myMarryInfo,List<MarryUser> oldSpouseList,MarryUser myself,MarryUser spouse){ MarryInfoDto marryInfoDto = new MarryInfoDto(); marryInfoDto.setId(myself.getId()); marryInfoDto.setName(myself.getName()); marryInfoDto.setBirthday(myself.getBirthday()); marryInfoDto.setAddress(myself.getAddress()); marryInfoDto.setIdNo(myself.getIdNo()); marryInfoDto.setMarryStatus(myself.getMarryStatus()); marryInfoDto.setSex(myself.getSex()); marryInfoDto.setNation(myself.getNation()); marryInfoDto.setPhone(myself.getPhone()); marryInfoDto.setSpouseId(spouse.getId()); marryInfoDto.setSpouseName(spouse.getName()); marryInfoDto.setSpouseBirthday(spouse.getBirthday()); marryInfoDto.setSpouseAddress(spouse.getAddress()); marryInfoDto.setSpouseIdNo(spouse.getIdNo()); marryInfoDto.setSpouseMarryStatus(spouse.getMarryStatus()); marryInfoDto.setSpouseSex(spouse.getSex()); marryInfoDto.setSpouseNation(spouse.getNation()); marryInfoDto.setSpousePhone(spouse.getPhone()); marryInfoDto.setMarryId(myMarryInfo.getId()); marryInfoDto.setBearStatus(myMarryInfo.getBearStatus()); marryInfoDto.setHandbookStatus(myMarryInfo.getHandbookStatus()); marryInfoDto.setHandbookTime(myMarryInfo.getHandbookTime()); marryInfoDto.setOneBorn(myMarryInfo.getOneBorn()); marryInfoDto.setOneBornTime(myMarryInfo.getOneBornTime()); marryInfoDto.setContent(myMarryInfo.getContent()); marryInfoDto.setRemark(myMarryInfo.getRemark()); marryInfoDto.setMarryTime(myMarryInfo.getMarryTime()); marryInfoDto.setOldSpouseList(oldSpouseList); return marryInfoDto; } @Transactional public AjaxResult addInfo(MarryInfoDto marryInfoDto){ SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); String meId= IdUtils.simpleUUID(); String spouseId = IdUtils.simpleUUID(); //添加自己的信息 MarryUser myself = new MarryUser(); myself.setId(meId); myself.setName(marryInfoDto.getName()); myself.setBirthday(marryInfoDto.getBirthday()); myself.setAddress(marryInfoDto.getAddress()); myself.setIdNo(marryInfoDto.getIdNo()); myself.setMarryStatus(marryInfoDto.getMarryStatus()); myself.setSex(marryInfoDto.getSex()); myself.setMyId(userId); myself.setNation(marryInfoDto.getNation()); myself.setPhone(marryInfoDto.getPhone()); marryUserService.save(myself); //添加配偶的信息 MarryUser spouse = new MarryUser(); spouse.setId(spouseId); spouse.setName(marryInfoDto.getSpouseName()); spouse.setBirthday(marryInfoDto.getSpouseBirthday()); spouse.setAddress(marryInfoDto.getSpouseAddress()); spouse.setIdNo(marryInfoDto.getSpouseIdNo()); spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); spouse.setSex(marryInfoDto.getSpouseSex()); spouse.setNation(marryInfoDto.getSpouseNation()); spouse.setPhone(marryInfoDto.getSpousePhone()); marryUserService.save(spouse); //添加生育情况(中间表)信息 ZMarry zMarry = new ZMarry(); zMarry.setUserId(userId); zMarry.setSpouseId(spouseId); zMarry.setMarryTime(marryInfoDto.getMarryTime()); zMarry.setBearStatus(marryInfoDto.getBearStatus()); zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); zMarry.setOneBorn(marryInfoDto.getOneBorn()); zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); zMarry.setContent(marryInfoDto.getContent()); zMarry.setRemark(marryInfoDto.getRemark()); zMarry.setDeleteStatus(0); zMarryService.save(zMarry); List<MarryUser> oldSpouseList = marryInfoDto.getOldSpouseList(); //添加前任的信息 if(oldSpouseList!=null&&oldSpouseList.size()!=0){ for (MarryUser marryUser : oldSpouseList) { //先添加配偶用户信息 String spId = IdUtils.simpleUUID(); marryUser.setId(spId); marryUserService.save(marryUser); //再添加中间表信息 ZMarry oldMarry = new ZMarry(); oldMarry.setUserId(userId); oldMarry.setSpouseId(spId); oldMarry.setDeleteStatus(1); zMarryService.save(oldMarry); } } return AjaxResult.success(); } @Transactional public AjaxResult updateInfo(MarryInfoDto marryInfoDto){ SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); //更新自己的信息 MarryUser myself = new MarryUser(); myself.setId(marryInfoDto.getId()); myself.setName(marryInfoDto.getName()); myself.setBirthday(marryInfoDto.getBirthday()); myself.setAddress(marryInfoDto.getAddress()); myself.setIdNo(marryInfoDto.getIdNo()); myself.setMarryStatus(marryInfoDto.getMarryStatus()); myself.setSex(marryInfoDto.getSex()); myself.setNation(marryInfoDto.getNation()); myself.setPhone(marryInfoDto.getPhone()); marryUserService.updateById(myself); //更新配偶的信息 //先查询是更新配偶信息还是换配偶,因为配偶只能有一个 //这里暂时用名字来判断吧,如果有重名的人就会有bug //先查询 String spouseName = marryInfoDto.getSpouseName(); MarryUser marry = marryUserService.getById(marryInfoDto.getSpouseId()); String marryName = marry.getName(); if(!spouseName.equals(marryName)){ //如果正妻子换人了,就新增而不是修改,同时删除旧纪录 //将现在中间表的妻子改成前妻 LambdaQueryWrapper<ZMarry> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZMarry::getUserId,userId) .eq(ZMarry::getSpouseId,marryInfoDto.getSpouseId()); ZMarry one = getOne(lqw); one.setDeleteStatus(1); zMarryService.updateById(one); //新增用户信息表 String spouseId = IdUtils.simpleUUID(); MarryUser spouse = new MarryUser(); spouse.setId(spouseId); spouse.setName(marryInfoDto.getSpouseName()); spouse.setBirthday(marryInfoDto.getSpouseBirthday()); spouse.setAddress(marryInfoDto.getSpouseAddress()); spouse.setIdNo(marryInfoDto.getSpouseIdNo()); spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); spouse.setSex(marryInfoDto.getSpouseSex()); spouse.setNation(marryInfoDto.getSpouseNation()); spouse.setPhone(marryInfoDto.getSpousePhone()); marryUserService.save(spouse); //新增中间表 //添加生育情况(中间表)信息 ZMarry zMarry = new ZMarry(); zMarry.setUserId(userId); zMarry.setSpouseId(spouseId); zMarry.setMarryTime(marryInfoDto.getMarryTime()); zMarry.setBearStatus(marryInfoDto.getBearStatus()); zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); zMarry.setOneBorn(marryInfoDto.getOneBorn()); zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); zMarry.setContent(marryInfoDto.getContent()); zMarry.setRemark(marryInfoDto.getRemark()); zMarry.setDeleteStatus(0); zMarryService.save(zMarry); }else { MarryUser spouse = new MarryUser(); spouse.setId(marryInfoDto.getSpouseId()); spouse.setName(marryInfoDto.getSpouseName()); spouse.setBirthday(marryInfoDto.getSpouseBirthday()); spouse.setAddress(marryInfoDto.getSpouseAddress()); spouse.setIdNo(marryInfoDto.getSpouseIdNo()); spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); spouse.setSex(marryInfoDto.getSpouseSex()); spouse.setNation(marryInfoDto.getSpouseNation()); spouse.setPhone(marryInfoDto.getSpousePhone()); marryUserService.updateById(spouse); //更新生育情况信息 ZMarry zMarry = new ZMarry(); zMarry.setId(marryInfoDto.getMarryId()); zMarry.setMarryTime(marryInfoDto.getMarryTime()); zMarry.setBearStatus(marryInfoDto.getBearStatus()); zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); zMarry.setOneBorn(marryInfoDto.getOneBorn()); zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); zMarry.setContent(marryInfoDto.getContent()); zMarry.setRemark(marryInfoDto.getRemark()); zMarry.setDeleteStatus(0); zMarryService.updateById(zMarry); } //更新前任信息 List<MarryUser> oldSpouseList = marryInfoDto.getOldSpouseList(); if(oldSpouseList!=null&&oldSpouseList.size()!=0){ for (MarryUser marryUser : oldSpouseList) { //修改用户前任信息 marryUserService.updateById(marryUser); //中间表不需要修改 } } return AjaxResult.success(); } public AjaxResult deleteOld(String spouseId){ marryUserService.removeById(spouseId); return AjaxResult.success(); } // @Resource // MarryUserService marryUserService; // // @Autowired // ZMarryServiceImpl zMarryService; // // @Override // public AjaxResult getNow() { // SysUser user = SecurityUtils.getLoginUser().getUser(); // Long userId = user.getUserId(); // // //先查询个人信息 // LambdaQueryWrapper<MarryUser> marryUserLambdaQueryWrapper1 = new LambdaQueryWrapper<>(); // marryUserLambdaQueryWrapper1.eq(MarryUser::getMyId, userId); // MarryUser myself = marryUserService.getOne(marryUserLambdaQueryWrapper1); // // //再查询中间表信息 // if (myself == null) { // throw new RuntimeException("您暂时还未在婚姻表中添加个人信息"); // } // LambdaQueryWrapper<ZMarry> zMarryLambdaQueryWrapper = new LambdaQueryWrapper<>(); // zMarryLambdaQueryWrapper.eq(ZMarry::getUserId, myself.getMyId()) // .eq(ZMarry::getDeleteStatus, 0); // ZMarry myMarryInfo = getOne(zMarryLambdaQueryWrapper);//只能有一个配偶 // // //根据中间表信息查询配偶信息 // if (myMarryInfo == null) { // throw new RuntimeException("您暂时还未在婚姻表中添加婚姻信息"); // } // String spouseId = myMarryInfo.getSpouseId(); // LambdaQueryWrapper<MarryUser> marryUserLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); // marryUserLambdaQueryWrapper2.eq(MarryUser::getId, spouseId); // MarryUser spouse = marryUserService.getOne(marryUserLambdaQueryWrapper2); // if (spouse == null) { // throw new RuntimeException("您暂时还未在婚姻表中添加配偶信息"); // } // // //根据中间表信息查询前任信息 // LambdaQueryWrapper<ZMarry> zMarryOldLQW = new LambdaQueryWrapper<>(); // zMarryOldLQW.eq(ZMarry::getUserId,myself.getMyId()) // .eq(ZMarry::getDeleteStatus,1); // List<ZMarry> oldList = list(zMarryOldLQW); // // //前任信息表 // List<MarryUser> oldSpouseList = new ArrayList<>(); // for (ZMarry zMarry : oldList) { // String spouseId1 = zMarry.getSpouseId(); // MarryUser oldSpouse = marryUserService.getById(spouseId1); // oldSpouseList.add(oldSpouse); // } // //// //统一封装返回 //// HashMap<String, Object> resultMap = new HashMap<>(); //// resultMap.put("myInfo",myself); //// resultMap.put("spouseInfo",spouse); //// resultMap.put("marryInfo",myMarryInfo); //// resultMap.put("oldSpouseInfo",oldSpouseList); // // //转成DTO返回 // MarryInfoDto marryInfoDto = MarryInfoToDto(myMarryInfo, oldSpouseList, myself, spouse); // return AjaxResult.success(marryInfoDto); // } // // private MarryInfoDto MarryInfoToDto(ZMarry myMarryInfo,List<MarryUser> oldSpouseList,MarryUser myself,MarryUser spouse){ // MarryInfoDto marryInfoDto = new MarryInfoDto(); // marryInfoDto.setId(myself.getId()); // marryInfoDto.setName(myself.getName()); // marryInfoDto.setBirthday(myself.getBirthday()); // marryInfoDto.setAddress(myself.getAddress()); // marryInfoDto.setIdNo(myself.getIdNo()); // marryInfoDto.setMarryStatus(myself.getMarryStatus()); // marryInfoDto.setSex(myself.getSex()); // marryInfoDto.setNation(myself.getNation()); // marryInfoDto.setPhone(myself.getPhone()); // // marryInfoDto.setSpouseId(spouse.getId()); // marryInfoDto.setSpouseName(spouse.getName()); // marryInfoDto.setSpouseBirthday(spouse.getBirthday()); // marryInfoDto.setSpouseAddress(spouse.getAddress()); // marryInfoDto.setSpouseIdNo(spouse.getIdNo()); // marryInfoDto.setSpouseMarryStatus(spouse.getMarryStatus()); // marryInfoDto.setSpouseSex(spouse.getSex()); // marryInfoDto.setSpouseNation(spouse.getNation()); // marryInfoDto.setSpousePhone(spouse.getPhone()); // // marryInfoDto.setMarryId(myMarryInfo.getId()); // marryInfoDto.setBearStatus(myMarryInfo.getBearStatus()); // marryInfoDto.setHandbookStatus(myMarryInfo.getHandbookStatus()); // marryInfoDto.setHandbookTime(myMarryInfo.getHandbookTime()); // marryInfoDto.setOneBorn(myMarryInfo.getOneBorn()); // marryInfoDto.setOneBornTime(myMarryInfo.getOneBornTime()); // marryInfoDto.setContent(myMarryInfo.getContent()); // marryInfoDto.setRemark(myMarryInfo.getRemark()); // marryInfoDto.setMarryTime(myMarryInfo.getMarryTime()); // // marryInfoDto.setOldSpouseList(oldSpouseList); // return marryInfoDto; // } // // // // // @Transactional // public AjaxResult addInfo(MarryInfoDto marryInfoDto){ // SysUser user = SecurityUtils.getLoginUser().getUser(); // Long userId = user.getUserId(); // // String meId= IdUtils.simpleUUID(); // String spouseId = IdUtils.simpleUUID(); // // //添加自己的信息 // MarryUser myself = new MarryUser(); // myself.setId(meId); // myself.setName(marryInfoDto.getName()); // myself.setBirthday(marryInfoDto.getBirthday()); // myself.setAddress(marryInfoDto.getAddress()); // myself.setIdNo(marryInfoDto.getIdNo()); // myself.setMarryStatus(marryInfoDto.getMarryStatus()); // myself.setSex(marryInfoDto.getSex()); // myself.setMyId(userId); // myself.setNation(marryInfoDto.getNation()); // myself.setPhone(marryInfoDto.getPhone()); // marryUserService.save(myself); // // //添加配偶的信息 // MarryUser spouse = new MarryUser(); // spouse.setId(spouseId); // spouse.setName(marryInfoDto.getSpouseName()); // spouse.setBirthday(marryInfoDto.getSpouseBirthday()); // spouse.setAddress(marryInfoDto.getSpouseAddress()); // spouse.setIdNo(marryInfoDto.getSpouseIdNo()); // spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); // spouse.setSex(marryInfoDto.getSpouseSex()); // spouse.setNation(marryInfoDto.getSpouseNation()); // spouse.setPhone(marryInfoDto.getSpousePhone()); // marryUserService.save(spouse); // // //添加生育情况(中间表)信息 // ZMarry zMarry = new ZMarry(); // zMarry.setUserId(userId); // zMarry.setSpouseId(spouseId); // zMarry.setMarryTime(marryInfoDto.getMarryTime()); // zMarry.setBearStatus(marryInfoDto.getBearStatus()); // zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); // zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); // zMarry.setOneBorn(marryInfoDto.getOneBorn()); // zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); // zMarry.setContent(marryInfoDto.getContent()); // zMarry.setRemark(marryInfoDto.getRemark()); // zMarry.setDeleteStatus(0); // zMarryService.save(zMarry); // // // List<MarryUser> oldSpouseList = marryInfoDto.getOldSpouseList(); // // //添加前任的信息 // if(oldSpouseList!=null&&oldSpouseList.size()!=0){ // for (MarryUser marryUser : oldSpouseList) { // //先添加配偶用户信息 // String spId = IdUtils.simpleUUID(); // marryUser.setId(spId); // marryUserService.save(marryUser); // // //再添加中间表信息 // ZMarry oldMarry = new ZMarry(); // oldMarry.setUserId(userId); // oldMarry.setSpouseId(spId); // oldMarry.setDeleteStatus(1); // zMarryService.save(oldMarry); // } // } // // return AjaxResult.success(); // } // // @Transactional // public AjaxResult updateInfo(MarryInfoDto marryInfoDto){ // // SysUser user = SecurityUtils.getLoginUser().getUser(); // Long userId = user.getUserId(); // //更新自己的信息 // MarryUser myself = new MarryUser(); // myself.setId(marryInfoDto.getId()); // myself.setName(marryInfoDto.getName()); // myself.setBirthday(marryInfoDto.getBirthday()); // myself.setAddress(marryInfoDto.getAddress()); // myself.setIdNo(marryInfoDto.getIdNo()); // myself.setMarryStatus(marryInfoDto.getMarryStatus()); // myself.setSex(marryInfoDto.getSex()); // myself.setNation(marryInfoDto.getNation()); // myself.setPhone(marryInfoDto.getPhone()); // marryUserService.updateById(myself); // // //更新配偶的信息 // // //先查询是更新配偶信息还是换配偶,因为配偶只能有一个 // //这里暂时用名字来判断吧,如果有重名的人就会有bug // //先查询 // String spouseName = marryInfoDto.getSpouseName(); // MarryUser marry = marryUserService.getById(marryInfoDto.getSpouseId()); // String marryName = marry.getName(); // if(!spouseName.equals(marryName)){ // // //如果正妻子换人了,就新增而不是修改,同时删除旧纪录 // //将现在中间表的妻子改成前妻 // LambdaQueryWrapper<ZMarry> lqw = new LambdaQueryWrapper<>(); // lqw.eq(ZMarry::getUserId,userId) // .eq(ZMarry::getSpouseId,marryInfoDto.getSpouseId()); // ZMarry one = getOne(lqw); // one.setDeleteStatus(1); // zMarryService.updateById(one); // // //新增用户信息表 // String spouseId = IdUtils.simpleUUID(); // MarryUser spouse = new MarryUser(); // spouse.setId(spouseId); // spouse.setName(marryInfoDto.getSpouseName()); // spouse.setBirthday(marryInfoDto.getSpouseBirthday()); // spouse.setAddress(marryInfoDto.getSpouseAddress()); // spouse.setIdNo(marryInfoDto.getSpouseIdNo()); // spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); // spouse.setSex(marryInfoDto.getSpouseSex()); // spouse.setNation(marryInfoDto.getSpouseNation()); // spouse.setPhone(marryInfoDto.getSpousePhone()); // marryUserService.save(spouse); // // //新增中间表 // //添加生育情况(中间表)信息 // ZMarry zMarry = new ZMarry(); // zMarry.setUserId(userId); // zMarry.setSpouseId(spouseId); // zMarry.setMarryTime(marryInfoDto.getMarryTime()); // zMarry.setBearStatus(marryInfoDto.getBearStatus()); // zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); // zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); // zMarry.setOneBorn(marryInfoDto.getOneBorn()); // zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); // zMarry.setContent(marryInfoDto.getContent()); // zMarry.setRemark(marryInfoDto.getRemark()); // zMarry.setDeleteStatus(0); // zMarryService.save(zMarry); // // // // }else { // // MarryUser spouse = new MarryUser(); // spouse.setId(marryInfoDto.getSpouseId()); // spouse.setName(marryInfoDto.getSpouseName()); // spouse.setBirthday(marryInfoDto.getSpouseBirthday()); // spouse.setAddress(marryInfoDto.getSpouseAddress()); // spouse.setIdNo(marryInfoDto.getSpouseIdNo()); // spouse.setMarryStatus(marryInfoDto.getSpouseMarryStatus()); // spouse.setSex(marryInfoDto.getSpouseSex()); // spouse.setNation(marryInfoDto.getSpouseNation()); // spouse.setPhone(marryInfoDto.getSpousePhone()); // marryUserService.updateById(spouse); // // //更新生育情况信息 // ZMarry zMarry = new ZMarry(); // zMarry.setId(marryInfoDto.getMarryId()); // zMarry.setMarryTime(marryInfoDto.getMarryTime()); // zMarry.setBearStatus(marryInfoDto.getBearStatus()); // zMarry.setHandbookStatus(marryInfoDto.getHandbookStatus()); // zMarry.setHandbookTime(marryInfoDto.getHandbookTime()); // zMarry.setOneBorn(marryInfoDto.getOneBorn()); // zMarry.setOneBornTime(marryInfoDto.getOneBornTime()); // zMarry.setContent(marryInfoDto.getContent()); // zMarry.setRemark(marryInfoDto.getRemark()); // zMarry.setDeleteStatus(0); // zMarryService.updateById(zMarry); // } // // //更新前任信息 // List<MarryUser> oldSpouseList = marryInfoDto.getOldSpouseList(); // if(oldSpouseList!=null&&oldSpouseList.size()!=0){ // for (MarryUser marryUser : oldSpouseList) { // //修改用户前任信息 // marryUserService.updateById(marryUser); // //中间表不需要修改 // } // } // return AjaxResult.success(); // } // // public AjaxResult deleteOld(String spouseId){ // marryUserService.removeById(spouseId); // return AjaxResult.success(); // } }