ShiftController.java
4.81 KB
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
package com.hotent.Calendar.controller;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.hotent.Calendar.manager.CalendarShiftManager;
import com.hotent.Calendar.manager.CalendarShiftPeroidManager;
import com.hotent.Calendar.model.CalendarShift;
import com.hotent.Calendar.model.CalendarShiftPeroid;
import com.hotent.Calendar.params.CalendarShiftVo;
import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.base.controller.BaseController;
import com.hotent.base.id.IdGenerator;
import com.hotent.base.model.CommonResult;
import com.hotent.base.query.PageList;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.util.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 班次管理
*
* @company 广州宏天软件股份有限公司
* @author zhangxianwen
* @email zhangxw@jee-soft.cn
* @date 2018年6月26日
*/
@RestController
@RequestMapping("/calendar/shift/v1/")
@Api(tags="班次管理")
@ApiGroup(group= {ApiGroupConsts.GROUP_PORTAL})
public class ShiftController extends BaseController<CalendarShiftManager,CalendarShift> {
@Resource
private CalendarShiftManager calendarShiftManager;
@Resource
private CalendarShiftPeroidManager calendarShiftPeroidManager;
@Resource
IdGenerator idGenerator;
@RequestMapping(value="list", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "班次管理列表(分页条件查询)", httpMethod = "POST", notes = "班次管理列表(分页条件查询)")
public PageList<CalendarShift> listJson(@ApiParam(name="queryFilter",value="通用查询对象")@RequestBody QueryFilter<CalendarShift> queryFilter) throws Exception {
return calendarShiftManager.query(queryFilter);
}
@RequestMapping(value="get",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取班次明细", httpMethod = "GET", notes = "获取班次明细")
public CalendarShiftVo get(@ApiParam(name="id",value="班次id", required = true) @RequestParam String id) throws Exception{
List<CalendarShiftPeroid> shiftPeroidlist = new ArrayList<CalendarShiftPeroid>();
if (StringUtil.isNotEmpty(id)) {
CalendarShift shift = calendarShiftManager.get(id);
shiftPeroidlist = calendarShiftPeroidManager.getByShiftId(id);
return new CalendarShiftVo(shift, shiftPeroidlist);
}
return null;
}
@RequestMapping(value="save",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "保存班次信息", httpMethod = "POST", notes = "保存班次信息")
public CommonResult<String> save(@ApiParam(name="calendarShiftVo",value="班次信息", required = true) @RequestBody CalendarShiftVo calendarShiftVo) throws Exception{
String msg = "";
CalendarShift calendarshift = calendarShiftVo.getCalendarShift();
List<CalendarShiftPeroid> peroids = calendarShiftVo.getShiftPeroidlist();
calendarshift.setCalendarShiftPeroidList(peroids);
String shiftId = calendarshift.getId();
if (StringUtil.isEmpty(shiftId)) {
shiftId = idGenerator.getSuid();
calendarshift.setId(shiftId);
calendarShiftManager.create(calendarshift);
msg = "保存成功";
} else {
shiftId = calendarshift.getId();
calendarShiftManager.update(calendarshift);
msg = "更新成功";
}
return new CommonResult<String>(true, msg);
}
@RequestMapping(value="remove",method=RequestMethod.DELETE, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "批量删除班次记录(逻辑删除)", httpMethod = "DELETE", notes = "批量删除班次记录(逻辑删除)")
public CommonResult<String> remove(@ApiParam(name="ids",value="班次记录ID,多个用“,”号分隔", required = true) @RequestParam String ids) throws Exception{
String[] aryIds = StringUtil.getStringAryByStr(ids);
calendarShiftManager.removeByIds(aryIds);
return new CommonResult<>(true, "删除成功");
}
@RequestMapping(value="setDefault",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "设置默认时,只能有一个是默认的", httpMethod = "GET", notes = "设置默认时,只能有一个是默认的")
public CommonResult<String> setDefault(@ApiParam(name="id",value="班次id", required = true) @RequestParam String id) throws Exception{
String msg = "设置成功";
calendarShiftManager.setDefaultShift(id);
return new CommonResult<String>(true, msg);
}
}