lsw 1 jaar geleden
bovenliggende
commit
dc57895783
23 gewijzigde bestanden met toevoegingen van 399 en 106 verwijderingen
  1. 1 2
      app/common/common.scss
  2. 2 2
      app/common/http.js
  3. 8 0
      app/pages.json
  4. 94 70
      app/pages/company/index.vue
  5. 79 0
      app/pages/company/search.vue
  6. 11 8
      app/pages/index/index.vue
  7. 2 2
      app/pages/user/index.vue
  8. 29 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_CompanyController.java
  9. 8 6
      ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_RelateController.java
  10. 18 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/CompanyDto.java
  11. 21 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/vo/CompanyListVo.java
  12. 29 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/vo/RelateCompanyListVo.java
  13. 6 1
      ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/CompanyMapper.java
  14. 7 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/RelateMapper.java
  15. 4 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/service/ICompanyService.java
  16. 5 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/service/IRelateService.java
  17. 7 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/CompanyServiceImpl.java
  18. 25 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/RelateServiceImpl.java
  19. 3 0
      ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/UserServiceImpl.java
  20. 0 5
      ruoyi-admin/src/main/resources/mapper/work/CompanyMapper.xml
  21. 17 4
      ruoyi-admin/src/main/resources/mapper/work/RelateMapper.xml
  22. 0 3
      ruoyi-admin/src/main/resources/mapper/work/UserMapper.xml
  23. 23 3
      ruoyi-admin/src/test/java/com/ruoyi/user.java

+ 1 - 2
app/common/common.scss

@@ -12,8 +12,7 @@
 	}
 }
 .tab {
-	background-color: white;
-	padding: 5px;
+	padding: 0px 5px 5px 5px;
 	/* #ifdef H5 */
 	margin-top: -1px;
 	/* #endif */

+ 2 - 2
app/common/http.js

@@ -1,9 +1,9 @@
-const ip = 'http://127.0.0.1:9191';
+//const ip = 'http://127.0.0.1:9191';
 //const ip = 'http://192.168.0.107:9191';
 //const ip = 'http://211.149.236.41:8080/houtai-api';
 //const ip = 'http://192.168.174.80:9191';
 //const ip = 'http://106.55.241.82:9191';
-//const ip = 'http://106.55.241.82:9191';
+const ip = 'http://192.168.0.100:9191';
 /**
  * 封装的http请求
  */

+ 8 - 0
app/pages.json

@@ -46,6 +46,14 @@
 			"style" : 
 			{
 				"navigationBarTitleText" : "关联企业",
+				"enablePullDownRefresh" : true
+			}
+		},
+		{
+			"path" : "pages/company/search",
+			"style" : 
+			{
+				"navigationBarTitleText" : "手动关联",
 				"enablePullDownRefresh" : false
 			}
 		}

+ 94 - 70
app/pages/company/index.vue

@@ -1,19 +1,23 @@
 <template>
-	<view class="notice">
-		<view class="tz_item" v-for="(item, index) in list" :key="index" @click="detail(item)">
-			<view class="ctop">
-				<text class="icon tb">&#xe734;</text>
-				<text class="tag">通知公告</text>
-				<view class="clear"></view>
-			</view>
-			<view class="content">
-				<view class="title omit">{{ item.title }}</view>
+	<view>
+		<view class="tab">
+			<u-tabs :list="tab" :current="0"></u-tabs>
+		</view>
+		<view class="list">
+			<view class="item" v-for="(item, index) in list" :key="index">
+				<view class="title">{{ item.companyName }}</view>
+				<view class="op">
+					<text>{{ item.createTime }}</text>
+					<text class="del" @click="del(item)">解除</text>
+				</view>
 			</view>
-			<view class="time">{{ item.createTime }}</view>
-			<view class="clear"></view>
+			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
+			<u-empty v-if="!loadMore && list.length == 0" text="尚未关联公司"></u-empty>
+		</view>
+		<view class="footer">
+			<view class="db"><button class="btn" @click="show = true">关联企业</button></view>
 		</view>
-		<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
-		<u-empty v-if="!loadMore && list.length == 0"></u-empty>
+		<u-action-sheet round="20" :actions="actions" @select="selectClick" cancelText="取消" :show="show" @close="show = false"></u-action-sheet>
 	</view>
 </template>
 
