package com.yh.saas.platform.controller;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
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 com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.winsea.svc.base.base.entity.CommonCustomDropDown;
import com.winsea.svc.base.base.service.ICommonCustomDropDownService;

/**
 * <p>
 * 'winsea_platform.certificate_view' is not BASE TABLE 前端控制器
 * </p>
 *
 * @author jiangailong
 * @since 2019-09-4
 */
@RestController
@RequestMapping("/customDropDown")
public class CompanyCustomDropDownController {

	@SofaReference
    private ICommonCustomDropDownService customDropDownService;

    @GetMapping("/query/customDropDown")
    public List<CommonCustomDropDown> queryCommonParameterTenant(CommonCustomDropDown parameterCompany) {
        return customDropDownService.selectList(new EntityWrapper<CommonCustomDropDown>()
                .eq(CommonCustomDropDown.QueryFields.COMP_ID, parameterCompany.getCompId())
                .eq(CommonCustomDropDown.QueryFields.CONST_CODE, parameterCompany.getConstCode())
                .setSqlSelect("const_code as constCode,const_key as constKey,const_value as constValue,id as id"));
    }

    /**
     * 新增
     *
     * @param
     */
    @PostMapping("/api/saveAdd")
    public String saveAdd(@RequestBody CommonCustomDropDown example) {
    	return this.customDropDownService.create(example);
    }

    /**
     * 编辑
     */
    @PostMapping("/api/saveEdit")
    public void saveEdit(@RequestBody CommonCustomDropDown example) {
        customDropDownService.updateAllColumnById(example);
    }

    /**
     * 删除 da
     */
    @PostMapping("/api/saveDelete")
    public void saveDelete(@RequestBody CommonCustomDropDown example) {
        customDropDownService.deleteById(example.getId());
    }
}

