WebMemberUnitController.java 4.09 KB
package com.lhcredit.project.webbusiness.controller;

import java.util.Date;
import java.util.List;

import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.framework.aspectj.lang.enums.OperatorType;
import com.lhcredit.framework.web.page.TableDataInfo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lhcredit.framework.aspectj.lang.annotation.Log;
import com.lhcredit.framework.aspectj.lang.enums.BusinessType;
import com.lhcredit.project.business.memberUnit.domain.MemberUnit;
import com.lhcredit.project.business.memberUnit.service.IMemberUnitService;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;


/**
 * 会员单位信息对外接口
 *
 * @author lhcredit
 * @date 2025-11-18
 */
@RestController
@RequestMapping("/web/memberUnit")
public class WebMemberUnitController extends BaseController {
    @Autowired
    private IMemberUnitService memberUnitService;

    /**
     * 查询会员单位列表接口
     */
    @ApiOperation("查询会员单位列表")
    @Log(title = "会员单位", businessType = BusinessType.LIST, operatorType = OperatorType.WEB)
    @PostMapping("/getList")
    public AjaxResult list(@RequestBody MemberUnit memberUnit) {
        startPage(memberUnit.getPageNum(), memberUnit.getPageSize());
        memberUnit.setDelStatus("0");
        List<MemberUnit> list = memberUnitService.selectMemberUnitList(memberUnit);
        return toAjax(list);
    }

    /**
     * 查询会员单位详情接口
     */
    @ApiOperation("查询会员单位详情")
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "int", paramType = "path")
    @Log(title = "会员单位", businessType = BusinessType.DETAIL, operatorType = OperatorType.WEB)
    @GetMapping("/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        MemberUnit memberUnit =memberUnitService.changeModel(memberUnitService.selectMemberUnitById(id));
        if (StringUtils.isNull(memberUnit)) {
            return AjaxResult.error("该信息不存在");
        }
        return toAjax(memberUnit);
    }

    /**
     * 新增保存会员单位接口
     */
    @ApiOperation("新增会员单位")
    @ApiImplicitParam(name = "memberUnit", value = "会员单位", dataType = "MemberUnit")
    @Log(title = "会员单位", businessType = BusinessType.INSERT, operatorType = OperatorType.WEB)
    @PostMapping
    public AjaxResult addSave(MemberUnit memberUnit) {
        memberUnit.setCreateBy(ShiroUtils.getLoginName());
        memberUnit.setCreateTime(new Date());
        memberUnit.setUpdateBy(ShiroUtils.getLoginName());
        memberUnit.setUpdateTime(new Date());
        return toAjax(memberUnitService.insertMemberUnit(memberUnit));
    }

    /**
     * 修改保存会员单位接口
     */
    @ApiOperation("修改会员单位")
    @ApiImplicitParam(name = "memberUnit", value = "会员单位", dataType = "MemberUnit")
    @Log(title = "会员单位", businessType = BusinessType.UPDATE, operatorType = OperatorType.WEB)
    @PutMapping
    public AjaxResult update(MemberUnit memberUnit) {
        if (StringUtils.isNull(memberUnit) || StringUtils.isNull(memberUnit.getId())){
            return AjaxResult.error("主键id不能为空");
        }
        memberUnit.setUpdateBy(ShiroUtils.getLoginName());
        memberUnit.setUpdateTime(new Date());
        return toAjax(memberUnitService.updateMemberUnit(memberUnit));
    }

    /**
     * 删除会员单位接口
     */
    @ApiOperation("删除会员单位")
    @ApiImplicitParam(name = "ids", value = "主键id,多条以英文逗号分隔", required = true, dataType = "String", paramType = "path")
    @Log(title = "会员单位", businessType = BusinessType.DELETE, operatorType = OperatorType.WEB)
    @DeleteMapping("/{ids}")
    public AjaxResult delete(@PathVariable String ids) {
        return toAjax(memberUnitService.deleteMemberUnitByIds(ids));
    }

}