SubjectController.java 1.83 KB
package com.bsth.controller.subject;

import com.bsth.controller.BaseController;
import com.bsth.entity.subject.Subject;
import com.bsth.service.subject.SubjectService;
import com.bsth.service.subject.SubjectUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping("subject")
public class SubjectController extends BaseController<Subject, Integer> {

    private static final Logger LOGGER = LoggerFactory.getLogger(SubjectController.class);

    @Autowired
    SubjectService subjectService;

    @Autowired
    SubjectUserService subjectUserService;

    @RequestMapping("/subjectList")
    public List<Subject> subjectList(){
        List<Subject> r=subjectService.subjectAll();
        return r;
    }

    @RequestMapping("/selectSubject")
    public Map<String,String> selectSubject(@RequestParam() Map<String, Object> map){
        Map<String,String> result=new HashMap<>();
        try {
            String[] ids=map.get("ids").toString().split(",");
            String[] fractions=map.get("fractionStr").toString().split(",");
            String isOperate=map.get("isOperate").toString();
            String className=map.get("className").toString();
            subjectUserService.selectSubject(ids,fractions,isOperate,className);
            result.put("result","成功");
            return result;
        } catch (Exception e) {
            LOGGER.error("",e);
            // TODO: handle exception
            result.put("result","失败");
            return result;
        }
    }


}