|
|
@@ -9,6 +9,8 @@ import com.jpsoft.lotteryActivity.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.lotteryActivity.modules.base.entity.AwardInfo;
|
|
|
import com.jpsoft.lotteryActivity.modules.base.service.AwardInfoService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -29,11 +31,11 @@ public class AwardInfoController {
|
|
|
|
|
|
@Autowired
|
|
|
private ActivityInfoService activityInfoService;
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value="创建空记录")
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "创建空记录")
|
|
|
@GetMapping("create")
|
|
|
- public MessageResult<AwardInfo> create(){
|
|
|
+ public MessageResult<AwardInfo> create() {
|
|
|
MessageResult<AwardInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
AwardInfo awardInfo = new AwardInfo();
|
|
|
@@ -44,17 +46,31 @@ public class AwardInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="添加信息")
|
|
|
+ @ApiOperation(value = "添加信息")
|
|
|
@PostMapping("add")
|
|
|
- public MessageResult<AwardInfo> add(@RequestBody AwardInfo awardInfo,@RequestAttribute String subject){
|
|
|
+ public MessageResult<AwardInfo> add(@RequestBody AwardInfo awardInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<AwardInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
awardInfo.setId(UUID.randomUUID().toString());
|
|
|
- awardInfo.setDelFlag(false);
|
|
|
+ awardInfo.setDelFlag(false);
|
|
|
awardInfo.setCreateBy(subject);
|
|
|
awardInfo.setCreateTime(new Date());
|
|
|
|
|
|
+ String imageUrl = "";
|
|
|
+
|
|
|
+ if (awardInfo.getImageList() != null) {
|
|
|
+ for (Map<String, String> map : awardInfo.getImageList()) {
|
|
|
+ String url = map.get("url");
|
|
|
+ imageUrl += url + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(imageUrl)) {
|
|
|
+ String url = imageUrl.substring(0,imageUrl.lastIndexOf(","));
|
|
|
+ awardInfo.setImage(url);
|
|
|
+ }
|
|
|
+
|
|
|
int affectCount = awardInfoService.insert(awardInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
@@ -64,9 +80,8 @@ public class AwardInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库添加失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -75,24 +90,42 @@ public class AwardInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="获取信息")
|
|
|
+ @ApiOperation(value = "获取信息")
|
|
|
@GetMapping("edit/{id}")
|
|
|
- public MessageResult<AwardInfo> edit(@PathVariable("id") String id){
|
|
|
+ public MessageResult<AwardInfo> edit(@PathVariable("id") String id) {
|
|
|
MessageResult<AwardInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
AwardInfo awardInfo = awardInfoService.get(id);
|
|
|
|
|
|
if (awardInfo != null) {
|
|
|
+ if (StringUtils.isNotEmpty(awardInfo.getImage())) {
|
|
|
+ String[] imageArr = awardInfo.getImage().split(",");
|
|
|
+ List<Map> annexFileList = new ArrayList<>();
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ for (String item : imageArr) {
|
|
|
+ Map map = new HashedMap();
|
|
|
+ map.put("fileName", index);
|
|
|
+ map.put("url", item);
|
|
|
+ map.put("name", index);
|
|
|
+ annexFileList.add(map);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+
|
|
|
+ awardInfo.setImageList(annexFileList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(awardInfo);
|
|
|
} else {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -101,15 +134,29 @@ public class AwardInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="更新用户")
|
|
|
+ @ApiOperation(value = "更新用户")
|
|
|
@PostMapping("update")
|
|
|
- public MessageResult<AwardInfo> update(@RequestBody AwardInfo awardInfo,@RequestAttribute String subject){
|
|
|
+ public MessageResult<AwardInfo> update(@RequestBody AwardInfo awardInfo, @RequestAttribute String subject) {
|
|
|
MessageResult<AwardInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- awardInfo.setUpdateBy(subject);
|
|
|
+ awardInfo.setUpdateBy(subject);
|
|
|
awardInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
+
|
|
|
+ String imageUrl = "";
|
|
|
+
|
|
|
+ if (awardInfo.getImageList() != null) {
|
|
|
+ for (Map<String, String> map : awardInfo.getImageList()) {
|
|
|
+ String url = map.get("url");
|
|
|
+ imageUrl += url + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(imageUrl)) {
|
|
|
+ String url = imageUrl.substring(0,imageUrl.lastIndexOf(","));
|
|
|
+ awardInfo.setImage(url);
|
|
|
+ }
|
|
|
+
|
|
|
int affectCount = awardInfoService.update(awardInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
@@ -119,9 +166,8 @@ public class AwardInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库更新失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -130,19 +176,19 @@ public class AwardInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
+ @ApiOperation(value = "删除用户")
|
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<AwardInfo> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
+ public MessageResult<AwardInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<AwardInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
- AwardInfo awardInfo = awardInfoService.get(id);
|
|
|
+
|
|
|
+ AwardInfo awardInfo = awardInfoService.get(id);
|
|
|
awardInfo.setDelFlag(true);
|
|
|
awardInfo.setUpdateBy(subject);
|
|
|
awardInfo.setUpdateTime(new Date());
|
|
|
-
|
|
|
- int affectCount = awardInfoService.update(awardInfo);
|
|
|
+
|
|
|
+ int affectCount = awardInfoService.update(awardInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
@@ -150,9 +196,8 @@ public class AwardInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库删除失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -162,9 +207,9 @@ public class AwardInfoController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="批量删除")
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
@PostMapping("batchDelete")
|
|
|
- public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
@@ -186,9 +231,8 @@ public class AwardInfoController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -197,34 +241,52 @@ public class AwardInfoController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
|
String activityId,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
- HttpServletRequest request){
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
|
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","asc"));
|
|
|
+ sortList.add(new Sort("num_", "asc"));
|
|
|
|
|
|
- searchParams.put("activityId",activityId);
|
|
|
+ searchParams.put("activityId", activityId);
|
|
|
|
|
|
- Page<AwardInfo> page = awardInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+ Page<AwardInfo> page = awardInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
- for (AwardInfo awardInfo:page) {
|
|
|
+ for (AwardInfo awardInfo : page) {
|
|
|
ActivityInfo activityInfo = activityInfoService.get(awardInfo.getActivityId());
|
|
|
- if(activityInfo!=null) {
|
|
|
+ if (activityInfo != null) {
|
|
|
awardInfo.setActivityName(activityInfo.getName());
|
|
|
}
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(awardInfo.getImage())){
|
|
|
+ String[] imageArr = awardInfo.getImage().split(",");
|
|
|
+ List<Map> annexFileList = new ArrayList<>();
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ for (String item : imageArr) {
|
|
|
+ Map map = new HashedMap();
|
|
|
+ map.put("fileName", index);
|
|
|
+ map.put("url", item);
|
|
|
+ map.put("name", index);
|
|
|
+ annexFileList.add(map);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+
|
|
|
+ awardInfo.setImageList(annexFileList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -235,11 +297,10 @@ public class AwardInfoController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "findByActivityId",method = RequestMethod.POST)
|
|
|
- public MessageResult<List<AwardInfo>> list(String activityId,HttpServletRequest request){
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "findByActivityId", method = RequestMethod.POST)
|
|
|
+ public MessageResult<List<AwardInfo>> list(String activityId, HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|