|
@@ -1,15 +1,14 @@
|
|
package com.jpsoft.education.modules.fee.controller;
|
|
package com.jpsoft.education.modules.fee.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
-
|
|
|
|
import com.jpsoft.education.modules.common.dto.MessageResult;
|
|
import com.jpsoft.education.modules.common.dto.MessageResult;
|
|
import com.jpsoft.education.modules.common.dto.Sort;
|
|
import com.jpsoft.education.modules.common.dto.Sort;
|
|
|
|
+import com.jpsoft.education.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.education.modules.fee.entity.FeeInfo;
|
|
import com.jpsoft.education.modules.fee.entity.FeeInfo;
|
|
import com.jpsoft.education.modules.fee.service.FeeInfoService;
|
|
import com.jpsoft.education.modules.fee.service.FeeInfoService;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
-
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import org.apache.ibatis.mapping.ResultMap;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,20 +20,37 @@ import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/feeInfo")
|
|
@RequestMapping("/feeInfo")
|
|
|
|
+@Api(description = "feeInfo")
|
|
public class FeeInfoController {
|
|
public class FeeInfoController {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FeeInfoService feeInfoService;
|
|
private FeeInfoService feeInfoService;
|
|
|
|
|
|
|
|
+ @ApiOperation(value="创建空记录")
|
|
|
|
+ @GetMapping("create")
|
|
|
|
+ public MessageResult<FeeInfo> create(){
|
|
|
|
+ MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ FeeInfo feeInfo = new FeeInfo();
|
|
|
|
+
|
|
|
|
+ msgResult.setData(feeInfo);
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value="添加信息")
|
|
@ApiOperation(value="添加信息")
|
|
@PostMapping("add")
|
|
@PostMapping("add")
|
|
- public MessageResult<FeeInfo> add(@ModelAttribute FeeInfo feeInfo){
|
|
|
|
|
|
+ public MessageResult<FeeInfo> add(@RequestBody FeeInfo feeInfo,@RequestAttribute String subject){
|
|
MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
- feeInfo.setFeeId(UUID.randomUUID().toString());
|
|
|
|
-
|
|
|
|
|
|
+ feeInfo.setId(UUID.randomUUID().toString());
|
|
|
|
+ feeInfo.setDelIf(false);
|
|
|
|
+ feeInfo.setCreateBy(subject);
|
|
|
|
+ feeInfo.setCreateTime(new Date());
|
|
|
|
+
|
|
int affectCount = feeInfoService.insert(feeInfo);
|
|
int affectCount = feeInfoService.insert(feeInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
@@ -56,8 +72,8 @@ public class FeeInfoController {
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value="获取信息")
|
|
@ApiOperation(value="获取信息")
|
|
- @GetMapping("detail/{id}")
|
|
|
|
- public MessageResult<FeeInfo> detail(@PathVariable("id") String id){
|
|
|
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
|
+ public MessageResult<FeeInfo> edit(@PathVariable("id") String id){
|
|
MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -83,10 +99,13 @@ public class FeeInfoController {
|
|
|
|
|
|
@ApiOperation(value="更新用户")
|
|
@ApiOperation(value="更新用户")
|
|
@PostMapping("update")
|
|
@PostMapping("update")
|
|
- public MessageResult<FeeInfo> update(@ModelAttribute FeeInfo feeInfo){
|
|
|
|
|
|
+ public MessageResult<FeeInfo> update(@RequestBody FeeInfo feeInfo,@RequestAttribute String subject){
|
|
MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ feeInfo.setModifyBy(subject);
|
|
|
|
+ feeInfo.setModifyTime(new Date());
|
|
|
|
+
|
|
int affectCount = feeInfoService.update(feeInfo);
|
|
int affectCount = feeInfoService.update(feeInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
@@ -107,19 +126,25 @@ public class FeeInfoController {
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
|
|
|
+ @ApiOperation(value="删除")
|
|
@PostMapping("delete/{id}")
|
|
@PostMapping("delete/{id}")
|
|
- public MessageResult<FeeInfo> delete(@PathVariable("id") String id){
|
|
|
|
- MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
+ public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
- int affectCount = feeInfoService.delete(id);
|
|
|
|
|
|
+ FeeInfo feeInfo = feeInfoService.get(id);
|
|
|
|
+ feeInfo.setDelIf(true);
|
|
|
|
+ feeInfo.setModifyBy(subject);
|
|
|
|
+ feeInfo.setModifyTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = feeInfoService.update(feeInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(affectCount);
|
|
} else {
|
|
} else {
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
- msgResult.setMessage("数据库删除失败");
|
|
|
|
|
|
+ msgResult.setMessage("删除失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
@@ -134,58 +159,66 @@ public class FeeInfoController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value="批量删除")
|
|
@ApiOperation(value="批量删除")
|
|
- @PostMapping("batchDelete/{id}")
|
|
|
|
- public MessageResult<FeeInfo> batchDelete(@PathVariable("id") String id){
|
|
|
|
- MessageResult<FeeInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
+ @PostMapping("batchDelete")
|
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
- msgResult.setResult(false);
|
|
|
|
- msgResult.setMessage("未实现");
|
|
|
|
|
|
+ try {
|
|
|
|
+ int affectCount = 0;
|
|
|
|
+
|
|
|
|
+ for (String id : idList) {
|
|
|
|
+ FeeInfo feeInfo = feeInfoService.get(id);
|
|
|
|
+ feeInfo.setDelIf(true);
|
|
|
|
+ feeInfo.setModifyBy(subject);
|
|
|
|
+ feeInfo.setModifyTime(new Date());
|
|
|
|
+
|
|
|
|
+ affectCount += feeInfoService.update(feeInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(affectCount);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value="列表")
|
|
@ApiOperation(value="列表")
|
|
- @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
|
- public MessageResult<Map> list(
|
|
|
|
|
|
+ @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Map> pageList(
|
|
String id,
|
|
String id,
|
|
- @RequestParam(value="draw",defaultValue="1") int draw,
|
|
|
|
- @RequestParam(value="start",defaultValue="1") int start,
|
|
|
|
- @RequestParam(value="length",defaultValue="20") int length,
|
|
|
|
- HttpServletRequest request){
|
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
+ @RequestAttribute String subject){
|
|
|
|
|
|
//当前用户ID
|
|
//当前用户ID
|
|
System.out.println(subject);
|
|
System.out.println(subject);
|
|
|
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
- Map<String,Object> searchParms = new HashMap<>();
|
|
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
List<Sort> sortList = new ArrayList<>();
|
|
sortList.add(new Sort("id_","asc"));
|
|
sortList.add(new Sort("id_","asc"));
|
|
|
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
- searchParms.put("id","%" + id + "%");
|
|
|
|
|
|
+ searchParams.put("id","%" + id + "%");
|
|
}
|
|
}
|
|
|
|
|
|
- int pageNum = start / length;
|
|
|
|
-
|
|
|
|
- if (start % length != 0) {
|
|
|
|
- pageNum++;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int pageSize = length;
|
|
|
|
-
|
|
|
|
- Page<FeeInfo> page = feeInfoService.pageSearch(searchParms,pageNum,pageSize,sortList);
|
|
|
|
-
|
|
|
|
- HashMap<String, Object> wrapper = new HashMap<String, Object>();
|
|
|
|
- wrapper.put("draw",draw);
|
|
|
|
- wrapper.put("recordsTotal", page.getTotal());
|
|
|
|
- wrapper.put("recordsFiltered", page.getTotal());
|
|
|
|
- wrapper.put("data", page.getResult());
|
|
|
|
|
|
+ Page<FeeInfo> page = feeInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
- msgResult.setData(wrapper);
|
|
|
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|