package com.ruoyi.web.controller.zhang;
|
|
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.poi.ExcelUtil;
|
import com.ruoyi.domain.ZInfoUser;
|
import com.ruoyi.domain.ZfDoctor;
|
import com.ruoyi.domain.dto.MarryInfoDto;
|
import com.ruoyi.service.MarrySelfService;
|
import com.ruoyi.service.ZInfoUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
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;
|
|
@Resource
|
ZInfoUserService zInfoUserService;
|
|
@Autowired
|
private ISysUserService userService;
|
|
//获取所有信息
|
@GetMapping()
|
public AjaxResult getInfo(){
|
return marrySelfService.getInfo();
|
}
|
|
//新增或修改基本信息
|
@PostMapping()
|
public AjaxResult updateData(@RequestBody MarryInfoDto marryInfoDto){
|
try{
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
Long userId = user.getUserId();
|
|
ZInfoUser infoBysysId = zInfoUserService.getInfoBysysId(userId);
|
if(infoBysysId!=null) {
|
ZInfoUser zInfoUser = new ZInfoUser();
|
Long spouseId = infoBysysId.getSpouseId();
|
zInfoUser.setUserId(spouseId);
|
zInfoUser.setNickName(marryInfoDto.getSpouseName());
|
if(!marryInfoDto.getSpouseSex().isEmpty()) zInfoUser.setSex(marryInfoDto.getSpouseSex().equals("男")?0:1);
|
zInfoUser.setBirth(marryInfoDto.getSpouseBirthday());
|
zInfoUser.setNation(marryInfoDto.getSpouseNation());
|
zInfoUser.setIdNum(marryInfoDto.getSpouseIdNo());
|
zInfoUser.setPhoneNumber(marryInfoDto.getSpousePhone());
|
zInfoUser.setMaritalStatus(marryInfoDto.getSpouseMarryStatus());
|
zInfoUser.setLocationAddress(marryInfoDto.getSpouseAddress());
|
zInfoUserService.updateById(zInfoUser);
|
|
ZInfoUser spouseBysysId = zInfoUserService.getInfoById(spouseId);
|
if(spouseBysysId !=null) {
|
Long spouseUId = spouseBysysId.getSysId();
|
SysUser sysUser = new SysUser();
|
sysUser.setUserId(spouseUId);
|
sysUser.setNickName(marryInfoDto.getSpouseName());
|
if (!marryInfoDto.getSpouseSex().isEmpty())
|
sysUser.setSex(marryInfoDto.getSpouseSex().equals("男") ? "0" : "1");
|
userService.updateUser(sysUser);
|
}
|
|
}} catch (Exception e) {
|
e.printStackTrace();
|
System.out.println("报错"+e.getMessage());
|
return AjaxResult.error("更新失败");
|
}
|
return AjaxResult.success( 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, "个人婚姻数据");
|
}
|
}
|