|
|
@@ -0,0 +1,99 @@
|
|
|
+package com.jpsoft.employment.modules.base.api;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.employment.modules.base.entity.LoveProject;
|
|
|
+import com.jpsoft.employment.modules.base.entity.WishInfo;
|
|
|
+import com.jpsoft.employment.modules.base.entity.WishInfoUserRecord;
|
|
|
+import com.jpsoft.employment.modules.base.service.LoveProjectService;
|
|
|
+import com.jpsoft.employment.modules.base.service.StudentAspirationsService;
|
|
|
+import com.jpsoft.employment.modules.base.service.WishInfoService;
|
|
|
+import com.jpsoft.employment.modules.base.service.WishInfoUserRecordService;
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/base/api/love")
|
|
|
+@Api(description = "爱心项目")
|
|
|
+public class LoveApi {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LoveProjectService loveProjectService;
|
|
|
+ @Autowired
|
|
|
+ private WishInfoUserRecordService wishInfoUserRecordService;
|
|
|
+ @Autowired
|
|
|
+ private StudentAspirationsService studentAspirationsService;
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @ApiOperation(value="心愿单列表")
|
|
|
+ @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="title", value="名称", required=false, paramType="query"),
|
|
|
+ })
|
|
|
+ public MessageResult list(
|
|
|
+ String title,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize){
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(title)) {
|
|
|
+ searchParams.put("title","%" + title + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
+
|
|
|
+ Page<LoveProject> page = loveProjectService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="心愿单详情")
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="ID", required=true, paramType="query"),
|
|
|
+ })
|
|
|
+ public MessageResult<LoveProject> edit(@PathVariable("id") String id){
|
|
|
+ MessageResult<LoveProject> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ LoveProject loveProject = loveProjectService.get(id);
|
|
|
+
|
|
|
+ if (loveProject != null) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(loveProject);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+}
|