package com.xunhong.erp.turbo.user.infrastructure.convert;


import com.xunhong.erp.turbo.api.user.dto.cmd.UserUpdateCmd;
import com.xunhong.erp.turbo.api.user.dto.cmd.UserUpdateWxCmd;
import com.xunhong.erp.turbo.user.domain.entity.User;
import com.xunhong.erp.turbo.user.infrastructure.entity.UserDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValueCheckStrategy;

/**
 * @author shenyifei
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface UserConvert {
	User toUser(UserDO userDO);

	@Mapping(target = "unionid", ignore = true)
	@Mapping(target = "mpOpenid", ignore = true)
	@Mapping(target = "maOpenid", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "state", ignore = true)
	@Mapping(target = "lastLoginAt", ignore = true)
	@Mapping(target = "isPartner", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "isAdmin", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	@Mapping(target = "bindPhoneAt", ignore = true)
	@Mapping(target = "phone", ignore = true)
	@Mapping(target = "birthday", ignore = true)
	void toUser(@MappingTarget UserDO userDO, UserUpdateCmd userUpdateCmd);

	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "state", ignore = true)
	@Mapping(target = "remark", ignore = true)
	@Mapping(target = "phone", ignore = true)
	@Mapping(target = "nickname", ignore = true)
	@Mapping(target = "name", ignore = true)
	@Mapping(target = "lastLoginAt", ignore = true)
	@Mapping(target = "isPartner", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "isAdmin", ignore = true)
	@Mapping(target = "gender", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	@Mapping(target = "birthday", ignore = true)
	@Mapping(target = "bindPhoneAt", ignore = true)
	@Mapping(target = "avatar", ignore = true)
	void toUser(@MappingTarget UserDO userDO, UserUpdateWxCmd userUpdateWxCmd);
}
