首页>代码>基于SSM+jsp的高校后勤报修系统代码分享>/jspm28ezb/src/main/java/com/controller/BaoxiuwentiController.java
package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.BaoxiuwentiEntity;
import com.entity.view.BaoxiuwentiView;

import com.service.BaoxiuwentiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;

/**
 * 报修问题
 * 后端接口
 */
@RestController
@RequestMapping("/baoxiuwenti")
public class BaoxiuwentiController {
    @Autowired
    private BaoxiuwentiService baoxiuwentiService;



    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,BaoxiuwentiEntity baoxiuwenti, 
		HttpServletRequest request){

		String tableName = request.getSession().getAttribute("tableName").toString();
		if(tableName.equals("weixiuyuan")) {
			baoxiuwenti.setGonghao((String)request.getSession().getAttribute("username"));
		}
        EntityWrapper<BaoxiuwentiEntity> ew = new EntityWrapper<BaoxiuwentiEntity>();
    	PageUtils page = baoxiuwentiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, baoxiuwenti), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,BaoxiuwentiEntity baoxiuwenti, 
		HttpServletRequest request){
        EntityWrapper<BaoxiuwentiEntity> ew = new EntityWrapper<BaoxiuwentiEntity>();
    	PageUtils page = baoxiuwentiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, baoxiuwenti), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( BaoxiuwentiEntity baoxiuwenti){
       	EntityWrapper<BaoxiuwentiEntity> ew = new EntityWrapper<BaoxiuwentiEntity>();
      	ew.allEq(MPUtil.allEQMapPre( baoxiuwenti, "baoxiuwenti")); 
        return R.ok().put("data", baoxiuwentiService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(BaoxiuwentiEntity baoxiuwenti){
        EntityWrapper< BaoxiuwentiEntity> ew = new EntityWrapper< BaoxiuwentiEntity>();
 		ew.allEq(MPUtil.allEQMapPre( baoxiuwenti, "baoxiuwenti")); 
		BaoxiuwentiView baoxiuwentiView =  baoxiuwentiService.selectView(ew);
		return R.ok("查询报修问题成功").put("data", baoxiuwentiView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        BaoxiuwentiEntity baoxiuwenti = baoxiuwentiService.selectById(id);
        return R.ok().put("data", baoxiuwenti);
    }

    /**
     * 前端详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        BaoxiuwentiEntity baoxiuwenti = baoxiuwentiService.selectById(id);
        return R.ok().put("data", baoxiuwenti);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BaoxiuwentiEntity baoxiuwenti, HttpServletRequest request){
    	baoxiuwenti.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(baoxiuwenti);

        baoxiuwentiService.insert(baoxiuwenti);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody BaoxiuwentiEntity baoxiuwenti, HttpServletRequest request){
    	baoxiuwenti.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(baoxiuwenti);

        baoxiuwentiService.insert(baoxiuwenti);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BaoxiuwentiEntity baoxiuwenti, HttpServletRequest request){
        //ValidatorUtils.validateEntity(baoxiuwenti);
        baoxiuwentiService.updateById(baoxiuwenti);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        baoxiuwentiService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<BaoxiuwentiEntity> wrapper = new EntityWrapper<BaoxiuwentiEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}

		String tableName = request.getSession().getAttribute("tableName").toString();
		if(tableName.equals("weixiuyuan")) {
			wrapper.eq("gonghao", (String)request.getSession().getAttribute("username"));
		}

		int count = baoxiuwentiService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	
	





}
最近下载更多
清横白川玉  LV6 4月21日
wanglinddad  LV54 3月28日
帅涵123456  LV2 2月29日
admin_z  LV22 2月5日
qwertyuiop1379  LV3 1月23日
做自己的太阳  LV11 1月20日
lilong007  LV20 2023年12月30日
zzy021903  LV1 2023年12月12日
wangyh1  LV2 2023年11月15日
lbsers  LV5 2023年11月9日
最近浏览更多
asdfghjkl679 昨天
暂无贡献等级
hmf1989 前天
暂无贡献等级
清横白川玉  LV6 4月21日
educationAAA  LV2 4月18日
15293703087 4月15日
暂无贡献等级
op123129 4月15日
暂无贡献等级
mzqnxyh  LV2 4月12日
zolscy  LV12 4月7日
wanglinddad  LV54 3月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友