admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.newvideo.service.imp;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.newvideo.dao.AdminUserDao;
import com.newvideo.domain.AdminInfo;
import com.newvideo.util.Constant;
import com.newvideo.util.StringUtil;
 
@Service
public class AdminUserService {
    @Resource
    private AdminUserDao adminUserDao;
 
    public AdminUserDao getAdminUserDao() {
        return adminUserDao;
    }
 
    public void setAdminUserDao(AdminUserDao adminUserDao) {
        this.adminUserDao = adminUserDao;
    }
 
    /**
     * 用户登录
     * 
     * @param username
     * @param pwd
     * @return
     */
    public AdminInfo login(String username, String pwd) {
        List<AdminInfo> list = adminUserDao.list("from AdminInfo a where a.account=? and a.pwd=?",
                new String[] { username, StringUtil.Md5(pwd) });
        if (list != null && list.size() > 0)
            return list.get(0);
        return null;
    }
 
    /**
     * 获取管理人员信息
     * 
     * @param id
     * @return
     */
    public AdminInfo getAdminInfo(String id) {
        AdminInfo admin = adminUserDao.find(AdminInfo.class, id);
        return admin;
    }
 
    /**
     * 获取管理人员列表
     * 
     * @param id
     * @return
     */
    public List<AdminInfo> getAdminInfoList() {
        List<AdminInfo> admin = adminUserDao.list("from AdminInfo where superadmin='0'");
        return admin;
    }
 
    public List<AdminInfo> getAdminInfoList(String key, int pageIndex) {
        List<AdminInfo> admin = adminUserDao.list("from AdminInfo a where a.id>1 and a.account like ?",
                (pageIndex - 1) * Constant.pageCount, Constant.pageCount, new String[] { "%" + key + "%" });
        return admin;
    }
 
    public long getAdminInfoListCount(String key) {
        return adminUserDao.getCount("select count(*) from AdminInfo a where a.id>1 and a.account like ?",
                new String[] { "%" + key + "%" });
    }
 
    /**
     * 修改用管理员信息
     * 
     * @param info
     */
    public void updateAdminInfo(AdminInfo info) {
        adminUserDao.update(info);
    }
 
    /**
     * 删除管理员信息
     * 
     * @param info
     */
    public void deleteAdminInfo(AdminInfo info) {
        adminUserDao.delete(info);
    }
 
    /**
     * 添加管理员
     * 
     * @param info
     */
    public void addAdmin(AdminInfo info) {
        adminUserDao.save(info);
    }
}