• vo
 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
package com.someapp.vo;
public class UserVO {
  private int id;
  private String username;
  private String hashedPassword;

  public int getId() {
    return id;
  }
  public void setId(int id) {
    this.id = id;
  }
  public String getUsername() {
    return username;
  }
  public void setUsername(String username) {
    this.username = username;
  }
  public String getHashedPassword() {
    return hashedPassword;
  }
  public void setHashedPassword(String hashedPassword) {
    this.hashedPassword = hashedPassword;
  }
}
  • dao
1
2
3
4
5
import org.apache.ibatis.annotations.Param;

public interface IUserDAO {
  List<UserVO> selectUsers(@Param(“paramVO”) UserVO paramVO);
}
  • xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<resultMap id="userResultMap" type="User">
  <id property="id" column="user_id" />
  <result property="username" column="user_name"/>
  <result property="password" column="hashed_password"/>
</resultMap>

<select id="selectUsers"  parameterType="com.someapp.vo.User"  resultMap="userResultMap">
  select user_id, user_name, hashed_password
  from some_table
 <include refid="whereList"/>
</select>

<sql id="whereList"> 
WHERE 1 = 1
  <if test="ParamVO.title != null">
    AND title = #{paramVO.title}
  </if>
</sql>
  • service
1
2
3
4
5
6
@Path(“/api”)
public interface IUserService {
  @POST
  @Path(“/v1/users”)
  ReturnVO selectUsers(UserVO userVO);
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
@named
public UserService implements IUserService {
	@Inject
	private IUserDAO userDAO;

      ReturnVO selectUsers(UserVO userVO) {
		ReturnVO ReturnVO = new ReturnVO()
	    try {
			PagedResult<UserVO> pagedResult = userDAO. selectUsers(userVO);
			returnVO = ResultUtil.success(pagedResult);
		}
		excep (Exception e) {
			returnVO = ResultUtil.serverErr

			
			
			
	}
}
  • web/actions