CustomerWxController.java 4.01 KB
package cn.fw.valhalla.controller.wx;

import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.common.web.auth.PassportAuthBean;
import cn.fw.common.web.auth.annotation.CurrentUser;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.enums.AuthType;
import cn.fw.valhalla.domain.dto.CorrelationDto;
import cn.fw.valhalla.domain.dto.NewCustomerDTO;
import cn.fw.valhalla.domain.vo.customer.CarArchiveVO;
import cn.fw.valhalla.domain.vo.customer.CustomerChangeInfoVO;
import cn.fw.valhalla.service.bus.cust.ContactBizService;
import cn.fw.valhalla.service.bus.cust.CustomerBizService;
import cn.fw.valhalla.service.bus.cust.CustomerChangeBizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

import static cn.fw.common.web.util.ResultBuilder.success;

/**
 * @author : kurisu
 * @className : CustomerWxController
 * @description : 档案微信端控制器
 * @date: 2020-08-13 15:00
 */
@Slf4j
@Validated
@RestController
@Authorization(AuthType.WECHAT)
@RequestMapping("/wx/customer")
public class CustomerWxController {
    private final CustomerBizService customerBizService;
    private final CustomerChangeBizService changeBizService;
    private final ContactBizService contactBizService;

    @Autowired
    public CustomerWxController(final CustomerBizService customerBizService,
                                final CustomerChangeBizService changeBizService,
                                final ContactBizService contactBizService) {
        this.customerBizService = customerBizService;
        this.changeBizService = changeBizService;
        this.contactBizService = contactBizService;
    }

    /**
     * C端-查询是否关联保有客档案
     *
     * @param user       当前登录用户
     * @param customerId 保有客档案id
     * @return 操作结果
     */
    @GetMapping("/exist/correlation")
    @ControllerMethod("查询是否关联保有客档案")
    public Message<Boolean> existCorrelation(@CurrentUser PassportAuthBean user, @NotNull(message = "档案ID不能为空") Long customerId) {
        return success(contactBizService.existCorrelation(user.getUserId(), customerId));
    }

    /**
     * C端wx-档案关联送修人
     *
     * @param user           当前登录用户
     * @param correlationDto 联系人信息
     * @return 操作结果
     */
    @PostMapping("/correlation")
    @ControllerMethod("关联送修人")
    public Message<Boolean> correlation(@CurrentUser PassportAuthBean user,
                                        @Validated @RequestBody CorrelationDto correlationDto) {
        return success(contactBizService.correlation(user, correlationDto));
    }

    /**
     * C端wx-档案查询
     *
     * @param cusId
     * @return
     * @Deprecated 将在下版本移除此接口 2022-03-15
     */
    @GetMapping("/info")
    @ControllerMethod("保有客档案查询")
    public Message<CustomerChangeInfoVO> info(@NotNull(message = "档案id不能为空") Long cusId) {
        return success(changeBizService.mpGetById(cusId));
    }


    /**
     * 查询所有档案
     *
     * @param user
     * @return
     */
    @GetMapping("/car/list")
    @ControllerMethod("查询所有档案")
    public Message<List<CarArchiveVO>> carList(@CurrentUser PassportAuthBean user) {
        return success(customerBizService.defaultCustomer(user.getUserId()));
    }

    /**
     * 新增变更档案
     *
     * @param user
     * @param dto
     * @return
     */
    @PostMapping("/new/save")
    @ControllerMethod("新增档案信息")
    public Message<Void> saveCustomer(@CurrentUser PassportAuthBean user, @Validated @RequestBody final NewCustomerDTO dto) {
        dto.setMemberId(user.getUserId());
        changeBizService.saveCustomer(dto);
        return success();
    }

}