package com.steerinfo.appservice.appmeterbasecustomersupplier.controller;

import com.steerinfo.appservice.appmeterbasecustomersupplier.model.AppMeterBaseCustomerSupplier;
import com.steerinfo.appservice.appmeterbasecustomersupplier.service.IAppMeterBaseCustomerSupplierService;
import com.steerinfo.framework.controller.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
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;

import java.util.HashMap;
import java.util.HashSet;

/**
 * MeterBaseCustomerSupplier RESTful接口：
 * @author generator
 * @version 1.0-SNAPSHORT 2020-06-15 11:14
 * 类描述
 * 修订历史：
 * 日期：2020-06-15
 * 作者：generator
 * 参考：
 * 描述：MeterBaseCustomerSupplier RESTful接口
 * @see null
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 */
@RestController
@RequestMapping("/${api.version}/appservice/meterbasecustomersuppliers")
public class AppMeterBaseCustomerSupplierController extends BaseRESTfulController {

    @Autowired
    IAppMeterBaseCustomerSupplierService appMeterBaseCustomerSupplierService;


    @ApiOperation(value = "供应商App登录", notes = "根据传过来的参数判断登录是否成功")
    @PostMapping(value = "/login")
    public RESTfulResult login(@RequestBody AppMeterBaseCustomerSupplier model) {
        try {
            RESTfulResult rm = appMeterBaseCustomerSupplierService.login(model);
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "供应商App修改密码", notes = "根据传过来的参数判断")
    @PostMapping(value = "/modifyPassword")
    public RESTfulResult modifyPassword(@RequestBody AppMeterBaseCustomerSupplier model) {
        try {
            RESTfulResult rm = appMeterBaseCustomerSupplierService.modifyPassword(model);
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

}
