1.模糊查询like拼接:
- phone like concat(concat("%",#{phone}),"%")
2.jquery中attr和prop的区别:
- 对于HTML元素本身就带有的固定属性,在处理时,使用prop()方法;
- 对于HTML元素我们自己定义的DOM属性,在处理时,使用attr()方法;
3.分页参数:
page:当前的页码
pageSize:每页的记录条数
//记录起始位置
((page-1)*pageSize)+1
//记录的结束位置
page*pageSize
4.==与equals:
用了包装类型一定要注意使用==和quals。==比较值和内存地址,equals比较值。
5.List集合去重:
List list={'a','b','c','b','d','e','e'};
List listTemp = new ArrayList();
for(int i=0;i
6.注解方式if判断:
@Select({""})
@Results({
@Result(column = "special_id", property = "specialId", jdbcType = JdbcType.BIGINT, id = true),
@Result(column = "special_name", property = "specialName", jdbcType = JdbcType.VARCHAR),
@Result(column = "special_img_url", property = "specialImgUrl", jdbcType = JdbcType.VARCHAR),
@Result(column = "special_start_time", property = "specialStartTime", jdbcType = JdbcType.DATE),
@Result(column = "special_end_time", property = "specialEndTime", jdbcType = JdbcType.DATE),
@Result(column = "special_extra_name", property = "specialExtraName", jdbcType = JdbcType.VARCHAR),
@Result(column = "special_description_picture_url", property = "specialDescriptionPictureUrl", jdbcType = JdbcType.VARCHAR),
@Result(column = "special_goods_total", property = "specialGoodsTotal", jdbcType = JdbcType.INTEGER),
@Result(column="special_id",property="specialGoods",many=@Many(select="com.lahuo.api.mapper.GoodsMapper.queryGoodsBySpecialId"))
})
public List querySpecialListByKind(@Param("specialKind") int specialKind,@Param("status") int status,@Param("pageSize") int pageSize,@Param("currentPage") int currentPage);
7.将时间转换为字符串 yyyy-MM-dd HH:mm:ss:
public static String dateToStrLong(java.util.Date dateDate) {
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = f.format(dateDate);
return dateString;
}
8.新增记录并返回主键值:
@Options(useGeneratedKeys=true, keyProperty="goodsId", keyColumn="goods_id")
@Insert("insert into goods (supplier_id,category_id,fabric_id,goods_name,goods_img_url,wholesale_min_number,sales_seven_days,sales_total,sale_price,purchase_price,goods_no,goods_status,video_url,origin_id,origin_name,weight,market_id,estimate_weight,has_video) values(#{supplierId},#{categoryId},#{fabricId},#{goodsName},#{goodsImgUrl},#{wholesaleMinNumber},#{salesSevenDays},#{salesTotal},#{salePrice},#{purchasePrice},#{goodsNo},#{goodsStatus},#{videoUrl},#{originId},#{originName},#{weight},#{marketId},#{estimateWeight},#{hasVideo})")
Long addGoods(@Param("supplierId") Integer supplierId,@Param("categoryId") Integer categoryId,@Param("fabricId") Integer fabricId,@Param("goodsName") String goodsName,@Param("goodsImgUrl") String goodsImgUrl,@Param("wholesaleMinNumber") Integer wholesaleMinNumber,@Param("salesSevenDays") int salesSevenDays,@Param("salesTotal") int salesTotal,@Param("salePrice") Long salePrice,@Param("purchasePrice") Long purchasePrice,@Param("goodsNo") String goodsNo,@Param("goodsStatus") int goodsStatus,@Param("videoUrl") String videoUrl,@Param("originId") Integer originId,@Param("originName") String originName,@Param("weight") Long weight,@Param("marketId") Integer marketId,@Param("estimateWeight") Long estimateWeight,@Param("hasVideo") Integer hasVideo);
9.注解事务回滚:
rollbackFor: 遇到哪些异常必须回滚
noRollbackFor: 遇到哪些异常必须不会滚
@Transactional(rollbackFor={RuntimeException.class, Exception.class, LahuoException.class})
public int editGoods(){
...
}
10.MySQL 字段名与 保留关键字冲突:
格式 : `字段名`
eg:
select *,row_number() over(order by system_message_express.message_id asc) `row`
from system_message_express
where customer_id=1
11.js引用另一个js的变量:
1.config.js 作为配置文件,如下:
const ctx = "http://localhost:8080";
2.html中引用两个js,注意顺序:
3.在special.js中直接使用ctx。
12.多条记录合并为一条记录:
select distinct c.color_name
from color c,goods_sku gs,special_goods sg
where c.color_id=gs.color_id and gs.goods_id=sg.goods_id and sg.special_id=6
同时利用group by 与group_concat就能达到效果:
select distinct gs.goods_id,GROUP_CONCAT(distinct color_name) color_name
from color c,goods_sku gs,special_goods sg
where c.color_id=gs.color_id and gs.goods_id=sg.goods_id and sg.special_id=6
group by gs.goods_id