package com.zhongzheng.controller.user;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.modules.user.bo.UserSchoolInfoAddBo;
import com.zhongzheng.modules.user.bo.UserSchoolInfoEditBo;
import com.zhongzheng.modules.user.bo.UserSchoolInfoQueryBo;
import com.zhongzheng.modules.user.domain.UserSchoolInfo;
import com.zhongzheng.modules.user.service.IUserSchoolInfoService;
import com.zhongzheng.modules.user.vo.UserSchoolInfoVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 用户学校信息Controller
 *
 * @author hjl
 * @date 2021-07-21
 */
@Api(value = "客户端用户学校信息控制器", tags = {"客户端用户学校信息管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/user/school/info")
public class UserSchoolInfoController extends BaseController {

    private final IUserSchoolInfoService iUserSchoolInfoService;

    /**
     * 查询用户学校信息列表
     */
  /*  @ApiOperation("查询用户学校信息列表")
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo<UserSchoolInfoVo> list(UserSchoolInfoQueryBo bo) {
        startPage();
        List<UserSchoolInfoVo> list = iUserSchoolInfoService.queryList(bo);
        return getDataTable(list);
    }*/

    /**
     * 导出用户学校信息列表
     */
   /* @ApiOperation("导出用户学校信息列表")
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "用户学校信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<UserSchoolInfoVo> export(UserSchoolInfoQueryBo bo) {
        List<UserSchoolInfoVo> list = iUserSchoolInfoService.queryList(bo);
        ExcelUtil<UserSchoolInfoVo> util = new ExcelUtil<UserSchoolInfoVo>(UserSchoolInfoVo.class);
        return util.exportExcel(list, "用户学校信息");
    }*/

    /**
     * 获取用户学校信息详细信息
     */
    @ApiOperation("获取用户学校信息详细信息")
    @PreAuthorize("@ss.hasPermi('app:user:school:info:query')")
    @GetMapping("/{userId}")
    public AjaxResult<UserSchoolInfoVo> getInfo(@PathVariable("userId" ) Long userId) {
        return AjaxResult.success(iUserSchoolInfoService.queryByUserId(userId));
    }

    /**
     * 新增用户学校信息
     */
   /* @ApiOperation("新增用户学校信息")
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "用户学校信息", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody UserSchoolInfoAddBo bo) {
        return toAjax(iUserSchoolInfoService.insertByAddBo(bo) ? 1 : 0);
    }*/

    /**
     * 修改用户学校信息
     */
    @ApiOperation("修改用户学校信息")
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "用户学校信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody UserSchoolInfoEditBo bo) throws IllegalAccessException {
        return toAjax(iUserSchoolInfoService.updateByEditBo(bo,true) ? 1 : 0);
    }

    /**
     * 删除用户学校信息
     */
   /* @ApiOperation("删除用户学校信息")
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "用户学校信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{userSchoolIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] userSchoolIds) {
        return toAjax(iUserSchoolInfoService.deleteWithValidByIds(Arrays.asList(userSchoolIds), true) ? 1 : 0);
    }*/
}
