Commit 19d6865d by gechengyang

提交springboot+mybatis测试代码

parent b575638b
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<version>2.5.12</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
......@@ -17,7 +17,7 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mybatis.spring-boot.version>1.3.0</mybatis.spring-boot.version>
<mybatis.spring-boot.version>2.2.0</mybatis.spring-boot.version>
<mysql.connector.version>5.1.46</mysql.connector.version>
<alibaba.druid.version>1.1.6</alibaba.druid.version>
<page.helper.version>1.2.5</page.helper.version>
......@@ -90,6 +90,22 @@
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.5.10</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
</dependencies>
......@@ -101,7 +117,8 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<!-- <version>2.1.1.RELEASE</version>-->
<version>2.5.12</version>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
......
package com.brilliance.controller;
import com.brilliance.entity.Smqinf;
import com.brilliance.mapper.SmqinfMapper;
import com.brilliance.vo.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/*
*
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@RestController
@RequestMapping("/smqinf")
public class SmqInfController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private SmqinfMapper smqinfMapper;
/* @Autowired
public SmqInfController(SmqinfMapper smqinfMapper) {
this.smqinfMapper = smqinfMapper;
}
*/
@GetMapping("/get")
//localhost:8085/smqinf/get?id=123&nam=zhangsan
public Result testParams(@RequestParam("id") String id,@RequestParam("nam") String paramName){
System.out.println("id==="+id);
System.out.println("name==="+paramName);
return new Result(id+"..."+paramName);
}
@GetMapping("/get1")
//localhost:8085/smqinf/get?id=123&nam=zhangsan
public Result testParams1(@RequestParam Map<String,Object> requestMap){
System.out.println("requesMap=="+requestMap);
return new Result(requestMap);
}
@PostMapping("/post2/{inr}/{nam}")
public Result testPathVariable(@PathVariable String inr,@PathVariable String nam) {
Smqinf smqinf=smqinfMapper.selectByPrimaryKey(inr);
return new Result(smqinf);
}
@PostMapping("/post")
public Result getSmqInfo(@RequestBody Smqinf requestSmqInf) {
String inr=requestSmqInf.getInr();
System.out.println("test...test...");
Smqinf smqinf=smqinfMapper.selectByPrimaryKey(inr);
return new Result(smqinf);
}
// 请求头
@GetMapping("/header")
public String getWithHeader(@RequestHeader("tokenid") String header) {
return "Header: " + header;
}
@GetMapping("/header1")
public Map getWithHeader(@RequestHeader Map map) {
return map;
}
}
package com.brilliance.controller;
import com.brilliance.entity.Smqlck;
import com.brilliance.service.SmqlckService;
import com.brilliance.vo.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Optional;
/*
*
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@RestController
@RequestMapping("/smqlck")
public class SmqLckController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private SmqlckService smqlckService;
@PostMapping("/post")
public Result getSmqInfo(@RequestBody Smqlck smqlck) {
String inr=smqlck.getInr();
smqlckService.createLck(smqlck);
System.out.println("test...test...");
return new Result();
}
}
package com.brilliance.controller;
import com.brilliance.entity.Mps;
import com.brilliance.service.LckService;
import com.brilliance.service.MpsService;
import com.brilliance.vo.Result;
import org.apache.commons.lang.reflect.MethodUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@RestController
@RequestMapping("mps")
public class XxxtskController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private MpsService mpsService;
@Autowired
private LckService lckService;
@PostMapping("xxxtsk")
public Result userList() {
List<Mps> mpsList = mpsService.getMpsList("XXX",">","A",new Date(),"sttdattim ASC");
for(Mps mps :mpsList){
}
Mps mps=new Mps();
String inr="CTEST001";
mps.setInr(inr);
mps.setChncod("SWT");
mps.setDir(">");
mps.setLstdattim(new Date());
mps.setRcvdattim(new Date());
mps.setSrcchncod("CTS");
mps.setSta("W");
mps.setSttdattim(new Date());
mps.setIsmx(0L);
//mpsService.test();
// mpsService.insert(mps);
// mpsService.delete(inr);
return new Result(mpsList);
}
public static void main(String[] args) {
Mps mps=new Mps();
mps.setInr("TEST0001");
System.out.println(mps.getClass().getSimpleName().toLowerCase());
try {
Object inrObj = MethodUtils.invokeMethod(mps, "getInr",null);
System.out.println(inrObj);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.brilliance.entity;
public class Clsmsg {
private String inr;
private String src;
private String des;
private String app;
private String msgno;
private String msgid;
private String msgref;
private String workdate;
private String reserve;
private String msgtyp;
private String gid;
private String sendid;
private String recvid;
private String snddattim;
private String vesion;
public String getInr() {
return inr;
}
public void setInr(String inr) {
this.inr = inr == null ? null : inr.trim();
}
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src == null ? null : src.trim();
}
public String getDes() {
return des;
}
public void setDes(String des) {
this.des = des == null ? null : des.trim();
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app == null ? null : app.trim();
}
public String getMsgno() {
return msgno;
}
public void setMsgno(String msgno) {
this.msgno = msgno == null ? null : msgno.trim();
}
public String getMsgid() {
return msgid;
}
public void setMsgid(String msgid) {
this.msgid = msgid == null ? null : msgid.trim();
}
public String getMsgref() {
return msgref;
}
public void setMsgref(String msgref) {
this.msgref = msgref == null ? null : msgref.trim();
}
public String getWorkdate() {
return workdate;
}
public void setWorkdate(String workdate) {
this.workdate = workdate == null ? null : workdate.trim();
}
public String getReserve() {
return reserve;
}
public void setReserve(String reserve) {
this.reserve = reserve == null ? null : reserve.trim();
}
public String getMsgtyp() {
return msgtyp;
}
public void setMsgtyp(String msgtyp) {
this.msgtyp = msgtyp == null ? null : msgtyp.trim();
}
public String getGid() {
return gid;
}
public void setGid(String gid) {
this.gid = gid == null ? null : gid.trim();
}
public String getSendid() {
return sendid;
}
public void setSendid(String sendid) {
this.sendid = sendid == null ? null : sendid.trim();
}
public String getRecvid() {
return recvid;
}
public void setRecvid(String recvid) {
this.recvid = recvid == null ? null : recvid.trim();
}
public String getSnddattim() {
return snddattim;
}
public void setSnddattim(String snddattim) {
this.snddattim = snddattim == null ? null : snddattim.trim();
}
public String getVesion() {
return vesion;
}
public void setVesion(String vesion) {
this.vesion = vesion == null ? null : vesion.trim();
}
}
\ No newline at end of file
package com.brilliance.entity;
import java.util.Date;
public class Lck {
public class Cnt {
private String nam;
private String txt;
private Short val;
private Date dattim;
private Short stp;
public String getNam() {
return nam;
......@@ -17,19 +15,19 @@ public class Lck {
this.nam = nam == null ? null : nam.trim();
}
public String getTxt() {
return txt;
public Short getVal() {
return val;
}
public void setTxt(String txt) {
this.txt = txt == null ? null : txt.trim();
public void setVal(Short val) {
this.val = val;
}
public Date getDattim() {
return dattim;
public Short getStp() {
return stp;
}
public void setDattim(Date dattim) {
this.dattim = dattim;
public void setStp(Short stp) {
this.stp = stp;
}
}
\ No newline at end of file
package com.brilliance.entity;
import java.util.Date;
public class Mpe {
private String inr;
private String chncod;
private Date dattim;
private String mpsinr;
private String nxtchncod;
private String nxtsmhinr;
private String prvsta;
private String smhinr;
private String sta;
private String txt;
private String rspsta;
private String prvrspsta;
private String usr;
private String frmnam;
private String etyinr;
private String ptyinr;
public String getInr() {
return inr;
}
public void setInr(String inr) {
this.inr = inr == null ? null : inr.trim();
}
public String getChncod() {
return chncod;
}
public void setChncod(String chncod) {
this.chncod = chncod == null ? null : chncod.trim();
}
public Date getDattim() {
return dattim;
}
public void setDattim(Date dattim) {
this.dattim = dattim;
}
public String getMpsinr() {
return mpsinr;
}
public void setMpsinr(String mpsinr) {
this.mpsinr = mpsinr == null ? null : mpsinr.trim();
}
public String getNxtchncod() {
return nxtchncod;
}
public void setNxtchncod(String nxtchncod) {
this.nxtchncod = nxtchncod == null ? null : nxtchncod.trim();
}
public String getNxtsmhinr() {
return nxtsmhinr;
}
public void setNxtsmhinr(String nxtsmhinr) {
this.nxtsmhinr = nxtsmhinr == null ? null : nxtsmhinr.trim();
}
public String getPrvsta() {
return prvsta;
}
public void setPrvsta(String prvsta) {
this.prvsta = prvsta == null ? null : prvsta.trim();
}
public String getSmhinr() {
return smhinr;
}
public void setSmhinr(String smhinr) {
this.smhinr = smhinr == null ? null : smhinr.trim();
}
public String getSta() {
return sta;
}
public void setSta(String sta) {
this.sta = sta == null ? null : sta.trim();
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt == null ? null : txt.trim();
}
public String getRspsta() {
return rspsta;
}
public void setRspsta(String rspsta) {
this.rspsta = rspsta == null ? null : rspsta.trim();
}
public String getPrvrspsta() {
return prvrspsta;
}
public void setPrvrspsta(String prvrspsta) {
this.prvrspsta = prvrspsta == null ? null : prvrspsta.trim();
}
public String getUsr() {
return usr;
}
public void setUsr(String usr) {
this.usr = usr == null ? null : usr.trim();
}
public String getFrmnam() {
return frmnam;
}
public void setFrmnam(String frmnam) {
this.frmnam = frmnam == null ? null : frmnam.trim();
}
public String getEtyinr() {
return etyinr;
}
public void setEtyinr(String etyinr) {
this.etyinr = etyinr == null ? null : etyinr.trim();
}
public String getPtyinr() {
return ptyinr;
}
public void setPtyinr(String ptyinr) {
this.ptyinr = ptyinr == null ? null : ptyinr.trim();
}
}
\ No newline at end of file
package com.brilliance.entity;
import java.util.Date;
public class Mps {
private String inr;
private String chncod;
private String dir;
private Date lstdattim;
private String nxtchncod;
private String pntinr;
private Date rcvdattim;
private Date rspdattim;
private String rspsta;
private String smhinr;
private Date snddattim;
private String srcchncod;
private String sta;
private String nxtsta;
private String stp;
private Date sttdattim;
private String tgtchncod;
private Date tgtdattime;
private String isman;
private String isblk;
private String etyinr;
private String ptyinr;
private String flg;
private String rspcod;
private String reptrksta;
private String swetyp;
private String sweack;
private String rptsta;
private String messageid;
private String blktyp;
private String xhxflg;
private Long ismx;
public String getInr() {
return inr;
}
public void setInr(String inr) {
this.inr = inr == null ? null : inr.trim();
}
public String getChncod() {
return chncod;
}
public void setChncod(String chncod) {
this.chncod = chncod == null ? null : chncod.trim();
}
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir == null ? null : dir.trim();
}
public Date getLstdattim() {
return lstdattim;
}
public void setLstdattim(Date lstdattim) {
this.lstdattim = lstdattim;
}
public String getNxtchncod() {
return nxtchncod;
}
public void setNxtchncod(String nxtchncod) {
this.nxtchncod = nxtchncod == null ? null : nxtchncod.trim();
}
public String getPntinr() {
return pntinr;
}
public void setPntinr(String pntinr) {
this.pntinr = pntinr == null ? null : pntinr.trim();
}
public Date getRcvdattim() {
return rcvdattim;
}
public void setRcvdattim(Date rcvdattim) {
this.rcvdattim = rcvdattim;
}
public Date getRspdattim() {
return rspdattim;
}
public void setRspdattim(Date rspdattim) {
this.rspdattim = rspdattim;
}
public String getRspsta() {
return rspsta;
}
public void setRspsta(String rspsta) {
this.rspsta = rspsta == null ? null : rspsta.trim();
}
public String getSmhinr() {
return smhinr;
}
public void setSmhinr(String smhinr) {
this.smhinr = smhinr == null ? null : smhinr.trim();
}
public Date getSnddattim() {
return snddattim;
}
public void setSnddattim(Date snddattim) {
this.snddattim = snddattim;
}
public String getSrcchncod() {
return srcchncod;
}
public void setSrcchncod(String srcchncod) {
this.srcchncod = srcchncod == null ? null : srcchncod.trim();
}
public String getSta() {
return sta;
}
public void setSta(String sta) {
this.sta = sta == null ? null : sta.trim();
}
public String getNxtsta() {
return nxtsta;
}
public void setNxtsta(String nxtsta) {
this.nxtsta = nxtsta == null ? null : nxtsta.trim();
}
public String getStp() {
return stp;
}
public void setStp(String stp) {
this.stp = stp == null ? null : stp.trim();
}
public Date getSttdattim() {
return sttdattim;
}
public void setSttdattim(Date sttdattim) {
this.sttdattim = sttdattim;
}
public String getTgtchncod() {
return tgtchncod;
}
public void setTgtchncod(String tgtchncod) {
this.tgtchncod = tgtchncod == null ? null : tgtchncod.trim();
}
public Date getTgtdattime() {
return tgtdattime;
}
public void setTgtdattime(Date tgtdattime) {
this.tgtdattime = tgtdattime;
}
public String getIsman() {
return isman;
}
public void setIsman(String isman) {
this.isman = isman == null ? null : isman.trim();
}
public String getIsblk() {
return isblk;
}
public void setIsblk(String isblk) {
this.isblk = isblk == null ? null : isblk.trim();
}
public String getEtyinr() {
return etyinr;
}
public void setEtyinr(String etyinr) {
this.etyinr = etyinr == null ? null : etyinr.trim();
}
public String getPtyinr() {
return ptyinr;
}
public void setPtyinr(String ptyinr) {
this.ptyinr = ptyinr == null ? null : ptyinr.trim();
}
public String getFlg() {
return flg;
}
public void setFlg(String flg) {
this.flg = flg == null ? null : flg.trim();
}
public String getRspcod() {
return rspcod;
}
public void setRspcod(String rspcod) {
this.rspcod = rspcod == null ? null : rspcod.trim();
}
public String getReptrksta() {
return reptrksta;
}
public void setReptrksta(String reptrksta) {
this.reptrksta = reptrksta == null ? null : reptrksta.trim();
}
public String getSwetyp() {
return swetyp;
}
public void setSwetyp(String swetyp) {
this.swetyp = swetyp == null ? null : swetyp.trim();
}
public String getSweack() {
return sweack;
}
public void setSweack(String sweack) {
this.sweack = sweack == null ? null : sweack.trim();
}
public String getRptsta() {
return rptsta;
}
public void setRptsta(String rptsta) {
this.rptsta = rptsta == null ? null : rptsta.trim();
}
public String getMessageid() {
return messageid;
}
public void setMessageid(String messageid) {
this.messageid = messageid == null ? null : messageid.trim();
}
public String getBlktyp() {
return blktyp;
}
public void setBlktyp(String blktyp) {
this.blktyp = blktyp == null ? null : blktyp.trim();
}
public String getXhxflg() {
return xhxflg;
}
public void setXhxflg(String xhxflg) {
this.xhxflg = xhxflg == null ? null : xhxflg.trim();
}
public Long getIsmx() {
return ismx;
}
public void setIsmx(Long ismx) {
this.ismx = ismx;
}
}
\ No newline at end of file
package com.brilliance.entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Table(name="smh")
public class Smh {
@Id
@Column(name="inr")
private String inr;
@Column(name="crtfrm")
private String crtfrm;
private String crtfrm;
@Column(name = "dattim")
private Date dattim;
public String getInr() {
return inr;
}
public void setInr(String smhinr) {
this.inr = smhinr;
public void setInr(String inr) {
this.inr = inr == null ? null : inr.trim();
}
public String getCrtfrm() {
......@@ -30,14 +22,14 @@ public class Smh {
}
public void setCrtfrm(String crtfrm) {
this.crtfrm = crtfrm;
this.crtfrm = crtfrm == null ? null : crtfrm.trim();
}
public Date getDattim() {
return dattim;
}
public void setDattim(Date dateTime) {
this.dattim = dateTime;
public void setDattim(Date dattim) {
this.dattim = dattim;
}
}
}
\ No newline at end of file
package com.brilliance.entity;
import java.util.Date;
public class Smqinf {
private String inr;
private String pth;
private Short cnt;
private String sta;
private Date credat;
private String mesgno;
private String objinr;
private String objtyp;
public String getInr() {
return inr;
}
public void setInr(String inr) {
this.inr = inr == null ? null : inr.trim();
}
public String getPth() {
return pth;
}
public void setPth(String pth) {
this.pth = pth == null ? null : pth.trim();
}
public Short getCnt() {
return cnt;
}
public void setCnt(Short cnt) {
this.cnt = cnt;
}
public String getSta() {
return sta;
}
public void setSta(String sta) {
this.sta = sta == null ? null : sta.trim();
}
public Date getCredat() {
return credat;
}
public void setCredat(Date credat) {
this.credat = credat;
}
public String getMesgno() {
return mesgno;
}
public void setMesgno(String mesgno) {
this.mesgno = mesgno == null ? null : mesgno.trim();
}
public String getObjinr() {
return objinr;
}
public void setObjinr(String objinr) {
this.objinr = objinr == null ? null : objinr.trim();
}
public String getObjtyp() {
return objtyp;
}
public void setObjtyp(String objtyp) {
this.objtyp = objtyp == null ? null : objtyp.trim();
}
}
\ No newline at end of file
package com.brilliance.entity;
public class Smqlck {
private String inr;
public String getInr() {
return inr;
}
public void setInr(String inr) {
this.inr = inr == null ? null : inr.trim();
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistration
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//@Configuration
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Bean
......
package com.brilliance.mapper;
import com.brilliance.entity.Clsmsg;
public interface ClsmsgMapper {
int deleteByPrimaryKey(String inr);
int insert(Clsmsg record);
int insertSelective(Clsmsg record);
Clsmsg selectByPrimaryKey(String inr);
int updateByPrimaryKeySelective(Clsmsg record);
int updateByPrimaryKey(Clsmsg record);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Cnt;
public interface CntMapper {
int insert(Cnt record);
int insertSelective(Cnt record);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Lck;
import org.apache.ibatis.annotations.Param;
public interface LckMapper {
int insert(Lck record);
int insertSelective(Lck record);
Lck selectLck(@Param("nam") String userName, @Param("txt") String txtInfo);
int deleteByPrimaryKey(@Param("txt") String txtInfo,@Param("nam") String userName);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Mpe;
public interface MpeMapper {
int insert(Mpe record);
int insertSelective(Mpe record);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Mpi;
import org.apache.ibatis.annotations.Param;
public interface MpiMapper {
int deleteByPrimaryKey(String inr);
int insert(Mpi record);
int insertSelective(Mpi record);
Mpi selectByPrimaryKey(String inr);
int updateByPrimaryKeySelective(Mpi record);
int updateByPrimaryKey(Mpi record);
Mpi getMpi(@Param("othref") String othref, @Param("dir") String dir);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Mps;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface MpsMapper {
int deleteByPrimaryKey(String inr);
int insert(Mps record);
int insertSelective(Mps record);
Mps selectByPrimaryKey(String inr);
int updateByPrimaryKeySelective(Mps record);
int updateByPrimaryKey(Mps record);
//Platform.mdbReadset($mpslst,new Argument("nxtchncod",channel).and("sta",state).and("dir",dir).and("sttdattim",LE,new Date()),new Argument("sttdattim",ASC));
List<Mps> getMpsList(@Param("nxtchncod") String nxtchncod,@Param("dir") String dir,@Param("sta") String sta,@Param("sttdattim") Date sttdattim,@Param("orderBy") String orderBy) ;
int counterMps(@Param("dir") String dir);
String getSrcchncod(@Param("inr") String inr);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Smh;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface SmhMapper {
//@Select({"select * from user where age=#{age}"})
@Select({"select * from smh where inr= #{inr} "})
Smh selectSmh(@Param("inr") String inr);
int deleteByPrimaryKey(String inr);
@Insert({"insert into smh(inr,crtfrm,dattim) values (#{inr},#{crtfrm},#{dattim})"})
int insert(Smh smh);
int insert(Smh record);
int insertSelective(Smh record);
Smh selectByPrimaryKey(String inr);
int updateByPrimaryKeySelective(Smh record);
int updateByPrimaryKey(Smh record);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Smqinf;
import org.springframework.stereotype.Repository;
@Repository
public interface SmqinfMapper {
int deleteByPrimaryKey(String inr);
int insert(Smqinf record);
int insertSelective(Smqinf record);
Smqinf selectByPrimaryKey(String inr);
int updateByPrimaryKeySelective(Smqinf record);
int updateByPrimaryKey(Smqinf record);
}
\ No newline at end of file
package com.brilliance.mapper;
import com.brilliance.entity.Smqlck;
public interface SmqlckMapper {
int deleteByPrimaryKey(String inr);
int insert(Smqlck record);
int insertSelective(Smqlck record);
}
\ No newline at end of file
package com.brilliance.service;
import com.brilliance.entity.Mps;
import java.util.Date;
import java.util.List;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
public interface LckService {
boolean dbLock(Object obj,String userName);
boolean dbUnlock(Object obj,String userName);
boolean dbLock(String modeType,String inr,String userName);
boolean dbUnlock(String modeType, String inr,String name);
}
package com.brilliance.service;
import com.brilliance.entity.Mps;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
public interface MpsService {
List<Mps> getMpsList(String nxtchncod, String dir, String sta, Date sttdattim,String orderBy) ;
boolean insert(Mps mps);
boolean delete(String inr);
void test();
}
package com.brilliance.service;
import com.brilliance.entity.Smqlck;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.jpa.repository.JpaRepository;
//@Mapper
public interface SmqlckService {
boolean createLck(Smqlck smqlck);
}
package com.brilliance.service.impl;
import com.brilliance.entity.Lck;
import com.brilliance.mapper.LckMapper;
import com.brilliance.service.LckService;
import org.apache.commons.lang.reflect.MethodUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@Service
public class LckServiceImpl implements LckService {
private static Logger logger=LoggerFactory.getLogger(LckServiceImpl.class);
@Autowired
private LckMapper lckMapper;
@Override
public boolean dbLock(Object obj, String userName) {
Lck lck=new Lck();
Object inrObj =null;
if(obj==null)
return false;
String modeType=obj.getClass().getSimpleName().toLowerCase();
try {
inrObj = MethodUtils.invokeMethod(obj, "getInr",null);
} catch (Exception e) {
e.printStackTrace();
return false;
}
if(inrObj==null) {
return false;
}
String inr= (String) inrObj;
String txt=modeType+inr;
Lck lck1 = lckMapper.selectLck(userName, modeType);
if(lck1!=null){
logger.info("lck has been exsist,lck txt=【"+lck1.getTxt()+"】");
return false;
}
logger.info("logger test");
lck.setTxt(txt);
lck.setNam(userName);
lck.setDattim(new Date());
int insert = lckMapper.insert(lck);
if(insert>0)
return true;
return false;
}
@Override
public boolean dbUnlock(Object obj, String userName) {
String modeType=obj.getClass().getSimpleName().toLowerCase();
String inr="";
try {
Object inrObj = MethodUtils.invokeMethod(obj, "getInr",null);
} catch (Exception e) {
e.printStackTrace();
return false;
}
String txt=modeType+inr;
int delete = lckMapper.deleteByPrimaryKey(txt, userName);
if(delete>0)
return true;
return false;
}
@Override
public boolean dbLock(String modeType, String inr,String userName) {
Lck lck=new Lck();
lck.setTxt(modeType+inr);
lck.setNam(userName);
int insert = lckMapper.insert(lck);
if(insert>0)
return true;
return false;
}
@Override
public boolean dbUnlock(String modeType, String inr,String name) {
String txt=modeType+inr;
int delete = lckMapper.deleteByPrimaryKey(txt, name);
if(delete>0)
return true;
return false;
}
}
package com.brilliance.service.impl;
import com.brilliance.entity.Mps;
import com.brilliance.mapper.MpsMapper;
import com.brilliance.service.MpsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@Service
public class MpsServiceServiceImpl implements MpsService {
@Autowired
private MpsMapper mpsMapper;
@Override
public List<Mps> getMpsList(String nxtchncod, String dir, String sta, Date sttdattim,String orderBy) {
return mpsMapper.getMpsList(nxtchncod,dir,sta,sttdattim,orderBy);
}
@Override
public boolean insert(Mps mps) {
int insert = mpsMapper.insert(mps);
if(insert>0)
return true;
else
return false;
}
@Override
public boolean delete(String inr) {
int deleteByPrimaryKey = mpsMapper.deleteByPrimaryKey(inr);
if(deleteByPrimaryKey>0)
return true;
else
return false;
}
@Override
public void test() {
int i = mpsMapper.counterMps(">");
String srcchncod=mpsMapper.getSrcchncod("00000972");
}
}
package com.brilliance.service.impl;
import com.brilliance.entity.Smqlck;
import com.brilliance.mapper.SmqlckMapper;
import com.brilliance.service.SmqlckService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SmqlckServiceImp implements SmqlckService {
@Autowired
private SmqlckMapper smqlckMapper;
@Override
public boolean createLck(Smqlck smqlck) {
System.out.println("it is a test !");
try {
int insert = smqlckMapper.insert(smqlck);
if(insert>0){
return true;
}else{
return false;
}
}catch (Exception e){
e.printStackTrace();;
return false;
}
}
}
......@@ -3,9 +3,9 @@ server:
spring:
datasource:
url: jdbc:oracle:thin:@114.115.138.98:9400:XE
username: test
password: test
url: jdbc:oracle:thin:@192.168.0.110:1524:XE
username: ncb_gj
password: ncb_gj
driver-class-name: oracle.jdbc.driver.OracleDriver
......@@ -7,7 +7,7 @@ logging:
# mybatis配置
mybatis:
mapperLocations: classpath:com.brilliance.mapper/*.xml
mapperLocations: classpath:mapper/*.xml
configuration:
logImpl: org.apache.ibatis.logging.stdout.StdOutImpl
call-setters-on-nulls: true
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.brilliance.mapper.MpeMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Mpe" >
<result column="INR" property="inr" jdbcType="CHAR" />
<result column="CHNCOD" property="chncod" jdbcType="VARCHAR" />
<result column="DATTIM" property="dattim" jdbcType="TIMESTAMP" />
<result column="MPSINR" property="mpsinr" jdbcType="VARCHAR" />
<result column="NXTCHNCOD" property="nxtchncod" jdbcType="VARCHAR" />
<result column="NXTSMHINR" property="nxtsmhinr" jdbcType="VARCHAR" />
<result column="PRVSTA" property="prvsta" jdbcType="CHAR" />
<result column="SMHINR" property="smhinr" jdbcType="VARCHAR" />
<result column="STA" property="sta" jdbcType="CHAR" />
<result column="TXT" property="txt" jdbcType="VARCHAR" />
<result column="RSPSTA" property="rspsta" jdbcType="CHAR" />
<result column="PRVRSPSTA" property="prvrspsta" jdbcType="CHAR" />
<result column="USR" property="usr" jdbcType="VARCHAR" />
<result column="FRMNAM" property="frmnam" jdbcType="VARCHAR" />
<result column="ETYINR" property="etyinr" jdbcType="CHAR" />
<result column="PTYINR" property="ptyinr" jdbcType="CHAR" />
</resultMap>
<insert id="insert" parameterType="com.brilliance.entity.Mpe" >
insert into TEST.MPE (INR, CHNCOD, DATTIM,
MPSINR, NXTCHNCOD, NXTSMHINR,
PRVSTA, SMHINR, STA, TXT,
RSPSTA, PRVRSPSTA, USR, FRMNAM,
ETYINR, PTYINR)
values (#{inr,jdbcType=CHAR}, #{chncod,jdbcType=VARCHAR}, #{dattim,jdbcType=TIMESTAMP},
#{mpsinr,jdbcType=VARCHAR}, #{nxtchncod,jdbcType=VARCHAR}, #{nxtsmhinr,jdbcType=VARCHAR},
#{prvsta,jdbcType=CHAR}, #{smhinr,jdbcType=VARCHAR}, #{sta,jdbcType=CHAR}, #{txt,jdbcType=VARCHAR},
#{rspsta,jdbcType=CHAR}, #{prvrspsta,jdbcType=CHAR}, #{usr,jdbcType=VARCHAR}, #{frmnam,jdbcType=VARCHAR},
#{etyinr,jdbcType=CHAR}, #{ptyinr,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.brilliance.entity.Mpe" >
insert into TEST.MPE
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="inr != null" >
INR,
</if>
<if test="chncod != null" >
CHNCOD,
</if>
<if test="dattim != null" >
DATTIM,
</if>
<if test="mpsinr != null" >
MPSINR,
</if>
<if test="nxtchncod != null" >
NXTCHNCOD,
</if>
<if test="nxtsmhinr != null" >
NXTSMHINR,
</if>
<if test="prvsta != null" >
PRVSTA,
</if>
<if test="smhinr != null" >
SMHINR,
</if>
<if test="sta != null" >
STA,
</if>
<if test="txt != null" >
TXT,
</if>
<if test="rspsta != null" >
RSPSTA,
</if>
<if test="prvrspsta != null" >
PRVRSPSTA,
</if>
<if test="usr != null" >
USR,
</if>
<if test="frmnam != null" >
FRMNAM,
</if>
<if test="etyinr != null" >
ETYINR,
</if>
<if test="ptyinr != null" >
PTYINR,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="inr != null" >
#{inr,jdbcType=CHAR},
</if>
<if test="chncod != null" >
#{chncod,jdbcType=VARCHAR},
</if>
<if test="dattim != null" >
#{dattim,jdbcType=TIMESTAMP},
</if>
<if test="mpsinr != null" >
#{mpsinr,jdbcType=VARCHAR},
</if>
<if test="nxtchncod != null" >
#{nxtchncod,jdbcType=VARCHAR},
</if>
<if test="nxtsmhinr != null" >
#{nxtsmhinr,jdbcType=VARCHAR},
</if>
<if test="prvsta != null" >
#{prvsta,jdbcType=CHAR},
</if>
<if test="smhinr != null" >
#{smhinr,jdbcType=VARCHAR},
</if>
<if test="sta != null" >
#{sta,jdbcType=CHAR},
</if>
<if test="txt != null" >
#{txt,jdbcType=VARCHAR},
</if>
<if test="rspsta != null" >
#{rspsta,jdbcType=CHAR},
</if>
<if test="prvrspsta != null" >
#{prvrspsta,jdbcType=CHAR},
</if>
<if test="usr != null" >
#{usr,jdbcType=VARCHAR},
</if>
<if test="frmnam != null" >
#{frmnam,jdbcType=VARCHAR},
</if>
<if test="etyinr != null" >
#{etyinr,jdbcType=CHAR},
</if>
<if test="ptyinr != null" >
#{ptyinr,jdbcType=CHAR},
</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
jdbc.driverLocation=lib/ojdbc6-11.2.0.3.jar
jdbc.driverClass=oracle.jdbc.driver.OracleDriver
jdbc.connectionURL=jdbc:oracle:thin:@114.115.138.98:9400:XE
jdbc.userId=test
jdbc.password=test
\ No newline at end of file
jdbc.connectionURL=jdbc:oracle:thin:@192.168.0.110:1524:XE
jdbc.userId=ncb_gj
jdbc.password=ncb_gj
\ No newline at end of file
......@@ -51,7 +51,7 @@
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator targetPackage="com.brilliance.mapper" targetProject="src/main/resources">
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
......@@ -60,21 +60,29 @@
<!-- <property name="enableSubPackages" value="true"/>-->
</javaClientGenerator>
<table schema="test" tableName="LCK" domainObjectName="Lck" enableCountByExample="false"
<table schema="ncb_gj" tableName="Clsmsg" domainObjectName="Clsmsg" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<table schema="ncb_gj" tableName="Cnt" domainObjectName="Cnt" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<table schema="ncb_gj" tableName="smh" domainObjectName="Smh" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<table schema="ncb_gj" tableName="SMQINF" domainObjectName="Smqinf" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<!-- <table schema="test" tableName="MPI" domainObjectName="Mpi" enableCountByExample="false"
<table schema="ncb_gj" tableName="SMQLCK" domainObjectName="Smqlck" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>-->
<!--
<table schema="test" tableName="MPS" domainObjectName="Mps" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<table schema="test" tableName="MPE" domainObjectName="Mpe" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>-->
selectByExampleQueryId="false"/>
</context>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.brilliance.mapper.ClsmsgMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Clsmsg" >
<id column="INR" property="inr" jdbcType="CHAR" />
<result column="SRC" property="src" jdbcType="VARCHAR" />
<result column="DES" property="des" jdbcType="VARCHAR" />
<result column="APP" property="app" jdbcType="VARCHAR" />
<result column="MSGNO" property="msgno" jdbcType="VARCHAR" />
<result column="MSGID" property="msgid" jdbcType="VARCHAR" />
<result column="MSGREF" property="msgref" jdbcType="VARCHAR" />
<result column="WORKDATE" property="workdate" jdbcType="VARCHAR" />
<result column="RESERVE" property="reserve" jdbcType="VARCHAR" />
<result column="MSGTYP" property="msgtyp" jdbcType="VARCHAR" />
<result column="GID" property="gid" jdbcType="VARCHAR" />
<result column="SENDID" property="sendid" jdbcType="VARCHAR" />
<result column="RECVID" property="recvid" jdbcType="VARCHAR" />
<result column="SNDDATTIM" property="snddattim" jdbcType="VARCHAR" />
<result column="VESION" property="vesion" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
INR, SRC, DES, APP, MSGNO, MSGID, MSGREF, WORKDATE, RESERVE, MSGTYP, GID, SENDID,
RECVID, SNDDATTIM, VESION
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from NCB_GJ.CLSMSG
where INR = #{inr,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from NCB_GJ.CLSMSG
where INR = #{inr,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.brilliance.entity.Clsmsg" >
insert into NCB_GJ.CLSMSG (INR, SRC, DES, APP,
MSGNO, MSGID, MSGREF,
WORKDATE, RESERVE, MSGTYP,
GID, SENDID, RECVID,
SNDDATTIM, VESION)
values (#{inr,jdbcType=CHAR}, #{src,jdbcType=VARCHAR}, #{des,jdbcType=VARCHAR}, #{app,jdbcType=VARCHAR},
#{msgno,jdbcType=VARCHAR}, #{msgid,jdbcType=VARCHAR}, #{msgref,jdbcType=VARCHAR},
#{workdate,jdbcType=VARCHAR}, #{reserve,jdbcType=VARCHAR}, #{msgtyp,jdbcType=VARCHAR},
#{gid,jdbcType=VARCHAR}, #{sendid,jdbcType=VARCHAR}, #{recvid,jdbcType=VARCHAR},
#{snddattim,jdbcType=VARCHAR}, #{vesion,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.brilliance.entity.Clsmsg" >
insert into NCB_GJ.CLSMSG
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="inr != null" >
INR,
</if>
<if test="src != null" >
SRC,
</if>
<if test="des != null" >
DES,
</if>
<if test="app != null" >
APP,
</if>
<if test="msgno != null" >
MSGNO,
</if>
<if test="msgid != null" >
MSGID,
</if>
<if test="msgref != null" >
MSGREF,
</if>
<if test="workdate != null" >
WORKDATE,
</if>
<if test="reserve != null" >
RESERVE,
</if>
<if test="msgtyp != null" >
MSGTYP,
</if>
<if test="gid != null" >
GID,
</if>
<if test="sendid != null" >
SENDID,
</if>
<if test="recvid != null" >
RECVID,
</if>
<if test="snddattim != null" >
SNDDATTIM,
</if>
<if test="vesion != null" >
VESION,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="inr != null" >
#{inr,jdbcType=CHAR},
</if>
<if test="src != null" >
#{src,jdbcType=VARCHAR},
</if>
<if test="des != null" >
#{des,jdbcType=VARCHAR},
</if>
<if test="app != null" >
#{app,jdbcType=VARCHAR},
</if>
<if test="msgno != null" >
#{msgno,jdbcType=VARCHAR},
</if>
<if test="msgid != null" >
#{msgid,jdbcType=VARCHAR},
</if>
<if test="msgref != null" >
#{msgref,jdbcType=VARCHAR},
</if>
<if test="workdate != null" >
#{workdate,jdbcType=VARCHAR},
</if>
<if test="reserve != null" >
#{reserve,jdbcType=VARCHAR},
</if>
<if test="msgtyp != null" >
#{msgtyp,jdbcType=VARCHAR},
</if>
<if test="gid != null" >
#{gid,jdbcType=VARCHAR},
</if>
<if test="sendid != null" >
#{sendid,jdbcType=VARCHAR},
</if>
<if test="recvid != null" >
#{recvid,jdbcType=VARCHAR},
</if>
<if test="snddattim != null" >
#{snddattim,jdbcType=VARCHAR},
</if>
<if test="vesion != null" >
#{vesion,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.brilliance.entity.Clsmsg" >
update NCB_GJ.CLSMSG
<set >
<if test="src != null" >
SRC = #{src,jdbcType=VARCHAR},
</if>
<if test="des != null" >
DES = #{des,jdbcType=VARCHAR},
</if>
<if test="app != null" >
APP = #{app,jdbcType=VARCHAR},
</if>
<if test="msgno != null" >
MSGNO = #{msgno,jdbcType=VARCHAR},
</if>
<if test="msgid != null" >
MSGID = #{msgid,jdbcType=VARCHAR},
</if>
<if test="msgref != null" >
MSGREF = #{msgref,jdbcType=VARCHAR},
</if>
<if test="workdate != null" >
WORKDATE = #{workdate,jdbcType=VARCHAR},
</if>
<if test="reserve != null" >
RESERVE = #{reserve,jdbcType=VARCHAR},
</if>
<if test="msgtyp != null" >
MSGTYP = #{msgtyp,jdbcType=VARCHAR},
</if>
<if test="gid != null" >
GID = #{gid,jdbcType=VARCHAR},
</if>
<if test="sendid != null" >
SENDID = #{sendid,jdbcType=VARCHAR},
</if>
<if test="recvid != null" >
RECVID = #{recvid,jdbcType=VARCHAR},
</if>
<if test="snddattim != null" >
SNDDATTIM = #{snddattim,jdbcType=VARCHAR},
</if>
<if test="vesion != null" >
VESION = #{vesion,jdbcType=VARCHAR},
</if>
</set>
where INR = #{inr,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.brilliance.entity.Clsmsg" >
update NCB_GJ.CLSMSG
set SRC = #{src,jdbcType=VARCHAR},
DES = #{des,jdbcType=VARCHAR},
APP = #{app,jdbcType=VARCHAR},
MSGNO = #{msgno,jdbcType=VARCHAR},
MSGID = #{msgid,jdbcType=VARCHAR},
MSGREF = #{msgref,jdbcType=VARCHAR},
WORKDATE = #{workdate,jdbcType=VARCHAR},
RESERVE = #{reserve,jdbcType=VARCHAR},
MSGTYP = #{msgtyp,jdbcType=VARCHAR},
GID = #{gid,jdbcType=VARCHAR},
SENDID = #{sendid,jdbcType=VARCHAR},
RECVID = #{recvid,jdbcType=VARCHAR},
SNDDATTIM = #{snddattim,jdbcType=VARCHAR},
VESION = #{vesion,jdbcType=VARCHAR}
where INR = #{inr,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.brilliance.mapper.LckMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Lck" >
<mapper namespace="com.brilliance.mapper.CntMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Cnt" >
<result column="NAM" property="nam" jdbcType="VARCHAR" />
<result column="TXT" property="txt" jdbcType="VARCHAR" />
<result column="DATTIM" property="dattim" jdbcType="TIMESTAMP" />
<result column="VAL" property="val" jdbcType="DECIMAL" />
<result column="STP" property="stp" jdbcType="DECIMAL" />
</resultMap>
<insert id="insert" parameterType="com.brilliance.entity.Lck" >
insert into TEST.LCK (NAM, TXT, DATTIM
<insert id="insert" parameterType="com.brilliance.entity.Cnt" >
insert into NCB_GJ.CNT (NAM, VAL, STP
)
values (#{nam,jdbcType=VARCHAR}, #{txt,jdbcType=VARCHAR}, #{dattim,jdbcType=TIMESTAMP}
values (#{nam,jdbcType=VARCHAR}, #{val,jdbcType=DECIMAL}, #{stp,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" parameterType="com.brilliance.entity.Lck" >
insert into TEST.LCK
<insert id="insertSelective" parameterType="com.brilliance.entity.Cnt" >
insert into NCB_GJ.CNT
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="nam != null" >
NAM,
</if>
<if test="txt != null" >
TXT,
<if test="val != null" >
VAL,
</if>
<if test="dattim != null" >
DATTIM,
<if test="stp != null" >
STP,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="nam != null" >
#{nam,jdbcType=VARCHAR},
</if>
<if test="txt != null" >
#{txt,jdbcType=VARCHAR},
<if test="val != null" >
#{val,jdbcType=DECIMAL},
</if>
<if test="dattim != null" >
#{dattim,jdbcType=TIMESTAMP},
<if test="stp != null" >
#{stp,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from TEST.LCK
where TXT = #{txt,jdbcType=CHAR} and NAM=#{nam}
</delete>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.brilliance.mapper.SmhMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Smh" >
<id column="INR" property="inr" jdbcType="CHAR" />
<result column="CRTFRM" property="crtfrm" jdbcType="VARCHAR" />
<result column="DATTIM" property="dattim" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
INR, CRTFRM, DATTIM
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from NCB_GJ.SMH
where INR = #{inr,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from NCB_GJ.SMH
where INR = #{inr,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.brilliance.entity.Smh" >
insert into NCB_GJ.SMH (INR, CRTFRM, DATTIM
)
values (#{inr,jdbcType=CHAR}, #{crtfrm,jdbcType=VARCHAR}, #{dattim,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.brilliance.entity.Smh" >
insert into NCB_GJ.SMH
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="inr != null" >
INR,
</if>
<if test="crtfrm != null" >
CRTFRM,
</if>
<if test="dattim != null" >
DATTIM,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="inr != null" >
#{inr,jdbcType=CHAR},
</if>
<if test="crtfrm != null" >
#{crtfrm,jdbcType=VARCHAR},
</if>
<if test="dattim != null" >
#{dattim,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.brilliance.entity.Smh" >
update NCB_GJ.SMH
<set >
<if test="crtfrm != null" >
CRTFRM = #{crtfrm,jdbcType=VARCHAR},
</if>
<if test="dattim != null" >
DATTIM = #{dattim,jdbcType=TIMESTAMP},
</if>
</set>
where INR = #{inr,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.brilliance.entity.Smh" >
update NCB_GJ.SMH
set CRTFRM = #{crtfrm,jdbcType=VARCHAR},
DATTIM = #{dattim,jdbcType=TIMESTAMP}
where INR = #{inr,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.brilliance.mapper.SmqinfMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Smqinf" >
<id column="INR" property="inr" jdbcType="CHAR" />
<result column="PTH" property="pth" jdbcType="VARCHAR" />
<result column="CNT" property="cnt" jdbcType="DECIMAL" />
<result column="STA" property="sta" jdbcType="CHAR" />
<result column="CREDAT" property="credat" jdbcType="TIMESTAMP" />
<result column="MESGNO" property="mesgno" jdbcType="VARCHAR" />
<result column="OBJINR" property="objinr" jdbcType="CHAR" />
<result column="OBJTYP" property="objtyp" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
INR, PTH, CNT, STA, CREDAT, MESGNO, OBJINR, OBJTYP
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from NCB_GJ.SMQINF
where INR = #{inr,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from NCB_GJ.SMQINF
where INR = #{inr,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.brilliance.entity.Smqinf" >
insert into NCB_GJ.SMQINF (INR, PTH, CNT, STA,
CREDAT, MESGNO, OBJINR,
OBJTYP)
values (#{inr,jdbcType=CHAR}, #{pth,jdbcType=VARCHAR}, #{cnt,jdbcType=DECIMAL}, #{sta,jdbcType=CHAR},
#{credat,jdbcType=TIMESTAMP}, #{mesgno,jdbcType=VARCHAR}, #{objinr,jdbcType=CHAR},
#{objtyp,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.brilliance.entity.Smqinf" >
insert into NCB_GJ.SMQINF
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="inr != null" >
INR,
</if>
<if test="pth != null" >
PTH,
</if>
<if test="cnt != null" >
CNT,
</if>
<if test="sta != null" >
STA,
</if>
<if test="credat != null" >
CREDAT,
</if>
<if test="mesgno != null" >
MESGNO,
</if>
<if test="objinr != null" >
OBJINR,
</if>
<if test="objtyp != null" >
OBJTYP,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="inr != null" >
#{inr,jdbcType=CHAR},
</if>
<if test="pth != null" >
#{pth,jdbcType=VARCHAR},
</if>
<if test="cnt != null" >
#{cnt,jdbcType=DECIMAL},
</if>
<if test="sta != null" >
#{sta,jdbcType=CHAR},
</if>
<if test="credat != null" >
#{credat,jdbcType=TIMESTAMP},
</if>
<if test="mesgno != null" >
#{mesgno,jdbcType=VARCHAR},
</if>
<if test="objinr != null" >
#{objinr,jdbcType=CHAR},
</if>
<if test="objtyp != null" >
#{objtyp,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.brilliance.entity.Smqinf" >
update NCB_GJ.SMQINF
<set >
<if test="pth != null" >
PTH = #{pth,jdbcType=VARCHAR},
</if>
<if test="cnt != null" >
CNT = #{cnt,jdbcType=DECIMAL},
</if>
<if test="sta != null" >
STA = #{sta,jdbcType=CHAR},
</if>
<if test="credat != null" >
CREDAT = #{credat,jdbcType=TIMESTAMP},
</if>
<if test="mesgno != null" >
MESGNO = #{mesgno,jdbcType=VARCHAR},
</if>
<if test="objinr != null" >
OBJINR = #{objinr,jdbcType=CHAR},
</if>
<if test="objtyp != null" >
OBJTYP = #{objtyp,jdbcType=VARCHAR},
</if>
</set>
where INR = #{inr,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.brilliance.entity.Smqinf" >
update NCB_GJ.SMQINF
set PTH = #{pth,jdbcType=VARCHAR},
CNT = #{cnt,jdbcType=DECIMAL},
STA = #{sta,jdbcType=CHAR},
CREDAT = #{credat,jdbcType=TIMESTAMP},
MESGNO = #{mesgno,jdbcType=VARCHAR},
OBJINR = #{objinr,jdbcType=CHAR},
OBJTYP = #{objtyp,jdbcType=VARCHAR}
where INR = #{inr,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.brilliance.mapper.SmqlckMapper" >
<resultMap id="BaseResultMap" type="com.brilliance.entity.Smqlck" >
<id column="INR" property="inr" jdbcType="CHAR" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from NCB_GJ.SMQLCK
where INR = #{inr,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.brilliance.entity.Smqlck" >
insert into NCB_GJ.SMQLCK (INR)
values (#{inr,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.brilliance.entity.Smqlck" >
insert into NCB_GJ.SMQLCK
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="inr != null" >
INR,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="inr != null" >
#{inr,jdbcType=CHAR},
</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
......@@ -18,7 +18,9 @@
</environments>
<mappers>
<package name="com/brilliance/mapper"/>
<mapper resource="mapper/SmqinfMapper.xml"/>
<package name="com/brilliance/mapper"/>
<!--<mapper resource="com/brilliance/mapper/MpsMapper.xml"/>
<mapper resource="com/brilliance/mapper/MpiMapper.xml"/>
<mapper resource="com/brilliance/mapper/MpeMapper.xml"/>
......
......@@ -19,9 +19,10 @@
<mappers>
<!-- <package name="mappers"/>-->
<mapper resource="com/brilliance/mapper/MpsMapper.xml"/>
<mapper resource="com/brilliance/mapper/MpiMapper.xml"/>
<mapper resource="com/brilliance/mapper/MpeMapper.xml"/>
<mapper resource="com/brilliance/mapper/LckMapper.xml"/>
<mapper resource="mapper/ClsmsgMapper.xml"/>
<mapper resource="mapper/CntMapper.xml"/>
<mapper resource="mapper/SmhMapper.xml"/>
<mapper resource="mapper/SmqinfMapper.xml"/>
<mapper resource="mapper/SmqlckMapper.xml"/>
</mappers>
</configuration>
package com.brilliance.test;
import com.brilliance.entity.Lck;
import com.brilliance.entity.Mpi;
import com.brilliance.entity.Mps;
import com.brilliance.entity.Smh;
import com.brilliance.mapper.LckMapper;
import com.brilliance.mapper.MpiMapper;
import com.brilliance.mapper.MpsMapper;
import com.alibaba.druid.pool.DruidDataSource;
import com.brilliance.entity.*;
import com.brilliance.mapper.SmhMapper;
import com.brilliance.util.DbCommonUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.sql.SQLException;
import java.util.List;
public class MybatisTest {
@Test
public void test_dbUtil() throws SQLException {
//1、创建数据源(数据库连接池)对象
DruidDataSource ds =new DruidDataSource();
//2、设置参数
//(1)设置基本参数
ds.setDriverClassName("oracle.jdbc.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@192.168.0.110:1524:XE");
ds.setUsername("ncb_gj");
ds.setPassword("ncb_gj");
ds.setInitialSize(5);//一开始提前申请好5个连接,不够了,重写申请
ds.setMaxActive(10);//最多不超过10个,如果10都用完了,还没还回来,就会出现等待
ds.setMaxWait(1000);//用户最多等1000毫秒,如果1000毫秒还没有人还回来,就异常了
QueryRunner queryRunner=new QueryRunner(ds);
String sql = "SELECT * FROM clsmsg";
List<Clsmsg> clsMsgList = queryRunner.query(sql, new BeanListHandler<>(Clsmsg.class));
System.out.println("clsMsgList==="+clsMsgList);
sql="select * from clsmsg where inr='00000007'";
Clsmsg clsmsg = queryRunner.query(sql, new BeanHandler<>(Clsmsg.class));
System.out.println(clsmsg.getSrc());
}
@Test
public void test_annotation() throws Exception {
String resource = "mybatis-config-annotation.xml";
/*String resource = "mybatis-config-annotation.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
// sqlSessionFactory.getConfiguration().addMapper(MpsMapper.class);
......@@ -37,16 +63,16 @@ public class MybatisTest {
Smh smh1=new Smh();
smh1.setInr("TESTINR1");
smh1.setCrtfrm("TTT");
smh1.setDattim(new Date());
//smh1.setDattim(new Date());
int insert = smhMapper.insert(smh1);
System.out.println("insert==="+insert);
openSession.commit();
openSession.close();
openSession.close();*/
}
@Test
public void test() throws Exception {
String resource = "mybatis-config.xml";
/* String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
// sqlSessionFactory.getConfiguration().addMapper(MpsMapper.class);
......@@ -55,13 +81,13 @@ public class MybatisTest {
MpsMapper mpsMapper = openSession.getMapper(MpsMapper.class);
int cnt = mpsMapper.counterMps(">");
System.out.println("cnt="+cnt);
openSession.close();
openSession.close();*/
}
@Test
public void test2() throws Exception {
SqlSession openSession = DbCommonUtil.getSqlSession();
/* SqlSession openSession = DbCommonUtil.getSqlSession();
MpsMapper mpsMapper = openSession.getMapper(MpsMapper.class);
int cnt = mpsMapper.counterMps(">");
Mps mps = mpsMapper.selectByPrimaryKey("00000972");
......@@ -78,6 +104,6 @@ public class MybatisTest {
System.out.println(lck.getDattim());
}
DbCommonUtil.close(openSession);
DbCommonUtil.close(openSession);*/
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment