/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.wechat.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.wechat.global.base.dao.impl.BaseDao;
import com.wechat.model.dbEntity.MdeAddress;
import com.wechat.model.dto.AddressesDto;

/**
 * 单表生成DAO接口
 * @author jadyn.wu
 * @version 2019-08-28
 */
@Repository
public class MdeAddressDao extends BaseDao {
	
	/**
	 *  根据用户id查询地址信息
	 * 
	 * @return
	 */
	public List<AddressesDto> selectByUser(String userId) {
        return super.select("MdeAddressMapper.selectByUser", userId);
    }
	
	
	public int insert(MdeAddress entity) {
		return super.insert("MdeAddressMapper.insert", entity);
	}
	
	public int update(MdeAddress entity) {
		return super.update("MdeAddressMapper.updateByPrimaryKey", entity);	
	}
	
	//修改为非默认
	public int undefault(String userId) {
		MdeAddress entity = new MdeAddress();
		entity.setUserId(userId);
		return super.update("MdeAddressMapper.undefault", entity);	
	}
	
	
	/**
	 *  根据地址id查询地址信息
	 * 
	 * @return
	 */
	public AddressesDto selectByAddid(Integer addId ,String userId) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("addId",addId);
		map.put("userId",userId);
        return super.selectOne("MdeAddressMapper.selectByAddid", map);
    }
	
	
	public int delete(Map<String,Object> map) {
		return sqlSession.delete("MdeAddressMapper.deleteByPrimaryKey", map);
	}
	

}