| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.UpdatePhoneDto; |
| | | import com.ruoyi.system.dto.UpdateUserDto; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.model.TAppealServices; |
| | | import com.ruoyi.system.model.TChildcareServices; |
| | | import com.ruoyi.system.model.TMicroWish; |
| | | import com.ruoyi.system.query.AppealServicesStatusQuery; |
| | | import com.ruoyi.system.query.MicroWishStatusQuery; |
| | | import com.ruoyi.system.service.TAppUserService; |
| | | import com.ruoyi.system.service.TAppealServicesService; |
| | | import com.ruoyi.system.service.TChildcareServicesService; |
| | | import com.ruoyi.system.service.TMicroWishService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/userIndex") |
| | | @Api(tags = "个人中心") |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | public class UserIndexController { |
| | | |
| | | private final TAppUserService tAppUserService; |
| | | private final TChildcareServicesService tChildcareServicesService; |
| | | private final TAppealServicesService tAppealServicesService; |
| | | private final TMicroWishService tMicroWishService; |
| | | private final TokenService tokenService; |
| | | |
| | | |
| | | public UserIndexController(TAppUserService tAppUserService, TChildcareServicesService tChildcareServicesService, TAppealServicesService tAppealServicesService, TMicroWishService tMicroWishService, TokenService tokenService) { |
| | | this.tAppUserService = tAppUserService; |
| | | this.tChildcareServicesService = tChildcareServicesService; |
| | | this.tAppealServicesService = tAppealServicesService; |
| | | this.tMicroWishService = tMicroWishService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--用户信息",response = TAppUser.class) |
| | | @GetMapping(value = "/getUserInfo") |
| | | public R<TAppUser> getUserInfo() { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Integer userId = tokenService.getLoginUserApplet().getUserId(); |
| | | return R.ok(tAppUserService.getById(userId)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--托育服务记录",response = TChildcareServices.class) |
| | | @PostMapping(value = "/getChildcareServicesList") |
| | | public R<Page<TChildcareServices>> getChildcareServicesList(@RequestBody BasePage basePage) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Page<TChildcareServices> page = new Page<>(basePage.getPageNum(), basePage.getPageSize()); |
| | | Page<TChildcareServices> childcareServicesPage = tChildcareServicesService.page(page, Wrappers.<TChildcareServices>lambdaQuery().eq(TChildcareServices::getAppUserId, userId).orderByDesc(BaseModel::getCreateTime)); |
| | | return R.ok(childcareServicesPage); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--托育服务记录详情",response = TChildcareServices.class) |
| | | @GetMapping(value = "/getChildcareServicesDetail/{id}") |
| | | public R<TChildcareServices> getChildcareServicesDetail(@PathVariable String id) { |
| | | TChildcareServices childcareServices = tChildcareServicesService.getById(id); |
| | | return R.ok(childcareServices); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--诉求服务记录",response = TAppealServices.class) |
| | | @PostMapping(value = "/getAppealServicesList") |
| | | public R<Page<TAppealServices>> getAppealServicesList(@RequestBody AppealServicesStatusQuery query) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Page<TAppealServices> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<TAppealServices> appealServicesPage = tAppealServicesService.page(page, Wrappers.<TAppealServices>lambdaQuery().eq(TAppealServices::getAppUserId, userId).eq(TAppealServices::getAppealType,1).eq(Objects.nonNull(query.getStatus()), TAppealServices::getStatus, query.getStatus()).orderByDesc(BaseModel::getCreateTime)); |
| | | return R.ok(appealServicesPage); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--诉求服务记录/随手拍详情",response = TAppealServices.class) |
| | | @GetMapping(value = "/getAppealServicesDetail/{id}") |
| | | public R<TAppealServices> getAppealServicesList(@PathVariable String id) { |
| | | TAppealServices appealServices = tAppealServicesService.getById(id); |
| | | return R.ok(appealServices); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--随手拍记录",response = TAppealServices.class) |
| | | @PostMapping(value = "/getSnapShareList") |
| | | public R<Page<TAppealServices>> getSnapShareList(@RequestBody AppealServicesStatusQuery query) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Page<TAppealServices> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<TAppealServices> appealServicesPage = tAppealServicesService.page(page, Wrappers.<TAppealServices>lambdaQuery().eq(TAppealServices::getAppUserId, userId).eq(TAppealServices::getAppealType,2).eq(Objects.nonNull(query.getStatus()), TAppealServices::getStatus, query.getStatus()).orderByDesc(BaseModel::getCreateTime)); |
| | | return R.ok(appealServicesPage); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--微心愿记录",response = TMicroWish.class) |
| | | @PostMapping(value = "/getMicroWishList") |
| | | public R<Page<TMicroWish>> getMicroWishList(@RequestBody MicroWishStatusQuery query) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Page<TMicroWish> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<TMicroWish> microWishPage = tMicroWishService.page(page, Wrappers.<TMicroWish>lambdaQuery() |
| | | .eq(TMicroWish::getAppUserId, userId) |
| | | .eq(Objects.nonNull(query.getStatus()), TMicroWish::getStatus, query.getStatus()) |
| | | .orderByDesc(BaseModel::getCreateTime)); |
| | | return R.ok(microWishPage); |
| | | } |
| | | |
| | | @ApiOperation(value = "个人中心--微心愿详情",response = TMicroWish.class) |
| | | @GetMapping(value = "/getMicroWishDetail/{id}") |
| | | public R<TMicroWish> getMicroWishDetail(@PathVariable String id) { |
| | | TMicroWish microWish = tMicroWishService.getById(id); |
| | | return R.ok(microWish); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人中心--修改手机号") |
| | | @PostMapping(value = "/updatePhone") |
| | | public R<?> getMicroWishDetail(@RequestBody UpdatePhoneDto dto) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | long count = tAppUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhoneNumber, dto.getPhone()).ne(TAppUser::getId, userId)); |
| | | Integer userId = tokenService.getLoginUserApplet().getUserId(); |
| | | long count = tAppUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, dto.getPhone()).ne(TAppUser::getId, userId)); |
| | | if (count > 0) { |
| | | return R.fail("手机号已存在"); |
| | | } |
| | | tAppUserService.update(new LambdaUpdateWrapper<TAppUser>().set(TAppUser::getPhoneNumber, dto.getPhone()).eq(TAppUser::getId, userId)); |
| | | tAppUserService.update(new LambdaUpdateWrapper<TAppUser>().set(TAppUser::getPhone, dto.getPhone()).eq(TAppUser::getId, userId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "个人中心--修改信息") |
| | | @PostMapping(value = "/updateUserInfo") |
| | | public R<?> updateUserInfo(@RequestBody UpdateUserDto dto) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Integer userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser appUser = tAppUserService.getById(userId); |
| | | |
| | | if(dto.getAvatar()!=null){ |
| | | appUser.setAvatar(dto.getAvatar()); |
| | | appUser.setProfilePhoto(dto.getAvatar()); |
| | | } |
| | | |
| | | if(dto.getNickName()!=null){ |
| | | appUser.setNickName(dto.getNickName()); |
| | | appUser.setName(dto.getNickName()); |
| | | } |
| | | |
| | | if(dto.getGender()!=null){ |
| | |
| | | } |
| | | |
| | | if(dto.getBirthday()!=null){ |
| | | appUser.setBirthDate(dto.getBirthday()); |
| | | appUser.setBirthday(dto.getBirthday()); |
| | | } |
| | | |
| | | if(dto.getName()!=null){ |
| | |
| | | |
| | | |
| | | if(dto.getPhone()!=null){ |
| | | long count = tAppUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhoneNumber, dto.getPhone()).ne(TAppUser::getId, userId)); |
| | | long count = tAppUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, dto.getPhone()).ne(TAppUser::getId, userId)); |
| | | if (count > 0) { |
| | | return R.fail("手机号已存在"); |
| | | } |
| | | appUser.setPhoneNumber(dto.getPhone()); |
| | | appUser.setPhone(dto.getPhone()); |
| | | } |
| | | tAppUserService.updateById(appUser); |
| | | |