1
luodangjia
2025-01-22 895ed97195660b0196b61f5da626ac6d18e2068d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.ruoyi.company.controller.front;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
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.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;
 
import java.util.List;
 
@RestController
@RequestMapping("/front/company")
@Tag(name = "企业端-企业相关接口")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class CompanyController {
    private final CompanyService companyService;
 
    @GetMapping("/getCompanyByUserId")
    public R<List<Company>> getCompanyByUserId(Long userId){
        List<Company> list = companyService.list(new LambdaQueryWrapper<Company>()
                .eq(Company::getUserId, userId));
        return R.ok(list);
    }
 
    @Operation(summary = "获取当前用户企业详情")
    @GetMapping("/getCompanyDetail")
    public R<Company> getCompanyDetail(){
        Long userId = SecurityUtils.getAppLoginUser().getUserId();
        Company company = companyService.getOne(new LambdaQueryWrapper<Company>()
                .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();
    }
}