package com.examples.dao;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.examples.vo.AddressVO;
@CacheNamespace(implementation=org.mybatis.caches.ehcache.EhcacheCache.class)
Public interface AddressDAO{
String GET_ADDRESS_BY_ID = "SELECT * FROM vw_address WHERE id = #{addressId}";
String INSERT_ADDRESS = "INSERT into address (building,street,location,town,postCode,countyId,countryId,notes,createdOn,createdBy,active)
VALUES (#{building},#{street},#{location},#{town},#{postCode},#{countyId},#{countryId},#{notes},sysdate(),#{createdBy},1)";
String UPDATE_ADDRESS = "UPDATE address set building=#{building},countyId=#{countyId}, street=#{street},location=#{location},town=#{town},postCode=#{postCode},notes=#{notes},modifiedOn=sysdate(),modifiedBy=#{modifiedBy},countryId=#{countryId} where id= #{id}";
String DELETE_ADDRESS = "DELETE from address WHERE id = #{addressId}";
@Select(GET_ADDRESS_BY_ID)
@Options(useCache=true)
public AddressVO doSelectAddress(long addressId) throws Exception;
@Insert(INSERT_ADDRESS)
@Options(useGeneratedKeys = true, keyProperty = "id", flushCache=true)
public int doCreateAddress(AddressVO address) throws Exception;
@Update(UPDATE_ADDRESS)
@Options(flushCache=true)
public int doUpdateAddress(AddressVO address) throws Exception;
@Delete(DELETE_ADDRESS)
@Options(flushCache=true)
public int doDeleteAddress(long addressId) throws Exception;
}
package com.examples.dao;
import java.util.List;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.examples.vo.AddressVO;
import com.examples.vo.CandidateVO;
import com.examples.vo.EmployerVO;
import com.examples.vo.PersonVO;
@CacheNamespace(implementation=org.mybatis.caches.ehcache.EhcacheCache.class)
public interface CandidateDAO {
String GET_CANDIDATE_BY_ID="select c.* from candidate c where id=#{id} and active=1";
String GET_CANDIDATES_BY_USER_COMPANY = "select * from vw_company_candidate where companyId=#{companyId} and active=1";
String GET_CANDIDATE_BY_ID_AND_USER_COMPANY = "select * from vw_company_candidate where companyId=#{companyId} and id=#{candidateId} and active=1";
String INSERT_CANDIDATE = "INSERT INTO candidate (" +
" personId,addressId,employerId,clientId,basic,ote,met," +
" reference,exclusive,createdOn,createdBy,active," +
" priority,code,offers,referredBy,statusId,salCurrencyId,salTenureId) " +
"VALUES " +
" (#{person.id},#{address.id},#{employer.id},#{client.id}," +
" #{basic},#{ote},#{met},#{reference}," +
" #{exclusive},sysdate(),#{createdBy},1,#{priority}," +
" #{code},#{offers},#{referredBy},#{statusId},#{salCurrencyId},#{salTenureId})";
String UPDATE_CANDIDATE = "UPDATE candidate SET " +
" personId=#{person.id}, addressId=#{address.id}, employerId=#{employer.id}, clientId=#{client.id}," +
" basic=#{basic}, ote=#{ote},met=#{met},reference=#{reference}," +
" exclusive=#{exclusive},modifiedOn=sysdate(),modifiedBy=#{modifiedBy},active=#{active},priority=#{priority}," +
" code=#{code},offers=#{offers},referredBy=#{referredBy},statusId=#{statusId}, " +
" salCurrencyId=#{salCurrencyId},salTenureId=#{salTenureId} where id=#{id}";
String DELETE_CANDIDATE = "update candidate set active=0 where id=#{candidateId}";
String MAP_CANDIDATE_SECTOR = "insert ignore into candidate_sector(sectorId,candidateId) values (#{sectorId},#{candidateId})";
@Select(GET_CANDIDATES_BY_USER_COMPANY)
@Results(value = {
@Result(property="id", column="id"),
@Result(property="person", column="personId", javaType=PersonVO.class, mailto:one=@One(select=%22com.examples.dao.PersonDAO.doSelectPerson")),
@Result(property="address", column="addressId", javaType=AddressVO.class, mailto:one=@One(select=%22com.examples.dao.AddressDAO.doSelectAddress"))
})
public List<candidatevo> doSelectCandidatesByCompany(long companyId);
@Select(GET_CANDIDATE_BY_ID)
@Results({
@Result(property="id", column="id"),
@Result(property="person", column="personId", javaType=PersonVO.class, mailto:one=@One(select=%22com.examples.dao.PersonDAO.doSelectPerson")),
@Result(property="address",column="addressId", javaType=AddressVO.class, mailto:one=@One(select=%22com.examples.dao.AddressDAO.doSelectAddress")),
@Result(property="sectors", column="id", javaType=List.class,many=@Many(select = "com.examples.dao.SectorDAO.doSelectSectorsByCandidate"))
})
public CandidateVO doSelectCandidateById(long candidateId);
@Insert(INSERT_CANDIDATE)
@Options(useGeneratedKeys = true, keyProperty = "id", flushCache=true)
public int doCreateCandidate(CandidateVO candidate) throws Exception;
@Update(UPDATE_CANDIDATE)
@Options(flushCache=true)
public int doUpdateCandidate(CandidateVO candidate) throws Exception;
@Delete(DELETE_CANDIDATE)
@Options(flushCache=true)
public int doDeleteCandidate(long candidateId) throws Exception;
@Insert(MAP_CANDIDATE_SECTOR)
public void doMapCandidateSector(@Param("sectorId") long sectorId, @Param("candidateId") long candidateId);
}
</candidatevo>
댓글 없음:
댓글 쓰기