package com.goafanti.admin.controller; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.goafanti.admin.service.DepartmentService; import com.goafanti.common.bo.Result; import com.goafanti.common.constant.ErrorConstants; import com.goafanti.common.controller.CertifyApiController; import com.goafanti.common.model.WorkingHours; import com.goafanti.common.utils.StringUtils; @Controller @RequestMapping(value = "/api/admin/department") public class AdminDepartmentApiController extends CertifyApiController { @Resource private DepartmentService departmentService; /** * 新增工作时间 */ @RequestMapping(value = "/workingHours/add", method = RequestMethod.POST) public Result add(WorkingHours in) { Result res = new Result(); if (in.getType()==null||StringUtils.isBlank(in.getName())|| StringUtils.isBlank(in.getStart())||StringUtils.isBlank(in.getRestStart())|| StringUtils.isBlank(in.getEnd())||StringUtils.isBlank(in.getRestEnd())) { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "")); return res; } if (departmentService.checkWorkingHoursType(in.getType())) { res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "", "分类")); return res; } res.setData(departmentService.addWorkingHours(in)); return res; } /** * 删除工作时间 */ @RequestMapping(value = "/workingHours/delete", method = RequestMethod.POST) public Result delete(Integer id) { Result res = new Result(); if (id==null) { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "")); return res; } if (departmentService.checkDepWorkingHouresType(id)) { res.getError().add(buildError( "已分配无法删除!。", "已分配无法删除!")); return res; } res.setData(departmentService.deleteWorkingHours(id)); return res; } /** * 工作时间列表 */ @RequestMapping(value = "/workingHours/list", method = RequestMethod.GET) public Result list() { Result res = new Result(); res.setData(departmentService.selectWorkingHours()); return res; } /** * 工作时间列表 */ @RequestMapping(value = "/workingHours/get", method = RequestMethod.GET) public Result get(String depId) { Result res = new Result(); if (depId==null) { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "")); return res; } res.setData(departmentService.getWorkingHours(depId)); return res; } /** * 工作时间列表 */ @RequestMapping(value = "/selectAllDep", method = RequestMethod.GET) public Result selectAllDep() { Result res = new Result(); res.setData(departmentService.selectAllDep()); return res; } }