Commit a5cc8d5d by HlQ

[add] 引入 mybatis-plus-join-boot-starter 依赖

[chg] 用户绑定角色,角色绑定资源以及项目和合同互相绑定三个接口bug修改
1 parent 35883028
Showing 93 changed files with 478 additions and 302 deletions
...@@ -56,6 +56,11 @@ ...@@ -56,6 +56,11 @@
<version>3.5.4</version> <version>3.5.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>1.4.7.2</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>wx-java-mp-spring-boot-starter</artifactId> <artifactId>wx-java-mp-spring-boot-starter</artifactId>
<version>4.5.0</version> <version>4.5.0</version>
......
package vion; package vion;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import vion.third.DingMod;
@SpringBootApplication @SpringBootApplication
@MapperScan("vion.mapper") @MapperScan("vion.mapper")
...@@ -17,23 +12,4 @@ public class Application { ...@@ -17,23 +12,4 @@ public class Application {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(Application.class, args);
} }
@Autowired
private DingMod dingMod;
private final static Logger logger = LoggerFactory.getLogger(Application.class);
@Scheduled(cron = "${third.run.cron:0 0 2 * * ?}")
public void startJob() {
try {
logger.info("启动");
//定时获取钉钉用户列表
dingMod.getDeptList();
dingMod.getDingUserList();
logger.info("启动完成");
} catch (Exception e) {
e.printStackTrace();
}
}
} }
package vion.advice; package vion.advice;
import cn.dev33.satoken.exception.NotLoginException; import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.NotPermissionException;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -71,5 +72,11 @@ public class ResBodyAdvice implements ResponseBodyAdvice<Object> { ...@@ -71,5 +72,11 @@ public class ResBodyAdvice implements ResponseBodyAdvice<Object> {
log.error("未登录", e.getMessage()); log.error("未登录", e.getMessage());
return ResultUtil.error(401, "请重新登录"); return ResultUtil.error(401, "请重新登录");
} }
@ExceptionHandler(NotPermissionException.class)
public ResultVO notPermissionExceptionHandler(NotPermissionException e) {
log.error("无权限", e.getMessage());
return ResultUtil.error(500, "缺少权限:" + e.getPermission());
}
} }
...@@ -20,19 +20,19 @@ public class AccountController { ...@@ -20,19 +20,19 @@ public class AccountController {
private final IAccountService accountService; private final IAccountService accountService;
@GetMapping("/accounts") @GetMapping("/accounts")
@SaCheckPermission(value = "account:list", orRole="admin") @SaCheckPermission(value = "account:list", orRole = "admin")
public Page<Account> getAccountList(BaseDTO dto) { public Page<Account> getAccountList(BaseDTO dto) {
return accountService.page(Page.of(dto.getPageNum(), dto.getPageSize())); return accountService.page(Page.of(dto.getPageNum(), dto.getPageSize()));
} }
@GetMapping("/account") @GetMapping("/account")
@SaCheckPermission(value = "account:query", orRole="admin") @SaCheckPermission(value = "account:query", orRole = "admin")
public Account getProductByID(Integer id) { public Account getProductByID(Integer id) {
return accountService.getById(id); return accountService.getById(id);
} }
@PostMapping("/accounts") @PostMapping("/accounts")
@SaCheckPermission(value = "account:editAndSave", orRole="admin") @SaCheckPermission(value = "account:editAndSave", orRole = "admin")
public Account saveOrUpdate(@RequestBody Account data) { public Account saveOrUpdate(@RequestBody Account data) {
accountService.save(data); accountService.save(data);
return data; return data;
......
package vion.controller; package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.cron.ContractRunner; import vion.cron.ContractRunner;
import vion.dto.ContractDTO; import vion.dto.ContractDTO;
import vion.dto.RContractStoreDTO;
import vion.model.RContractStore; import vion.model.RContractStore;
import vion.service.IContractService; import vion.service.IContractService;
import vion.service.IRContractStoreService; import vion.service.IRContractStoreService;
import vion.vo.ContractVO; import vion.vo.ContractVO;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 合同管理 * 合同管理
...@@ -28,31 +34,67 @@ public class ContractController { ...@@ -28,31 +34,67 @@ public class ContractController {
private final Converter converter; private final Converter converter;
@GetMapping("/contract") @GetMapping("/contract")
@SaCheckPermission(value = "contract:list", orRole="admin") @SaCheckPermission(value = "contract:list", orRole = "admin")
public Page<ContractVO> list(ContractDTO dto) { public Page<ContractVO> list(ContractDTO dto) {
return contractService.list(dto); return contractService.list(dto);
} }
@GetMapping("/contract/{id}") @GetMapping("/contract/{id}")
@SaCheckPermission(value = "contract:query", orRole="admin") @SaCheckPermission(value = "contract:query", orRole = "admin")
public ContractVO getById(@PathVariable Long id) { public ContractVO getById(@PathVariable Long id) {
return converter.convert(contractService.getById(id), new ContractVO()); return converter.convert(contractService.getById(id), new ContractVO());
} }
@PostMapping("/contract/{id}") @PostMapping("/contract/{id}")
@SaCheckPermission(value = "contract:edit", orRole="admin") @SaCheckPermission(value = "contract:edit", orRole = "admin")
public String updateById(@PathVariable Long id, ContractDTO dto) { public String updateById(@PathVariable Long id, ContractDTO dto) {
return contractService.updateById(id, dto); return contractService.updateById(id, dto);
} }
@PostMapping("/contract/store") @PostMapping("/contract/store")
@SaCheckPermission(value = "contract:store:edit", orRole = "admin") @SaCheckPermission(value = "contract:store:edit", orRole = "admin")
public String saveOrUpdateRContractStore(@RequestBody List<RContractStore> contractStoreList) { public String saveOrUpdateRContractStore(@RequestBody RContractStoreDTO dto) {
return contractStoreService.saveBatch(contractStoreList) ? "更新成功" : "更新失败"; Assert.isFalse(ArrayUtil.isAllNotNull(dto.getStoreId(), dto.getContractId()), "合同id和项目id不能同时传值");
if (ObjUtil.isNotNull(dto.getContractId())) {
Opt.ofEmptyAble(dto.getStoreIds())
.ifPresent(storeIds -> {
List<RContractStore> contractStoreList = storeIds.stream()
.map(storeId -> {
RContractStore contractStore = new RContractStore();
contractStore.setContractId(dto.getContractId());
contractStore.setStoreId(storeId);
return contractStore;
}).collect(Collectors.toList());
contractStoreService.saveBatch(contractStoreList);
});
}
if (ObjUtil.isNotNull(dto.getStoreId())) {
Opt.ofEmptyAble(dto.getContractIds())
.ifPresent(contractIds -> {
List<RContractStore> contractStoreList = contractIds.stream()
.map(contractId -> {
RContractStore contractStore = new RContractStore();
contractStore.setContractId(contractId);
contractStore.setStoreId(dto.getStoreId());
return contractStore;
}).collect(Collectors.toList());
contractStoreService.saveBatch(contractStoreList);
});
}
return "成功";
}
@GetMapping("/contract/store")
@SaCheckPermission(value = "contract:store:query", orRole = "admin")
public List<RContractStore> getRContractStore(Long contractId, Long storeId) {
return contractStoreService.lambdaQuery()
.eq(ObjUtil.isNotNull(contractId), RContractStore::getContractId, contractId)
.eq(ObjUtil.isNotNull(storeId), RContractStore::getStoreId, storeId)
.list();
} }
@PostMapping("/contractSync") @PostMapping("/contractSync")
@SaCheckPermission(value = "contract:sync", orRole="admin") @SaCheckPermission(value = "contract:sync", orRole = "admin")
public String manualSyncContract() { public String manualSyncContract() {
return contractRunner.contractSync() ? "成功" : "失败"; return contractRunner.contractSync() ? "成功" : "失败";
} }
......
...@@ -21,8 +21,14 @@ public class ContractPaymentController { ...@@ -21,8 +21,14 @@ public class ContractPaymentController {
private final IContractPaymentService contractPaymentService; private final IContractPaymentService contractPaymentService;
private final Converter converter; private final Converter converter;
@GetMapping("/contractPayment/{id}")
@SaCheckPermission(value = "contractPayment:query", orRole = "admin")
public List<ContractPayment> getPaymentById(@PathVariable Long id) {
return contractPaymentService.lambdaQuery().eq(ContractPayment::getContractId, id).list();
}
@PostMapping("/contractPayment") @PostMapping("/contractPayment")
@SaCheckPermission(value = "contractPayment:edit", orRole="admin") @SaCheckPermission(value = "contractPayment:edit", orRole = "admin")
public String updPayment(@RequestBody List<ContractPaymentDTO> dtoList) { public String updPayment(@RequestBody List<ContractPaymentDTO> dtoList) {
return contractPaymentService.saveBatch(converter.convert(dtoList, ContractPayment.class)) ? "更新成功" : "更新失败"; return contractPaymentService.saveBatch(converter.convert(dtoList, ContractPayment.class)) ? "更新成功" : "更新失败";
} }
......
...@@ -25,20 +25,20 @@ public class DictionaryController { ...@@ -25,20 +25,20 @@ public class DictionaryController {
private final Converter converter; private final Converter converter;
@GetMapping("/dictionarys") @GetMapping("/dictionarys")
@SaCheckPermission(value = "dict:list", orRole="admin") @SaCheckPermission(value = "dict:list", orRole = "admin")
public Page<Dictionary> getDictionaryList(DictionaryDTO data) { public Page<Dictionary> getDictionaryList(DictionaryDTO data) {
return dictionaryService.lambdaQuery(converter.convert(data, new Dictionary())) return dictionaryService.lambdaQuery(converter.convert(data, new Dictionary()))
.page(Page.of(data.getPageNum(), data.getPageSize())); .page(Page.of(data.getPageNum(), data.getPageSize()));
} }
@GetMapping("/dictionary") @GetMapping("/dictionary")
@SaCheckPermission(value = "dict:query", orRole="admin") @SaCheckPermission(value = "dict:query", orRole = "admin")
public Object getDictionaryByID(@RequestParam(name = "id") Integer id) { public Object getDictionaryById(Long id) {
return dictionaryService.getById(id); return dictionaryService.getById(id);
} }
@PostMapping("/dictionary") @PostMapping("/dictionary")
@SaCheckPermission(value = "dict:editAndSave", orRole="admin") @SaCheckPermission(value = "dict:editAndSave", orRole = "admin")
public String saveOrUpdateDictionary(@RequestBody DictionaryDTO data) { public String saveOrUpdateDictionary(@RequestBody DictionaryDTO data) {
Dictionary dictionary = converter.convert(data, new Dictionary()); Dictionary dictionary = converter.convert(data, new Dictionary());
return dictionaryService.saveOrUpdate(dictionary) ? "成功" : "失败"; return dictionaryService.saveOrUpdate(dictionary) ? "成功" : "失败";
...@@ -53,7 +53,7 @@ public class DictionaryController { ...@@ -53,7 +53,7 @@ public class DictionaryController {
@GetMapping("/dictionaryType") @GetMapping("/dictionaryType")
@SaCheckPermission(value = "dict:type:query", orRole = "admin") @SaCheckPermission(value = "dict:type:query", orRole = "admin")
public Object getDictionaryTypeByID(@RequestParam Integer id) { public Object getDictionaryTypeById(@RequestParam Integer id) {
return dictionaryTypeService.getById(id); return dictionaryTypeService.getById(id);
} }
......
...@@ -23,26 +23,26 @@ public class InspectController { ...@@ -23,26 +23,26 @@ public class InspectController {
private final Converter converter; private final Converter converter;
@GetMapping("/inspects") @GetMapping("/inspects")
@SaCheckPermission(value = "inspect:list", orRole="admin") @SaCheckPermission(value = "inspect:list", orRole = "admin")
public Page<Inspect> getInspectList(InspectDTO data) { public Page<Inspect> getInspectList(InspectDTO data) {
return inspectService.getInspectList(data); return inspectService.getInspectList(data);
} }
@GetMapping("/inspect") @GetMapping("/inspect")
@SaCheckPermission(value = "inspect:query", orRole="admin") @SaCheckPermission(value = "inspect:query", orRole = "admin")
public Inspect getProductById(@RequestParam(name = "id") Integer id) { public Inspect getProductById(@RequestParam(name = "id") Integer id) {
return inspectService.getById(id); return inspectService.getById(id);
} }
@PostMapping("/inspects") @PostMapping("/inspects")
@SaCheckPermission(value = "inspect:editAndSave", orRole="admin") @SaCheckPermission(value = "inspect:editAndSave", orRole = "admin")
public String saveOrUpdate(@RequestBody InspectDTO data) { public String saveOrUpdate(@RequestBody InspectDTO data) {
Inspect inspect = converter.convert(data, new Inspect()); Inspect inspect = converter.convert(data, new Inspect());
return inspectService.saveOrUpdate(inspect) ? "成功" : "失败"; return inspectService.saveOrUpdate(inspect) ? "成功" : "失败";
} }
@PostMapping("/updateInspectStatus") @PostMapping("/updateInspectStatus")
@SaCheckPermission(value = "inspect:editStatus", orRole="admin") @SaCheckPermission(value = "inspect:editStatus", orRole = "admin")
public String UpdateStatus(@RequestBody InspectDTO data) { public String UpdateStatus(@RequestBody InspectDTO data) {
boolean result = inspectService.lambdaUpdate() boolean result = inspectService.lambdaUpdate()
.eq(Inspect::getId, data.getId()) .eq(Inspect::getId, data.getId())
......
...@@ -22,19 +22,19 @@ public class ProductController { ...@@ -22,19 +22,19 @@ public class ProductController {
private final Converter converter; private final Converter converter;
@GetMapping("/products") @GetMapping("/products")
@SaCheckPermission(value = "product:list", orRole="admin") @SaCheckPermission(value = "product:list", orRole = "admin")
public Page<ProductVO> getProductList(ProductDTO productDTO) { public Page<ProductVO> getProductList(ProductDTO productDTO) {
return productService.getProductList(productDTO); return productService.getProductList(productDTO);
} }
@GetMapping("/product") @GetMapping("/product")
@SaCheckPermission(value = "product:query", orRole="admin") @SaCheckPermission(value = "product:query", orRole = "admin")
public Product getProductByID(@RequestParam Long projectId) { public Product getProductByID(@RequestParam Long projectId) {
return productService.getById(projectId); return productService.getById(projectId);
} }
@PostMapping("/products") @PostMapping("/products")
@SaCheckPermission(value = "product:editAndSave", orRole="admin") @SaCheckPermission(value = "product:editAndSave", orRole = "admin")
public String saveOrUpdate(@RequestBody ProductDTO productDTO) { public String saveOrUpdate(@RequestBody ProductDTO productDTO) {
Product data = converter.convert(productDTO, new Product()); Product data = converter.convert(productDTO, new Product());
return productService.saveOrUpdate(data) ? "成功" : "失败"; return productService.saveOrUpdate(data) ? "成功" : "失败";
......
package vion.controller; package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import io.github.linpeilie.Converter; import cn.hutool.core.lang.Opt;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -23,14 +23,21 @@ import java.util.stream.Collectors; ...@@ -23,14 +23,21 @@ import java.util.stream.Collectors;
public class RRoleResourceController { public class RRoleResourceController {
private final IRRoleResourceService roleResourceService; private final IRRoleResourceService roleResourceService;
private final Converter converter;
@PostMapping("/rRoleRes") @PostMapping("/rRoleRes")
@SaCheckPermission(value = "role:resource:edit", orRole = "admin") @SaCheckPermission(value = "role:resource:edit", orRole = "admin")
public String saveOrUpdateRUserRole(@RequestBody List<RRoleResourceDTO> dto) { public String saveOrUpdateRUserRole(@RequestBody RRoleResourceDTO dto) {
List<Long> roleIdList = dto.stream().map(RRoleResourceDTO::getRoleId).collect(Collectors.toList()); roleResourceService.lambdaUpdate().in(RRoleResource::getRoleId, dto.getRoleId()).remove();
roleResourceService.lambdaUpdate().in(RRoleResource::getRoleId, roleIdList).remove(); Opt.ofEmptyAble(dto.getResourceIds()).ifPresent(l -> {
return roleResourceService.saveBatch(converter.convert(dto, RRoleResource.class)) ? "创建成功" : "创建失败"; List<RRoleResource> list = l.stream().map(resourceId -> {
RRoleResource rRoleResource = new RRoleResource();
rRoleResource.setRoleId(dto.getRoleId());
rRoleResource.setResourceId(resourceId);
return rRoleResource;
}).collect(Collectors.toList());
roleResourceService.saveBatch(list);
});
return "成功";
} }
} }
package vion.controller; package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import io.github.linpeilie.Converter; import cn.hutool.core.lang.Opt;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vion.dto.RUserRoleDTO; import vion.dto.RUserRoleDTO;
import vion.model.RUserRole; import vion.model.RUserRole;
import vion.service.IRUserRoleService; import vion.service.IRUserRoleService;
...@@ -20,13 +23,20 @@ import java.util.stream.Collectors; ...@@ -20,13 +23,20 @@ import java.util.stream.Collectors;
public class RUserRoleController { public class RUserRoleController {
private final IRUserRoleService rUserRoleService; private final IRUserRoleService rUserRoleService;
private final Converter converter;
@PostMapping("/rUserRole") @PostMapping("/rUserRole")
@SaCheckPermission(value = "user:role:edit", orRole = "admin") @SaCheckPermission(value = "user:role:edit", orRole = "admin")
public String saveOrUpdateRUserRole(@RequestBody List<RUserRoleDTO> dto) { public String saveOrUpdateRUserRole(@RequestBody RUserRoleDTO dto) {
List<Long> userIdList = dto.stream().map(RUserRoleDTO::getUserId).collect(Collectors.toList()); rUserRoleService.lambdaUpdate().in(RUserRole::getUserId, dto.getUserId()).remove();
rUserRoleService.lambdaUpdate().in(RUserRole::getUserId, userIdList).remove(); Opt.ofEmptyAble(dto.getRoleIds()).ifPresent(l -> {
return rUserRoleService.saveBatch(converter.convert(dto, RUserRole.class)) ? "创建成功" : "创建失败"; List<RUserRole> list = l.stream().map(roleId -> {
RUserRole rUserRole = new RUserRole();
rUserRole.setUserId(dto.getUserId());
rUserRole.setRoleId(roleId);
return rUserRole;
}).collect(Collectors.toList());
rUserRoleService.saveBatch(list);
});
return "成功";
} }
} }
...@@ -16,7 +16,6 @@ import java.util.List; ...@@ -16,7 +16,6 @@ import java.util.List;
/** /**
* 资源管理 * 资源管理
*
*/ */
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
...@@ -27,33 +26,33 @@ public class ResourceController { ...@@ -27,33 +26,33 @@ public class ResourceController {
private final Converter converter; private final Converter converter;
@GetMapping("/resource") @GetMapping("/resource")
@SaCheckPermission(value = "resource:list", orRole="admin") @SaCheckPermission(value = "resource:list", orRole = "admin")
public Page<ResourceVO> list(ResourceDTO dto) { public Page<ResourceVO> list(ResourceDTO dto) {
return resourceService.list(dto); return resourceService.list(dto);
} }
@GetMapping("/resource/tree") @GetMapping("/resource/tree")
@SaCheckPermission @SaCheckPermission(value = "resource:tree", orRole = "admin")
public List<Tree<Long>> listTree(Long id) { public List<Tree<Long>> listTree(Long id) {
return resourceService.listTree(id); return resourceService.listTree(id);
} }
@GetMapping("/resource/{id}") @GetMapping("/resource/{id}")
@SaCheckPermission(value = "resource:query", orRole="admin") @SaCheckPermission(value = "resource:query", orRole = "admin")
public ResourceVO getRoleById(@PathVariable Long id) { public ResourceVO getRoleById(@PathVariable Long id) {
Resource resource = resourceService.getById(id); Resource resource = resourceService.getById(id);
return converter.convert(resource, new ResourceVO()); return converter.convert(resource, new ResourceVO());
} }
@PostMapping("/resource") @PostMapping("/resource")
@SaCheckPermission(value = "resource:save", orRole="admin") @SaCheckPermission(value = "resource:save", orRole = "admin")
private String save(@RequestBody ResourceDTO dto) { private String save(@RequestBody ResourceDTO dto) {
Resource resource = converter.convert(dto, new Resource()); Resource resource = converter.convert(dto, new Resource());
return resourceService.save(resource) ? "创建成功" : "创建失败"; return resourceService.save(resource) ? "创建成功" : "创建失败";
} }
@PostMapping("/resource/{id}") @PostMapping("/resource/{id}")
@SaCheckPermission(value = "resource:edit", orRole="admin") @SaCheckPermission(value = "resource:edit", orRole = "admin")
private String update(@PathVariable Long id, @RequestBody RoleDTO dto) { private String update(@PathVariable Long id, @RequestBody RoleDTO dto) {
Resource resource = converter.convert(dto, new Resource()); Resource resource = converter.convert(dto, new Resource());
resource.setId(id); resource.setId(id);
...@@ -61,7 +60,7 @@ public class ResourceController { ...@@ -61,7 +60,7 @@ public class ResourceController {
} }
@DeleteMapping("/resource/{id}") @DeleteMapping("/resource/{id}")
@SaCheckPermission(value = "resource:remove", orRole="admin") @SaCheckPermission(value = "resource:remove", orRole = "admin")
private String remove(@PathVariable Long id) { private String remove(@PathVariable Long id) {
return resourceService.removeById(id) ? "删除成功" : "删除失败"; return resourceService.removeById(id) ? "删除成功" : "删除失败";
} }
......
...@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission; ...@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Opt; import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -20,7 +21,6 @@ import java.util.stream.Collectors; ...@@ -20,7 +21,6 @@ import java.util.stream.Collectors;
/** /**
* 角色管理 * 角色管理
*
*/ */
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
...@@ -35,41 +35,50 @@ public class RoleController { ...@@ -35,41 +35,50 @@ public class RoleController {
private final Converter converter; private final Converter converter;
@GetMapping("/role") @GetMapping("/role")
@SaCheckPermission(value = "role:list", orRole="admin") @SaCheckPermission(value = "role:list", orRole = "admin")
public Page<RoleVO> list(RoleDTO dto) { public Page<RoleVO> list(RoleDTO dto) {
return roleService.list(dto); return roleService.list(dto);
} }
@GetMapping("/role/{id}") @GetMapping("/role/{id}")
@SaCheckPermission(value = "role:query", orRole="admin") @SaCheckPermission(value = "role:query", orRole = "admin")
public RoleVO getRoleById(@PathVariable Long id) { public RoleVO getRoleById(@PathVariable Long id) {
Role role = roleService.getById(id); Role role = roleService.getById(id);
return converter.convert(role, new RoleVO()); return converter.convert(role, new RoleVO());
} }
@PostMapping("/role") @PostMapping("/role")
@SaCheckPermission(value = "role:save", orRole="admin") @SaCheckPermission(value = "role:save", orRole = "admin")
private String save(@RequestBody RoleDTO dto) { private String save(@RequestBody RoleDTO dto) {
if (StrUtil.equals(dto.getCode(), "admin")) {
return "管理员角色编码[admin]已存在,不允许再次创建";
}
Role role = converter.convert(dto, new Role()); Role role = converter.convert(dto, new Role());
return roleService.save(role) ? "创建成功" : "创建失败"; return roleService.save(role) ? "创建成功" : "创建失败";
} }
@PostMapping("/role/{id}") @PostMapping("/role/{id}")
@SaCheckPermission(value = "role:edit", orRole="admin") @SaCheckPermission(value = "role:edit", orRole = "admin")
private String update(@PathVariable Long id, @RequestBody RoleDTO dto) { private String update(@PathVariable Long id, @RequestBody RoleDTO dto) {
if (id == 1) {
return "管理员角色不允许修改";
}
Role role = converter.convert(dto, new Role()); Role role = converter.convert(dto, new Role());
role.setId(id); role.setId(id);
return roleService.updateById(role) ? "更新成功" : "更新失败"; return roleService.updateById(role) ? "更新成功" : "更新失败";
} }
@DeleteMapping("/role/{id}") @DeleteMapping("/role/{id}")
@SaCheckPermission(value = "role:remove", orRole="admin") @SaCheckPermission(value = "role:remove", orRole = "admin")
private String remove(@PathVariable Long id) { private String remove(@PathVariable Long id) {
if (id == 1) {
return "管理员角色不允许删除";
}
return roleService.removeById(id) ? "删除成功" : "删除失败"; return roleService.removeById(id) ? "删除成功" : "删除失败";
} }
@GetMapping("/role/user/{id}") @GetMapping("/role/user/{id}")
@SaCheckPermission(value = "role:user", orRole="admin") @SaCheckPermission(value = "role:user", orRole = "admin")
public List<UserVO> listUserById(@PathVariable Long id) { public List<UserVO> listUserById(@PathVariable Long id) {
List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getRoleId, id).list(); List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getRoleId, id).list();
List<User> userList = Opt.ofEmptyAble(userRoleList) List<User> userList = Opt.ofEmptyAble(userRoleList)
...@@ -81,7 +90,7 @@ public class RoleController { ...@@ -81,7 +90,7 @@ public class RoleController {
} }
@GetMapping("/role/resource/{id}") @GetMapping("/role/resource/{id}")
@SaCheckPermission(value = "role:resource", orRole="admin") @SaCheckPermission(value = "role:resource", orRole = "admin")
public List<ResourceVO> listResourceById(@PathVariable Long id) { public List<ResourceVO> listResourceById(@PathVariable Long id) {
List<RRoleResource> roleResourceList = roleResourceService.lambdaQuery().eq(RRoleResource::getRoleId, id).list(); List<RRoleResource> roleResourceList = roleResourceService.lambdaQuery().eq(RRoleResource::getRoleId, id).list();
List<Resource> resourceList = Opt.ofEmptyAble(roleResourceList) List<Resource> resourceList = Opt.ofEmptyAble(roleResourceList)
......
...@@ -33,13 +33,13 @@ public class ServiceOrderController { ...@@ -33,13 +33,13 @@ public class ServiceOrderController {
private final Converter converter; private final Converter converter;
@GetMapping("/order/{id}") @GetMapping("/order/{id}")
@SaCheckPermission(value = "order:query", orRole="admin") @SaCheckPermission(value = "order:query", orRole = "admin")
public ServiceOrder getOrderById(@PathVariable Long id) { public ServiceOrder getOrderById(@PathVariable Long id) {
return serviceOrderService.getById(id); return serviceOrderService.getById(id);
} }
@PostMapping("/order") @PostMapping("/order")
@SaCheckPermission(value = "order:save", orRole="admin") @SaCheckPermission(value = "order:save", orRole = "admin")
private Object save(@RequestBody ServiceOrderDTO serviceOrderDTO) { private Object save(@RequestBody ServiceOrderDTO serviceOrderDTO) {
Long count = serviceOrderService.lambdaQuery().eq(ServiceOrder::getTaskId, serviceOrderDTO.getTaskId()).count(); Long count = serviceOrderService.lambdaQuery().eq(ServiceOrder::getTaskId, serviceOrderDTO.getTaskId()).count();
Assert.isFalse(count > 0, "该工单已存在服务单,不能重复创建!"); Assert.isFalse(count > 0, "该工单已存在服务单,不能重复创建!");
...@@ -49,7 +49,7 @@ public class ServiceOrderController { ...@@ -49,7 +49,7 @@ public class ServiceOrderController {
} }
@PostMapping("/order/{id}") @PostMapping("/order/{id}")
@SaCheckPermission(value = "order:edit", orRole="admin") @SaCheckPermission(value = "order:edit", orRole = "admin")
private String update(@PathVariable Long id, @RequestBody ServiceOrderDTO serviceOrderDTO) { private String update(@PathVariable Long id, @RequestBody ServiceOrderDTO serviceOrderDTO) {
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder()); ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
serviceOrder.setId(id); serviceOrder.setId(id);
...@@ -57,7 +57,7 @@ public class ServiceOrderController { ...@@ -57,7 +57,7 @@ public class ServiceOrderController {
} }
@DeleteMapping("/order/{id}") @DeleteMapping("/order/{id}")
@SaCheckPermission(value = "order:remove", orRole="admin") @SaCheckPermission(value = "order:remove", orRole = "admin")
private String remove(@PathVariable Long id) { private String remove(@PathVariable Long id) {
return serviceOrderService.removeById(id) ? "删除成功" : "删除失败"; return serviceOrderService.removeById(id) ? "删除成功" : "删除失败";
} }
...@@ -76,7 +76,7 @@ public class ServiceOrderController { ...@@ -76,7 +76,7 @@ public class ServiceOrderController {
/** /**
* 签字专用更新接口 * 签字专用更新接口
* *
* @param unid 服务单unid * @param unid 服务单unid
* @param serviceOrderDTO dto * @param serviceOrderDTO dto
* @return java.lang.String * @return java.lang.String
*/ */
...@@ -87,7 +87,7 @@ public class ServiceOrderController { ...@@ -87,7 +87,7 @@ public class ServiceOrderController {
} }
@GetMapping("/order/pushWechat") @GetMapping("/order/pushWechat")
@SaCheckPermission(value = "order:wechatPush", orRole="admin") @SaCheckPermission(value = "order:wechatPush", orRole = "admin")
public String sendOrder(Long id) { public String sendOrder(Long id) {
return serviceOrderService.sendOrder(id); return serviceOrderService.sendOrder(id);
} }
......
...@@ -76,9 +76,9 @@ public class StoreController { ...@@ -76,9 +76,9 @@ public class StoreController {
return storeService.updateStoreStage(statusDTO, token); return storeService.updateStoreStage(statusDTO, token);
} }
@GetMapping("/store/contract/{id}") // 未用到
// @GetMapping("/store/contract/{id}")
@SaCheckPermission(value = "store:contract", orRole="admin") @SaCheckPermission(value = "store:contract", orRole="admin")
// todo 权限未加库
public List<ContractVO> listContractById(@PathVariable Long id) { public List<ContractVO> listContractById(@PathVariable Long id) {
List<RContractStore> contractStoreList = contractStoreService.lambdaQuery().eq(RContractStore::getStoreId, id).list(); List<RContractStore> contractStoreList = contractStoreService.lambdaQuery().eq(RContractStore::getStoreId, id).list();
List<Long> contractIdList = contractStoreList.stream().map(RContractStore::getContractId).collect(Collectors.toList()); List<Long> contractIdList = contractStoreList.stream().map(RContractStore::getContractId).collect(Collectors.toList());
......
...@@ -24,19 +24,19 @@ public class TaskController { ...@@ -24,19 +24,19 @@ public class TaskController {
private final IFaultLogService faultLogService; private final IFaultLogService faultLogService;
@GetMapping("/tasks") @GetMapping("/tasks")
@SaCheckPermission(value = "task:list", orRole="admin") @SaCheckPermission(value = "task:list", orRole = "admin")
public Page<TaskVO> getTaskList(TaskDTO data) { public Page<TaskVO> getTaskList(TaskDTO data) {
return taskService.getTaskList(data); return taskService.getTaskList(data);
} }
@GetMapping("/task") @GetMapping("/task")
@SaCheckPermission(value = "task:query", orRole="admin") @SaCheckPermission(value = "task:query", orRole = "admin")
public TaskVO getTaskById(Long taskId) { public TaskVO getTaskById(Long taskId) {
return taskService.getTaskById(taskId); return taskService.getTaskById(taskId);
} }
@PostMapping("/tasks") @PostMapping("/tasks")
@SaCheckPermission(value = "task:editAndSave", orRole="admin") @SaCheckPermission(value = "task:editAndSave", orRole = "admin")
public Long saveOrUpdate(TaskDTO data, @RequestHeader String token) { public Long saveOrUpdate(TaskDTO data, @RequestHeader String token) {
return taskService.circTask(data, token); return taskService.circTask(data, token);
} }
......
...@@ -17,8 +17,8 @@ import javax.servlet.http.HttpServletResponse; ...@@ -17,8 +17,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
/** /**
* 预工单 * 预工单
*/ */
@RestController @RestController
@RequestMapping(Global.BASE_URL) @RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor @RequiredArgsConstructor
...@@ -30,19 +30,19 @@ public class TaskTempController { ...@@ -30,19 +30,19 @@ public class TaskTempController {
private final Converter converter; private final Converter converter;
@GetMapping("/taskTemps") @GetMapping("/taskTemps")
@SaCheckPermission(value = "taskTemp:list", orRole="admin") @SaCheckPermission(value = "taskTemp:list", orRole = "admin")
public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) { public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) {
return taskTempService.getTaskTempList(data); return taskTempService.getTaskTempList(data);
} }
@GetMapping("/taskTemp") @GetMapping("/taskTemp")
@SaCheckPermission(value = "taskTemp:query", orRole="admin") @SaCheckPermission(value = "taskTemp:query", orRole = "admin")
public TaskTempVO getTaskTempById(Long id) { public TaskTempVO getTaskTempById(Long id) {
return taskTempService.getTaskTempById(id); return taskTempService.getTaskTempById(id);
} }
@PostMapping("/taskTemp") @PostMapping("/taskTemp")
@SaCheckPermission(value = "taskTemp:editAndSave", orRole="admin") @SaCheckPermission(value = "taskTemp:editAndSave", orRole = "admin")
public Object saveOrUpdateTaskTemp(TaskTempDTO data) { public Object saveOrUpdateTaskTemp(TaskTempDTO data) {
return taskTempService.saveOrUpdTaskTemp(data); return taskTempService.saveOrUpdTaskTemp(data);
} }
...@@ -59,7 +59,7 @@ public class TaskTempController { ...@@ -59,7 +59,7 @@ public class TaskTempController {
} }
@PostMapping("/taskTemp/{id}") @PostMapping("/taskTemp/{id}")
@SaCheckPermission(value = "taskTemp:edit", orRole="admin") @SaCheckPermission(value = "taskTemp:edit", orRole = "admin")
public String upd(@PathVariable(name = "id") Long id, TaskTempDTO data) { public String upd(@PathVariable(name = "id") Long id, TaskTempDTO data) {
TaskTemp taskTemp = converter.convert(data, new TaskTemp()); TaskTemp taskTemp = converter.convert(data, new TaskTemp());
taskTemp.setId(id); taskTemp.setId(id);
......
...@@ -48,24 +48,23 @@ public class UserController { ...@@ -48,24 +48,23 @@ public class UserController {
private final WechatMod wechatMod; private final WechatMod wechatMod;
@GetMapping("/users") @GetMapping("/users")
@SaCheckPermission(value = "user:list", orRole="admin") @SaCheckPermission(value = "user:list", orRole = "admin")
public Page<User> getUserList(UserDTO dto) { public Page<UserVO> getUserList(UserDTO dto) {
return userService.lambdaQuery(converter.convert(dto, new User())) return userService.getUserList(dto);
.orderByDesc(User::getModifyTime)
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
} }
@GetMapping("/user") @GetMapping("/user")
@SaCheckPermission(value = "user:query", orRole="admin") @SaCheckPermission(value = "user:query", orRole = "admin")
public User getUserByID(@RequestParam(name = "id") Integer id) { public User getUserByID(@RequestParam(name = "id") Integer id) {
return userService.getById(id); return userService.getById(id);
} }
@PostMapping("/user") @PostMapping("/user")
@SaCheckPermission(value = "user:edit", orRole="admin") @SaCheckPermission(value = "user:edit", orRole = "admin")
public String update(@RequestBody List<User> data) { public String update(@RequestBody List<User> data) {
return Opt.ofEmptyAble(data).map(userService::updateBatchById).orElse(false) ? "更新成功" : "更新失败"; return Opt.ofEmptyAble(data).map(userService::updateBatchById).orElse(false) ? "更新成功" : "更新失败";
} }
@GetMapping("/user/{token}") @GetMapping("/user/{token}")
@SaCheckPermission(value = "user:token:query", orRole = "admin") @SaCheckPermission(value = "user:token:query", orRole = "admin")
public UserVO getUserByToken(@PathVariable String token) { public UserVO getUserByToken(@PathVariable String token) {
...@@ -73,14 +72,13 @@ public class UserController { ...@@ -73,14 +72,13 @@ public class UserController {
} }
@GetMapping("/orgTree") @GetMapping("/orgTree")
@SaCheckPermission(value = "user:orgTree", orRole="admin") @SaCheckPermission(value = "user:orgTree", orRole = "admin")
public List<Tree<String>> getOrgTree(String deptId) { public List<Tree<String>> getOrgTree(String deptId) {
return userService.getOrgTree(deptId); return userService.getOrgTree(deptId);
} }
@GetMapping("/user/role/{id}") @GetMapping("/user/role/{id}")
@SaCheckPermission(value = "user:role", orRole="admin") @SaCheckPermission(value = "user:role", orRole = "admin")
// todo 权限未加库
public List<RoleVO> listRoleById(@PathVariable Long id) { public List<RoleVO> listRoleById(@PathVariable Long id) {
List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getUserId, id).list(); List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getUserId, id).list();
List<Role> roleList = Opt.ofEmptyAble(userRoleList) List<Role> roleList = Opt.ofEmptyAble(userRoleList)
......
package vion.cron;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import vion.third.DingMod;
/**
* @author HlQ
* @date 2023/11/30
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class OrgRunner {
private final DingMod dingMod;
@Scheduled(cron = "0 0 2 * * ?")
public void syncOrg() {
log.info("钉钉组织关系同步启动");
dingMod.getDeptList();
dingMod.getDingUserList();
log.info("钉钉组织关系同步完成");
}
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class RContractStoreDTO {
private Long id;
/**
* 合同ID
*/
private Long contractId;
/**
* 项目ID
*/
private Long storeId;
private List<Long> contractIds;
private List<Long> storeIds;
}
\ No newline at end of file \ No newline at end of file
...@@ -3,6 +3,8 @@ package vion.dto; ...@@ -3,6 +3,8 @@ package vion.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
...@@ -21,5 +23,7 @@ public class RRoleResourceDTO extends BaseDTO { ...@@ -21,5 +23,7 @@ public class RRoleResourceDTO extends BaseDTO {
*/ */
private Long resourceId; private Long resourceId;
private List<Long> resourceIds;
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,6 +3,8 @@ package vion.dto; ...@@ -3,6 +3,8 @@ package vion.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
...@@ -20,4 +22,6 @@ public class RUserRoleDTO extends BaseDTO { ...@@ -20,4 +22,6 @@ public class RUserRoleDTO extends BaseDTO {
* 角色id * 角色id
*/ */
private Long roleId; private Long roleId;
private List<Long> roleIds;
} }
\ No newline at end of file \ No newline at end of file
...@@ -15,7 +15,6 @@ public class UserDTO extends BaseDTO { ...@@ -15,7 +15,6 @@ public class UserDTO extends BaseDTO {
private Long id; private Long id;
private String userid; private String userid;
private String username; private String username;
private String password;
private String phone; private String phone;
private Long deptId; private Long deptId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
......
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Account; import vion.model.Account;
public interface AccountMapper extends BaseMapper<Account> { public interface AccountMapper extends MPJBaseMapper<Account> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Address; import vion.model.Address;
public interface AddressMapper extends BaseMapper<Address> { public interface AddressMapper extends MPJBaseMapper<Address> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Contract; import vion.model.Contract;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/29 * @date 2023/11/29
*/ */
public interface ContractMapper extends BaseMapper<Contract> { public interface ContractMapper extends MPJBaseMapper<Contract> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.ContractPayment; import vion.model.ContractPayment;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/29 * @date 2023/11/29
*/ */
public interface ContractPaymentMapper extends BaseMapper<ContractPayment> { public interface ContractPaymentMapper extends MPJBaseMapper<ContractPayment> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Dept; import vion.model.Dept;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/10 * @date 2023/11/10
*/ */
public interface DeptMapper extends BaseMapper<Dept> { public interface DeptMapper extends MPJBaseMapper<Dept> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Dictionary; import vion.model.Dictionary;
public interface DictionaryMapper extends BaseMapper<Dictionary> { public interface DictionaryMapper extends MPJBaseMapper<Dictionary> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.DictionaryType; import vion.model.DictionaryType;
public interface DictionaryTypeMapper extends BaseMapper<DictionaryType> { public interface DictionaryTypeMapper extends MPJBaseMapper<DictionaryType> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.FaultLog; import vion.model.FaultLog;
public interface FaultLogMapper extends BaseMapper<FaultLog> { public interface FaultLogMapper extends MPJBaseMapper<FaultLog> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.FileInfo; import vion.model.FileInfo;
public interface FileMapper extends BaseMapper<FileInfo> { public interface FileMapper extends MPJBaseMapper<FileInfo> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Inspect; import vion.model.Inspect;
public interface InspectMapper extends BaseMapper<Inspect> { public interface InspectMapper extends MPJBaseMapper<Inspect> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Product; import vion.model.Product;
public interface ProductMapper extends BaseMapper<Product> { public interface ProductMapper extends MPJBaseMapper<Product> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RContractStore; import vion.model.RContractStore;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/29 * @date 2023/11/29
*/ */
public interface RContractStoreMapper extends BaseMapper<RContractStore> { public interface RContractStoreMapper extends MPJBaseMapper<RContractStore> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RRoleResource; import vion.model.RRoleResource;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface RRoleResourceMapper extends BaseMapper<RRoleResource> { public interface RRoleResourceMapper extends MPJBaseMapper<RRoleResource> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RUserRole; import vion.model.RUserRole;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface RUserRoleMapper extends BaseMapper<RUserRole> { public interface RUserRoleMapper extends MPJBaseMapper<RUserRole> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Resource; import vion.model.Resource;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface ResourceMapper extends BaseMapper<Resource> { public interface ResourceMapper extends MPJBaseMapper<Resource> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Role; import vion.model.Role;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface RoleMapper extends BaseMapper<Role> { public interface RoleMapper extends MPJBaseMapper<Role> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.ServiceOrder; import vion.model.ServiceOrder;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/21 * @date 2023/11/21
*/ */
public interface ServiceOrderMapper extends BaseMapper<ServiceOrder> { public interface ServiceOrderMapper extends MPJBaseMapper<ServiceOrder> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Store; import vion.model.Store;
public interface StoreMapper extends BaseMapper<Store> { public interface StoreMapper extends MPJBaseMapper<Store> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Task; import vion.model.Task;
public interface TaskMapper extends BaseMapper<Task> { public interface TaskMapper extends MPJBaseMapper<Task> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.TaskTemp; import vion.model.TaskTemp;
public interface TaskTempMapper extends BaseMapper<TaskTemp> { public interface TaskTempMapper extends MPJBaseMapper<TaskTemp> {
} }
package vion.mapper; package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.User; import vion.model.User;
public interface UserMapper extends BaseMapper<User> { public interface UserMapper extends MPJBaseMapper<User> {
} }
...@@ -2,7 +2,10 @@ package vion.model; ...@@ -2,7 +2,10 @@ package vion.model;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data; import lombok.Data;
import vion.dto.RContractStoreDTO;
import java.util.Date; import java.util.Date;
...@@ -12,6 +15,9 @@ import java.util.Date; ...@@ -12,6 +15,9 @@ import java.util.Date;
*/ */
@Data @Data
@TableName(value = "r_contract_store") @TableName(value = "r_contract_store")
@AutoMappers({
@AutoMapper(target = RContractStoreDTO.class),
})
public class RContractStore { public class RContractStore {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
......
...@@ -26,7 +26,7 @@ public class Role { ...@@ -26,7 +26,7 @@ public class Role {
/** /**
* 角色名称 * 角色名称
*/ */
@TableField(value = "\"name\"") @TableField(value = "\"name\"", condition = SqlCondition.LIKE)
private String name; private String name;
/** /**
......
...@@ -25,7 +25,6 @@ public class User { ...@@ -25,7 +25,6 @@ public class User {
private String userid; private String userid;
@TableField(condition = SqlCondition.LIKE) @TableField(condition = SqlCondition.LIKE)
private String username; private String username;
private String password;
private String phone; private String phone;
private Long deptId; private Long deptId;
@TableField(value = "create_time", fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
......
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.Account; import vion.model.Account;
public interface IAccountService extends IService<Account> { public interface IAccountService extends MPJBaseService<Account> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.Address; import vion.model.Address;
public interface IAddressService extends IService<Address> { public interface IAddressService extends MPJBaseService<Address> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.Contract; import vion.model.Contract;
import vion.model.ContractPayment; import vion.model.ContractPayment;
...@@ -8,7 +8,7 @@ import vion.model.ContractPayment; ...@@ -8,7 +8,7 @@ import vion.model.ContractPayment;
* @author HlQ * @author HlQ
* @date 2023/11/29 * @date 2023/11/29
*/ */
public interface IContractPaymentService extends IService<ContractPayment> { public interface IContractPaymentService extends MPJBaseService<ContractPayment> {
void calMoney(Contract contract); void calMoney(Contract exitContract, Contract dto);
} }
...@@ -3,14 +3,14 @@ package vion.service; ...@@ -3,14 +3,14 @@ package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vion.dto.ContractDTO; import vion.dto.ContractDTO;
import vion.model.Contract; import vion.model.Contract;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.vo.ContractVO; import vion.vo.ContractVO;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/29 * @date 2023/11/29
*/ */
public interface IContractService extends IService<Contract>{ public interface IContractService extends MPJBaseService<Contract>{
Page<ContractVO> list(ContractDTO dto); Page<ContractVO> list(ContractDTO dto);
......
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.Dept; import vion.model.Dept;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/10 * @date 2023/11/10
*/ */
public interface IDeptService extends IService<Dept> { public interface IDeptService extends MPJBaseService<Dept> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.Dictionary; import vion.model.Dictionary;
public interface IDictionaryService extends IService<Dictionary> { public interface IDictionaryService extends MPJBaseService<Dictionary> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.DictionaryType; import vion.model.DictionaryType;
public interface IDictionaryTypeService extends IService<DictionaryType> { public interface IDictionaryTypeService extends MPJBaseService<DictionaryType> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.FaultLog; import vion.model.FaultLog;
public interface IFaultLogService extends IService<FaultLog> { public interface IFaultLogService extends MPJBaseService<FaultLog> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.FileInfo; import vion.model.FileInfo;
public interface IFileService extends IService<FileInfo> { public interface IFileService extends MPJBaseService<FileInfo> {
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.InspectDTO; import vion.dto.InspectDTO;
import vion.model.Inspect; import vion.model.Inspect;
public interface IInspectService extends IService<Inspect> { public interface IInspectService extends MPJBaseService<Inspect> {
Page<Inspect> getInspectList(InspectDTO data); Page<Inspect> getInspectList(InspectDTO data);
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.ProductDTO; import vion.dto.ProductDTO;
import vion.model.Product; import vion.model.Product;
import vion.vo.ProductVO; import vion.vo.ProductVO;
public interface IProductService extends IService<Product> { public interface IProductService extends MPJBaseService<Product> {
Page<ProductVO> getProductList(ProductDTO productDTO); Page<ProductVO> getProductList(ProductDTO productDTO);
} }
package vion.service; package vion.service;
import vion.model.RContractStore; import vion.model.RContractStore;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/29 * @date 2023/11/29
*/ */
public interface IRContractStoreService extends IService<RContractStore>{ public interface IRContractStoreService extends MPJBaseService<RContractStore>{
} }
package vion.service; package vion.service;
import vion.model.RRoleResource; import vion.model.RRoleResource;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface IRRoleResourceService extends IService<RRoleResource>{ public interface IRRoleResourceService extends MPJBaseService<RRoleResource>{
} }
package vion.service; package vion.service;
import vion.model.RUserRole; import vion.model.RUserRole;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface IRUserRoleService extends IService<RUserRole>{ public interface IRUserRoleService extends MPJBaseService<RUserRole>{
} }
...@@ -2,7 +2,7 @@ package vion.service; ...@@ -2,7 +2,7 @@ package vion.service;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.ResourceDTO; import vion.dto.ResourceDTO;
import vion.model.Resource; import vion.model.Resource;
import vion.vo.ResourceVO; import vion.vo.ResourceVO;
...@@ -13,7 +13,7 @@ import java.util.List; ...@@ -13,7 +13,7 @@ import java.util.List;
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface IResourceService extends IService<Resource>{ public interface IResourceService extends MPJBaseService<Resource>{
Page<ResourceVO> list(ResourceDTO dto); Page<ResourceVO> list(ResourceDTO dto);
......
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.RoleDTO; import vion.dto.RoleDTO;
import vion.model.Role; import vion.model.Role;
import vion.vo.RoleVO; import vion.vo.RoleVO;
...@@ -10,7 +10,7 @@ import vion.vo.RoleVO; ...@@ -10,7 +10,7 @@ import vion.vo.RoleVO;
* @author HlQ * @author HlQ
* @date 2023/11/28 * @date 2023/11/28
*/ */
public interface IRoleService extends IService<Role>{ public interface IRoleService extends MPJBaseService<Role> {
Page<RoleVO> list(RoleDTO dto); Page<RoleVO> list(RoleDTO dto);
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.model.ServiceOrder; import vion.model.ServiceOrder;
/** /**
* @author HlQ * @author HlQ
* @date 2023/11/21 * @date 2023/11/21
*/ */
public interface IServiceOrderService extends IService<ServiceOrder> { public interface IServiceOrderService extends MPJBaseService<ServiceOrder> {
String sendOrder(Long id); String sendOrder(Long id);
} }
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.StatusDTO; import vion.dto.StatusDTO;
import vion.dto.StoreDTO; import vion.dto.StoreDTO;
import vion.model.Store; import vion.model.Store;
import vion.vo.StoreVO; import vion.vo.StoreVO;
public interface IStoreService extends IService<Store> { public interface IStoreService extends MPJBaseService<Store> {
Page<StoreVO> getStoreList(StoreDTO data); Page<StoreVO> getStoreList(StoreDTO data);
......
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.TaskDTO; import vion.dto.TaskDTO;
import vion.model.Task; import vion.model.Task;
import vion.vo.TaskVO; import vion.vo.TaskVO;
public interface ITaskService extends IService<Task> { public interface ITaskService extends MPJBaseService<Task> {
Page<TaskVO> getTaskList(TaskDTO data); Page<TaskVO> getTaskList(TaskDTO data);
......
package vion.service; package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.github.yulichang.base.MPJBaseService;
import vion.dto.TaskTempDTO; import vion.dto.TaskTempDTO;
import vion.model.TaskTemp; import vion.model.TaskTemp;
import vion.vo.TaskTempVO; import vion.vo.TaskTempVO;
public interface ITaskTempService extends IService<TaskTemp> { public interface ITaskTempService extends MPJBaseService<TaskTemp> {
Page<TaskTempVO> getTaskTempList(TaskTempDTO data); Page<TaskTempVO> getTaskTempList(TaskTempDTO data);
TaskTempVO getTaskTempById(Long id); TaskTempVO getTaskTempById(Long id);
......
package vion.service; package vion.service;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import vion.dto.UserDTO;
import vion.model.User; import vion.model.User;
import vion.vo.UserVO;
import java.util.List; import java.util.List;
public interface IUserService extends IService<User> { public interface IUserService extends MPJBaseService<User> {
Page<UserVO> getUserList(UserDTO dto);
List<Tree<String>> getOrgTree(String deptId); List<Tree<String>> getOrgTree(String deptId);
......
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.AccountMapper; import vion.mapper.AccountMapper;
import vion.model.Account; import vion.model.Account;
import vion.service.IAccountService; import vion.service.IAccountService;
@Service @Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountService { public class AccountServiceImpl extends MPJBaseServiceImpl<AccountMapper, Account> implements IAccountService {
} }
\ No newline at end of file \ No newline at end of file
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.AddressMapper; import vion.mapper.AddressMapper;
import vion.model.Address; import vion.model.Address;
import vion.service.IAddressService; import vion.service.IAddressService;
@Service @Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressService { public class AddressServiceImpl extends MPJBaseServiceImpl<AddressMapper, Address> implements IAddressService {
} }
package vion.service.impl; package vion.service.impl;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.ContractPaymentMapper; import vion.mapper.ContractPaymentMapper;
...@@ -20,23 +20,23 @@ import java.util.stream.Collectors; ...@@ -20,23 +20,23 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ContractPaymentServiceImpl extends ServiceImpl<ContractPaymentMapper, ContractPayment> implements IContractPaymentService { public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPaymentMapper, ContractPayment> implements IContractPaymentService {
@Override @Override
public void calMoney(Contract contract) { public void calMoney(Contract exitContract, Contract dto) {
List<ContractPayment> contractPaymentList = this.lambdaQuery().eq(ContractPayment::getContractId, contract.getId()).list(); List<ContractPayment> contractPaymentList = this.lambdaQuery().eq(ContractPayment::getContractId, dto.getId()).list();
Map<Integer, BigDecimal> type2RatioMap = contractPaymentList.stream().collect(Collectors.toMap(ContractPayment::getPaymentType, ContractPayment::getPaymentRatio)); Map<Integer, BigDecimal> type2RatioMap = contractPaymentList.stream().collect(Collectors.toMap(ContractPayment::getPaymentType, ContractPayment::getPaymentRatio));
Integer status = contract.getStatus(); Integer status = dto.getStatus() == null ? exitContract.getStatus() : dto.getStatus();
BigDecimal sumRatio = new BigDecimal(0); BigDecimal sumRatio = new BigDecimal(0);
for (int i = 1; i <= status; i++) { for (int i = 1; i <= status; i++) {
BigDecimal ratio = type2RatioMap.get(i); BigDecimal ratio = type2RatioMap.get(i);
NumberUtil.add(ratio, sumRatio); NumberUtil.add(ratio, sumRatio);
} }
BigDecimal totalAmount = contract.getTotalAmount(); BigDecimal totalAmount = exitContract.getTotalAmount();
BigDecimal curAmount = NumberUtil.mul(totalAmount, sumRatio); BigDecimal curAmount = NumberUtil.mul(totalAmount, sumRatio);
BigDecimal recAmount = NumberUtil.sub(curAmount, contract.getPaidAmount()); BigDecimal recAmount = NumberUtil.sub(curAmount, dto.getPaidAmount() != null ? dto.getPaidAmount() : exitContract.getPaidAmount());
BigDecimal outsideAmount = NumberUtil.sub(totalAmount, recAmount); BigDecimal outsideAmount = NumberUtil.sub(totalAmount, recAmount);
contract.setReceivableAmount(recAmount); dto.setReceivableAmount(recAmount);
contract.setOutstandingAmount(outsideAmount); dto.setOutstandingAmount(outsideAmount);
} }
} }
...@@ -7,7 +7,7 @@ import cn.hutool.core.lang.Opt; ...@@ -7,7 +7,7 @@ import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -34,7 +34,7 @@ import java.util.List; ...@@ -34,7 +34,7 @@ import java.util.List;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> implements IContractService { public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Contract> implements IContractService {
private final IFileService fileService; private final IFileService fileService;
private final IContractPaymentService contractPaymentService; private final IContractPaymentService contractPaymentService;
...@@ -56,8 +56,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i ...@@ -56,8 +56,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
Contract exitContract = this.getById(id); Contract exitContract = this.getById(id);
Contract contract = converter.convert(dto, new Contract()); Contract contract = converter.convert(dto, new Contract());
contract.setId(id); contract.setId(id);
if (ObjUtil.notEqual(contract.getStatus(), exitContract.getStatus())) { if ((ObjUtil.notEqual(contract.getStatus(), exitContract.getStatus()) && contract.getStatus() != null) || dto.getPaidAmount() != null) {
contractPaymentService.calMoney(contract); contractPaymentService.calMoney(exitContract, contract);
} }
this.updateById(contract); this.updateById(contract);
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser"); UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
......
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.DeptMapper; import vion.mapper.DeptMapper;
import vion.model.Dept; import vion.model.Dept;
...@@ -11,5 +11,5 @@ import vion.service.IDeptService; ...@@ -11,5 +11,5 @@ import vion.service.IDeptService;
* @date 2023/11/10 * @date 2023/11/10
*/ */
@Service @Service
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService { public class DeptServiceImpl extends MPJBaseServiceImpl<DeptMapper, Dept> implements IDeptService {
} }
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.DictionaryMapper; import vion.mapper.DictionaryMapper;
import vion.model.Dictionary; import vion.model.Dictionary;
import vion.service.IDictionaryService; import vion.service.IDictionaryService;
@Service @Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements IDictionaryService { public class DictionaryServiceImpl extends MPJBaseServiceImpl<DictionaryMapper, Dictionary> implements IDictionaryService {
} }
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.DictionaryTypeMapper; import vion.mapper.DictionaryTypeMapper;
import vion.model.DictionaryType; import vion.model.DictionaryType;
import vion.service.IDictionaryTypeService; import vion.service.IDictionaryTypeService;
@Service @Service
public class DictionaryTypeServiceImpl extends ServiceImpl<DictionaryTypeMapper, DictionaryType> implements IDictionaryTypeService { public class DictionaryTypeServiceImpl extends MPJBaseServiceImpl<DictionaryTypeMapper, DictionaryType> implements IDictionaryTypeService {
} }
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.FaultLogMapper; import vion.mapper.FaultLogMapper;
import vion.model.FaultLog; import vion.model.FaultLog;
import vion.service.IFaultLogService; import vion.service.IFaultLogService;
@Service @Service
public class FaultLogServiceImpl extends ServiceImpl<FaultLogMapper, FaultLog> implements IFaultLogService { public class FaultLogServiceImpl extends MPJBaseServiceImpl<FaultLogMapper, FaultLog> implements IFaultLogService {
} }
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.FileMapper; import vion.mapper.FileMapper;
import vion.model.FileInfo; import vion.model.FileInfo;
import vion.service.IFileService; import vion.service.IFileService;
@Service @Service
public class FileServiceImpl extends ServiceImpl<FileMapper, FileInfo> implements IFileService { public class FileServiceImpl extends MPJBaseServiceImpl<FileMapper, FileInfo> implements IFileService {
} }
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class InspectServiceImpl extends ServiceImpl<InspectMapper, Inspect> implements IInspectService { public class InspectServiceImpl extends MPJBaseServiceImpl<InspectMapper, Inspect> implements IInspectService {
private final IStoreService storeService; private final IStoreService storeService;
private final IAccountService accountService; private final IAccountService accountService;
......
...@@ -2,7 +2,7 @@ package vion.service.impl; ...@@ -2,7 +2,7 @@ package vion.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -20,7 +20,7 @@ import java.util.stream.Collectors; ...@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService { public class ProductServiceImpl extends MPJBaseServiceImpl<ProductMapper, Product> implements IProductService {
private final IStoreService storeService; private final IStoreService storeService;
private final Converter converter; private final Converter converter;
......
package vion.service.impl; package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import vion.mapper.RContractStoreMapper; import vion.mapper.RContractStoreMapper;
import vion.model.RContractStore; import vion.model.RContractStore;
import vion.service.IRContractStoreService; import vion.service.IRContractStoreService;
...@@ -10,6 +10,6 @@ import vion.service.IRContractStoreService; ...@@ -10,6 +10,6 @@ import vion.service.IRContractStoreService;
* @date 2023/11/29 * @date 2023/11/29
*/ */
@Service @Service
public class RContractStoreServiceImpl extends ServiceImpl<RContractStoreMapper, RContractStore> implements IRContractStoreService { public class RContractStoreServiceImpl extends MPJBaseServiceImpl<RContractStoreMapper, RContractStore> implements IRContractStoreService {
} }
package vion.service.impl; package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import vion.mapper.RRoleResourceMapper; import vion.mapper.RRoleResourceMapper;
import vion.model.RRoleResource; import vion.model.RRoleResource;
import vion.service.IRRoleResourceService; import vion.service.IRRoleResourceService;
...@@ -10,6 +10,6 @@ import vion.service.IRRoleResourceService; ...@@ -10,6 +10,6 @@ import vion.service.IRRoleResourceService;
* @date 2023/11/28 * @date 2023/11/28
*/ */
@Service @Service
public class RRoleResourceServiceImpl extends ServiceImpl<RRoleResourceMapper, RRoleResource> implements IRRoleResourceService { public class RRoleResourceServiceImpl extends MPJBaseServiceImpl<RRoleResourceMapper, RRoleResource> implements IRRoleResourceService {
} }
package vion.service.impl; package vion.service.impl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import vion.mapper.RUserRoleMapper; import vion.mapper.RUserRoleMapper;
import vion.model.RUserRole; import vion.model.RUserRole;
import vion.service.IRUserRoleService; import vion.service.IRUserRoleService;
...@@ -10,6 +10,6 @@ import vion.service.IRUserRoleService; ...@@ -10,6 +10,6 @@ import vion.service.IRUserRoleService;
* @date 2023/11/28 * @date 2023/11/28
*/ */
@Service @Service
public class RUserRoleServiceImpl extends ServiceImpl<RUserRoleMapper, RUserRole> implements IRUserRoleService { public class RUserRoleServiceImpl extends MPJBaseServiceImpl<RUserRoleMapper, RUserRole> implements IRUserRoleService {
} }
...@@ -8,7 +8,7 @@ import cn.hutool.core.lang.tree.TreeNode; ...@@ -8,7 +8,7 @@ import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,7 +28,7 @@ import java.util.Map; ...@@ -28,7 +28,7 @@ import java.util.Map;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements IResourceService { public class ResourceServiceImpl extends MPJBaseServiceImpl<ResourceMapper, Resource> implements IResourceService {
private final Converter converter; private final Converter converter;
......
package vion.service.impl; package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.dto.RoleDTO; import vion.dto.RoleDTO;
import vion.mapper.RoleMapper; import vion.mapper.RoleMapper;
import vion.model.RUserRole;
import vion.model.Role; import vion.model.Role;
import vion.model.User;
import vion.service.IRUserRoleService;
import vion.service.IRoleService; import vion.service.IRoleService;
import vion.service.IUserService;
import vion.vo.RoleVO; import vion.vo.RoleVO;
import vion.vo.UserVO;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author HlQ * @author HlQ
...@@ -25,7 +19,7 @@ import java.util.stream.Collectors; ...@@ -25,7 +19,7 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService { public class RoleServiceImpl extends MPJBaseServiceImpl<RoleMapper, Role> implements IRoleService {
private final Converter converter; private final Converter converter;
......
...@@ -2,17 +2,17 @@ package vion.service.impl; ...@@ -2,17 +2,17 @@ package vion.service.impl;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Opt; import cn.hutool.core.lang.Opt;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.third.WechatMod;
import vion.mapper.ServiceOrderMapper; import vion.mapper.ServiceOrderMapper;
import vion.model.ServiceOrder; import vion.model.ServiceOrder;
import vion.model.Task; import vion.model.Task;
import vion.service.IServiceOrderService; import vion.service.IServiceOrderService;
import vion.service.ITaskService; import vion.service.ITaskService;
import vion.service.ITaskTempService; import vion.service.ITaskTempService;
import vion.third.WechatMod;
import java.util.List; import java.util.List;
...@@ -22,7 +22,7 @@ import java.util.List; ...@@ -22,7 +22,7 @@ import java.util.List;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ServiceOrderServiceImpl extends ServiceImpl<ServiceOrderMapper, ServiceOrder> implements IServiceOrderService { public class ServiceOrderServiceImpl extends MPJBaseServiceImpl<ServiceOrderMapper, ServiceOrder> implements IServiceOrderService {
private final ITaskService taskService; private final ITaskService taskService;
private final ITaskTempService taskTempService; private final ITaskTempService taskTempService;
......
...@@ -6,10 +6,11 @@ import cn.hutool.core.date.DateUtil; ...@@ -6,10 +6,11 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt; import cn.hutool.core.lang.Opt;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -31,7 +32,7 @@ import java.util.stream.Collectors; ...@@ -31,7 +32,7 @@ import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements IStoreService { public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> implements IStoreService {
private final IAccountService accountService; private final IAccountService accountService;
private final IRContractStoreService contractStoreService; private final IRContractStoreService contractStoreService;
...@@ -86,10 +87,12 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements ...@@ -86,10 +87,12 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
Contract contract = id2ContractMap.get(id); Contract contract = id2ContractMap.get(id);
Date maintainSdate = contract.getMaintainSdate(); Date maintainSdate = contract.getMaintainSdate();
Date maintainEdate = contract.getMaintainEdate(); Date maintainEdate = contract.getMaintainEdate();
boolean isIn = DateUtil.isIn(new Date(), maintainSdate, maintainEdate); if (ArrayUtil.isAllNotNull(maintainSdate, maintainEdate)) {
maintainStatusSet.add(isIn); boolean isIn = DateUtil.isIn(new Date(), maintainSdate, maintainEdate);
maintainStatusSet.add(isIn);
}
}); });
storeVO.setMaintainStatus(maintainStatusSet.contains(true) ? "在保" : "脱保"); storeVO.setMaintainStatus(CollUtil.isEmpty(maintainStatusSet) ? "--" : maintainStatusSet.contains(true) ? "在保" : "脱保");
} }
storeVOList.add(storeVO); storeVOList.add(storeVO);
......
...@@ -12,7 +12,8 @@ import cn.hutool.json.JSONArray; ...@@ -12,7 +12,8 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
...@@ -20,26 +21,26 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -20,26 +21,26 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import vion.Global; import vion.Global;
import vion.third.DingMod;
import vion.third.WechatMod;
import vion.dto.TaskDTO; import vion.dto.TaskDTO;
import vion.mapper.ServiceOrderMapper; import vion.mapper.ServiceOrderMapper;
import vion.mapper.TaskMapper; import vion.mapper.TaskMapper;
import vion.model.Dictionary; import vion.model.Dictionary;
import vion.model.*; import vion.model.*;
import vion.service.*; import vion.service.*;
import vion.third.DingMod;
import vion.third.WechatMod;
import vion.vo.TaskTempVO;
import vion.vo.TaskVO; import vion.vo.TaskVO;
import vion.vo.UserVO; import vion.vo.UserVO;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService { public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implements ITaskService {
private final ITaskTempService taskTempService; private final ITaskTempService taskTempService;
private final IFileService fileService; private final IFileService fileService;
...@@ -49,7 +50,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT ...@@ -49,7 +50,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
private final IAccountService accountService; private final IAccountService accountService;
private final IDictionaryService dictionaryService; private final IDictionaryService dictionaryService;
// 循环依赖,这里用mapper // 循环依赖,这里用mapper
// private final IServiceOrderService serviceOrderService; // private final MPJBaseServiceOrderService serviceOrderService;
private final ServiceOrderMapper serviceOrderMapper; private final ServiceOrderMapper serviceOrderMapper;
private final DingMod dingMod; private final DingMod dingMod;
private final WechatMod wechatMod; private final WechatMod wechatMod;
...@@ -59,7 +60,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT ...@@ -59,7 +60,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
@Override @Override
public Page<TaskVO> getTaskList(TaskDTO data) { public Page<TaskVO> getTaskList(TaskDTO data) {
Page<Task> taskList = this /*Page<Task> taskList = this
.lambdaQuery(converter.convert(data, new Task())) .lambdaQuery(converter.convert(data, new Task()))
.between(data.getStartdate() != null && data.getEnddate() != null, Task::getRepairTime, data.getStartdate(), data.getEnddate()) .between(data.getStartdate() != null && data.getEnddate() != null, Task::getRepairTime, data.getStartdate(), data.getEnddate())
.lt(data.getCurDate() != null, Task::getExpDate, data.getCurDate()) .lt(data.getCurDate() != null, Task::getExpDate, data.getCurDate())
...@@ -82,19 +83,31 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT ...@@ -82,19 +83,31 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
taskVO.setAccountName(accountList.stream().filter(a -> a.getId().equals(v.getAccountId())).map(Account::getName).findFirst().orElse("--")); taskVO.setAccountName(accountList.stream().filter(a -> a.getId().equals(v.getAccountId())).map(Account::getName).findFirst().orElse("--"));
taskVO.setServiceOrder(taskId2OrderMap.get(v.getId())); taskVO.setServiceOrder(taskId2OrderMap.get(v.getId()));
taskVOList.add(taskVO); taskVOList.add(taskVO);
})); }));*/
return Page.<TaskVO>of(data.getPageNum(), data.getPageSize(), taskList.getTotal()).setRecords(taskVOList);
MPJLambdaWrapper<Task> wrapper = new MPJLambdaWrapper<>(converter.convert(data, new Task()))
.selectAll(Task.class)
.selectAs(Store::getName, TaskVO::getStoreName)
.selectAs(Account::getName, TaskVO::getAccountName)
.selectAssociation(ServiceOrder.class, TaskVO::getServiceOrder)
.leftJoin(Store.class, Store::getId, Task::getStoreId)
.leftJoin(Account.class, Account::getId, Task::getAccountId)
.leftJoin(ServiceOrder.class, ServiceOrder::getTaskId, Task::getId)
.between(data.getStartdate() != null && data.getEnddate() != null, Task::getRepairTime, data.getStartdate(), data.getEnddate())
.lt(data.getCurDate() != null, Task::getExpDate, data.getCurDate());
return this.selectJoinListPage(Page.of(data.getPageNum(), data.getPageSize()), TaskVO.class, wrapper);
} }
@Override @Override
public TaskVO getTaskById(Long taskId) { public TaskVO getTaskById(Long taskId) {
Task task = this.getById(taskId); MPJLambdaWrapper<Task> wrapper = new MPJLambdaWrapper<Task>()
List<FileInfo> fileInfos = fileService.list(Wrappers.<FileInfo>lambdaUpdate() .selectAll(Task.class)
.eq(FileInfo::getSourceId, task.getId()) .selectCollection(FileInfo.class, TaskTempVO::getFileList)
.eq(FileInfo::getStoreId, task.getStoreId())); .leftJoin(FileInfo.class, on -> on
TaskVO taskVO = converter.convert(task, TaskVO.class); .eq(FileInfo::getSourceId, Task::getId)
taskVO.setFileList(fileInfos); .eq(FileInfo::getStoreId, Task::getStoreId))
return taskVO; .eq(Task::getId, taskId);
return this.selectJoinOne(TaskVO.class, wrapper);
} }
@Override @Override
...@@ -211,7 +224,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT ...@@ -211,7 +224,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
Opt.ofNullable(data.getFiles()) Opt.ofNullable(data.getFiles())
.ifPresent(fileList -> .ifPresent(fileList ->
Arrays.stream(fileList).forEach(infile -> { Arrays.stream(fileList).forEach(infile -> {
//上传url地址
String orgName = infile.getOriginalFilename(); String orgName = infile.getOriginalFilename();
String fileName = orgName.substring(0, orgName.lastIndexOf(".")); String fileName = orgName.substring(0, orgName.lastIndexOf("."));
String fileExt = orgName.substring(orgName.lastIndexOf(".")); String fileExt = orgName.substring(orgName.lastIndexOf("."));
......
package vion.service.impl; package vion.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt; import cn.hutool.core.lang.Opt;
...@@ -8,15 +7,13 @@ import cn.hutool.core.util.StrUtil; ...@@ -8,15 +7,13 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter; import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.third.DingMod;
import vion.third.WechatMod;
import vion.dto.TaskTempDTO; import vion.dto.TaskTempDTO;
import vion.mapper.TaskTempMapper; import vion.mapper.TaskTempMapper;
import vion.model.FileInfo; import vion.model.FileInfo;
...@@ -25,6 +22,8 @@ import vion.model.User; ...@@ -25,6 +22,8 @@ import vion.model.User;
import vion.service.IFileService; import vion.service.IFileService;
import vion.service.ITaskTempService; import vion.service.ITaskTempService;
import vion.service.IUserService; import vion.service.IUserService;
import vion.third.DingMod;
import vion.third.WechatMod;
import vion.vo.TaskTempVO; import vion.vo.TaskTempVO;
import java.io.File; import java.io.File;
...@@ -36,7 +35,7 @@ import java.util.stream.Collectors; ...@@ -36,7 +35,7 @@ import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class TaskTempServiceImpl extends ServiceImpl<TaskTempMapper, TaskTemp> implements ITaskTempService { public class TaskTempServiceImpl extends MPJBaseServiceImpl<TaskTempMapper, TaskTemp> implements ITaskTempService {
private final IFileService fileService; private final IFileService fileService;
private final IUserService userService; private final IUserService userService;
...@@ -59,15 +58,14 @@ public class TaskTempServiceImpl extends ServiceImpl<TaskTempMapper, TaskTemp> i ...@@ -59,15 +58,14 @@ public class TaskTempServiceImpl extends ServiceImpl<TaskTempMapper, TaskTemp> i
@Override @Override
public TaskTempVO getTaskTempById(Long id) { public TaskTempVO getTaskTempById(Long id) {
TaskTemp taskTemp = this.getById(id); MPJLambdaWrapper<TaskTemp> wrapper = new MPJLambdaWrapper<TaskTemp>()
List<FileInfo> fileInfos = Opt.ofNullable(taskTemp) .selectAll(TaskTemp.class)
.map(tmp -> fileService.list(Wrappers.<FileInfo>lambdaUpdate() .selectCollection(FileInfo.class, TaskTempVO::getFileList)
.eq(FileInfo::getSourceId, tmp.getId()) .leftJoin(FileInfo.class, on -> on
.eq(FileInfo::getStoreId, 0L))) .eq(FileInfo::getSourceId, TaskTemp::getId)
.orElse(ListUtil.empty()); .eq(FileInfo::getStoreId, 0L))
TaskTempVO taskTempVO = converter.convert(taskTemp, TaskTempVO.class); .eq(TaskTemp::getId, id);
taskTempVO.setFileList(fileInfos); return this.selectJoinOne(TaskTempVO.class, wrapper);
return taskTempVO;
} }
@Override @Override
......
package vion.service.impl; package vion.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Opt; import cn.hutool.core.lang.Opt;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode; import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.dto.UserDTO;
import vion.mapper.UserMapper; import vion.mapper.UserMapper;
import vion.model.Dept; import vion.model.Dept;
import vion.model.RUserRole;
import vion.model.Role;
import vion.model.User; import vion.model.User;
import vion.service.IDeptService; import vion.service.IDeptService;
import vion.service.IRoleService;
import vion.service.IUserService; import vion.service.IUserService;
import vion.vo.RoleVO;
import vion.vo.UserVO;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService { public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implements IUserService {
private final IDeptService deptService; private final IDeptService deptService;
private final IRoleService roleService;
private final Converter converter;
@Override
public Page<UserVO> getUserList(UserDTO dto) {
MPJLambdaWrapper<User> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, new User()))
.selectAll(User.class)
.select(Dept::getDeptName)
.leftJoin(Dept.class, Dept::getDeptId, User::getDeptId);
Page<UserVO> userVOS = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), UserVO.class, wrapper);
MPJLambdaWrapper<Role> roleWrapper = new MPJLambdaWrapper<Role>()
.selectAll(Role.class)
.select(RUserRole::getUserId)
.leftJoin(RUserRole.class, RUserRole::getRoleId, Role::getId)
.in(RUserRole::getUserId, userVOS.getRecords().stream().map(UserVO::getId).collect(Collectors.toList()));
List<RoleVO> roleVOList = roleService.selectJoinList(RoleVO.class, roleWrapper);
Opt.ofEmptyAble(roleVOList)
.map(l -> l.stream().collect(Collectors.groupingBy(RoleVO::getUserId)))
.ifPresent(m -> userVOS.getRecords().forEach(u -> u.setRoleVOList(m.getOrDefault(u.getId(), ListUtil.empty()))));
return userVOS;
}
@Override @Override
public List<Tree<String>> getOrgTree(String deptId) { public List<Tree<String>> getOrgTree(String deptId) {
......
...@@ -238,25 +238,7 @@ public class DingMod { ...@@ -238,25 +238,7 @@ public class DingMod {
return "该用户禁止登录系统,请联系管理员!"; return "该用户禁止登录系统,请联系管理员!";
} }
Long id = userVO.getId(); Long id = userVO.getId();
List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getUserId, id).list(); setRolesAndPerms(id, userVO);
List<RRoleResource> roleResourceList = Opt.ofEmptyAble(userRoleList)
.map(urList -> urList.stream().map(RUserRole::getRoleId).collect(Collectors.toList()))
.map(roleIdList -> {
// 获取用户关联的角色
List<Role> roles = roleService.listByIds(roleIdList);
List<RoleVO> roleVOS = converter.convert(roles, RoleVO.class);
userVO.setRoleVOList(roleVOS);
return roleResourceService.lambdaQuery().select(RRoleResource::getResourceId).in(RRoleResource::getRoleId, roleIdList).list();
}).orElse(ListUtil.empty());
// 获取角色关联的资源
Opt.ofEmptyAble(roleResourceList)
.map(rrList -> rrList.stream().map(RRoleResource::getResourceId).collect(Collectors.toList()))
.ifPresent(resourceIdList -> {
List<Resource> resourceList = resourceService.listByIds(resourceIdList);
List<String> permCodeList = resourceList.stream().map(Resource::getPerm).collect(Collectors.toList());
userVO.setPermCodeList(permCodeList);
});
StpUtil.login(id); StpUtil.login(id);
String token = StpUtil.getTokenValue(); String token = StpUtil.getTokenValue();
...@@ -285,7 +267,10 @@ public class DingMod { ...@@ -285,7 +267,10 @@ public class DingMod {
User user = userService.lambdaQuery().select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus).eq(User::getUserid, userid).one(); User user = userService.lambdaQuery().select(User::getId, User::getUserid, User::getUsername, User::getPhone, User::getStatus).eq(User::getUserid, userid).one();
UserVO userVO = converter.convert(user, new UserVO()); UserVO userVO = converter.convert(user, new UserVO());
StpUtil.login(userVO.getId()); Long id = userVO.getId();
setRolesAndPerms(id, userVO);
StpUtil.login(id);
String token = StpUtil.getTokenValue(); String token = StpUtil.getTokenValue();
userVO.setToken(token); userVO.setToken(token);
...@@ -309,6 +294,27 @@ public class DingMod { ...@@ -309,6 +294,27 @@ public class DingMod {
return "钉钉回调异常,请联系相关人员"; return "钉钉回调异常,请联系相关人员";
} }
private void setRolesAndPerms(Long id, UserVO userVO) {
List<RUserRole> userRoleList = userRoleService.lambdaQuery().eq(RUserRole::getUserId, id).list();
List<RRoleResource> roleResourceList = Opt.ofEmptyAble(userRoleList)
.map(urList -> urList.stream().map(RUserRole::getRoleId).collect(Collectors.toList()))
.map(roleIdList -> {
// 获取用户关联的角色
List<Role> roles = roleService.listByIds(roleIdList);
List<RoleVO> roleVOS = converter.convert(roles, RoleVO.class);
userVO.setRoleVOList(roleVOS);
return roleResourceService.lambdaQuery().select(RRoleResource::getResourceId).in(RRoleResource::getRoleId, roleIdList).list();
}).orElse(ListUtil.empty());
// 获取角色关联的资源
Opt.ofEmptyAble(roleResourceList)
.map(rrList -> rrList.stream().map(RRoleResource::getResourceId).collect(Collectors.toList()))
.ifPresent(resourceIdList -> {
List<Resource> resourceList = resourceService.listByIds(resourceIdList);
List<String> permCodeList = resourceList.stream().map(Resource::getPerm).collect(Collectors.toList());
userVO.setPermCodeList(permCodeList);
});
}
/** /**
* 构建获取用户信息url * 构建获取用户信息url
*/ */
......
package vion.vo; package vion.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data; import lombok.Data;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
@Data @Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultVO<T> { public class ResultVO<T> {
private Integer code; private Integer code;
private String msg; private String msg;
......
...@@ -22,4 +22,6 @@ public class RoleVO { ...@@ -22,4 +22,6 @@ public class RoleVO {
private Date createTime; private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime; private Date updateTime;
private Long userId;
} }
...@@ -13,7 +13,6 @@ public class UserVO { ...@@ -13,7 +13,6 @@ public class UserVO {
private Long id; private Long id;
private String userid; private String userid;
private String username; private String username;
private String password;
private String phone; private String phone;
private Long deptId; private Long deptId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
...@@ -37,4 +36,6 @@ public class UserVO { ...@@ -37,4 +36,6 @@ public class UserVO {
private List<String> permCodeList; private List<String> permCodeList;
private List<RoleVO> roleVOList; private List<RoleVO> roleVOList;
private String deptName;
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!