Commit fb073d85 by gechengyang

提交模板化代码

parent 12ade8bd
...@@ -20,8 +20,9 @@ import com.brilliance.remit.service.CpdService; ...@@ -20,8 +20,9 @@ import com.brilliance.remit.service.CpdService;
/** /**
This java was generated by Auto Generator. This java was generated by Auto Generator.
created at time 2018-12-17 17:14:05 created at time 2018-12-17 17:38:42
**/ **/
@RequestMapping("cpd")
@Controller @Controller
public class CpdController { public class CpdController {
@Autowired @Autowired
...@@ -30,8 +31,8 @@ public class CpdController { ...@@ -30,8 +31,8 @@ public class CpdController {
private static final Log log = LogFactory.getLog(CpdController.class); private static final Log log = LogFactory.getLog(CpdController.class);
@ResponseBody @ResponseBody
@RequestMapping(value = "/cpd", method = RequestMethod.POST) @RequestMapping(value = "/test", method = RequestMethod.POST)
public Object login(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) { public Object test(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) {
/** /**
you can do business hanle here. you can do business hanle here.
**/ **/
......
package com.brilliance.remit.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.brilliance.remit.common.response.ErrorCodes;
import com.brilliance.remit.common.response.ResultUtil;
import com.brilliance.remit.service.RemitService;
@Controller
public class RemitController {
@Autowired
private RemitService remitService;
private static final Log log = LogFactory.getLog(RemitController.class);
@ResponseBody
@RequestMapping(value = "/test", method = RequestMethod.GET)
public Object login(HttpServletRequest request, HttpSession session) {
remitService.save();
return ResultUtil.result(ErrorCodes.SUCCESS, "ok", null);
}
@ResponseBody
@RequestMapping(value = "/tet1", method = RequestMethod.GET)
public Object login(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) {
System.out.println(dataMap);
remitService.save();
return ResultUtil.result(ErrorCodes.SUCCESS, "ok", null);
}
}
package com.brilliance.remit.service; package com.brilliance.remit.service;
public interface CntService { public interface CntService {
int getCntInr(String nam); int counter(String nam);
} }
...@@ -2,7 +2,7 @@ package com.brilliance.remit.service; ...@@ -2,7 +2,7 @@ package com.brilliance.remit.service;
/** /**
This java was generated by Auto Generator. This java was generated by Auto Generator.
created at time 2018-12-17 17:14:05 created at time 2018-12-17 17:38:41
**/ **/
public interface CpdService { public interface CpdService {
......
package com.brilliance.remit.service;
public interface RemitService {
public boolean save();
}
...@@ -16,7 +16,7 @@ public class CntServiceImpl implements CntService { ...@@ -16,7 +16,7 @@ public class CntServiceImpl implements CntService {
private CouMapper couMapper; private CouMapper couMapper;
@Override @Override
public synchronized int getCntInr(String nam) { public synchronized int counter(String nam) {
Cou cnt = couMapper.selectByPrimaryKey(nam); Cou cnt = couMapper.selectByPrimaryKey(nam);
if (cnt == null) { if (cnt == null) {
cnt = new Cou(); cnt = new Cou();
......
...@@ -14,9 +14,10 @@ import org.apache.commons.logging.Log; ...@@ -14,9 +14,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.brilliance.remit.service.CpdService; import com.brilliance.remit.service.CpdService;
import com.brilliance.remit.db.dao.CpdMapper; import com.brilliance.remit.db.dao.CpdMapper;
import com.brilliance.remit.service.CntService;
/** /**
This java was generated by Auto Generator. This java was generated by Auto Generator.
created at time 2018-12-17 17:14:05 created at time 2018-12-17 17:38:41
**/ **/
@Service("cpdService") @Service("cpdService")
...@@ -26,25 +27,22 @@ public class CpdServiceImp implements CpdService { ...@@ -26,25 +27,22 @@ public class CpdServiceImp implements CpdService {
@Resource(name = "txManager") @Resource(name = "txManager")
private DataSourceTransactionManager transactionManager; private DataSourceTransactionManager transactionManager;
private CntService cntService = (CntService) SpringContextUtil.getApplicationContext().getBean(CntService.class);
private static Log log = LogFactory.getLog(CpdServiceImp.class); private static Log log = LogFactory.getLog(CpdServiceImp.class);
@Override @Override
public void sample() { public void sample() {
CntService cntService = (CntService) SpringContextUtil.getApplicationContext().getBean(CntService.class);
// 事务操作 // 事务操作
TransactionStatus status = transactionManager.getTransaction(DbUtil.getDbDefinition()); TransactionStatus status = transactionManager.getTransaction(DbUtil.getDbDefinition());
try { try {
//you can do business hanle herer // you can do business hanle herer
transactionManager.commit(status); transactionManager.commit(status);
// get inr method // get inr method
cntService.getCntInr("XXX"); cntService.counter("XXX");
} catch (Exception e) { } catch (Exception e) {
log.error("error", e); log.error("error", e);
transactionManager.rollback(status); transactionManager.rollback(status);
} }
} }
} }
package com.brilliance.remit.service.imp;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import com.brilliance.remit.common.util.DbUtil;
import com.brilliance.remit.common.util.SpringContextUtil;
import com.brilliance.remit.db.dao.CpdMapper;
import com.brilliance.remit.db.dao.TrnMapper;
import com.brilliance.remit.db.model.Cpd;
import com.brilliance.remit.service.CntService;
import com.brilliance.remit.service.RemitService;
@Service("remitService")
public class RemitServiceImp implements RemitService {
@Autowired
private CpdMapper cpdMapper;
@Autowired
private TrnMapper trnMapper;
private static int i = 10;
@Resource(name = "txManager")
private DataSourceTransactionManager transactionManager;
private CntService cntService = (CntService) SpringContextUtil.getApplicationContext().getBean(CntService.class);
private static Log log = LogFactory.getLog(RemitServiceImp.class);
@Override
public boolean save() {
// 事务操作
TransactionStatus status = transactionManager.getTransaction(DbUtil.getDbDefinition());
try {
Cpd cpd = new Cpd();
cpd.setINR(String.valueOf(i));
i++;
cpdMapper.insert(cpd);
cntService.getCntInr("AAA");
transactionManager.commit(status);
} catch (Exception e) {
log.error("error", e);
transactionManager.rollback(status);
return false;
}
return true;
}
}
...@@ -22,6 +22,7 @@ import com.brilliance.remit.service.${entity.name}Service; ...@@ -22,6 +22,7 @@ import com.brilliance.remit.service.${entity.name}Service;
This java was generated by Auto Generator. This java was generated by Auto Generator.
created at time ${entity.date} created at time ${entity.date}
**/ **/
@RequestMapping("${entity.lowerName}")
@Controller @Controller
public class ${entity.name}Controller { public class ${entity.name}Controller {
@Autowired @Autowired
...@@ -30,8 +31,8 @@ public class ${entity.name}Controller { ...@@ -30,8 +31,8 @@ public class ${entity.name}Controller {
private static final Log log = LogFactory.getLog(${entity.name}Controller.class); private static final Log log = LogFactory.getLog(${entity.name}Controller.class);
@ResponseBody @ResponseBody
@RequestMapping(value = "/${entity.lowerName}", method = RequestMethod.POST) @RequestMapping(value = "/test", method = RequestMethod.POST)
public Object login(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) { public Object test(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) {
/** /**
you can do business hanle here. you can do business hanle here.
**/ **/
......
...@@ -14,6 +14,7 @@ import org.apache.commons.logging.Log; ...@@ -14,6 +14,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.brilliance.remit.service.${entity.name}Service; import com.brilliance.remit.service.${entity.name}Service;
import com.brilliance.remit.db.dao.${entity.name}Mapper; import com.brilliance.remit.db.dao.${entity.name}Mapper;
import com.brilliance.remit.service.CntService;
/** /**
This java was generated by Auto Generator. This java was generated by Auto Generator.
created at time ${entity.date} created at time ${entity.date}
...@@ -26,25 +27,22 @@ public class ${entity.name}ServiceImp implements ${entity.name}Service { ...@@ -26,25 +27,22 @@ public class ${entity.name}ServiceImp implements ${entity.name}Service {
@Resource(name = "txManager") @Resource(name = "txManager")
private DataSourceTransactionManager transactionManager; private DataSourceTransactionManager transactionManager;
private CntService cntService = (CntService) SpringContextUtil.getApplicationContext().getBean(CntService.class);
private static Log log = LogFactory.getLog(${entity.name}ServiceImp.class); private static Log log = LogFactory.getLog(${entity.name}ServiceImp.class);
@Override @Override
public void sample() { public void sample() {
CntService cntService = (CntService) SpringContextUtil.getApplicationContext().getBean(CntService.class);
// 事务操作 // 事务操作
TransactionStatus status = transactionManager.getTransaction(DbUtil.getDbDefinition()); TransactionStatus status = transactionManager.getTransaction(DbUtil.getDbDefinition());
try { try {
//you can do business hanle herer // you can do business hanle herer
transactionManager.commit(status); transactionManager.commit(status);
// get inr method // get inr method
cntService.getCntInr("XXX"); cntService.counter("XXX");
} catch (Exception e) { } catch (Exception e) {
log.error("error", e); log.error("error", e);
transactionManager.rollback(status); transactionManager.rollback(status);
} }
} }
} }
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