基于javaweb+mysql的springboot农业物资管理系统(java+springboot+easyui+html+maven+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot农业物资管理系统(java+springboot+easyui+html+maven+mysql)
项目介绍
农业物资管理系统,管理员可以对角色进行配置,分配用户角色; 主要功能包含:登录、注册、修改密码、零售出库、零售退货、采购订单管理、采购入库管理、采购退货管理、销售管理、财务管理、报表管理、物资管理、基本资料管理。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;
技术栈
-
后端:springboot MyBatis
-
前端:HTML+css+javascript+jQuery+easyui
使用说明
运行成功后,访问http://localhost:8080/ 到登录页面
管理员用户名:admin 密码:123456
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BaseResponseInfo importExcel(List<Supplier> mList) throws Exception {
logService.insertLog("商家",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
BaseResponseInfo info = new BaseResponseInfo();
Map<String, Object> data = new HashMap<String, Object>();
try {
for(Supplier s: mList) {
supplierMapper.insertSelective(s);
}
info.code = 200;
data.put("message", "成功");
} catch (Exception e) {
e.printStackTrace();
info.code = 500;
data.put("message", e.getMessage());
}
info.data = data;
return info;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplierByIds(String ids)throws Exception {
logService.insertLog("商家",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = supplierMapperEx.batchDeleteSupplierByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
*正常删除,要考虑数据完整性,进行完整性校验
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplierByIdsNormal(String ids) throws Exception {
/**
* 校验
* 1、财务主表 jsh_accounthead
* 2、单据主表 jsh_depothead
res.code = 200;
res.data = data;
logger.info("===============用户登录 login 方法调用结束===============");
} catch(Exception e){
e.printStackTrace();
logger.error(e.getMessage());
res.code = 500;
res.data = "用户登录失败";
}
return res;
}
@GetMapping(value = "/getUserSession")
public BaseResponseInfo getSessionUser(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> data = new HashMap<String, Object>();
Object userInfo = request.getSession().getAttribute("user");
if(userInfo!=null) {
User user = (User) userInfo;
user.setPassword(null);
data.put("user", user);
}
res.code = 200;
res.data = data;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取session失败";
}
return res;
}
@GetMapping(value = "/logout")
public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse response)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
request.getSession().removeAttribute("user");
request.getSession().removeAttribute("tenantId");
request.getSession().removeAttribute("userNumLimit");
request.getSession().removeAttribute("billsNumLimit");
response.sendRedirect("/login.html");
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "退出失败";
}
return res;
}
@PostMapping(value = "/resetPwd")
public String resetPwd(@RequestParam("id") Long id,
HttpServletRequest request) throws Exception {
} else {
if (realIp.equals(forwarded)) {
ip = realIp;
} else {
if (forwarded != null) {
forwarded = forwarded.split(",")[0];
}
ip = realIp + "/" + forwarded;
}
}
return ip;
}
/**
* 获取访问者IP
*
* 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。
*
* 本方法先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割),
* 如果还不存在则调用Request .getRemoteAddr()。
*
* @param request
* @return
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Real-IP");
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
return ip;
}
ip = request.getHeader("X-Forwarded-For");
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个IP值,第一个为真实IP。
int index = ip.indexOf(',');
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
} else {
return request.getRemoteAddr();
}
}
/**
* 转化前台批量传入的ID值
*
* @param data
* @return 转化后的ID值数组
*/
public static int[] changeDataForm(String data) {
String[] dataStr = data.split(",");
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountByIds(String ids) throws Exception{
logService.insertLog("账户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountByIdsNormal(String ids) throws Exception{
/**
* 校验:
* 1、财务主表 jsh_accounthead
* 2、财务子表 jsh_accountitem
* 3、单据主表 jsh_depothead
* 是否有相关数据
* */
int deleteTotal=0;
if(StringUtils.isEmpty(ids)){
return deleteTotal;
}
String [] idArray=ids.split(",");
/**
* 校验财务主表 jsh_accounthead
* */
List<AccountHead> accountHeadList=null;
try{
accountHeadList = accountHeadMapperEx.getAccountHeadListByAccountIds(idArray);
public void checkIsExist(Long id, String materialName, String serialNumber) throws Exception{
/**
* 商品名称不为空时,检查商品名称是否存在
* */
if(StringUtil.isNotEmpty(materialName)){
List<Material> mlist=null;
try{
mlist = materialMapperEx.findByMaterialName(materialName);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(mlist==null||mlist.size()<1){
//商品名称不存在
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
ExceptionConstants.MATERIAL_NOT_EXISTS_MSG);
}else if(mlist.size()>1){
//商品信息不唯一
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ONLY_CODE,
ExceptionConstants.MATERIAL_NOT_ONLY_MSG);
}
}
/***
* 判断序列号是否已存在
* */
List <SerialNumberEx> list=null;
try{
list = serialNumberMapperEx.findBySerialNumber(serialNumber);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(list!=null&&list.size()>0){
if(list.size()>1){
//存在多个同名序列号
throw new BusinessRunTimeException(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_CODE,
ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_MSG);
}else{
//存在一个序列号
if(id==null){
//新增,存在要添加的序列号
if(!("系统管理").equals(fun.getName())) {
dataList.add(fun);
}
}
}
//筛选功能列表
for (Functions functions : dataList) {
JSONObject item = new JSONObject();
item.put("id", functions.getId());
item.put("text", functions.getName());
//勾选判断1
Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (flag == true) {
item.put("checked", true);
}
//结束
List<Functions> dataList1 = functionsService.findRoleFunctions(functions.getNumber());
JSONArray dataArray1 = new JSONArray();
if (null != dataList1) {
for (Functions functions1 : dataList1) {
item.put("state", "open"); //如果不为空,节点不展开
JSONObject item1 = new JSONObject();
item1.put("id", functions1.getId());
item1.put("text", functions1.getName());
//勾选判断2
//Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions1.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (flag == true) {
item1.put("checked", true);
}
//结束
List<Functions> dataList2 = functionsService.findRoleFunctions(functions1.getNumber());
JSONArray dataArray2 = new JSONArray();
if (null != dataList2) {
for (Functions functions2 : dataList2) {
item1.put("state", "closed"); //如果不为空,节点不展开
JSONObject item2 = new JSONObject();
item2.put("id", functions2.getId());
/**
* 根据id查找信息
* @param supplierId
* @param request
* @return
*/
@GetMapping(value = "/findById")
public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
JSONArray dataArray = new JSONArray();
List<Supplier> dataList = supplierService.findById(supplierId);
if (null != dataList) {
for (Supplier supplier : dataList) {
JSONObject item = new JSONObject();
item.put("id", supplier.getId());
//名称
item.put("supplier", supplier.getSupplier());
item.put("type", supplier.getType());
item.put("contacts", supplier.getContacts());
item.put("phonenum", supplier.getPhonenum());
item.put("email", supplier.getEmail());
item.put("AdvanceIn", supplier.getAdvancein());
item.put("BeginNeedGet", supplier.getBeginneedget());
item.put("BeginNeedPay", supplier.getBeginneedpay());
/**
* */
if(supplier.getIsystem()!=null){
item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
}
item.put("description", supplier.getDescription());
item.put("fax", supplier.getFax());
item.put("telephone", supplier.getTelephone());
item.put("address", supplier.getAddress());
item.put("taxNum", supplier.getTaxnum());
item.put("bankName", supplier.getBankname());
item.put("accountNumber", supplier.getAccountnumber());
item.put("taxRate", supplier.getTaxrate());
item.put("enabled", supplier.getEnabled());
dataArray.add(item);
}
res.code = 200;
res.data = dataArray;
}
} catch (Exception e) {
String remoteAddr = getIpAddr(request);
String forwarded = request.getHeader("X-Forwarded-For");
String realIp = request.getHeader("X-Real-IP");
String ip = null;
if (realIp == null) {
if (forwarded == null) {
ip = remoteAddr;
} else {
ip = remoteAddr + "/" + forwarded.split(",")[0];
}
} else {
if (realIp.equals(forwarded)) {
ip = realIp;
} else {
if (forwarded != null) {
forwarded = forwarded.split(",")[0];
}
ip = realIp + "/" + forwarded;
}
}
return ip;
}
/**
* 获取访问者IP
*
* 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。
*
* 本方法先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割),
* 如果还不存在则调用Request .getRemoteAddr()。
*
* @param request
* @return
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("X-Real-IP");
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
return ip;
}
ip = request.getHeader("X-Forwarded-For");
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个IP值,第一个为真实IP。
int index = ip.indexOf(',');
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
} else {
return request.getRemoteAddr();
}
}
List<DepotHead> list = null;
try{
list = depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<DepotHead> getDepotHeadGiftOut(String projectId)throws Exception {
DepotHeadExample example = new DepotHeadExample();
if (projectId != null) {
example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId));
}
List<DepotHead> list = null;
try{
list =depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows)throws Exception {
List<DepotHeadVo4InOutMCount> list = null;
try{
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId)throws Exception {
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}
@Service
public class AccountHeadService {
private Logger logger = LoggerFactory.getLogger(AccountHeadService.class);
@Resource
private AccountHeadMapper accountHeadMapper;
}
return list;
}
/**
* 批量删除用户
* */
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void batDeleteUser(String ids) throws Exception{
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
String idsArray[]=ids.split(",");
int result =0;
try{
result=userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE);
}catch(Exception e){
JshException.writeFail(logger, e);
}
if(result<1){
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE,
ExceptionConstants.USER_DELETE_FAILED_MSG);
}
}
public List<TreeNodeEx> getOrganizationUserTree()throws Exception {
List<TreeNodeEx> list =null;
try{
list=userMapperEx.getNodeTree();
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
}
* @param type
* @param request
* @return
*/
@GetMapping(value = "/findInDetail")
public BaseResponseInfo findInDetail(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("organId") Integer oId,
@RequestParam("projectId") Integer pid,
@RequestParam("depotIds") String dids,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<DepotHeadVo4InDetail> resList = new ArrayList<DepotHeadVo4InDetail>();
List<DepotHeadVo4InDetail> list = depotHeadService.findByAll(beginTime, endTime, type, pid, dids, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findByAllCount(beginTime, endTime, type, pid, dids, oId);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4InDetail dhd : list) {
resList.add(dhd);
}
}
map.put("rows", resList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 入库出库统计接口
* @param currentPage
* @param pageSize
* @param oId
* @param pid
* @param dids
* @param beginTime
* @param endTime
* @param type
* @param request
* @return
*/
for (int i = 0; i < deletedJson.size(); i++) {
//首先回收序列号,如果是调拨,不用处理序列号
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())){
DepotItem depotItem = getDepotItem(tempDeletedJson.getLong("Id"));
if(depotItem==null){
continue;
}
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
Material material= materialService.getMaterial(depotItem.getMaterialid());
if(material==null){
continue;
}
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())){
serialNumberService.cancelSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
userInfo);
}
}
this.deleteDepotItem(tempDeletedJson.getLong("Id"), request);
bf.append(tempDeletedJson.getLong("Id"));
if(i<(deletedJson.size()-1)){
bf.append(",");
}
}
this.batchDeleteDepotItemByIds(bf.toString());
}
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
DepotItem depotItem = new DepotItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
depotItem.setHeaderid(headerId);
depotItem.setMaterialid(tempInsertedJson.getLong("MaterialId"));
depotItem.setMunit(tempInsertedJson.getString("Unit"));
if (!StringUtil.isEmpty(tempInsertedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempInsertedJson.getBigDecimal("OperNumber"));
try {
String Unit = tempInsertedJson.get("Unit").toString();
BigDecimal oNumber = tempInsertedJson.getBigDecimal("OperNumber");
Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString());
/***
* 为什么调用的方法要先把基础单位去掉,去掉之后后续还能获取到?
* */
//以下进行单位换算
// String UnitName = findUnitName(mId); //查询计量单位名称
String unitName = materialService.findUnitName(mId);
/**
* 过滤html文件中的文本
*
* @param content
* @return过滤后的文本
*/
public static String filterText(String content) {
return content.replace("/<(?:.|\\s)*?>/g", "");
}
/**
* 去掉字符串中所有符号,不论是全角,还是半角的,或是货币符号或者空格等
*
* @param s
* @return
*/
public static String removeSymbolForString(String s) {
StringBuffer buffer = new StringBuffer();
char[] chars = s.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ((chars[i] >= 19968 && chars[i] <= 40869) || (chars[i] >= 97 && chars[i] <= 122) || (chars[i] >= 65 && chars[i] <= 90)) {
buffer.append(chars[i]);
}
}
return buffer.toString();
}
/**
* 获取一个字符串的MD5
*
* @param msg
* @return 加密后的MD5字符串
* @throws NoSuchAlgorithmException
*/
public static String md5Encryp(String msg) throws NoSuchAlgorithmException {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(msg.getBytes());
return new BigInteger(1, md.digest()).toString(16);
}
}
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItemByIds(String ids) throws Exception{
logService.insertLog("财务明细",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}
}
break;
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("msgTip", msgTip);
/**
* 在IE模式下,无法获取到user数据,
* 在此处明确添加上user信息
* */
if(user!=null){
data.put("user",user);
}
res.code = 200;
res.data = data;
logger.info("===============用户登录 login 方法调用结束===============");
} catch(Exception e){
e.printStackTrace();
logger.error(e.getMessage());
res.code = 500;
res.data = "用户登录失败";
}
return res;
}
@GetMapping(value = "/getUserSession")
public BaseResponseInfo getSessionUser(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> data = new HashMap<String, Object>();
Object userInfo = request.getSession().getAttribute("user");
if(userInfo!=null) {
User user = (User) userInfo;
user.setPassword(null);
data.put("user", user);
}
res.code = 200;
res.data = data;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取session失败";
}
return res;
}
@GetMapping(value = "/logout")
public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse response)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
request.getSession().removeAttribute("user");
request.getSession().removeAttribute("tenantId");
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserByObj(User user) throws Exception{
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
/**
* create by: cjl
* description:
* 添加事务控制
* @Param: md5Pwd
* @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) throws Exception{
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User user = new User();
user.setId(id);
user.setPassword(md5Pwd);
int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUser(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result= userMapper.deleteByPrimaryKey(id);
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}