Browse Source

修复商品名称搜索的bug

master
xyiege 4 years ago
parent
commit
e2090f9a0c
  1. 5
      src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java
  2. 7
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  3. 18
      src/main/resources/mapper/szwh/GoodsMapper.xml

5
src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java

@ -91,6 +91,11 @@ public class AdminGoodsController extends BaseController {
//qmap.put("data_type",data_type); //qmap.put("data_type",data_type);
qmap.put("g.goods_status",data_type); qmap.put("g.goods_status",data_type);
} }
// 商品名称
String goods= request.getString("goods");
if(StringUtils.isNotBlank(goods)){
qmap.put("gd.goods_name",goods);
}
// 创建时间 // 创建时间
// String createtime=request.getParameter("createtime"); // String createtime=request.getParameter("createtime");
// if(StringUtils.isNotBlank("createtime")){ // if(StringUtils.isNotBlank("createtime")){

7
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -180,9 +180,10 @@ public class GoodsServiceImpl implements GoodsService {
int total = goodsMapper.countGoodsListVo(gmap); int total = goodsMapper.countGoodsListVo(gmap);
retmap.put("total",total); retmap.put("total",total);
// 总的页 if(total<end){
// int totalpage = (int)Math.ceil(total/limit); end=total;
// retmap.put("last_page",totalpage); }
retmap.put("per_page",limit); retmap.put("per_page",limit);
retmap.put("start",start+1); // start 默认为0 retmap.put("start",start+1); // start 默认为0
retmap.put("end",end); retmap.put("end",end);

18
src/main/resources/mapper/szwh/GoodsMapper.xml

@ -62,9 +62,16 @@
<where> <where>
<if test="map!=null"> <if test="map!=null">
<foreach collection="map" item="v" index="k" separator="and"> <foreach collection="map" item="v" index="k" separator="and">
<if test="v != null and v != '' and k!='orderway' and k!='id'"> <if test="v != null and v != '' and k!='orderway' and k!='id' and k!='gd.goods_name' and k!='g.entrust_name'">
${k} = #{v} ${k} = #{v}
</if> </if>
<if test="k=='gd.goods_name'">
gd.goods_name like concat('%',#{v},'%')
OR g.goods_islicode like concat('%',#{v},'%')
</if>
<if test="k=='g.entrust_name'">
g.username like concat('%',#{v},'%')
</if>
</foreach> </foreach>
</if> </if>
</where> </where>
@ -83,9 +90,16 @@
<where> <where>
<if test="map!=null"> <if test="map!=null">
<foreach collection="map" item="v" index="k" separator="and"> <foreach collection="map" item="v" index="k" separator="and">
<if test="v != null and v != '' and k!='orderway' and k!='id'"> <if test="v != null and v != '' and k!='orderway' and k!='id' and k!='gd.goods_name' and k!='g.entrust_name'">
${k} = #{v} ${k} = #{v}
</if> </if>
<if test="k=='gd.goods_name'">
gd.goods_name like concat('%',#{v},'%')
OR g.goods_islicode like concat('%',#{v},'%')
</if>
<if test="k=='g.entrust_name'">
g.username like concat('%',#{v},'%')
</if>
</foreach> </foreach>
</if> </if>
</where> </where>

Loading…
Cancel
Save