发表于: 2019-12-10 15:35:15

2 1228


今日想法:


1.改报错

2.测试

3.提交


今日作为:


1.接口和类,大驼峰

2.变量,小驼峰

3.入参,语义化

4.参数,映射


<!--映射-->
<resultMap id="BannerMap" type="com.clxs.pojo.BannerPojo">
<id property="id" column="id" />
<result property="rightNow" column="right_now"/>
<result property="newTime" column="new_time"/>
<result property="newId" column="new_id"/>
<result property="updateTime" column="update_time"/>
<result property="updateId" column="update_id"/>
<result property="name" column="name"/>
<result property="img" column="img"/>
<result property="url" column="url"/>
</resultMap>
<!--映射-->
<resultMap id="GuideMap" type="com.clxs.pojo.GuidePojo">
<id property="id" column="id" />
<result property="pid" column="pid"/>
<result property="workId" column="work_id"/>
<result property="rightNow" column="right_now"/>
<result property="newTime" column="new_time"/>
<result property="newId" column="new_id"/>
<result property="updateTime" column="update_time"/>
<result property="updateId" column="update_id"/>
<result property="name" column="name"/>
</resultMap>
<!--映射-->
<resultMap id="MessageMap" type="com.clxs.pojo.MessagePojo">
<id property="id" column="id" />
<result property="workId" column="work_id"/>
<result property="rightNow" column="right_now"/>
<result property="newTime" column="new_time"/>
<result property="newName" column="new_name"/>
<result property="updateTime" column="update_time"/>
<result property="updateId" column="update_id"/>
<result property="content" column="content"/>
</resultMap>
<!--映射-->
<resultMap id="WorkMap" type="com.clxs.pojo.WorkPojo">
<id property="id" column="id" />
<result property="rightNow" column="right_now"/>
<result property="newTime" column="new_time"/>
<result property="newId" column="new_id"/>
<result property="updateTime" column="update_time"/>
<result property="updateId" column="update_id"/>
<result property="name" column="name"/>
<result property="introduction" column="introduction"/>
<result property="img" column="img"/>
</resultMap>
//轮播的持久层的接口
public interface BannerDao {

//    查询上架或下架的轮播图
   public List<BannerPojo> SelectByNow(Integer rightNow);

}
//导航的持久层的接口
public interface GuideDao {

//    查询上架或下架的导航栏的内容
   public List<GuidePojo> SelectByNow(Integer rightNow);

}
//留言的持久层的接口
public interface MessageDao {

//    根据导航栏的内容ID查询对应内容的留言
   public List<MessagePojo> SelectByWorkId(Integer workId);

//    游客增加留言
   public boolean InsertByMessage(MessagePojo message);

}
//内容的持久层的接口
public interface WorkDao {

//    根据导航栏的内容ID查询对应内容
   public List<WorkPojo> SelectByWorkId(Integer id);

//    根据搜索栏的内容对名称和介绍进行模糊查询
   public List<WorkPojo> SelectByAll(String name);

}
//轮播的业务层的接口的实现
@Service
public class BannerServiceimpl implements BannerService {

//    引入轮播的持久层的接口
   @Autowired
   private BannerDao bannerDao;

//    查询上架或下架的轮播图
   @Override
   public List<BannerPojo> SelectByNow(Integer rightNow) {
return bannerDao.SelectByNow(rightNow);
}

}
//导航的业务层的接口的实现
@Service
public class GuideServiceimpl implements GuideService {

//    引入导航的持久层的接口
   @Autowired
   private GuideDao guideDao;

//    查询上架或下架的导航栏的内容
   @Override
   public List<GuidePojo> SelectByNow(Integer rightNow) {
return guideDao.SelectByNow(rightNow);
}

}
//留言的业务层的接口的实现
@Service
public class MessageServiceimpl implements MessageService {

//    引入留言的持久层的接口
   @Autowired
   private MessageDao messageDao;

//    根据导航栏的内容ID查询对应的内容的留言
   @Override
   public List<MessagePojo> SelectByWorkId(Integer workId) {
return messageDao.SelectByWorkId(workId);
}

//    游客增加留言
   @Override
   public boolean InsertByMessage(MessagePojo message) {
return messageDao.InsertByMessage(message);
}

}
//内容的业务层的接口的实现
@Service
public class WorkServiceimpl implements WorkService {

//    引入内容的持久层的接口
   @Autowired
   private WorkDao workDao;

//    根据导航栏的内容ID查询对应的内容
   @Override
   public List<WorkPojo> SelectByWorkId(Integer id) {
return workDao.SelectByWorkId(id);
}

//    根据搜索栏的内容对名称和介绍进行模糊查询
   @Override
   public List<WorkPojo> SelectByAll(String name){
return workDao.SelectByAll(name);
}

}
//轮播的业务层的接口
@Service
public interface BannerService {

//    查询上架或下架的轮播图
   public List<BannerPojo> SelectByNow(Integer rightNow);

}
//导航的业务层的接口
@Service
public interface GuideService {

//    查询上架或下架的导航栏的内容
   public List<GuidePojo> SelectByNow(Integer rightNow);

}
//留言的业务层的接口
@Service
public interface MessageService {

//    根据导航栏的内容ID查询对应的内容的留言
   public List<MessagePojo> SelectByWorkId(Integer workId);

//    游客增加留言
   public boolean InsertByMessage(MessagePojo message);

}
//内容的业务层的接口
@Service
public interface WorkService {

//    根据导航栏的内容ID查询对应内容
   public List<WorkPojo> SelectByWorkId(Integer id);

//    根据搜索栏的内容对名称和介绍进行模糊查询
   public List<WorkPojo> SelectByAll(String name);

}
//控制层的接口和接口实现
@Controller
public class FrontController {

//    引入轮播的业务层的接口
   @Autowired
   private BannerService bannerService;

//    引入导航的业务层的接口
   @Autowired
   private GuideService guideService;

//    引入内容的业务层的接口
   @Autowired
   private WorkService workService;

//    引入留言的业务层的接口
   @Autowired
   private MessageService messageService;

//    查询上架或下架的轮播图
   @ResponseBody
   @RequestMapping(value = "/Banner" , method = RequestMethod.GET)
public List<BannerPojo> SelectByBanner(@RequestParam Integer rightNow){
List<BannerPojo> list = bannerService.SelectByNow(rightNow);
return list;
}

//    查询上架或下架的导航栏的内容
   @ResponseBody
   @RequestMapping(value = "/Guide" , method = RequestMethod.GET)
public List<GuidePojo> SelectByIndex(@RequestParam Integer rightNow){
List<GuidePojo> list = guideService.SelectByNow(rightNow);
return list;
}

//    模糊查询内容的名称和介绍
   @ResponseBody
   @RequestMapping(value = "/All" , method = RequestMethod.GET)
public List<WorkPojo> SelectByAll(@RequestParam String name){
List<WorkPojo> list = workService.SelectByAll(name);
return list;
}


//    根据导航栏的内容ID查询对应内容和对应内容的留言
   @ResponseBody
   @RequestMapping(value = "/Work" , method = RequestMethod.GET)
public Map<String,List> SelectByWork(@RequestParam Integer workId){
Map<String,List> map = new HashMap<>();
List A = new ArrayList<>();
List B = new ArrayList<>();
if (map !=null){
List AA = workService.SelectByWorkId(workId);
A.addAll(AA);
List BB = messageService.SelectByWorkId(workId);
B.addAll(BB);
}
map.put("Work",A);
map.put("Message",B);
return map;
}

//    游客增加留言
   @ResponseBody
   @RequestMapping(value = "/Message" , method = RequestMethod.POST)
public boolean InsertByMessage(MessagePojo message){

MessagePojo messagePojo = new MessagePojo();
messagePojo.setWorkId(message.getWorkId());
messagePojo.setRightNow(message.getRightNow());
//        插入自己生成的时间,不需要前端生成,数据传输的安全性考虑。
       messagePojo.setNewTime(System.currentTimeMillis());
//        插入自己生成的名称,不需要前端生成,数据传输的安全性考虑。
       messagePojo.setNewName(getUUID());
messagePojo.setUpdateTime(message.getUpdateTime());
messagePojo.setUpdateId(message.getWorkId());
messagePojo.setContent(message.getContent());

boolean list = messageService.InsertByMessage(messagePojo);
return list;
}

//    官方提供的随机生成名称的工具
   public static String getUUID(){
UUID uuid= UUID.randomUUID();
String str = uuid.toString();
String uuidStr=str.replace("-", "");
return uuidStr;
}

}

今日问题:


表格类和映射还有mybatis的实现原理的问题


明日想法:


等审核通过,开始看任务四


返回列表 返回列表
评论

    分享到