Browse Source

代码同步

shuzhan 2 years ago
parent
commit
be8a24b9cb

+ 2 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/TrainingPersonDAO.java

@@ -15,4 +15,6 @@ public interface TrainingPersonDAO {
 	int delete(String id);
 	List<TrainingPerson> list();
 	List<TrainingPerson> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+	TrainingPerson findByTrainingIdAndPersonId(String trainingId,String personId);
 }

+ 14 - 0
common/src/main/java/com/jpsoft/employment/modules/base/entity/JobInformationInfo.java

@@ -93,4 +93,18 @@ public class JobInformationInfo {
 
 	@ApiModelProperty(value = "浏览次数")
 	private Integer browseNumber;
+
+	@Transient
+	@ApiModelProperty(value = "出生日期")
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date birthday;
+
+	@Transient
+	@ApiModelProperty(value = "年龄")
+	private Integer age;
+
+	@Transient
+	@ApiModelProperty(value = "性别")
+	private String gender;
 }

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/TrainingPersonService.java

@@ -14,4 +14,5 @@ public interface TrainingPersonService {
 	int delete(String id);
 	List<TrainingPerson> list();
 	Page<TrainingPerson> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+	TrainingPerson findByTrainingIdAndPersonId(String trainingId,String personId);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/TrainingPersonServiceImpl.java

@@ -67,4 +67,9 @@ public class TrainingPersonServiceImpl implements TrainingPersonService {
         
         return page;
 	}
+
+	@Override
+	public TrainingPerson findByTrainingIdAndPersonId(String trainingId,String personId){
+		return trainingPersonDAO.findByTrainingIdAndPersonId(trainingId,personId);
+	}
 }

+ 7 - 1
common/src/main/resources/mapper/base/JobInformationInfo.xml

@@ -21,6 +21,9 @@
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
 			<result property="browseNumber" column="browse_number" />
+			<result property="birthday" column="birthday_" />
+			<result property="age" column="age_" />
+			<result property="sex" column="sex_" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.JobInformationInfo">
 	<!--
@@ -154,7 +157,10 @@
 	</select>
 	<select id="searchMobile" parameterType="hashmap" resultMap="JobInformationInfoMap">
 		<![CDATA[
-			select a.* from base_job_information_info a
+			SELECT
+				a.*
+			FROM
+				base_job_information_info a
 		]]>
 		<where>
 			a.del_flag=false

+ 8 - 2
common/src/main/resources/mapper/base/TrainingPerson.xml

@@ -66,8 +66,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="TrainingPersonMap">
-		select 
-id_,person_id,training_id,create_by,create_time,update_by,update_time,del_flag		from base_training_person where id_=#{0}
+		select * from base_training_person where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_training_person where id_=#{0}
@@ -88,4 +87,11 @@ id_,person_id,training_id,create_by,create_time,update_by,update_time,del_flag
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="findByTrainingIdAndPersonId" resultMap="TrainingPersonMap">
+		select * from base_training_person
+		where person_id =#{personId}
+		and training_id =#{trainingId}
+		and del_flag = 0
+		limit 1
+	</select>
 </mapper>

+ 2 - 0
web/src/main/java/com/jpsoft/employment/config/WebMvcConfig.java

