Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Lingyuezhixing opened this issue Nov 15, 2017 · 2 comments
Open

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

Lingyuezhixing opened this issue Nov 15, 2017 · 2 comments

Comments

@Lingyuezhixing
Copy link

@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);

}

@Rukey7
Copy link
Owner

Rukey7 commented Nov 17, 2017

嗯,这样应该会比我之前写法好

@yuekong
Copy link

yuekong commented Mar 22, 2018

@Lingyuezhixing 有没有更详细点的源码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants