1
luodangjia
2025-01-22 759e0540a7ca20f33ab265d00e7944e4f18a562b
ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/CompanyController.java
@@ -2,16 +2,17 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.company.api.domain.Company;
import com.ruoyi.company.api.domain.dto.MgtCompanyDTO;
import com.ruoyi.company.service.CompanyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -24,7 +25,6 @@
public class CompanyController {
    private final CompanyService companyService;
    @InnerAuth
    @GetMapping("/getCompanyByUserId")
    public R<List<Company>> getCompanyByUserId(Long userId){
        List<Company> list = companyService.list(new LambdaQueryWrapper<Company>()
@@ -40,4 +40,35 @@
                .eq(Company::getUserId, userId));
        return R.ok(company);
    }
    /**
     * 修改企业信息
     */
    @Operation(summary = "修改企业信息", tags = {"企业端"})
    @PutMapping("/updateCompany")
    public R<Void> updateCompany(@RequestBody MgtCompanyDTO mgtCompanyDTO){
        Long userId = SecurityUtils.getAppLoginUser().getUserId();
        Company companyDb = companyService.getOne(new LambdaQueryWrapper<Company>()
                .eq(Company::getUserId, userId));
        mgtCompanyDTO.setId(companyDb.getId());
        companyService.editCompany(mgtCompanyDTO);
        return R.ok();
    }
    /**
     * 修改企业联系方式
     */
    @Operation(summary = "修改企业联系方式", tags = {"企业端"})
    @PutMapping("/updateCompanyPhone")
    public R<Void> updateCompanyPhone(@RequestBody MgtCompanyDTO mgtCompanyDTO){
        Long userId = SecurityUtils.getAppLoginUser().getUserId();
        Company companyDb = companyService.getOne(new LambdaQueryWrapper<Company>()
                .eq(Company::getUserId, userId));
        companyDb.setContactName(mgtCompanyDTO.getContactName());
        companyDb.setContactPhone(mgtCompanyDTO.getContactPhone());
        companyDb.setEmail(mgtCompanyDTO.getEmail());
        companyService.updateById(companyDb);
        return R.ok();
    }
}