Browse Source

完成upms系统操作

shuzheng 9 years ago
parent
commit
6361a1f746

+ 68 - 9
zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/admin/controller/manage/SystemController.java

@@ -1,6 +1,7 @@
 package com.zheng.upms.admin.controller.manage;
 
 import com.zheng.common.base.BaseController;
+import com.zheng.upms.dao.model.UpmsSystem;
 import com.zheng.upms.dao.model.UpmsSystemExample;
 import com.zheng.upms.rpc.api.UpmsSystemService;
 import io.swagger.annotations.Api;
@@ -10,9 +11,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * 系统controller
@@ -30,7 +33,6 @@ public class SystemController extends BaseController {
 
 	@ApiOperation(value = "系统首页")
 	@RequiresPermissions("upms:system:read")
-    //@RequiresUser
 	@RequestMapping(value = "/index", method = RequestMethod.GET)
 	public String index() {
 		return "/manage/system/index";
@@ -38,14 +40,71 @@ public class SystemController extends BaseController {
 
 	@ApiOperation(value = "系统列表")
 	@RequiresPermissions("upms:system:read")
-    //@RequiresUser
 	@RequestMapping("/list")
 	@ResponseBody
-	public Object list() {
+	public Object list(
+			@RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
+			@RequestParam(required = false, defaultValue = "10", value = "limit") int limit,
+			@RequestParam(required = false, value = "sort") String sort,
+			@RequestParam(required = false, value = "order") String order) {
+		// 数据列表
 		UpmsSystemExample upmsSystemExample = new UpmsSystemExample();
-		upmsSystemExample.createCriteria()
-				.andSystemIdGreaterThan(0);
-		return upmsSystemService.selectByExample(upmsSystemExample);
+		upmsSystemExample.setOffset(offset);
+		upmsSystemExample.setLimit(limit);
+		if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
+			upmsSystemExample.setOrderByClause(sort + " " + order);
+		}
+		List<UpmsSystem> systems = upmsSystemService.selectByExample(upmsSystemExample);
+//		long total = upmsSystemService.countByExample(upmsSystemExample);
+		return systems;
+	}
+
+	@ApiOperation(value = "新增系统")
+	@RequiresPermissions("upms:system:create")
+	@RequestMapping(value = "/add", method = RequestMethod.GET)
+	public String add() {
+		return "/manage/system/add";
+	}
+
+	@ApiOperation(value = "新增系统")
+	@RequiresPermissions("cms:system:create")
+	@RequestMapping(value = "/add", method = RequestMethod.POST)
+	public String add(UpmsSystem upmsSystem, ModelMap modelMap) {
+		long time = System.currentTimeMillis();
+		upmsSystem.setCtime(time);
+		upmsSystem.setOrders(time);
+		int count = upmsSystemService.insertSelective(upmsSystem);
+		modelMap.put("count", count);
+		_log.info("新增记录id为:{}", upmsSystem.getSystemId());
+		return "redirect:/manage/system/list";
+	}
+
+	@ApiOperation(value = "删除系统")
+	@RequiresPermissions("cms:system:delete")
+	@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
+	public String delete(@PathVariable("ids") String ids, ModelMap modelMap) {
+		int count = upmsSystemService.deleteByPrimaryKeys(ids);
+		modelMap.put("count", count);
+		return "redirect:/manage/system/list";
+	}
+
+	@ApiOperation(value = "修改系统")
+	@RequiresPermissions("cms:system:update")
+	@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
+	public String update(@PathVariable("id") int id, ModelMap modelMap) {
+		UpmsSystem system = upmsSystemService.selectByPrimaryKey(id);
+		modelMap.put("system", system);
+		return "/manage/system/update";
+	}
+
+	@ApiOperation(value = "修改系统")
+	@RequiresPermissions("cms:system:update")
+	@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
+	public String update(@PathVariable("id") int id, UpmsSystem system, ModelMap modelMap) {
+		int count = upmsSystemService.updateByPrimaryKeySelective(system);
+		modelMap.put("count", count);
+		modelMap.put("id", id);
+		return "redirect:/manage/system/list";
 	}
 
 }