package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsHealthTongueParam;
import com.fs.his.vo.FsHealthTongueListVO;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsHealthTongue;
import com.fs.his.service.IFsHealthTongueService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

import static com.fs.his.utils.PhoneUtil.*;

/**
 * 舌苔Controller
 *
 * @author fs
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/his/healthTongue")
public class FsHealthTongueController extends BaseController
{
    @Autowired
    private IFsHealthTongueService fsHealthTongueService;

    /**
     * 查询舌苔列表
     */
    @PreAuthorize("@ss.hasPermi('his:healthTongue:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsHealthTongueParam param)
    {
        startPage();
        if (param.getPhoneMk()!=null&&param.getPhoneMk()!=""){
            param.setPhone(encryptPhone(param.getPhoneMk()));
        }
        List<FsHealthTongueListVO> list = fsHealthTongueService.selectFsHealthTongueListVO(param);
        for (FsHealthTongueListVO fsHealthTongueListVO : list) {
            fsHealthTongueListVO.setPhone(decryptAutoPhoneMk(fsHealthTongueListVO.getPhone()));
        }
        return getDataTable(list);
    }

    /**
     * 导出舌苔列表
     */
    @PreAuthorize("@ss.hasPermi('his:healthTongue:export')")
    @Log(title = "舌苔", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsHealthTongue fsHealthTongue)
    {
        List<FsHealthTongue> list = fsHealthTongueService.selectFsHealthTongueList(fsHealthTongue);
        ExcelUtil<FsHealthTongue> util = new ExcelUtil<FsHealthTongue>(FsHealthTongue.class);
        return util.exportExcel(list, "舌苔数据");
    }

    /**
     * 获取舌苔详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:healthTongue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsHealthTongueService.selectFsHealthTongueById(id));
    }

    /**
     * 新增舌苔
     */
    @PreAuthorize("@ss.hasPermi('his:healthTongue:add')")
    @Log(title = "舌苔", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsHealthTongue fsHealthTongue)
    {
        return toAjax(fsHealthTongueService.insertFsHealthTongue(fsHealthTongue));
    }

    /**
     * 修改舌苔
     */
    @PreAuthorize("@ss.hasPermi('his:healthTongue:edit')")
    @Log(title = "舌苔", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsHealthTongue fsHealthTongue)
    {
        return toAjax(fsHealthTongueService.updateFsHealthTongue(fsHealthTongue));
    }

    /**
     * 删除舌苔
     */
    @PreAuthorize("@ss.hasPermi('his:healthTongue:remove')")
    @Log(title = "舌苔", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsHealthTongueService.deleteFsHealthTongueByIds(ids));
    }
}
