fix: 自定义表头

This commit is contained in:
wenyann 2021-02-19 16:34:30 +08:00
parent 245b46dc19
commit 56a195b247
1 changed files with 16 additions and 3 deletions

View File

@ -241,13 +241,26 @@ public class SystemParameterService {
//保存表头 //保存表头
public void saveHeader(UserHeader userHeader) { public void saveHeader(UserHeader userHeader) {
UserHeaderExample example=new UserHeaderExample();
example.createCriteria().andUserIdEqualTo(userHeader.getUserId()).andTypeEqualTo(userHeader.getType());
if(userHeaderMapper.countByExample(example)>0){
userHeaderMapper.deleteByExample(example);
userHeader.setId(UUID.randomUUID().toString()); userHeader.setId(UUID.randomUUID().toString());
userHeaderMapper.insert(userHeader); userHeaderMapper.insert(userHeader);
}else{
userHeader.setId(UUID.randomUUID().toString());
userHeaderMapper.insert(userHeader);
}
example.clear();
} }
public UserHeader queryUserHeader(HeaderRequest headerRequest) { public UserHeader queryUserHeader(HeaderRequest headerRequest) {
UserHeaderExample example = new UserHeaderExample(); UserHeaderExample example = new UserHeaderExample();
example.createCriteria().andUserIdEqualTo(headerRequest.getUserId()).andTypeEqualTo(headerRequest.getType()); example.createCriteria().andUserIdEqualTo(headerRequest.getUserId()).andTypeEqualTo(headerRequest.getType());
return userHeaderMapper.selectByExample(example).get(0); List<UserHeader> list = userHeaderMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
} }
} }