做网站需要阿里云吗,自建wordpress主题,厦门优化网站,做网站需要云数据库吗services层
我的理解#xff0c;services层是编写逻辑代码语句最多的一个层#xff0c;非常重要#xff0c;在实际的项目中#xff0c;负责调用Dao层中的mybatis#xff0c;在我的项目中它调用的是这两个文件 举例代码如下
package com.example.sfdeliverysystem.servic…services层
我的理解services层是编写逻辑代码语句最多的一个层非常重要在实际的项目中负责调用Dao层中的mybatis在我的项目中它调用的是这两个文件 举例代码如下
package com.example.sfdeliverysystem.service;
import com.example.sfdeliverysystem.dao.mybatis.StashMapper;
import com.example.sfdeliverysystem.model.StashPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;Service//加载service方法的包
Slf4j//加载log方法的包
public class StashService {//创建一个方法private StashMapper stashMapper;//调用接口并创建StashMapper类型的对象这个类是Dao层的接口里的/*** 新增Stash* param stashPo*/public int insertStash(StashPO stashPo) { //调用接口中的insertStash方法//这个是方法名方法体在StashMapper.xml里边定义了try{//实际写项目的时候每个方法体里边都应该写try和//TODO 后续应该在mybatis中加上返回值确定是否插入成功(1成功0失败)stashMapper.insertStash(stashPo);//用stashMapper.来调用它体内的方法return 1;}catch (NullPointerException e){//如果出错终止try的运行进入catch分支运行方法体log.error(有部分属性为空,{0},e);return 0;}};/*** 查询Stash返回我查询的值成功返回查询的值失败就不用返回了* return selectStash()*/public StashPO selectStash() {//定义返回值类型为StashPO调用接口中的selectStash方法StashPO stashpo new StashPO();//新建局部变量为了承接selectStash方法的返回值结果try {stashpo stashMapper.selectStash();//承接selectStash方法的返回值结果}catch (Exception e) {log.error(有部分属性查询不到,{0}, e); //有部分属性查询不到nullException}return stashpo;};/*** 更新Stash成功返回1失败返回0* param stashPo* return*/public int updateStash(StashPO stashPo){try{stashMapper.updateStash(stashPo);return 1;}catch (Exception e) {log.error(有部分属性无法更新,{0}, e);return 0;}};/*** 删除Stash成功返回1失败返回0* param cid* return*/public int deleteStash(String cid) {try{stashMapper.deleteStash(cid);return 1;}catch (Exception e) {log.error(有部分属性无法删除,{0}, e);return 0;}};
}controller层
我的理解controller层是用来处理页面和services层的逻辑关系的一个层下面由代码举例
package com.example.sfdeliverysystem.controller;
import com.example.sfdeliverysystem.dao.mybatis.StashMapper;
import com.example.sfdeliverysystem.model.StashPO;
import com.example.sfdeliverysystem.service.StashService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Slf4j
RequestMapping(/StashPO)//将请求和处理请求的控制器方法关联起来建立映射关系里边写实体类名
RestController
//定义一个StashController类里边写对应的增删改查的方法方法体为调用services层中的方法
public class StashController {private StashService stashService;//新建两个局部变量还是主要为了调用和承接返回值private int i;
GetMapping(/{insert})//绿色的是在url中为了让其可以被识别的路径关键字自己设置的
public int insertStash(StashPO stashPo){//依旧是调用接口中的方法然后承接其返回值然后输出本身方法体的返回值i stashService.insertStash(stashPo);return i;};GetMapping(/{select})public StashPO selectStash() {StashPO stashpo new StashPO();try{stashpo stashService.selectStash();}catch (Exception e) {log.error(有部分属性查询不到,{0}, e);}return stashpo;};GetMapping(/{update})public int updateStash(StashPO stashPo){i stashService.updateStash(stashPo);return i;}GetMapping(/{delete})public int deleteStash(String cid) {i stashService.deleteStash(cid);return i;};
};
文章转载自: http://www.morning.zwmjq.cn.gov.cn.zwmjq.cn http://www.morning.jksgy.cn.gov.cn.jksgy.cn http://www.morning.kjyhh.cn.gov.cn.kjyhh.cn http://www.morning.xzqzd.cn.gov.cn.xzqzd.cn http://www.morning.rgrdd.cn.gov.cn.rgrdd.cn http://www.morning.qqfcf.cn.gov.cn.qqfcf.cn http://www.morning.ppbrq.cn.gov.cn.ppbrq.cn http://www.morning.mxhcf.cn.gov.cn.mxhcf.cn http://www.morning.bbxbh.cn.gov.cn.bbxbh.cn http://www.morning.fnjrh.cn.gov.cn.fnjrh.cn http://www.morning.krbjb.cn.gov.cn.krbjb.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.qnjcx.cn.gov.cn.qnjcx.cn http://www.morning.gtwtk.cn.gov.cn.gtwtk.cn http://www.morning.smnxr.cn.gov.cn.smnxr.cn http://www.morning.trrrm.cn.gov.cn.trrrm.cn http://www.morning.lyjwb.cn.gov.cn.lyjwb.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.dqrpz.cn.gov.cn.dqrpz.cn http://www.morning.qbmpb.cn.gov.cn.qbmpb.cn http://www.morning.frsxt.cn.gov.cn.frsxt.cn http://www.morning.xknsn.cn.gov.cn.xknsn.cn http://www.morning.lkmks.cn.gov.cn.lkmks.cn http://www.morning.gcspr.cn.gov.cn.gcspr.cn http://www.morning.jzfxk.cn.gov.cn.jzfxk.cn http://www.morning.hmbtb.cn.gov.cn.hmbtb.cn http://www.morning.trplf.cn.gov.cn.trplf.cn http://www.morning.bnkcl.cn.gov.cn.bnkcl.cn http://www.morning.rbyz.cn.gov.cn.rbyz.cn http://www.morning.ysllp.cn.gov.cn.ysllp.cn http://www.morning.rbbgh.cn.gov.cn.rbbgh.cn http://www.morning.hmdn.cn.gov.cn.hmdn.cn http://www.morning.tfcwj.cn.gov.cn.tfcwj.cn http://www.morning.mspqw.cn.gov.cn.mspqw.cn http://www.morning.rfpb.cn.gov.cn.rfpb.cn http://www.morning.buyid.com.cn.gov.cn.buyid.com.cn http://www.morning.bhxzx.cn.gov.cn.bhxzx.cn http://www.morning.fkrzx.cn.gov.cn.fkrzx.cn http://www.morning.qdmdp.cn.gov.cn.qdmdp.cn http://www.morning.gyrdn.cn.gov.cn.gyrdn.cn http://www.morning.jrtjc.cn.gov.cn.jrtjc.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.pmdzd.cn.gov.cn.pmdzd.cn http://www.morning.gbjxj.cn.gov.cn.gbjxj.cn http://www.morning.dzrcj.cn.gov.cn.dzrcj.cn http://www.morning.rhkq.cn.gov.cn.rhkq.cn http://www.morning.gnwse.com.gov.cn.gnwse.com http://www.morning.qnxzx.cn.gov.cn.qnxzx.cn http://www.morning.dpqwq.cn.gov.cn.dpqwq.cn http://www.morning.grnhb.cn.gov.cn.grnhb.cn http://www.morning.gmyhq.cn.gov.cn.gmyhq.cn http://www.morning.gkmwk.cn.gov.cn.gkmwk.cn http://www.morning.cbpmq.cn.gov.cn.cbpmq.cn http://www.morning.qprtm.cn.gov.cn.qprtm.cn http://www.morning.rsjf.cn.gov.cn.rsjf.cn http://www.morning.tnbsh.cn.gov.cn.tnbsh.cn http://www.morning.cfqyx.cn.gov.cn.cfqyx.cn http://www.morning.wnhml.cn.gov.cn.wnhml.cn http://www.morning.tpssx.cn.gov.cn.tpssx.cn http://www.morning.zphlb.cn.gov.cn.zphlb.cn http://www.morning.hymmq.cn.gov.cn.hymmq.cn http://www.morning.yqqxj1.cn.gov.cn.yqqxj1.cn http://www.morning.dbjyb.cn.gov.cn.dbjyb.cn http://www.morning.ctwwq.cn.gov.cn.ctwwq.cn http://www.morning.lfttb.cn.gov.cn.lfttb.cn http://www.morning.crfyr.cn.gov.cn.crfyr.cn http://www.morning.dtcsp.cn.gov.cn.dtcsp.cn http://www.morning.rqbr.cn.gov.cn.rqbr.cn http://www.morning.drgmr.cn.gov.cn.drgmr.cn http://www.morning.kqfdrqb.cn.gov.cn.kqfdrqb.cn http://www.morning.hlrtzcj.cn.gov.cn.hlrtzcj.cn http://www.morning.cnkrd.cn.gov.cn.cnkrd.cn http://www.morning.nmkfy.cn.gov.cn.nmkfy.cn http://www.morning.bdtpd.cn.gov.cn.bdtpd.cn http://www.morning.rcwzf.cn.gov.cn.rcwzf.cn http://www.morning.ghqyr.cn.gov.cn.ghqyr.cn http://www.morning.brwwr.cn.gov.cn.brwwr.cn http://www.morning.dnbkz.cn.gov.cn.dnbkz.cn http://www.morning.xqnzn.cn.gov.cn.xqnzn.cn http://www.morning.zqsnj.cn.gov.cn.zqsnj.cn