@@ -68,6 +68,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/dictionary/**")
 				.excludePathPatterns("/mobile/job/jobDetail")
 				.excludePathPatterns("/mobile/job/jobHuntDetail")
+				.excludePathPatterns("/mobile/training/trainingList")
+				.excludePathPatterns("/mobile/training/trainingDetail")
 		;
 
 

+ 0 - 3
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/JobApiController.java

@@ -328,9 +328,6 @@ public class JobApiController {
                     msgResult.setResult(false);
                 }
             }
-
-
-            msgResult.setResult(true);
         }catch (Exception e){
             msgResult.setResult(false);
             msgResult.setMessage(e.getMessage());

+ 0 - 71
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/NewsApiController.java

@@ -200,75 +200,4 @@ public class NewsApiController {
         return messageResult;
     }
 
-    @PostMapping("trainingList")
-    @ApiOperation(value = "技能培训")
-    public MessageResult<Map> trainingList(
-            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
-            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        MessageResult<Map> messageResult = new MessageResult<>();
-
-        try {
-
-            
-
-            Map<String,Object> searchParams = new HashMap<>();
-
-            List<Sort> sortList = new ArrayList<>();
-            sortList.add(new Sort("create_time","desc"));
-
-            searchParams.put("status","1");
-            Page<TrainingInfo> page = trainingInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
-
-            for (TrainingInfo trainingInfo:page) {
-                EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(trainingInfo.getEnterpriseId());
-                if(enterpriseInfo!=null){
-                    trainingInfo.setEnterpriseName(enterpriseInfo.getName());
-                }
-            }
-
-            messageResult.setResult(true);
-            messageResult.setData(PojoUtils.pageWrapper(page));
-        } catch (Exception ex) {
-            log.error(ex.getMessage());
-            messageResult.setResult(false);
-            messageResult.setMessage(ex.getMessage());
-        }
-
-        return messageResult;
-    }
-
-    @PostMapping("trainingDetail")
-    @ApiOperation(value = "技能培训详细")
-    public MessageResult<Map> trainingDetail(
-            @RequestParam(value = "id", defaultValue = "") String id) {
-        MessageResult<Map> messageResult = new MessageResult<>();
-        try {
-            
-            Map<String,Object> returnMap = new HashMap<>();
-
-            TrainingInfo trainingInfo = trainingInfoService.get(id);
-            if(trainingInfo == null){
-                throw new Exception("未找到内容");
-            }
-
-            EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(trainingInfo.getEnterpriseId());
-            if(enterpriseInfo!=null){
-                trainingInfo.setEnterpriseName(enterpriseInfo.getName());
-            }
-
-            returnMap.put("trainingInfo",trainingInfo);
-
-            PersonInfo personInfo = personInfoService.get(enterpriseInfo.getCreateBy());
-            returnMap.put("personInfo",personInfo);
-
-            messageResult.setResult(true);
-            messageResult.setData(returnMap);
-        } catch (Exception ex) {
-            log.error(ex.getMessage());
-            messageResult.setResult(false);
-            messageResult.setMessage(ex.getMessage());
-        }
-
-        return messageResult;
-    }
 }

+ 2 - 0
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/RecruitApiController.java

@@ -197,6 +197,8 @@ public class RecruitApiController {
                     PersonInfo personInfo = personInfoService.get(jobInformationInfo.getPersonId());
                     if(personInfo!=null){
                         jobInformationInfo.setPersonName(personInfo.getRealName());
+                        jobInformationInfo.setGender(personInfo.getGender());
+                        jobInformationInfo.setAge(personInfo.getAge());
                     }
 
                     jobInformationInfo.setIntendedIndustriesN(dataDictionaryService.findNameByCatalogNameAndValue("意向行业",jobInformationInfo.getIntendedIndustries()));

+ 238 - 0
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/TrainingApiController.java

@@ -0,0 +1,238 @@
+package com.jpsoft.employment.modules.mobile.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.base.entity.*;
+import com.jpsoft.employment.modules.base.service.*;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.utils.JwtUtil;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
+
+@Slf4j
+@RestController
+@RequestMapping("/mobile/training")
+@Api(description = "培训信息")
+public class TrainingApiController {
+    @Value("${jwt.secret}")
+    private String jwtSecret;
+
+    @Autowired
+    RabbitTemplate rabbitTemplate;
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+    @Autowired
+    private ValueOperations<String, Object> valueOperations;
+    @Autowired
+    private PersonInfoService personInfoService;
+    @Autowired
+    private TrainingInfoService trainingInfoService;
+    @Autowired
+    private TrainingPersonService trainingPersonService;
+    @Autowired
+    private EnterpriseInfoService enterpriseInfoService;
+
+    @PostMapping("trainingList")
+    @ApiOperation(value = "技能培训(公开接口")
+    public MessageResult<Map> trainingList(
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+            Map<String,Object> searchParams = new HashMap<>();
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+
+            searchParams.put("status","1");
+            Page<TrainingInfo> page = trainingInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+            for (TrainingInfo trainingInfo:page) {
+                EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(trainingInfo.getEnterpriseId());
+                if(enterpriseInfo!=null){
+                    trainingInfo.setEnterpriseName(enterpriseInfo.getName());
+                }
+            }
+
+            messageResult.setResult(true);
+            messageResult.setData(PojoUtils.pageWrapper(page));
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @ApiOperation(value="培训信息详细(公开接口")
+    @RequestMapping(value = "trainingDetail",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "trainingId", value = "培训信息ID", required = true, paramType = "form"),
+    })
+    public MessageResult<Map> trainingDetail(
+            @RequestParam(value="trainingId",defaultValue="") String trainingId,
+            HttpServletRequest request){
+        MessageResult<Map> msgResult = new MessageResult<>();
+        try {
+            String subject = "";
+
+            String token = request.getHeader("Authorization");
+
+            if (org.springframework.util.StringUtils.isEmpty(token)){
+                token = (String)request.getSession().getAttribute("token");
+            }
+
+            if (org.springframework.util.StringUtils.isEmpty(token)) {
+                token = request.getParameter("token");
+            }
+
+            if (StringUtils.isNotEmpty(token)){
+                subject = JwtUtil.decodeToken(jwtSecret,token);
+            }
+
+            Boolean isJoin = false;
+
+            Map<String,Object> returnMap = new HashMap<>();
+            TrainingInfo trainingInfo = trainingInfoService.get(trainingId);
+            if(trainingInfo == null){
+                throw new Exception("未找到信息");
+            }
+
+            EnterpriseInfo enterpriseInfo = enterpriseInfoService.get(trainingInfo.getEnterpriseId());
+            if(enterpriseInfo!=null){
+                trainingInfo.setEnterpriseName(enterpriseInfo.getName());
+            }
+
+            PersonInfo personInfo = personInfoService.get(subject);
+            if(personInfo != null){
+                TrainingPerson trainingPerson = trainingPersonService.findByTrainingIdAndPersonId(trainingId,personInfo.getId());
+                if(trainingPerson != null){
+                    isJoin = true;
+                }
+            }
+
+
+            returnMap.put("trainingInfo",trainingInfo);
+            returnMap.put("enterpriseInfo",enterpriseInfo);
+            returnMap.put("isJoin",isJoin);
+
+            msgResult.setData(returnMap);
+            msgResult.setResult(true);
+        }catch (Exception e){
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+            e.printStackTrace();
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="我要报名")
+    @RequestMapping(value = "joinTraining",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "trainingId", value = "培训信息ID", required = true, paramType = "form"),
+    })
+    public MessageResult<Map> joinTraining(
+            @RequestParam(value="trainingId",defaultValue="") String trainingId,
+            @RequestAttribute String subject){
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+        try {
+
+            PersonInfo personInfo = personInfoService.get(subject);
+            if (personInfo == null) {
+                throw new Exception("未登录");
+            }
+
+            TrainingPerson trainingPerson = trainingPersonService.findByTrainingIdAndPersonId(trainingId,personInfo.getId());
+            if(trainingPerson != null){
+                throw new Exception("已报名");
+            }
+
+            trainingPerson = new TrainingPerson();
+            trainingPerson.setId(UUID.randomUUID().toString());
+            trainingPerson.setDelFlag(false);
+            trainingPerson.setCreateBy(subject);
+            trainingPerson.setCreateTime(new Date());
+            trainingPerson.setTrainingId(trainingId);
+            trainingPerson.setPersonId(subject);
+
+            int count = trainingPersonService.insert(trainingPerson);
+
+            if(count > 0){
+                msgResult.setResult(true);
+                msgResult.setMessage("报名成功");
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("报名失败");
+            }
+        }catch (Exception e){
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+            e.printStackTrace();
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="我要取消报名")
+    @RequestMapping(value = "cancelTraining",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "trainingId", value = "培训信息ID", required = true, paramType = "form"),
+    })
+    public MessageResult<Map> cancelTraining(
+            @RequestParam(value="trainingId",defaultValue="") String trainingId,
+            @RequestAttribute String subject){
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+        try {
+
+            PersonInfo personInfo = personInfoService.get(subject);
+            if (personInfo == null) {
+                throw new Exception("未登录");
+            }
+
+            TrainingPerson trainingPerson = trainingPersonService.findByTrainingIdAndPersonId(trainingId,personInfo.getId());
+            if(trainingPerson == null){
+                throw new Exception("未报名");
+            }
+
+            trainingPerson.setDelFlag(true);
+            trainingPerson.setUpdateBy(subject);
+            trainingPerson.setUpdateTime(new Date());
+            int count = trainingPersonService.update(trainingPerson);
+
+            if(count > 0){
+                msgResult.setResult(true);
+                msgResult.setMessage("操作成功");
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("操作失败");
+            }
+
+        }catch (Exception e){
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+            e.printStackTrace();
+        }
+
+        return msgResult;
+    }
+
+}