shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
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
package com.iplatform.base.service;
 
import com.iplatform.model.po.S_group;
import com.iplatform.model.po.S_group_data;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.jdbc.service.BaseServiceImpl;
import org.springframework.stereotype.Service;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class GroupServiceImpl extends BaseServiceImpl {
 
    /**
     * 根据分组项ID,查询项目记录。
     * @param dataId
     * @return
     * @date 2023-09-11
     */
    public S_group_data queryGroupData(int dataId){
        return this.get(new S_group_data(dataId));
    }
 
    public List<S_group_data> queryAllGroupDataList(){
        return this.select("select * from s_group_data where status=1 order by gid, sort", new Object[]{}, new S_group_data());
    }
 
    /**
     * 获得(s_group_data)表下一个可用的最大ID。
     * @return
     * @date 2023-05-20
     */
    public int queryGroupDataNextId(){
        int maxId = this.queryForInt(SQL_MAX_ID_GROUP_DATA, new Object[]{});
        return maxId+1;
    }
 
    /**
     * 获得(s_group)表下一个可用的最大ID。
     * @return
     * @date 2023-05-20
     */
    public int queryGroupNextId(){
        int maxId = this.queryForInt(SQL_MAX_ID_GROUP, new Object[]{});
        return maxId+1;
    }
 
    public GenericPager<S_group_data> queryPageGroupDataList(int groupId, Integer status){
        Map<String, Object> params = new HashMap<>(4);
        params.put("gid", groupId);
 
        StringBuilder sql = new StringBuilder(SQL_PAGE_GROUP_DATA);
        if(status != null){
            sql.append(" and status=:status");
            params.put("status", status.intValue());
        }
        sql.append(" order by sort desc");
 
        return this.selectSplit(sql.toString(), params, new S_group_data());
    }
 
    public GenericPager<S_group> queryPageGroupList(String keywords){
        S_group group = new S_group();
        if(StringUtils.isNotEmpty(keywords)){
            String search = StringUtils.CHAR_PERCENT + keywords + StringUtils.CHAR_PERCENT;
            return this.selectSplit("select * from s_group where name like ? or info like ? order by id desc"
                    , new Object[]{search, search}, group);
        }
        return this.selectSplit(group);
    }
 
    private static final String SQL_MAX_ID_GROUP_DATA = "select max(id) from s_group_data";
    private static final String SQL_MAX_ID_GROUP = "select max(id) from s_group";
    private static final String SQL_PAGE_GROUP_DATA = "select * from s_group_data where gid=:gid";
}