zhangzeli
2021-11-09 fe2b2e037a91fbc22bd887174d37c7dd229333d3
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CustomerController.java
@@ -5,6 +5,8 @@
import cn.exrick.xboot.core.common.vo.PageVo;
import cn.exrick.xboot.core.common.vo.Result;
import cn.exrick.xboot.your.entity.Customer;
import cn.exrick.xboot.your.entity.CustomerReceive;
import cn.exrick.xboot.your.service.ICustomerReceiveService;
import cn.exrick.xboot.your.service.ICustomerService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -30,12 +32,18 @@
    @Autowired
    private ICustomerService iCustomerService;
    @Autowired
    private ICustomerReceiveService iCustomerReceiveService;
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "通过id获取")
    public Result<Customer> get(@PathVariable String id) {
        Customer customer = iCustomerService.getById(id);
        QueryWrapper<CustomerReceive> wrapper = new QueryWrapper<>();
        wrapper.eq("customer_id",id);
        wrapper.eq("status",1);
        List<CustomerReceive> list = iCustomerReceiveService.list(wrapper);
        customer.setReceives(list);
        return new ResultUtil<Customer>().setData(customer);
    }
@@ -70,6 +78,28 @@
        return new ResultUtil<Customer>().setErrorMsg("操作失败");
    }
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ApiOperation(value = "更新数据")
    public Result<Customer> update(String customerId,String lng,String lat,String address,String headImg) {
        Customer customer = iCustomerService.getById(customerId);
        if(StrUtil.isNotEmpty(lng)){
            customer.setLng(lng);
        }
        if(StrUtil.isNotEmpty(lat)){
            customer.setLat(lat);
        }
        if(StrUtil.isNotEmpty(address)){
            customer.setRegisteredAddress(address);
        }
        if(StrUtil.isNotEmpty(headImg)){
            customer.setHeadImg(headImg);
        }
        if (iCustomerService.saveOrUpdate(customer)) {
            return new ResultUtil<Customer>().setData(customer);
        }
        return new ResultUtil<Customer>().setErrorMsg("操作失败");
    }
    @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
    @ApiOperation(value = "批量通过id删除")
    public Result<Object> delAllByIds(@RequestParam String[] ids) {