@Insert("INSERT INTO sal_chance (chc_source, chc_cust_name, chc_title, chc_rate, chc_linkman, chc_tel, chc_desc, chc_create_by, chc_create_date)\n" + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW());") boolean findByInsertCal();,写一个方法
时间: 2024-03-19 17:43:14 浏览: 19
根据你提供的代码,我猜测你是在使用 MyBatis 框架,因此可以写一个如下的方法来插入一条记录:
```
@Insert("INSERT INTO sal_chance (chc_source, chc_cust_name, chc_title, chc_rate, chc_linkman, chc_tel, chc_desc, chc_create_by, chc_create_date) " +
"VALUES (#{chcSource}, #{chcCustName}, #{chcTitle}, #{chcRate}, #{chcLinkman}, #{chcTel}, #{chcDesc}, #{chcCreateBy}, NOW())")
boolean addChance(@Param("chcSource") String chcSource, @Param("chcCustName") String chcCustName,
@Param("chcTitle") String chcTitle, @Param("chcRate") Integer chcRate,
@Param("chcLinkman") String chcLinkman, @Param("chcTel") String chcTel,
@Param("chcDesc") String chcDesc, @Param("chcCreateBy") String chcCreateBy);
```
该方法使用了 MyBatis 的注解 `@Insert` 来进行 SQL 插入操作。方法的参数通过 `@Param` 注解指定了参数名称,对应了 SQL 语句中的占位符 `?`。其中 `NOW()` 函数也用在了 SQL 语句中来获取当前时间。最终返回值为插入是否成功的布尔值。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)