CloudBaseInfoController.java 5.07 KB
Newer Older
Zhou Yang's avatar
Zhou Yang committed
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
package com.hmit.kernes.controller;

import com.hmit.kernes.entity.CloudBaseInfoEntity;
import com.hmit.kernes.service.CloudBaseInfoService;
import com.hmit.kernes.service.ZhghApplyMedService;
import com.hmit.kernes.service.ZhghClickCountService;
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/baseinfo")
public class CloudBaseInfoController extends  AbstractController {
    @Autowired
    private CloudBaseInfoService cloudBaseInfoService;
    @Autowired
    private ZhghApplyMedService zhghApplyMedService;
    @Autowired
    private ZhghClickCountService zhghClickCountService;


    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,String type){
        Query query = new Query(params);
        List<CloudBaseInfoEntity> list= cloudBaseInfoService.queryList(query);
        int total=cloudBaseInfoService.queryTotal(query);
        PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
        return R.ok().put("page", pageUtil);
    }

    @RequestMapping("/userlist")
    public R userlist(){

        Long id=getUser().getUnionId();
        if(id==null)
            throw  new RRException("暂时查询不到相关记录,请稍后再试,或联系管理员");

        CloudBaseInfoEntity cloudBaseInfoEntity=cloudBaseInfoService.queryObject(id);

        return R.ok().put("baseinfo",cloudBaseInfoEntity);

    }


    @RequestMapping("/info/{id}")
    //@RequiresPermissions("sys:recommend:info")
    public R info(@PathVariable("") Long id){
        CloudBaseInfoEntity cloudBaseInfoEntity=cloudBaseInfoService.queryObject(id);

        return R.ok().put("baseinfo",cloudBaseInfoEntity);

    }

    @RequestMapping("/division")
    public R divisionTotal(){
       List<Map> list=cloudBaseInfoService.getTotalByDivision();

        return R.ok().put("list",list);

    }

    @RequestMapping("/ec")
    public R ec(){

        List<Map> list3=cloudBaseInfoService.getTotalByDivision();//地区总数

        List<Map> list5=cloudBaseInfoService.getMemDivCount();
        List<Map> list6=cloudBaseInfoService.getApplyIncrease();
        List<Map> list7=cloudBaseInfoService.getReceptionIncrease();
        List<Map> list8=cloudBaseInfoService.getAppIncrease();
        List<Map> list9=zhghApplyMedService.getMedIncrease();
        List<Map> contractList=cloudBaseInfoService.getContractIncrease();
        List<Map> clickList=zhghClickCountService.queryClickIncrease();
     //   List<Map> infoList=cloudBaseInfoService.getInfoCount(3,60);
        return R.ok()
                .put("list3",list3)
                .put("memList",list5)
                .put("apList",list6)
                .put("reList",list7)
                .put("appList",list8)
                .put("medList",list9)
                .put("contractList",contractList)
                .put("clickList",clickList);

    }



    @RequestMapping("/increase")
    public R increase(){
        List<Map> list1=cloudBaseInfoService.getIncrease();
        List<Map> list2=cloudBaseInfoService.getIncreaseByDivision();
        List<Map> list3=cloudBaseInfoService.getMemDivCount();
        return R.ok().put("list",list1).put("list2",list2).put("memList",list3);

    }
    @RequestMapping("/mem")
    public R mem(){
        List<Map> list1=cloudBaseInfoService.getMemDivCount();

        return R.ok().put("list",list1);

    }

    @RequestMapping("/save")
    public R save(@RequestBody CloudBaseInfoEntity cloudBaseInfoEntity){

        //数据校验

        Long id=getUser().getUnionId();
        if(id==null)
            throw  new RRException("暂时查询不到相关记录,请稍后再试,或联系管理员");
        verifyForm(cloudBaseInfoEntity);


        cloudBaseInfoEntity.setMakerId(getUserId());
        cloudBaseInfoEntity.setId(id);
        cloudBaseInfoService.saveWithId(cloudBaseInfoEntity);
        return R.ok();
    }

    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){

        cloudBaseInfoService.deleteBatch(ids);


        return R.ok();
    }
    @RequestMapping("/update")
    public R update(@RequestBody CloudBaseInfoEntity cloudBaseInfoEntity){
        //数据校验
        Long id=getUser().getUnionId();
        if(id==null)
            throw  new RRException("暂时查询不到相关记录,请稍后再试,或联系管理员");

       verifyForm(cloudBaseInfoEntity);

       cloudBaseInfoService.update(cloudBaseInfoEntity);

        return R.ok();
    }


    private CloudBaseInfoEntity verifyForm(CloudBaseInfoEntity c){

       // c.setMakerId(getUserId());
        c.setUpdateTime(new Date());
        c.setMakerName(getUser().getRealName());
        return  c;
    }

}