yunkai 8 years ago
parent
commit
f94f4fc186

+ 31 - 25
src/main/java/com/ekexiu/console/system/dao/MyCustomerDao.java

@ -1,25 +1,31 @@
1
package com.ekexiu.console.system.dao;
2
3
import com.ekexiu.console.system.po.MyCustomer;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.DAO;
6
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
7
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
8
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
9
import org.jfw.apt.orm.annotation.dao.param.Like;
10
import org.jfw.util.PageQueryResult;
11
12
import java.sql.Connection;
13
import java.sql.SQLException;
14
15
@DAO
16
public interface MyCustomerDao {
17
	@Nullable
18
	@SelectOne
19
	MyCustomer query(Connection con, String powerId) throws SQLException;
20
	
21
	@PageSelect
22
	@OrderBy(" ORDER BY create_time desc")
23
	PageQueryResult<MyCustomer> query(Connection con, @Like String name, @Like String address, @Like String orgname, @Nullable String powType, @Nullable String cuserId, int pageSize, int pageNo) throws SQLException;
24
25
}
1
package com.ekexiu.console.system.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Nullable;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
9
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
10
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
11
import org.jfw.apt.orm.annotation.dao.param.Like;
12
import org.jfw.util.PageQueryResult;
13

14
import com.ekexiu.console.system.po.MyCustomer;
15

16

17

18
@DAO
19
public interface MyCustomerDao {
20
	@Nullable
21
	@SelectOne
22
	MyCustomer query(Connection con, String powerId) throws SQLException;
23
	
24
	@PageSelect
25
	@OrderBy(" ORDER BY create_time desc")
26
	PageQueryResult<MyCustomer> query(Connection con,@Nullable @Like String name,@Nullable @Like String address,@Nullable @Like String orgname, @Nullable String powType, @Nullable String cuserId, int pageSize, int pageNo) throws SQLException;
27
	
28
	@PageSelect
29
	@OrderBy(" ORDER BY create_time desc")
30
	PageQueryResult<MyCustomer> allquery(Connection con,@Nullable @Like String name,@Nullable @Like String address,@Nullable @Like String orgname, @Nullable String powType, @Nullable @Like String cuserName, int pageSize, int pageNo) throws SQLException;
31
}

+ 84 - 58
src/main/java/com/ekexiu/console/system/service/MyCustomerService.java

@ -1,58 +1,84 @@
1
package com.ekexiu.console.system.service;
2
3
import com.ekexiu.console.system.dao.MyCustomerDao;
4
import com.ekexiu.console.system.po.MyCustomer;
5
import com.ekexiu.console.system.vo.ConsoleAuthUser;
6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.annotation.DefaultValue;
8
import org.jfw.apt.annotation.Nullable;
9
import org.jfw.apt.orm.annotation.dao.param.Like;
10
import org.jfw.apt.web.annotation.LoginUser;
11
import org.jfw.apt.web.annotation.Path;
12
import org.jfw.apt.web.annotation.operate.Get;
13
import org.jfw.apt.web.annotation.param.JdbcConn;
14
import org.jfw.apt.web.annotation.param.PathVar;
15
import org.jfw.util.PageQueryResult;
16
17
import java.sql.Connection;
18
import java.sql.SQLException;
19
20
21
@Path("/sys/mycustomer")
22
public class MyCustomerService {
23
	@Autowrie
24
	private MyCustomerDao myCustomerDao;
25
26
	public MyCustomerDao getMyCustomerDao() {
27
		return myCustomerDao;
28
	}
29
30
	public void setMyCustomerDao(MyCustomerDao myCustomerDao) {
31
		this.myCustomerDao = myCustomerDao;
32
	}
33
	@Get
34
	@Path("/pq")
35
	public PageQueryResult<MyCustomer> pageQuery(@JdbcConn Connection con, @Nullable @Like String name, @Nullable @Like String address, @Nullable @Like String orgname, @Nullable String powType, @LoginUser ConsoleAuthUser user, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize)throws SQLException{
36
		String Cname ="%";
37
		if(name!=null)
38
		{
39
			Cname="%"+name+"%";
40
		}
41
		String Caddress ="%";
42
		if(address!=null)
43
		{
44
			Caddress="%"+address+"%";
45
		}
46
		String Corgname ="%";
47
		if(orgname!=null)
48
		{
49
			Corgname="%"+orgname+"%";
50
		}
51
		return this.myCustomerDao.query(con, Cname, Caddress, Corgname, powType,user.getId(), pageSize, pageNo);
52
	}	
53
	@Get
54
	@Path("/id/{id}")
55
	public MyCustomer query(@JdbcConn Connection con, @PathVar String id)throws SQLException{
56
		return this.myCustomerDao.query(con, id);
57
	}	
58
}
1
package com.ekexiu.console.system.service;
2

