ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
后端mvc框架基于springmvc ~~~ /** * controller示例 * * 统一继承AppController * */ @RestController @RequestMapping("/example") public class ExampleController extends AppController { @Resource(name = "exampleService") private ExampleService exampleService; /** * 查询示例 * * inParam:map结构,将request.getParameter("xx")能取到的参数存入其中 * pagination:接收分页参数 */ @RequestMapping(value = "/queryList") public Object queryList(InParam<String, Object> inParam, Pagination pagination) { return exampleService.queryList(inParam, pagination); } } ~~~ ``` /** * service示例 * */ @Service("exampleService") public class ExampleService extends AppService { @Resource(name = "sqlSessionDao") private BaseSqlSessionDao dao; /** * 查询示例 * * @param param * @param pagination */ @SuppressWarnings( { "serial", "unchecked" }) @ICacheable(cacheSeconds = "100")//可指定缓存时间,单位秒,此值也可从属性文件中读取,例如:@ICacheable(cacheSeconds = "${cacheSeconds}") public PageData queryNameList(IData<String, Object> param, Pagination pagination) { return dao.selectList("NameListSQL.queryNameList", param, pagination); } } ``` ``` <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="NameListSQL"> <select id="queryNameList" resultType="com.walk.example.mvc.entity.TfNList"> SELECT A.* FROM TF_N_LIST A <where> <if test="listId != null and listId != ''"> AND A.LIST_ID = #{listId} </if> <if test="listName != null and listName != ''"> AND A.LIST_NAME LIKE #{listName} || '%' </if> <if test="custType != null and custType != ''"> AND A.CUST_TYPE = #{custType} </if> <if test="subCustType != null and subCustType != ''"> AND A.SUB_CUST_TYPE = #{subCustType} </if> </where> </select> </mapper> ```