package com.gx.obe.server.management.dictionary.controller;
import org.springframework.beans.factory.annotation.Autowired;
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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gx.obe.server.common.base.BaseController;
import com.gx.obe.server.management.dictionary.dao.ChainMapper;
import com.gx.obe.server.management.dictionary.entity.Chain;
import com.gx.obe.server.management.dictionary.service.ChainService;
import com.gx.obe.server.management.user.entity.AuthUserEntity;
import com.gx.obe.server.management.vo.UpdateAssignPropertyVo;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
/** 
 * @Description: 
 * @author wangxiang
 */
@Api(tags = "")
@RestController
@AllArgsConstructor
@RequestMapping("/chain")
public class ChainController extends BaseController<ChainService,Chain>{
	@Autowired
	public ChainMapper chainMapper;
	public ChainService chainService;
	
	/**
	 * @Description: 
	 * @author wangxiang
	 * @param tenderId
	 * @param userId
	 * @return 
	 */
	@GetMapping("/getChainByTenderIdAndType")
	public Chain getChainByTenderIdAndType(String tenderId, String chainType){
		QueryWrapper<Chain>  wrapper = new QueryWrapper<Chain>();
		wrapper.lambda().eq(Chain::getTenderId, tenderId)
						.eq(Chain::getChainType, chainType);
		return chainMapper.selectOne(wrapper);
	}
	
	/**
	 * @Description: 更新分配属性
	 * @author wangxiang
	 * @param updateAssignPropertyVo
	 * @return 
	 */
	@PostMapping("/updateAssignProperty")
    public boolean updateAssignProperty(@RequestBody UpdateAssignPropertyVo<Chain> updateAssignPropertyVo) {
		Chain chain = updateAssignPropertyVo.getEntity();
        String[] attributes = updateAssignPropertyVo.getAttributes();
        return chainService.updateAssignProperty(chain, attributes);
    }
	
	
}