ezhizao_zx 1 year ago
parent
commit
57139cec87

+ 21 - 25
src/main/java/cn/ezhizao/project/business/reconciliation/priceList/controller/BizEntrustOncePriceController.java

@@ -30,8 +30,7 @@ import cn.ezhizao.framework.web.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/business/oncePrice")
-public class BizEntrustOncePriceController extends BaseController
-{
+public class BizEntrustOncePriceController extends BaseController {
     @Resource
     private IBizEntrustPriceService bizEntrustPriceService;
 
@@ -40,8 +39,7 @@ public class BizEntrustOncePriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('oncePrice:oncePrice:list')")
     @GetMapping("/list")
-    public TableDataInfo list(BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public TableDataInfo list(BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         startPage();
         List<BizEntrustPrice> list = bizEntrustPriceService.getOnceList(bizEntrustPrice);
         return getDataTable(list);
@@ -53,9 +51,7 @@ public class BizEntrustOncePriceController extends BaseController
     @PreAuthorize("@ss.hasPermi('oncePrice:oncePrice:export')")
     @Log(title = "单次价目表", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
-        setTenantId(bizEntrustPrice);
+    public void export(HttpServletResponse response, BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         List<BizEntrustPrice> list = bizEntrustPriceService.getList(bizEntrustPrice);
         ExcelUtil<BizEntrustPrice> util = new ExcelUtil<BizEntrustPrice>(BizEntrustPrice.class);
         util.exportExcel(response, list, "单次价目表数据");
@@ -66,8 +62,7 @@ public class BizEntrustOncePriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:oncePrice:list')")
     @GetMapping("/taskTypeOnceList")
-    public AjaxResult getTaskTypeList()
-    {
+    public AjaxResult getTaskTypeList() {
         return success(bizEntrustPriceService.getTaskType(2));
     }
 
@@ -76,8 +71,7 @@ public class BizEntrustOncePriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:oncePrice:list')")
     @GetMapping(value = "/typeDetail/{id}")
-    public AjaxResult getTaskTypeDetailList(@PathVariable("id") Long id)
-    {
+    public AjaxResult getTaskTypeDetailList(@PathVariable("id") Long id) {
         return success(bizEntrustPriceService.getTaskTypeDetailList(id));
     }
 
@@ -86,8 +80,7 @@ public class BizEntrustOncePriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('oncePrice:oncePrice:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(bizEntrustPriceService.getById(id));
     }
 
@@ -97,11 +90,12 @@ public class BizEntrustOncePriceController extends BaseController
     @PreAuthorize("@ss.hasPermi('oncePrice:oncePrice:save')")
     @Log(title = "单次价目表", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult add(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         //判读是否存在该价目
+        setTenantId(bizEntrustPrice);
+        bizEntrustPrice.setToTenantId(bizEntrustPrice.getFromTenantId());
         List<BizEntrustPrice> list = bizEntrustPriceService.getOnceList(bizEntrustPrice);
-        if(list.size() > 0){
+        if (list.size() > 0) {
             return AjaxResult.error("该价目已存在");
         }
         return toAjax(bizEntrustPriceService.save(bizEntrustPrice));
@@ -113,16 +107,19 @@ public class BizEntrustOncePriceController extends BaseController
     @PreAuthorize("@ss.hasPermi('oncePrice:oncePrice:save')")
     @Log(title = "单次价目表", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult edit(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         //判读是否存在该价目
         List<BizEntrustPrice> list = bizEntrustPriceService.getOnceList(bizEntrustPrice);
-        if(list.size() > 0){
-            //如果存在,则判断是否是同一个价目
-            if(list.size() == 1&&list.get(0).getId().equals(bizEntrustPrice.getId())){
+        //如果存在多条数据
+        if (list.size() > 1) {
+            return AjaxResult.error("该价目已存在");
+        } else if (list.size() == 1) {
+            //如果存在一条数据且id一致
+            if (list.get(0).getId().equals(bizEntrustPrice.getId())) {
                 return toAjax(bizEntrustPriceService.updateById(bizEntrustPrice));
+            } else {
+                return AjaxResult.error("该价目已存在");
             }
-            return AjaxResult.error("该价目已存在");
         }
         return toAjax(bizEntrustPriceService.updateById(bizEntrustPrice));
     }
@@ -132,9 +129,8 @@ public class BizEntrustOncePriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('oncePrice:oncePrice:remove')")
     @Log(title = "单次价目表", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable List<Long> ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids) {
         return toAjax(bizEntrustPriceService.removeBatchByIds(ids));
     }
 }

+ 20 - 25
src/main/java/cn/ezhizao/project/business/reconciliation/priceList/controller/BizEntrustPriceController.java

@@ -32,8 +32,7 @@ import cn.ezhizao.framework.web.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/priceList/priceList")
-public class BizEntrustPriceController extends BaseController
-{
+public class BizEntrustPriceController extends BaseController {
     @Resource
     private IBizEntrustPriceService bizEntrustPriceService;
 
@@ -42,8 +41,7 @@ public class BizEntrustPriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:priceList:list')")
     @GetMapping("/list")
-    public TableDataInfo list(BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public TableDataInfo list(BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         startPage();
         List<BizEntrustPrice> list = bizEntrustPriceService.getList(bizEntrustPrice);
         return getDataTable(list);
@@ -55,8 +53,7 @@ public class BizEntrustPriceController extends BaseController
     @PreAuthorize("@ss.hasPermi('priceList:priceList:export')")
     @Log(title = "价目表系统", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public void export(HttpServletResponse response, BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         List<BizEntrustPrice> list = bizEntrustPriceService.getList(bizEntrustPrice);
         ExcelUtil<BizEntrustPrice> util = new ExcelUtil<BizEntrustPrice>(BizEntrustPrice.class);
         util.exportExcel(response, list, "价目表系统数据");
@@ -67,8 +64,7 @@ public class BizEntrustPriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:priceList:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(bizEntrustPriceService.getById(id));
     }
 
@@ -77,8 +73,7 @@ public class BizEntrustPriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:priceList:list')")
     @GetMapping("/tenantList")
-    public AjaxResult getTenantList(Tenant tenant)
-    {
+    public AjaxResult getTenantList(Tenant tenant) {
         return success(bizEntrustPriceService.getTenantList(tenant));
     }
 
@@ -87,8 +82,7 @@ public class BizEntrustPriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:priceList:list')")
     @GetMapping("/taskTypeList")
-    public AjaxResult getTaskTypeList()
-    {
+    public AjaxResult getTaskTypeList() {
         return success(bizEntrustPriceService.getTaskType(1));
     }
 
@@ -98,11 +92,12 @@ public class BizEntrustPriceController extends BaseController
     @PreAuthorize("@ss.hasPermi('priceList:priceList:save')")
     @Log(title = "价目表系统", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult add(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         //判读是否存在该价目
+        setTenantId(bizEntrustPrice);
+        bizEntrustPrice.setToTenantId(bizEntrustPrice.getFromTenantId());
         List<BizEntrustPrice> list = bizEntrustPriceService.getList(bizEntrustPrice);
-        if(list.size() > 0){
+        if (list.size() > 0) {
             return AjaxResult.error("该价目已存在");
         }
         return toAjax(bizEntrustPriceService.save(bizEntrustPrice));
@@ -114,18 +109,19 @@ public class BizEntrustPriceController extends BaseController
     @PreAuthorize("@ss.hasPermi('priceList:priceList:save')")
     @Log(title = "价目表系统", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult edit(@RequestBody BizEntrustPrice bizEntrustPrice) throws NoSuchFieldException, IllegalAccessException {
         //判读是否存在该价目
         List<BizEntrustPrice> list = bizEntrustPriceService.getList(bizEntrustPrice);
-        if(list.size() > 0){
-            //如果只有一条数据且id的相同
-            if(list.size()==1&&list.get(0).getId().equals(bizEntrustPrice.getId())){
+        //如果存在多条数据
+        if (list.size() > 1) {
+            return AjaxResult.error("该价目已存在");
+        } else if (list.size() == 1) {
+            //如果存在一条数据且id一致
+            if (list.get(0).getId().equals(bizEntrustPrice.getId())) {
                 return toAjax(bizEntrustPriceService.updateById(bizEntrustPrice));
-            }else{
+            } else {
                 return AjaxResult.error("该价目已存在");
             }
-
         }
         return toAjax(bizEntrustPriceService.updateById(bizEntrustPrice));
     }
@@ -135,9 +131,8 @@ public class BizEntrustPriceController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('priceList:priceList:remove')")
     @Log(title = "价目表系统", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable List<Long> ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids) {
         return toAjax(bizEntrustPriceService.removeBatchByIds(ids));
     }
 

+ 2 - 0
src/main/java/cn/ezhizao/project/business/reconciliation/priceList/domain/BizEntrustPrice.java

@@ -105,4 +105,6 @@ public class BizEntrustPrice extends BaseEntity
     @TableField(exist = false)
     private String taskTypeDetailName;
 
+    @TableField(exist = false)
+    protected Long tenantId;
 }

+ 2 - 2
src/main/java/cn/ezhizao/project/system/controller/SysDictTypeController.java

@@ -57,7 +57,7 @@ public class SysDictTypeController extends BaseController
     /**
      * 查询字典类型详细
      */
-    @PreAuthorize("@ss.hasPermi('system:dict:query,business:crm:dict:query')")
+    @PreAuthorize("@ss.hasAnyPermi('system:dict:query,business:crm:dict:query')")
     @GetMapping(value = "/{dictId}")
     public AjaxResult getInfo(@PathVariable Long dictId)
     {
@@ -67,7 +67,7 @@ public class SysDictTypeController extends BaseController
     /**
      * 新增字典类型
      */
-    @PreAuthorize("@ss.hasPermi('system:dict:add,business:crm:dict:add')")
+    @PreAuthorize("@ss.hasAnyPermi('system:dict:add,business:crm:dict:add')")
     @Log(title = "字典类型", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@Validated @RequestBody SysDictType dict) throws NoSuchFieldException, IllegalAccessException {

+ 3 - 2
src/main/java/cn/ezhizao/project/tenant/controller/TenantController.java

@@ -162,7 +162,7 @@ public class TenantController extends BaseController {
     @Log(title = "企业租户", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody Tenant tenant) {
-        return toAjax(tenantService.save(tenant));
+        return tenantService.save(tenant) ? success(tenant) : error();
     }
 
     @Value("${token.expireTime}")
@@ -296,13 +296,14 @@ public class TenantController extends BaseController {
     }
 
     private boolean initAdminRole(InitTenantVo initFlow) {
+        // 判断下角色是否存在,存在则获取角色,并不新增。
         SysRole sysRole = initFlow.getAdminRole();
         sysRole.setEditDisable("1");
         sysRole.setIsInit("1");
         sysRole.setTenantId(initFlow.getTenantId());
         List<Long> menuIds = tenantService.getTenantMenuIds(initFlow.getTenantId());
         sysRole.setMenuIds(menuIds.toArray(new Long[0]));
-        return (sysRole.getRoleId() != null && sysRole.getRoleId().equals(0L)) ? roleService.updateRole(sysRole) > 0 :
+        return (sysRole.getRoleId() != null && !sysRole.getRoleId().equals(0L)) ? roleService.updateRole(sysRole) > 0 :
                 roleService.insertRole(sysRole) > 0;
     }