SchedulePlanInfoController.java 1.72 KB
package com.bsth.controller.schedule;

import com.bsth.common.ResponseCode;
import com.bsth.controller.BaseController;
import com.bsth.entity.schedule.SchedulePlanInfo;
import com.bsth.service.schedule.SchedulePlanInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by xu on 16/6/16.
 */
@RestController
@RequestMapping("spic")
public class SchedulePlanInfoController extends BaseController<SchedulePlanInfo, Long> {
    @Autowired
    private SchedulePlanInfoService schedulePlanInfoService;

    @RequestMapping(value = "/groupinfos/{xlid}/{date}", method = RequestMethod.GET)
    public List<SchedulePlanInfoService.GroupInfo> findGroupInfo(
            @PathVariable(value = "xlid") Integer xlid,
            @PathVariable(value = "date") Date scheduleDate) {
        return schedulePlanInfoService.findGroupInfo(xlid, scheduleDate);
    }

    @RequestMapping(value = "/groupinfos/update", method = RequestMethod.POST)
    public Map<String, Object> updateGroupInfo(@RequestBody SchedulePlanInfoService.GroupInfoUpdate groupInfoUpdate) {
        Map<String, Object> resultMap = new HashMap<>();
        try {
            schedulePlanInfoService.updateGroupInfo(groupInfoUpdate);

            resultMap.put("status", ResponseCode.SUCCESS);
            resultMap.put("msg", "更新成功");
        } catch (Exception exp) {
            exp.printStackTrace();
            resultMap.put("status", ResponseCode.ERROR);
            resultMap.put("msg", exp.getLocalizedMessage());
        }

        return resultMap;
    }
}