insert into contract_c
(CONTRACT_ID,,OFFEROR,CONTRACT_NO,SIGNING_DATE,INPUT_BY,CHECK_BY,INSPECTOR,TOTAL_AMOUNT,
IMPORT_NUM,CREQUEST,CUSTOM_NAME,DELIVERY_PERIOD,SHIP_TIME,TRADE_TERMS,REMARK,PRINT_STYLE,
OLD_STATE,STATE,OUT_STATE,CREATE_BY,CREATE_DEPT,CREATE_TIME)
values
(
#{id},
#{offeror, jdbcType=VARCHAR},
#{contractNo, jdbcType=VARCHAR},
#{signingDate, jdbcType=TIMESTAMP},
#{inputBy, jdbcType=VARCHAR},
#{checkBy, jdbcType=VARCHAR},
#{inspector, jdbcType=VARCHAR},
#{totalAmount, jdbcType=DOUBLE},
#{importNum, jdbcType=INTEGER},
#{crequest, jdbcType=VARCHAR},
#{customName, jdbcType=VARCHAR},
#{deliveryPeriod, jdbcType=TIMESTAMP},
#{shipTime, jdbcType=TIMESTAMP},
#{tradeTerms, jdbcType=VARCHAR},
#{remark, jdbcType=VARCHAR},
#{printStyle, jdbcType=CHAR},
#{oldState, jdbcType=INTEGER},
#{state, jdbcType=INTEGER},
#{outState, jdbcType=INTEGER},
#{createBy, jdbcType=VARCHAR},
#{creatDept, jdbcType=VARCHAR},
#{creatTime, jdbcType=TIMESTAMP}
)
update contract_c
OFFEROR=#{offeror},
CONTRACT_NO=#{contractNo},
SIGNING_DATE=#{signingDate},
INPUT_BY=#{inputBy},
CHECK_BY=#{checkBy},
INSPECTOR=#{inspector},
TOTAL_AMOUNT=#{totalAmount},
IMPORT_NUM=#{importNum},
CREQUEST=#{crequest},
CUSTOM_NAME=#{customName},
DELIVERY_PERIOD=#{deliveryPeriod},
SHIP_TIME=#{shipTime},
TRADE_TERMS=#{tradeTerms},
REMARK=#{remark},
PRINT_STYLE=#{printStyle},
OLD_STATE=#{oldState},
STATE=#{state},
OUT_STATE=#{outState},
where contract_id=#{id}
delete from contract_c
where CONTRACT_ID=#{id}
delete from contract_c
where CONTRACT_ID in
#{id}
update contract_c set state=#{state}
where CONTRACT_ID in
#{id}
public void insert(T entity) {
this.getSqlSession().insert(ns + ".insert", entity);
}
@Override
public void insert(Contract contract) {
//设置UUID
contract.setId(UUID.randomUUID().toString());
contract.setState(0);//默认为草稿
contractDao.insert(contract);
}
所以Service层无需添加代码
//跳到添加编辑页面
@RequestMapping("/cargo/contract/tocreate.action")
public String tocreate(){
return "/cargo/contract/jContractCreate.jsp";
}
//添加
@RequestMapping("/cargo/contract/insert.action")
public String insert(Contract contract){
contractService.insert(contract);
return "redirect:/cargo/contract/list.action";
}
接下来我们编写编辑页面的jsp文件:
jContractCreate.jsp<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../base.jsp"%>
添加购销合同