3
import com.ekexiu.console.system.dao.MyCustomerDao;
4
import com.ekexiu.console.system.po.MyCustomer;
5
import com.ekexiu.console.system.vo.ConsoleAuthUser;
6

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.annotation.DefaultValue;
9
import org.jfw.apt.annotation.Nullable;
10
import org.jfw.apt.orm.annotation.dao.param.Like;
11
import org.jfw.apt.web.annotation.LoginUser;
12
import org.jfw.apt.web.annotation.Path;
13
import org.jfw.apt.web.annotation.operate.Get;
14
import org.jfw.apt.web.annotation.param.JdbcConn;
15
import org.jfw.apt.web.annotation.param.PathVar;
16
import org.jfw.util.PageQueryResult;
17

18
import java.sql.Connection;
19
import java.sql.SQLException;
20

21

22
@Path("/sys/mycustomer")
23
public class MyCustomerService {
24
	@Autowrie
25
	private MyCustomerDao myCustomerDao;
26

27
	public MyCustomerDao getMyCustomerDao() {
28
		return myCustomerDao;
29
	}
30

31
	public void setMyCustomerDao(MyCustomerDao myCustomerDao) {
32
		this.myCustomerDao = myCustomerDao;
33
	}
34
	@Get
35
	@Path("/pq")
36
	public PageQueryResult<MyCustomer> pageQuery(@JdbcConn Connection con, @Nullable @Like String name, @Nullable @Like String address, @Nullable @Like String orgname, @Nullable String powType, @LoginUser ConsoleAuthUser user, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize)throws SQLException{
37
		String Cname ="%";
38
		if(name!=null)
39
		{
40
			Cname="%"+name+"%";
41
		}
42
		String Caddress ="%";
43
		if(address!=null)
44
		{
45
			Caddress="%"+address+"%";
46
		}
47
		String Corgname ="%";
48
		if(orgname!=null)
49
		{
50
			Corgname="%"+orgname+"%";
51
		}
52
		return this.myCustomerDao.query(con, Cname, Caddress, Corgname, powType,user.getId(), pageSize, pageNo);
53
	}
54
	@Get
55
	@Path("/allpq")
56
	public PageQueryResult<MyCustomer> pageQuery(@JdbcConn Connection con, @Nullable @Like String name, @Nullable @Like String address, @Nullable @Like String orgname, @Nullable String powType, @Nullable @Like String cuserName, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize)throws SQLException{
57
		String Cname=null;
58
		if(name!=null)
59
		{
60
			Cname="%"+name+"%";
61
		}
62
		String Caddress=null;
63
		if(address!=null)
64
		{
65
			Caddress="%"+address+"%";
66
		}
67
		String Corgname =null;
68
		if(orgname!=null)
69
		{
70
			Corgname="%"+orgname+"%";
71
		}
72
		String Cusernames=null;
73
		if(cuserName!=null)
74
		{
75
			Cusernames="%"+cuserName+"%";
76
		}
77
		return this.myCustomerDao.allquery(con, Cname, Caddress,Corgname,powType,Cusernames, pageSize, pageNo);
78
	}
79
	@Get
80
	@Path("/id/{id}")
81
	public MyCustomer query(@JdbcConn Connection con, @PathVar String id)throws SQLException{
82
		return this.myCustomerDao.query(con, id);
83
	}	
84
}