RoleServiceImpl.java
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.tianbo.service.imp;
import com.tianbo.mapper.RoleMapper;
import com.tianbo.model.Role;
import com.tianbo.model.RoleExample;
import com.tianbo.model.UsersExample;
import com.tianbo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class RoleServiceImpl implements RoleService{
@Autowired
private RoleMapper roleMapper;
public List<Role> selectByExample(RoleExample example){
return roleMapper.selectByExample(example);
}
public int insert(Role record){
return roleMapper.insert(record);
}
public boolean checkRole(Role role){
//调用mapper类中的selectByExample方法,如果传入类型为null,则表示无条件查找
RoleExample example = new RoleExample();
RoleExample.Criteria criteria = example.createCriteria();
if (role.getRoleName()!=null){
criteria.andRoleNameEqualTo(role.getRoleName());
}
int count = roleMapper.countByExample(example); //没加入分页前的搜索总数据数
if (count>0){
return true;
}else {
return false;
}
}
}