supplierMapper
package com.leading.supplierservice.domain.supplier.mapper;
import com.leading.supplierservice.domain.supplier.dto.SupplierDTO;
import com.leading.supplierservice.domain.supplier.dto.SupplierDetailDTO;
import com.leading.supplierservice.domain.supplier.dto.SupplierInfoDTO;
import com.leading.supplierservice.domain.supplier.dto.SupplierListDTO;
import com.leading.supplierservice.domain.supplier.model.Supplier;
import org.apache.ibatis.annotations.*;
import java.util.List;
public interface SupplierMapper {
final String SUPPLIER_COLUMN = " no , name , shortName , contacts , dockingWay , memo , creatorId , creatorName , createTime , updateTime ";
final String SUPPLIER_COLUMN_PAGE_LIST = " id , no , name , shortName , contacts , dockingWay , memo , creatorName ";
/**
* 创建供应商
*
* @param supplier
*/
@Insert({
" insert into Supplier ( ",
SUPPLIER_COLUMN,
" ) values ( ",
" #{supplier.no} , #{supplier.name} , #{supplier.shortName} , #{supplier.contacts} , #{supplier.dockingWay} , #{supplier.memo} , #{supplier.creatorId} , #{supplier.creatorName} , now() , now() ",
" ) ",
})
@Options(useGeneratedKeys = true ,keyProperty="supplier.id", keyColumn="id")
Long createSupplier(@Param("supplier") Supplier supplier);
/**
* 更新
*
* @param supplier
*/
@Update({
"<script>",
" update Supplier ",
"<set>",
"<if test='supplier.name != null'> name='${supplier.name}' , </if>",
"<if test='supplier.shortName != null'> shortName='${supplier.shortName}' , </if>",
"<if test='supplier.contacts != null'> contacts='${supplier.contacts}' , </if>",
"<if test='supplier.dockingWay != null'> dockingWay=${supplier.dockingWay} , </if>",
"<if test='supplier.memo != null'> memo='${supplier.memo}' , </if>",
"updateTime = now()",
"</set>",
" where id = #{supplier.id} ",
"</script>"
})
void updateSupplier(@Param("supplier") Supplier supplier);
/**
* 分页查询 - 数量
*
* @param name
* @param contacts
* @return
*/
@Select({
"<script>",
" select count(id) from Supplier ",
"<where>",
"<if test=\"name != null and name !='' \"> and name='${name}' </if>",
"<if test=\"contacts != null and contacts!='' \"> and contacts='${contacts}' </if>",
"</where>",
"</script>"
})
Integer CountFindSupplierList(@Param("name") String name, @Param("contacts") String contacts);
/**
* 分页查询 - 数据
*
* @param name
* @param contacts
* @return
*/
@Select({
"<script>",
" select " + SUPPLIER_COLUMN_PAGE_LIST + " from Supplier ",
"<where>",
"<if test=\"name != null and name !='' \"> and name='${name}' </if>",
"<if test=\"contacts != null and contacts!='' \"> and contacts='${contacts}' </if>",
"</where>",
"order by updateTime desc ",
"limit ${offset},${pageSize}",
"</script>"
})
List<SupplierListDTO> findSupplierList(@Param("name") String name, @Param("contacts") String contacts, @Param("offset") Integer offset,
@Param("pageSize") Integer pageSize);
/**
* 获取详情
*
* @param id
* @return
*/
@Select({
"<script>",
" select * from Supplier where id=#{id} ",
"</script>"
})
Supplier getSupplierDetail(@Param("id") Long id);
}
suplierOperationLogMapper
package com.leading.supplierservice.domain.supplier.mapper;
import com.leading.common.model.ErpUserInfo;
import com.leading.supplierservice.domain.supplier.dto.SupplierOperationLogDTO;
import com.leading.supplierservice.domain.supplier.model.SupplierOperationLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface SupplierOperationLogMapper {
final String SUPPLIER_OPERATION_LOG_COLUMN = " supplierId , operation , description , operatorId , operatorInfo , operationTime ";
/**
* 创建日志
*
* @param supplierOperationLog
*/
@Insert({
" insert into SupplierOperationLog ( ",
SUPPLIER_OPERATION_LOG_COLUMN,
" ) values ( ",
" #{supplierOperationLog.supplierId} , #{supplierOperationLog.operation} , #{supplierOperationLog.description} , #{supplierOperationLog.operatorId} ,#{userInfo,typeHandler=com.leading.common.mybatis.handler.JsonTypeHandler} , now() ",
" ) ",
})
void createSupplierOperationLog(@Param("supplierOperationLog") SupplierOperationLog supplierOperationLog , @Param("userInfo")ErpUserInfo erpUserInfo);
/**
* 查询 - 根据供应商编号
*
* @param supplierId
*/
@Select({
"<script>",
" select * from SupplierOperationLog ",
"<where>",
"<if test='supplierId != null'> and supplierId=#{supplierId} </if>",
"</where>",
"</script>",
})
List<SupplierOperationLogDTO> findSupplierOperationLog(@Param("supplierId") Long supplierId);
}