12 changed files with 290 additions and 8 deletions
@ -0,0 +1,39 @@ |
|||
package com.epmet.resi.mine.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/11/3 9:58 |
|||
*/ |
|||
@Data |
|||
public class InitInfoResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 144944007101324497L; |
|||
/** |
|||
* 头像 |
|||
*/ |
|||
private String headImgUrl; |
|||
/** |
|||
* 姓 |
|||
*/ |
|||
private String surname; |
|||
/** |
|||
* 名 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 路牌号 |
|||
*/ |
|||
private String street; |
|||
/** |
|||
* 小区名称 |
|||
*/ |
|||
private String district; |
|||
/** |
|||
* 详细地址 |
|||
*/ |
|||
private String buildingAddress; |
|||
} |
@ -0,0 +1,55 @@ |
|||
package com.epmet.modules.mine.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.EditInfoFormDTO; |
|||
import com.epmet.modules.mine.service.PersonalCenterService; |
|||
import com.epmet.resi.mine.dto.result.InitInfoResultDTO; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 个人中心 |
|||
* @author zhaoqifeng |
|||
* @date 2020/11/3 9:48 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("personalcenter") |
|||
public class PersonalCenterController { |
|||
@Autowired |
|||
private PersonalCenterService personalCenterService; |
|||
|
|||
/** |
|||
* 修改信息页面初始化 |
|||
* @author zhaoqifeng |
|||
* @date 2020/11/3 10:03 |
|||
* @param tokenDto |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.resi.mine.dto.result.InitInfoResultDTO> |
|||
*/ |
|||
@PostMapping("initinfo") |
|||
public Result<InitInfoResultDTO> initInfo(@LoginUser TokenDto tokenDto) { |
|||
InitInfoResultDTO resultDTO = personalCenterService.initInfo(tokenDto); |
|||
return new Result<InitInfoResultDTO>().ok(resultDTO); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 修改信息 |
|||
* @author zhaoqifeng |
|||
* @date 2020/11/3 10:03 |
|||
* @param tokenDto |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
*/ |
|||
@PostMapping("editinfo") |
|||
public Result editInfo(@LoginUser TokenDto tokenDto, @RequestBody EditInfoFormDTO formDTO) { |
|||
personalCenterService.editInfo(tokenDto, formDTO); |
|||
return new Result(); |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.modules.mine.service; |
|||
|
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.dto.form.EditInfoFormDTO; |
|||
import com.epmet.resi.mine.dto.result.InitInfoResultDTO; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/11/3 9:50 |
|||
*/ |
|||
public interface PersonalCenterService { |
|||
|
|||
InitInfoResultDTO initInfo(TokenDto tokenDto); |
|||
|
|||
void editInfo(TokenDto tokenDto, EditInfoFormDTO formDTO); |
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.epmet.modules.mine.service.impl; |
|||
|
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.EditInfoFormDTO; |
|||
import com.epmet.dto.result.ResiUserBaseInfoResultDTO; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.modules.mine.service.PersonalCenterService; |
|||
import com.epmet.resi.mine.dto.result.InitInfoResultDTO; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/11/3 9:50 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class PersonalCenterServiceImpl implements PersonalCenterService { |
|||
|
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
@Override |
|||
public InitInfoResultDTO initInfo(TokenDto tokenDto) { |
|||
Result<ResiUserBaseInfoResultDTO> baseInfoResult = epmetUserOpenFeignClient.selectUserBaseInfo(tokenDto); |
|||
if (!baseInfoResult.success()) { |
|||
throw new RenException(baseInfoResult.getCode(), baseInfoResult.getMsg()); |
|||
} |
|||
InitInfoResultDTO resultDTO = new InitInfoResultDTO(); |
|||
resultDTO.setHeadImgUrl(baseInfoResult.getData().getHeadImgUrl()); |
|||
resultDTO.setSurname(baseInfoResult.getData().getSurname()); |
|||
resultDTO.setName(baseInfoResult.getData().getName()); |
|||
resultDTO.setStreet(baseInfoResult.getData().getStreet()); |
|||
resultDTO.setDistrict(baseInfoResult.getData().getDistrict()); |
|||
resultDTO.setBuildingAddress(baseInfoResult.getData().getBuildingAddress()); |
|||
return resultDTO; |
|||
} |
|||
|
|||
@Override |
|||
public void editInfo(TokenDto tokenDto, EditInfoFormDTO formDTO) { |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
Result result = epmetUserOpenFeignClient.editUserInfo(formDTO); |
|||
if (!result.success()) { |
|||
throw new RenException(result.getCode(), result.getMsg()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/11/3 9:55 |
|||
*/ |
|||
@NoArgsConstructor |
|||
@Data |
|||
public class EditInfoFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1280489016677129419L; |
|||
/** |
|||
* 头像 |
|||
*/ |
|||
@NotBlank(message = "头像不能为空") |
|||
private String userId; |
|||
/** |
|||
* 头像 |
|||
*/ |
|||
@NotBlank(message = "头像不能为空") |
|||
private String headImgUrl; |
|||
/** |
|||
* 姓 |
|||
*/ |
|||
@NotBlank(message = "姓不能为空") |
|||
private String surname; |
|||
/** |
|||
* 名 |
|||
*/ |
|||
@NotBlank(message = "名不能为空") |
|||
private String name; |
|||
/** |
|||
* 路牌号 |
|||
*/ |
|||
@NotBlank(message = "路牌号不能为空") |
|||
private String street; |
|||
/** |
|||
* 小区名称 |
|||
*/ |
|||
private String district; |
|||
/** |
|||
* 详细地址 |
|||
*/ |
|||
private String buildingAddress; |
|||
} |
Loading…
Reference in new issue