jeecg 增删改查 后台代码

本文介绍了一个接口管理系统的实现,包括接口的增删改查等基本操作。通过Java代码展示了如何使用Hibernate进行数据库交互,并实现了接口信息的展示、添加、更新及删除等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

package com.ps.application.controller;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.system.pojo.base.TSAttachment;
import org.jeecgframework.web.system.pojo.base.TSUser;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import com.lims.system.entity.CcLaboratoryEntity;
import com.lims.system.entity.CcLaboratoryProjectEntity;
import com.ps.application.entity.CcDockingEntity;
import com.ps.application.entity.CcTemplateEntity;
import com.ps.statistics.entity.CcQueInResultEntity;
import com.ps.util.QueInResultUtil;


/**
 * 
 * 功能介绍:接口管理
 * 
 * @author songzhiyong
 * 
 */
@Scope("prototype")
@Controller
@RequestMapping("/ccDockingController")
public class CcDockingController extends BaseController{
@Autowired
private SystemService systemService;

private String message;
/**
* 接口管理信息列表 页面跳转

* @return
*/
@RequestMapping(params = "dockingList")
public ModelAndView ccDockingList(HttpServletRequest request) {
return new ModelAndView("ps/application/ccDockingList");
}

/**
* 功能介绍:获取接口管理列表信息

* @author songzhiyong
*/
@RequestMapping(params = "doDockingList")
public void getdockingList(CcDockingEntity entity,CcQueInResultEntity ccQueInResultEntity, 
            int page, int rows, HttpServletRequest request, 
            HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(CcDockingEntity.class, dataGrid);
if(StringUtil.isNotEmpty(entity.getChineseName())){
cq.add(Restrictions.ilike("chineseName", entity.getChineseName(),MatchMode.ANYWHERE));
}
if(StringUtil.isNotEmpty(entity.getEnglishName())){
cq.add(Restrictions.ilike("englishName", entity.getEnglishName(),MatchMode.ANYWHERE));
}
if(StringUtil.isNotEmpty(entity.getUrl())){
cq.add(Restrictions.ilike("url", entity.getUrl(),MatchMode.ANYWHERE));
}
if(StringUtil.isNotEmpty(entity.getAppKey())){
cq.add(Restrictions.ilike("appKey", entity.getAppKey(),MatchMode.ANYWHERE));
}
cq.add(Restrictions.eq("del",1));
QueInResultUtil.queInResult(cq, ccQueInResultEntity);
this.systemService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}


/**
* 接口管理信息列表 页面跳转

* @return
*/
@RequestMapping(params = "goAddDocking")
public ModelAndView goAddDocking(HttpServletRequest request) {
return new ModelAndView("ps/application/docking-add");
}

/**
* 导入
* @param proid
* @param request
* @return
*/
@ResponseBody
@RequestMapping(params = "doAddDocking")
public AjaxJson importReportFile(HttpServletRequest request,String chineseName,String englishName,String url) {
AjaxJson j = new AjaxJson();
message = "项目新增成功";
String appKey=UUID.randomUUID().toString().replace("-","");
try {
CcDockingEntity entity=new CcDockingEntity();
entity.setChineseName(chineseName);
entity.setEnglishName(englishName);
entity.setUrl(url);
entity.setAppKey(appKey);
entity.setDel(1);
systemService.save(entity);

} catch (Exception e) {
message = "项目新增失败";
throw new BusinessException(e.getMessage());

j.setMsg(message);
return j;
}


@RequestMapping(params = "goUpdate")
public ModelAndView goUpdate(CcDockingEntity entity,HttpServletRequest req) {
if (StringUtil.isNotEmpty(entity.getId())) {
entity = systemService.getEntity(CcDockingEntity.class,entity.getId());
req.setAttribute("entity",entity);
}
ModelAndView modelAndView = new ModelAndView("ps/application/docking-update");

return modelAndView;
}

/**
* 更新
* @param proid
* @param request
* @return
*/
@ResponseBody
@RequestMapping(params = "doUpdate")
public AjaxJson doUpdate(HttpServletRequest request,CcDockingEntity ccDockingEntity) {
AjaxJson j = new AjaxJson();
message = "项目更新成功";
try {
CcDockingEntity entity=systemService.getEntity(CcDockingEntity.class,ccDockingEntity.getId());
entity.setChineseName(ccDockingEntity.getChineseName());
entity.setEnglishName(ccDockingEntity.getEnglishName());
entity.setUrl(ccDockingEntity.getUrl());
entity.setDel(1);
systemService.saveOrUpdate(entity);
} catch (Exception e) {
message = "项目更新失败";
throw new BusinessException(e.getMessage());

j.setMsg(message);
return j;
}

/**
* 查看
* @param entity
* @param req
* @return
*/
@RequestMapping(params = "goView")
public ModelAndView goView(CcDockingEntity entity,HttpServletRequest req) {
if (StringUtil.isNotEmpty(entity.getId())) {
entity = systemService.getEntity(CcDockingEntity.class,entity.getId());
req.setAttribute("entity",entity);
}
ModelAndView modelAndView = new ModelAndView("ps/application/docking-view");

return modelAndView;
}

@ResponseBody
@RequestMapping(params = "doDel")
public AjaxJson delDocument(String id, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
String message = "";
try {
message="信息删除成功!";
message = systemService.delById("cc_docking", "id", id) ? "信息删除成功!" : "信息删除失败!";
} catch (Exception e) {
e.printStackTrace();
message = "信息删除失败!";
}
j.setMsg(message);
return j;
}

}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值