yunkai 8 years ago
parent
commit
f94f4fc186

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

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

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

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