1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.hmit.kernes.controller;
import com.hmit.kernes.entity.CloudApplyEntity;
import com.hmit.kernes.entity.CloudBaseInfoEntity;
import com.hmit.kernes.service.CloudApplyService;
import com.hmit.kernes.service.CloudBaseInfoService;
import com.hmit.kernes.utils.PageUtils;
import com.hmit.kernes.utils.Query;
import com.hmit.kernes.utils.R;
import com.hmit.kernes.utils.RRException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/cloud/apply")
public class CloudApplyController extends AbstractController {
@Autowired
CloudApplyService cloudApplyService;
@Autowired
CloudBaseInfoService cloudBaseInfoService;
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
Query query = new Query(params);
List<CloudApplyEntity> list= cloudApplyService.queryList(query);
int total=cloudApplyService.queryTotal(query);
PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
@RequestMapping("/userlist")
public R userlist(@RequestParam Map<String, Object> params){
Long id=getUser().getUnionId();
if(id==null)
throw new RRException("暂时查询不到相关记录,请稍后再试,或联系管理员");
params.put("unionId",id.toString());
Query query = new Query(params);
List<CloudApplyEntity> list= cloudApplyService.queryList(query);
int total=cloudApplyService.queryTotal(query);
PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
@RequestMapping("/info/{id}")
//@RequiresPermissions("sys:recommend:info")
public R info(@PathVariable("") Long id){
CloudApplyEntity cloudApplyEntity=cloudApplyService.queryObject(id);
return R.ok().put("apply",cloudApplyEntity);
}
@RequestMapping("/user/save")
public R userSave(@RequestBody CloudApplyEntity cloudApplyEntity){
//数据校验
cloudApplyEntity=verifyForm(cloudApplyEntity);
cloudApplyService.save(cloudApplyEntity);
return R.ok();
}
@RequestMapping("/save")
public R save(@RequestBody CloudApplyEntity cloudApplyEntity){
cloudApplyEntity.setMakerId(getUserId());
cloudApplyEntity.setUpdateTime(new Date());
cloudApplyEntity.setMakerName(getUser().getRealName());
cloudApplyService.save(cloudApplyEntity);
return R.ok();
}
@RequestMapping("/delete")
//@RequiresPermissions("zhgh:reception:delete")
public R delete(@RequestBody Long[] ids){
cloudApplyService.deleteBatch(ids);
return R.ok();
}
@RequestMapping("/update")
//@RequiresPermissions("sys:menu:update")
public R update(@RequestBody CloudApplyEntity cloudApplyEntity){
cloudApplyEntity.setMakerId(getUserId());
cloudApplyEntity.setUpdateTime(new Date());
cloudApplyEntity.setMakerName(getUser().getRealName());
cloudApplyService.update(cloudApplyEntity);
return R.ok();
}
@RequestMapping("/user/update")
//@RequiresPermissions("sys:menu:update")
public R userUpdate(@RequestBody CloudApplyEntity cloudApplyEntity){
//数据校验
cloudApplyEntity= verifyForm(cloudApplyEntity);
cloudApplyService.update(cloudApplyEntity);
return R.ok();
}
private CloudApplyEntity verifyForm( CloudApplyEntity c){
if(getUserId()!=null){
CloudBaseInfoEntity cbie=cloudBaseInfoService.queryObject(getUser().getUnionId());
if(cbie==null){
throw new RRException("请先填写基本信息!");
}else{
c.setUnionId(cbie.getId());
c.setUnionName(cbie.getLocalUnionName());
}
}else{
throw new RRException("no user id!");
}
c.setMakerId(getUserId());
c.setUpdateTime(new Date());
c.setMakerName(getUser().getRealName());
return c;
}
}