A076_宠物管理模块_前台展示(列表_详情_领养)


寻主

内容介绍

1. 入库宠物-上架 (掌握)
2. 宠物前台展示 (掌握)
3. 领养/售卖 (掌握)

1.宠物管理模块

类型管理:扩展功能
宠物管理:
有crud,还有上架于下架,和服务差不多。 前后台都拷贝服务模块的。

2.宠物前台展示

2.1.宠物列表

Copy product.html

2.2.宠物详情
2.2.1.跳转到店铺

1)拷贝主页为店铺页
2)跳转到店铺页 宠物详情页
在这里插入图片描述
在这里插入图片描述
3)美化店铺
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

<script type="text/javascript">
 new Vue({
  el:"#myDiv",
  data:{
      user:{},
   shopId:null,
   shop:{}
  },
  methods:{
               goPublish(){
                   window.open("publish.html");
   },
               getShop(){
                   this.$http.get("/shop/"+this.shopId)
         .then(result=>{
             this.shop = result.data;
             document.getElementById("myTitle").innerHTML = this.shop.name;
         });
   }
  },
  mounted(){
     let user = localStorage.getItem("uUser");
     if(user){
         this.user = JSON.parse(user);
  }

  this.shopId = parseUrlParams2Obj(location.href).id;
  this.getShop();
  }
 })
</script>
2.2.2.领养

1)前台
在这里插入图片描述
在这里插入图片描述

adopt(){
                let petId = this.pet.id;
                let flag = window.confirm("你确认包养吗?")
 if(flag){
  this.$http.get("/pet/adopt/"+petId)
     .then(result=>{
        result = result.data;
        if(result.success){
           alert("领养成功!")
           location.href = "personcenter.html"
        }else{
           alert(result.message);
        }
     })
   }
 }
}

2)后台

Controller
@GetMapping("/adopt/{id}")
public AjaxResult adopt(@PathVariable(value = "id")Long petId, HttpServletRequest request){
    LoginInfo loginInfo = LoginContext.getLoginInfo(request);
    try {
        petService.adopt(petId,loginInfo.getId());
        return AjaxResult.me();
    } catch (Exception e) {
        e.printStackTrace();
        return AjaxResult.me().setSuccess(false).setMessage("不允许包养!"+e.getMessage());
    }
}
Service

@Override
public void adopt(Long petId,Long loginInfoId) {
    Pet pet = petMapper.loadById(petId);
    System.out.println(pet);
    //1 绑定领养用户
    User user = userMapper.loadByLoginInfoId(loginInfoId);
    pet.setUser_id(user.getId());
    //2 修改状态
    pet.setState(2); //已领养
    petMapper.update(pet);

    //3 @TODO 创建领养订单
}
Mapper.xml

<update id="update" parameterType="Pet">

    update t_pet set
    name          = #{name},
    resources= #{resources},
    saleprice= #{saleprice},
    offsaletime= #{offsaletime},
    onsaletime= #{onsaletime},
    state= #{state},
    costprice= #{costprice},
    createtime= #{createtime},
    type_id= #{type_id},
    shop_id= #{shop_id},
    user_id= #{user_id},
    search_master_msg_id= #{searchMasterMsg_id}
    where id = #{id}
</update>


<resultMap id="petMap" type="Pet">

    <id property="id" column="id"></id>
    <result property="name" column="name"></result>
    <result property="resources" column="resources"></result>
    <result property="saleprice" column="saleprice"></result>
    <result property="costprice" column="costprice"></result>
    <result property="offsaletime" column="offsaletime"></result>
    <result property="onsaletime" column="onsaletime"></result>
    <result property="state" column="state"></result>
    <result property="createtime" column="createtime"></result>
    <result property="searchMasterMsg_id" column="search_master_msg_id"></result>
    <result property="type_id" column="type_id"></result>
    <result property="shop_id" column="shop_id"></result>
    <!--private PetDetail detail = new PetDetail();-->
    <association property="detail" javaType="PetDetail">
        <id property="id" column="pdid"></id>
        <result property="intro" column="intro"></result>
        <result property="adoptNotice" column="adoptNotice"></result>
    </association>
    <association property="shop" javaType="Shop">
        <id property="id" column="sid"></id>
        <result property="name" column="sname"></result>
    </association>
</resultMap>
2.3.扩展功能

1)宠物类型
2)查询自己宠物
后台通过当前登录用户id,查询宠物在用户中心,我的资产里面,我的宠物进行展示
在这里插入图片描述
拷贝客人个人中心页面
在这里插入图片描述
在这里插入图片描述

3.

4.

5.课程总结

宠物后台管理
宠物前台列表
宠物详情页面
	基本展示
	跳转到店铺页面
	包养
查看用户自己宠物
    锻炼找错能力
5.1.重点
5.2.难点
5.3.如何掌握
5.4.排错技巧(技巧)

6.常见问题

7.课后练习

8.面试题

9.扩展知识或课外阅读推荐(可选)

9.1.扩展知识
9.2.课外阅读
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值