Skip to content

数据库里的记录可以这样交换顺序 #53

@Lingyuezhixing

Description

@Lingyuezhixing
@Override
public void swap(int fromPos, int toPos, List<NewsTypeInfo> list) {
    NewsTypeInfo fromInfo = list.get(fromPos);
    NewsTypeInfo toInfo = list.get(toPos);
    NewsTypeInfo tem = fromInfo;
    //要重写创建对象,不能去改变源对象,因为源对象在多处使用到
    fromInfo = new NewsTypeInfo(tem.getId(), toInfo.getName(), toInfo.getTypeId());
    toInfo = new NewsTypeInfo(toInfo.getId(), tem.getName(), tem.getTypeId());
    update(fromInfo);
    update(toInfo);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions