| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- package com.ylx.web.controller.massage;
- import com.alibaba.fastjson.JSON;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ylx.common.core.controller.BaseController;
- import com.ylx.common.core.domain.R;
- import com.ylx.common.utils.StringUtils;
- import com.ylx.massage.domain.TAddress;
- import com.ylx.massage.domain.vo.UserAddressListVO;
- import com.ylx.massage.service.TAddressService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * 轮播图(TAddress)表控制层
- *
- * @author makejava
- * @since 2024-04-11 17:18:52
- */
- @RestController
- @Api(tags = {"地址管理"})
- @RequestMapping("tAddress")
- @Slf4j
- public class TAddressController extends BaseController {
- /**
- * 服务对象
- */
- @Resource
- private TAddressService tAddressService;
- /**
- * 分页查询所有地址数据
- *
- * @param page 分页对象
- * @param tAddress 查询实体
- * @return R 所有数据
- */
- @GetMapping
- public R selectAll(Page<TAddress> page, TAddress tAddress) {
- return R.ok(this.tAddressService.page(page, new QueryWrapper<>(tAddress)));
- }
- /**
- * 根据姓名查询通讯地址列表
- *
- * @param page
- * @param tAddress
- * @return R
- */
- @GetMapping("pc/getAddressList")
- @ApiOperation("通讯地址列表")
- public R getAddressList(Page<TAddress> page, TAddress tAddress) {
- Page<TAddress> page1 = tAddressService.page(page, new LambdaQueryWrapper<TAddress>()
- .like(TAddress::getUserName, tAddress.getUserName())
- .orderByDesc(TAddress::getCreateTime));
- return R.ok(page1);
- }
- /**
- * 根据OpenId查询用户地址
- *
- * @param openId
- * @return R<List < TAddress>> 单条数据
- */
- @ApiOperation("根据OpenId查询用户地址")
- @GetMapping("getByOpenId")
- public R<List<TAddress>> selectOne(@RequestParam String openId) {
- LambdaQueryWrapper<TAddress> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
- objectLambdaQueryWrapper.eq(TAddress::getOpenid, openId);
- return R.ok(this.tAddressService.list(objectLambdaQueryWrapper));
- }
- /**
- * PC端根据openId查询用户地址
- *
- * @param openId 用户openId
- * @return R<List<UserAddressListVO>> 用户地址列表
- */
- @ApiOperation("PC端根据openId查询用户地址")
- @GetMapping("pc/getUserAddressList")
- public R<List<UserAddressListVO>> getUserAddressList(@RequestParam String openId) {
- try {
- if (StringUtils.isBlank(openId)) {
- return R.fail("openId不能为空");
- }
- return R.ok(this.tAddressService.getPcUserAddressList(openId));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- @ApiOperation("根据Id查询地址")
- @GetMapping("getById")
- public R<TAddress> getById(@RequestParam String id) {
- return R.ok(this.tAddressService.getById(id));
- }
- /**
- * 根据手机号码查询技师的虚拟地址(PC端)
- *
- * @param phone
- * @return R<List<TAddress>>
- */
- @ApiOperation("根据手机号码查询技师的虚拟地址")
- @GetMapping("getVirtualAddressByPhone")
- public R<List<TAddress>> getVirtualAddressByPhone(@RequestParam String phone) {
- try {
- LambdaQueryWrapper<TAddress> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
- objectLambdaQueryWrapper.eq(TAddress::getPhone, phone).eq(TAddress::getType, 2).eq(TAddress::getUserType,2);
- return R.ok(this.tAddressService.list(objectLambdaQueryWrapper));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 根据手机号码查询技师的虚拟地址(用户端)
- *
- * @param phone
- * @return R<List<TAddress>>
- */
- @ApiOperation("根据手机号码查询技师的虚拟地址")
- @GetMapping("/wx/getVirtualAddressByPhone")
- public R<List<TAddress>> getWXVirtualAddressByPhone(@RequestParam String phone) {
- try {
- LambdaQueryWrapper<TAddress> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
- objectLambdaQueryWrapper.eq(TAddress::getPhone, phone).eq(TAddress::getType, 2).eq(TAddress::getUserType,2);
- return R.ok(this.tAddressService.list(objectLambdaQueryWrapper));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 新增地址(用户端)
- *
- * @param tAddress 实体对象
- * @return R 新增结果
- */
- @PostMapping("save")
- @ApiOperation("新增地址")
- public R insert(@RequestBody TAddress tAddress) {
- try {
- return R.ok(this.tAddressService.insertAddress(tAddress));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 新增虚拟地址(商户端)
- *
- * @param tAddress 实体对象
- * @return R 新增结果
- */
- @PostMapping("saveVirtualAddress")
- @ApiOperation("新增虚拟地址")
- public R saveVirtualAddress(@RequestBody TAddress tAddress) {
- try {
- log.info("tAddress参数的值:{}", JSON.toJSONString(tAddress));
- return R.ok(this.tAddressService.insertVirtualAddress(tAddress));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 修改数据
- *
- * @param tAddress 实体对象
- * @return 修改结果
- */
- @PostMapping("/update")
- @ApiOperation("修改地址")
- public R update(@RequestBody TAddress tAddress) {
- return R.ok(this.tAddressService.updateAddress(tAddress));
- }
- /**
- * 删除数据
- *
- * @param idList 主键结合
- * @return 删除结果
- */
- @DeleteMapping("/delete")
- @ApiOperation("删除地址")
- public R delete(@RequestParam("idList") List<Long> idList) {
- return R.ok(this.tAddressService.removeByIds(idList));
- }
- /**
- * 删除技师的虚拟地址
- *
- * @param id
- * @return R
- */
- @DeleteMapping("/deleteVirtualAddress")
- @ApiOperation("删除地址")
- public R deleteVirtualAddress(@RequestParam("id") String id) {
- try {
- return R.ok(this.tAddressService.removeById(id));
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 设置默认地址
- * @param tAddress
- * @return R
- */
- @PostMapping("/defaultAddress")
- @ApiOperation("设置默认地址")
- public R defaultAddress(@RequestBody TAddress tAddress) {
- return R.ok(this.tAddressService.defaultAddress(tAddress));
- }
- }
|