@@ -21,6 +25,9 @@
 export default {
 	data() {
 		return {
+			tab: [{ name: '全部' }],
+			show: false,
+			actions: [{ name: '扫码关联' }, { name: '手动关联' }],
 			list: [],
 			param: { pageNum: 1, pageSize: 10, orderByColumn: 'createTime', isAsc: 'desc' },
 			loadMore: true
@@ -28,11 +35,14 @@ export default {
 	},
 	onLoad(e) {
 		this.getData();
+		uni.$on('company', (res) => {
+			this.refresh();
+		});
 	},
 	methods: {
 		getData() {
 			this.http.request({
-				url: '/app/user/company/list',
+				url: '/app/relate/list',
 				data: this.param,
 				loading: 'false',
 				success: (res) => {
@@ -44,9 +54,49 @@ export default {
 				}
 			});
 		},
-		detail(item) {
-			uni.navigateTo({
-				url: '/pages/notice/detail?id=' + item.id
+		selectClick(e) {
+			if (e.name == '手动关联') {
+				uni.navigateTo({ url: '/pages/company/search' });
+			} else {
+				uni.scanCode({
+					success: (res) => {
+						this.http.request({
+							url: '/app/relate/add',
+							data: { companyId: res.result },
+							method: 'POST',
+							success: (res) => {
+								uni.showModal({
+									title: '提示',
+									content: '关联成功',
+									showCancel: false,
+									success: (res) => {
+										this.refresh();
+									}
+								});
+							}
+						});
+					},
+					fail: (res) => {}
+				});
+			}
+		},
+		del(item) {
+			uni.showModal({
+				title: '提示',
+				content: '确定解除该企业关联?',
+				success: (res) => {
+					if (res.confirm) {
+						this.http.request({
+							url: '/app/relate/remove',
+							data: { companyId: item.companyId },
+							method: 'POST',
+							success: (res) => {
+								uni.showToast({ title: '解除成功' });
+								this.list.splice(this.list.indexOf(item), 1);
+							}
+						});
+					}
+				}
 			});
 		},
 		//刷新数据
@@ -75,63 +125,37 @@ export default {
 </script>
 
 <style lang="scss">
-page {
-	background-color: white;
-}
-.notice {
-	background-color: white;
-	.tz_item {
-		padding: 7px 15px 15px 15px;
-		color: $font-c;
+.list {
+	padding: 10px 10px 90px 10px;
+	.item {
+		background-color: white;
+		padding: 15px;
+		border-radius: 5px;
 		margin-bottom: 10px;
-		border-bottom: 1px solid #f0f2f7;
-		cursor: pointer;
-		.ctop {
-			position: relative;
-			.bage {
-				position: absolute;
-				width: 8px;
-				height: 8px;
-				left: 23px;
-				top: 0px;
-				border: 1px solid white;
-				border-radius: 50%;
-				background-color: red;
-			}
-			.tb {
-				width: 30px;
-				height: 30px;
-				line-height: 28px;
-				text-align: center;
-				border-radius: 50%;
-				font-size: 20px;
-				margin-right: 5px;
-				float: left;
-				background-color: #4581fb;
-				color: white;
-			}
-			.tag {
-				float: left;
-				font-size: 14px;
-				font-weight: bold;
-				margin-top: 4px;
-				margin-left: 5px;
-			}
-		}
-		.content {
-			float: left;
-			width: 75%;
-			margin-top: 10px;
-			color: #717171;
-			.title {
-				font-size: 14px;
-			}
+		.title {
+			padding-bottom: 10px;
 		}
-		.time {
+		.op {
+			border-top: 1px solid $line;
+			padding-top: 10px;
+			color: #676767;
 			font-size: 14px;
-			padding: 10px 0px 0px 0px;
-			float: right;
+			.del {
+				float: right;
+				color: #f44336;
+			}
 		}
 	}
 }
+.footer {
+	position: fixed;
+	width: 100%;
+	bottom: 0px;
+	padding-bottom: 13px;
+	background-color: white;
+	border-top: 1px solid $line;
+	.db {
+		padding: 15px 35px 10px 35px;
+	}
+}
 </style>

+ 79 - 0
app/pages/company/search.vue

@@ -0,0 +1,79 @@
+<template>
+	<view>
+		<view class="search"><u-search placeholder="公司名称" v-model="param.companyName" :animation="true" @search="getData()" @clear="clear()"></u-search></view>
+		<view class="list">
+			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
+				<text>{{ item.companyName }}</text>
+				<text class="icon">&#xe62b;</text>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+export default {
+	data() {
+		return {
+			list: [],
+			param: {}
+		};
+	},
+	methods: {
+		getData() {
+			this.http.request({
+				url: '/app/company/list',
+				data: this.param,
+				success: (res) => {
+					this.list = res.data.data;
+				}
+			});
+		},
+		detail(item) {
+			uni.showModal({
+				title: '提示',
+				content: '确定关联该企业?',
+				success: (res) => {
+					if (res.confirm) {
+						this.http.request({
+							url: '/app/relate/add',
+							data: { companyId: item.id },
+							method: 'POST',
+							success: (res) => {
+								uni.showModal({
+									title: '提示',
+									content: '关联成功',
+									showCancel: false,
+									success: (res) => {
+										uni.$emit('company');
+										uni.navigateBack();
+									}
+								});
+							}
+						});
+					}
+				}
+			});
+		},
+		clear() {
+			this.list = [];
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+.search {
+	padding: 12px 20px 12px 20px;
+	background-color: white;
+}
+.list {
+	.item {
+		padding: 17px;
+		background-color: white;
+		margin-top: 10px;
+		.icon {
+			float: right;
+		}
+	}
+}
+</style>

+ 11 - 8
app/pages/index/index.vue

@@ -39,7 +39,7 @@
 					<text class="icon">&#xe62b;</text>
 				</view>
 				<view class="state" v-else>
-					<view class="go">去关联</view>
+					<view class="go" :style="{ backgroundColor: user.isAuthentication === 1 ? '#5a7afc' : '#d6d6d6' }">去关联</view>
 				</view>
 			</view>
 			<!--开始接包-->
@@ -48,11 +48,10 @@
 				<view class="con">
 					<view class="bt">开始接包</view>
 					<view class="bor" style="background: linear-gradient(to right, #c9f1d4, rgb(250 255 252))"></view>
-					<view class="zt">未实名</view>
+					<view class="zt">{{ !user.isCompany || user.isCompany == 0 ? '请先完成上一步' : '去接包' }}</view>
 				</view>
 				<view class="state">
-					<text class="zt">已认证</text>
-					<text class="icon">&#xe62b;</text>
+					<view class="go" :style="{ backgroundColor: user.isCompany > 0 ? '#5a7afc' : '#d6d6d6' }" @click="tab()">去接包</view>
 				</view>
 			</view>
 			<!--电子签约-->
@@ -61,11 +60,10 @@
 				<view class="con">
 					<view class="bt">电子签约</view>
 					<view class="bor" style="background: linear-gradient(to right, #f6f6bf, rgb(246 246 246))"></view>
-					<view class="zt">未实名</view>
+					<view class="zt">{{ !user.isContract || user.isContract == 0 ? '请签约' : '已签约' }}</view>
 				</view>
 				<view class="state">
-					<text class="zt">已认证</text>
-					<text class="icon">&#xe62b;</text>
+					<view class="go" :style="{ backgroundColor: user.isCompany > 0 ? '#5a7afc' : '#d6d6d6' }">去签约</view>
 				</view>
 			</view>
 		</view>
@@ -114,6 +112,11 @@ export default {
 			} else {
 				uni.navigateTo({ url: '/pages/user/login' });
 			}
+		},
+		tab() {
+			if (this.user.isCompany > 0) {
+				uni.switchTab({ url: '/pages/packages/index' });
+			}
 		}
 	}
 };
@@ -164,7 +167,7 @@ export default {
 			}
 			.zt {
 				font-size: 13px;
-				padding-top: 3px;
+				padding-top: 5px;
 				color: #909090;
 			}
 		}

+ 2 - 2
app/pages/user/index.vue

@@ -44,8 +44,8 @@ export default {
 		};
 	},
 	onShow() {
-/* 		  this.user = {
-			token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImU3ZDZmYWZkLTY2YzQtNDAwMC1iOTgyLWFjZWI3ZmEyNzU2NyJ9.Vl0vxvIzabGbBRSlMziU4EhoLEU-qHnOL_oQsLxwxMhxEecw2hYixMlgebTLR80OzaNaVUXrNrzCw0shAe-h6g'
+ 		/*  this.user = {
+			token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjI2NTFjMmU4LTAxNzEtNDQwYS04YjA2LTcwOWI3N2ZhNGZiZCJ9.zb2gQaeHZApJkbo4LoSeZfnVVsJJ-QabY7FnsVn13Kf1KUgKeBQ82bwhzD-CqchI1dhUOQFoVh__zeJaJHFWGg'
 		};
 		uni.setStorageSync('user', this.user); */
 		if (this.hasLogin()) {

+ 29 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_CompanyController.java

@@ -0,0 +1,29 @@
+package com.ruoyi.web.work.api;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.web.work.domain.dto.CompanyDto;
+import com.ruoyi.web.work.service.ICompanyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 企业管理
+ *
+ * @author lsw
+ * @date 2024-04-16
+ */
+@RestController
+@RequestMapping("/app/company")
+public class Api_CompanyController extends BaseController {
+    @Autowired
+    private ICompanyService companyService;
+
+    @GetMapping("/list")
+    public AjaxResult list(@Validated CompanyDto dto) {
+        return AjaxResult.success(companyService.selectCompanyList(dto));
+    }
+}

+ 8 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_RelateController.java

@@ -4,11 +4,12 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.web.work.api.config.BaseController;
 import com.ruoyi.web.work.domain.Relate;
+import com.ruoyi.web.work.domain.vo.RelateCompanyListVo;
 import com.ruoyi.web.work.service.IRelateService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -27,17 +28,18 @@ public class Api_RelateController extends BaseController {
     public TableDataInfo list(Relate relate) {
         relate.setUserId(getUser().getId());
         startPage();
-        List<Relate> list = relateService.selectList(relate);
+        List<RelateCompanyListVo> list = relateService.selectRelateCompanyList(relate);
         return getDataTable(list);
     }
 
     @PostMapping("/add")
-    public AjaxResult add(@RequestBody Relate relate) {
+    public AjaxResult add(@Validated @RequestBody Relate relate) {
         return relateService.add(relate);
     }
 
-    @GetMapping("/remove/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids) {
-        return toAjax(relateService.removeByIds(Arrays.asList(ids)));
+    @PostMapping("/remove")
+    public AjaxResult remove(@RequestBody Relate relate) {
+        relate.setUserId(getUser().getId());
+        return toAjax(relateService.remove(relate));
     }
 }

+ 18 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/CompanyDto.java

@@ -0,0 +1,18 @@
+package com.ruoyi.web.work.domain.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @author lsw
+ * @date 2024-04-16
+ */
+@Data
+@Accessors(chain = true)
+public class CompanyDto {
+
+    @NotBlank(message = "企业名称不能为空")
+    private String companyName;
+}

+ 21 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/vo/CompanyListVo.java

@@ -0,0 +1,21 @@
+package com.ruoyi.web.work.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author lsw
+ * @date 2024-04-16
+ */
+@Data
+@Accessors(chain = true)
+public class CompanyListVo {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @ApiModelProperty(value = "企业名称")
+    private String companyName;
+
+}

+ 29 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/vo/RelateCompanyListVo.java

@@ -0,0 +1,29 @@
+package com.ruoyi.web.work.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * @author lsw
+ * @date 2024-04-16
+ */
+@Data
+@Accessors(chain = true)
+public class RelateCompanyListVo {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    private Long companyId;
+
+    @ApiModelProperty(value = "企业名称")
+    private String companyName;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+}

+ 6 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/CompanyMapper.java

@@ -2,6 +2,8 @@ package com.ruoyi.web.work.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.web.work.domain.Company;
+import com.ruoyi.web.work.domain.dto.CompanyDto;
+import com.ruoyi.web.work.domain.vo.CompanyListVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -14,6 +16,9 @@ import java.util.List;
 public interface CompanyMapper extends BaseMapper<Company> {
     List<Company> selectList(Company company);
 
+    @Select("SELECT * FROM tb_company WHERE state=0 AND company_name=#{companyName}")
+    List<CompanyListVo> selectCompanyList(CompanyDto dto);
+
     @Select("SELECT * FROM tb_company WHERE company_name=#{companyName}")
-    Company selectByCompanyName(@Param("companyName")String companyName);
+    Company selectByCompanyName(@Param("companyName") String companyName);
 }

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/RelateMapper.java

@@ -2,6 +2,8 @@ package com.ruoyi.web.work.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.web.work.domain.Relate;
+import com.ruoyi.web.work.domain.vo.RelateCompanyListVo;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
@@ -13,6 +15,11 @@ import java.util.List;
 public interface RelateMapper extends BaseMapper<Relate> {
     List<Relate> selectList(Relate relate);
 
+    List<RelateCompanyListVo> selectRelateCompanyList(Relate relate);
+
     @Select("SELECT * FROM tb_relate WHERE user_id=#{userId} AND company_id=#{companyId}")
     Relate check(Relate relate);
+
+    @Delete("DELETE  FROM tb_relate WHERE user_id=#{userId} AND company_id=#{companyId}")
+    boolean remove(Relate relate);
 }

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/ICompanyService.java

@@ -3,6 +3,8 @@ package com.ruoyi.web.work.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.web.work.domain.Company;
+import com.ruoyi.web.work.domain.dto.CompanyDto;
+import com.ruoyi.web.work.domain.vo.CompanyListVo;
 
 import java.rmi.ServerException;
 import java.util.List;
@@ -14,6 +16,8 @@ import java.util.List;
 public interface ICompanyService extends IService<Company>{
     List<Company> selectList(Company company);
 
+    List<CompanyListVo> selectCompanyList(CompanyDto dto);
+
     AjaxResult add(Company company) throws ServerException;
 
 }

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/IRelateService.java

@@ -3,6 +3,7 @@ package com.ruoyi.web.work.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.web.work.domain.Relate;
+import com.ruoyi.web.work.domain.vo.RelateCompanyListVo;
 
 import java.util.List;
 
@@ -13,5 +14,9 @@ import java.util.List;
 public interface IRelateService extends IService<Relate>{
     List<Relate> selectList(Relate relate);
 
+    List<RelateCompanyListVo> selectRelateCompanyList(Relate relate);
+
     AjaxResult add(Relate relate);
+
+    boolean remove(Relate relate);
 }

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/CompanyServiceImpl.java

@@ -7,6 +7,8 @@ import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.web.work.domain.Company;
+import com.ruoyi.web.work.domain.dto.CompanyDto;
+import com.ruoyi.web.work.domain.vo.CompanyListVo;
 import com.ruoyi.web.work.mapper.CompanyMapper;
 import com.ruoyi.web.work.service.ICompanyService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +36,11 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         return companyMapper.selectList(company);
     }
 
+    @Override
+    public List<CompanyListVo> selectCompanyList(CompanyDto dto) {
+        return companyMapper.selectCompanyList(dto);
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public AjaxResult add(Company company) throws ServerException {

+ 25 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/RelateServiceImpl.java

@@ -5,9 +5,12 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.web.work.api.util.AppUtil;
 import com.ruoyi.web.work.domain.Company;
 import com.ruoyi.web.work.domain.Relate;
+import com.ruoyi.web.work.domain.User;
+import com.ruoyi.web.work.domain.vo.RelateCompanyListVo;
 import com.ruoyi.web.work.mapper.RelateMapper;
 import com.ruoyi.web.work.service.ICompanyService;
 import com.ruoyi.web.work.service.IRelateService;
+import com.ruoyi.web.work.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -26,11 +29,19 @@ public class RelateServiceImpl extends ServiceImpl<RelateMapper, Relate> impleme
     @Autowired
     private ICompanyService companyService;
 
+    @Autowired
+    IUserService userService;
+
     @Override
     public List<Relate> selectList(Relate relate) {
         return relateMapper.selectList(relate);
     }
 
+    @Override
+    public List<RelateCompanyListVo> selectRelateCompanyList(Relate relate) {
+        return relateMapper.selectRelateCompanyList(relate);
+    }
+
     @Transactional
     @Override
     public AjaxResult add(Relate relate) {
@@ -39,11 +50,25 @@ public class RelateServiceImpl extends ServiceImpl<RelateMapper, Relate> impleme
             return AjaxResult.error("企业不存在或停用");
         }
         relate.setUserId(AppUtil.getUser().getId());
+        relate.setState(0);
         Relate check = relateMapper.check(relate);
         if (check != null) {
             return AjaxResult.error("你已关联该企业");
         }
         save(relate);
+        User user = userService.getById(AppUtil.getUser().getId());
+        user.setIsCompany(user.getIsCompany() + 1);
+        userService.updateById(user);
         return AjaxResult.success();
     }
+
+    @Override
+    public boolean remove(Relate relate) {
+        if (relateMapper.remove(relate)) {
+            User user = userService.getById(AppUtil.getUser().getId());
+            user.setIsCompany(user.getIsCompany() - 1);
+            return userService.updateById(user);
+        }
+        return false;
+    }
 }

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/UserServiceImpl.java

@@ -50,6 +50,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         if (user == null) {
             user = new User();
             user.setOpenId(res.getString("openid"));
+            user.setIsCompany(0);
+            user.setIsContract(0);
+            user.setIsAuthentication(0);
             user.setState(0);
             save(user);
             return AjaxResult.success(new AjaxResult().put("token", tokenService.createToken(user)));

+ 0 - 5
ruoyi-admin/src/main/resources/mapper/work/CompanyMapper.xml

@@ -9,13 +9,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>  
             <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
             <if test="director != null  and director != ''"> and director = #{director}</if>
-            <if test="email != null  and email != ''"> and email = #{email}</if>
             <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
             <if test="address != null  and address != ''"> and address = #{address}</if>
-            <if test="bankName != null  and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
-            <if test="bankAccount != null  and bankAccount != ''"> and bank_account = #{bankAccount}</if>
-            <if test="b1 != null  and b1 != ''"> and b1 = #{b1}</if>
-            <if test="business != null  and business != ''"> and business = #{business}</if>
             <if test="state != null "> and state = #{state}</if>
         </where>
     </select>

+ 17 - 4
ruoyi-admin/src/main/resources/mapper/work/RelateMapper.xml

@@ -5,12 +5,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.web.work.mapper.RelateMapper">
     
     <select id="selectList" resultType="com.ruoyi.web.work.domain.Relate">
-        select * from tb_relate
+        SELECT
+        r.*,
+        c.name,c.alipay,c.phone,c.is_contract,c.id_card
+        FROM tb_relate r
+        LEFT JOIN tb_user c ON c.id = r.user_id
         <where>  
-            <if test="userId != null "> and user_id = #{userId}</if>
-            <if test="companyId != null "> and company_id = #{companyId}</if>
-            <if test="state != null "> and state = #{state}</if>
+            <if test="companyId != null "> and r.company_id = #{companyId}</if>
+            <if test="name != null  and name != ''"> and c.name like concat('%', #{name}, '%')</if>
         </where>
     </select>
 
+    <select id="selectRelateCompanyList" resultType="com.ruoyi.web.work.domain.vo.RelateCompanyListVo">
+        SELECT
+        r.*,
+        c.company_name
+        FROM tb_relate r
+        LEFT JOIN tb_company c ON c.id = r.company_id
+        WHERE r.user_id =#{userId}
+        ORDER BY r.id DESC
+    </select>
+
 </mapper>

+ 0 - 3
ruoyi-admin/src/main/resources/mapper/work/UserMapper.xml

@@ -13,11 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="bankName != null  and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
             <if test="bankAccount != null  and bankAccount != ''"> and bank_account = #{bankAccount}</if>
             <if test="alipay != null  and alipay != ''"> and alipay = #{alipay}</if>
-            <if test="p1 != null  and p1 != ''"> and p1 = #{p1}</if>
-            <if test="p2 != null  and p2 != ''"> and p2 = #{p2}</if>
             <if test="serviceCompany != null  and serviceCompany != ''"> and service_company = #{serviceCompany}</if>
             <if test="isContract != null "> and is_contract = #{isContract}</if>
-            <if test="contractDate != null "> and contract_date = #{contractDate}</if>
             <if test="state != null "> and state = #{state}</if>
         </where>
     </select>

+ 23 - 3
ruoyi-admin/src/test/java/com/ruoyi/user.java

@@ -1,18 +1,38 @@
 package com.ruoyi;
 
+import com.ruoyi.web.work.domain.Notice;
+import com.ruoyi.web.work.domain.Relate;
+import com.ruoyi.web.work.service.INoticeService;
+import com.ruoyi.web.work.service.IRelateService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.transaction.annotation.Transactional;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = RuoYiApplication.class)
 public class user {
 
+    @Autowired
+    private IRelateService relateService;
+
+    @Autowired
+    private INoticeService noticeService;
 
     @Test
-    public void aa(){
-        System.out.println("a1111");
-    }
+    @Transactional
+    public void aa() {
+        Relate relate = new Relate();
+        relateService.updateById(relate);
 
+        Notice notice = new Notice();
+        notice.setTitle("高韦神");
+        notice.setState(0);
+        notice.setContents("高韦神");
+        noticeService.save(notice);
+
+        System.out.println("操作成功");
+    }
 }