|
|
@@ -1,25 +1,34 @@
|
|
|
package com.goafanti.admin.controller;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
-import com.goafanti.common.controller.BaseApiController;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.enums.CopyrightFields;
|
|
|
import com.goafanti.common.model.TechProject;
|
|
|
import com.goafanti.common.model.TechProjectLog;
|
|
|
import com.goafanti.common.model.TechWebsite;
|
|
|
-import com.goafanti.common.utils.AesUtils;
|
|
|
+import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.common.utils.Base64Utils;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
+import com.goafanti.techproject.bo.InputTechProject;
|
|
|
import com.goafanti.techproject.bo.TechWebsiteListBo;
|
|
|
import com.goafanti.techproject.service.TechProjectLogService;
|
|
|
import com.goafanti.techproject.service.TechProjectService;
|
|
|
@@ -28,26 +37,27 @@ import com.goafanti.user.service.UserService;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/api/admintechproject")
|
|
|
-public class AdminTechProjectController extends BaseApiController{
|
|
|
+public class AdminTechProjectController extends CertifyApiController {
|
|
|
@Value(value = "${aesSecretKey}")
|
|
|
- private String aesSecretKey = null;
|
|
|
+ private String aesSecretKey = null;
|
|
|
@Resource
|
|
|
- private TechProjectService techProjectService;
|
|
|
+ private TechProjectService techProjectService;
|
|
|
@Resource
|
|
|
- private TechWebsiteService techWebsiteService;
|
|
|
+ private TechWebsiteService techWebsiteService;
|
|
|
@Resource
|
|
|
- private TechProjectLogService techProjectLogService;
|
|
|
+ private TechProjectLogService techProjectLogService;
|
|
|
@Resource
|
|
|
- private UserService userService;
|
|
|
-
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
/**
|
|
|
* 科技项目申报列表
|
|
|
+ *
|
|
|
* @param pageNo
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/listTechProject", method = RequestMethod.POST)
|
|
|
- public Result listClientTechProject(String province, String uid, String pageNo, String pageSize){
|
|
|
+ public Result listClientTechProject(String province, String unitName, String pageNo, String pageSize) {
|
|
|
Result res = new Result();
|
|
|
Integer pNo = 1;
|
|
|
Integer pSize = 10;
|
|
|
@@ -57,50 +67,70 @@ public class AdminTechProjectController extends BaseApiController{
|
|
|
if (StringUtils.isNumeric(pageNo)) {
|
|
|
pNo = Integer.parseInt(pageNo);
|
|
|
}
|
|
|
- res.setData(techProjectService.listManageTechProject(province, uid, pNo, pSize));
|
|
|
+ res.setData(techProjectService.listManageTechProject(province, unitName, pNo, pSize));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 科技项目申报
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/applyTechProject", method = RequestMethod.POST)
|
|
|
- public Result applyTechProject(TechProject techProject, String uid){
|
|
|
+ public Result applyTechProject(@Valid InputTechProject techProject, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
- String aid = userService.selectByPrimaryKey(uid).getAid();
|
|
|
- techProjectService.saveTechProject(techProject, uid, aid);
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ CopyrightFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (!checkAdminLogin(res)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(techProject.getUid())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ User curUser = userService.selectByPrimaryKey(techProject.getUid());
|
|
|
+ if (checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ TechProject tp = new TechProject();
|
|
|
+ BeanUtils.copyProperties(techProject, tp);
|
|
|
+ techProjectService.saveTechProject(tp, userService.selectByPrimaryKey(tp.getUid()).getAid());
|
|
|
return res;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 科技项目申报详情
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/techProjectDetial", method = RequestMethod.POST)
|
|
|
- public Result techProjectDetial(String pid){
|
|
|
+ public Result techProjectDetial(String pid) {
|
|
|
Result res = new Result();
|
|
|
res.setData(techProjectService.selectProjectDetail(pid));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 科技项目状态流转
|
|
|
+ *
|
|
|
* @param pid
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/techProjectLog", method = RequestMethod.POST)
|
|
|
- public Result techProjectLog(String pid){
|
|
|
+ public Result techProjectLog(String pid) {
|
|
|
Result res = new Result();
|
|
|
res.setData(techProjectLogService.selectTechProjectLogByPid(pid));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * update科技项目
|
|
|
+ * update科技项目
|
|
|
+ *
|
|
|
* @param t
|
|
|
* @param l
|
|
|
* @param recordTimeFormattedDate
|
|
|
@@ -108,22 +138,57 @@ public class AdminTechProjectController extends BaseApiController{
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
@RequestMapping(value = "/updateTechProject", method = RequestMethod.POST)
|
|
|
- public Result updateTechProject(TechProject t, TechProjectLog l, String recordTimeFormattedDate) throws ParseException{
|
|
|
+ public Result updateTechProject(TechProject t, TechProjectLog l, String recordTimeFormattedDate)
|
|
|
+ throws ParseException {
|
|
|
Result res = new Result();
|
|
|
- Date recordTime =null;
|
|
|
+ Date recordTime = null;
|
|
|
if (!StringUtils.isBlank(recordTimeFormattedDate)) {
|
|
|
recordTime = DateUtils.parseDate(recordTimeFormattedDate, "yyyy-MM-dd");
|
|
|
}
|
|
|
res.setData(techProjectService.updateTechProject(t, l, recordTime));
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除科技项目记录
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteTechProject", method = RequestMethod.POST)
|
|
|
+ public Result deleteTechProject(@RequestParam(name = "ids[]", required = true) String[] ids) {
|
|
|
+ Result res = new Result();
|
|
|
+ List<String> id = new ArrayList<String>();
|
|
|
+ for (String s : ids) {
|
|
|
+ id.add(s);
|
|
|
+ }
|
|
|
+ res.setData(techProjectService.deleteByPrimaryKey(id));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除科技网址记录
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteTechWebsite", method = RequestMethod.POST)
|
|
|
+ public Result deleteTechWebsite(@RequestParam(name = "ids[]", required = true) String[] ids){
|
|
|
+ Result res = new Result();
|
|
|
+ List<String> id = new ArrayList<String>();
|
|
|
+ for (String s : ids) {
|
|
|
+ id.add(s);
|
|
|
+ }
|
|
|
+ res.setData(techWebsiteService.deleteByPrimaryKey(id));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 科技单位网址管理list
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(value = "/listTechWebsite", method = RequestMethod.POST)
|
|
|
- public Result listTechWebsite(String province, String unitName, String pageNo, String pageSize){
|
|
|
+ public Result listTechWebsite(String province, String unitName, String pageNo, String pageSize) {
|
|
|
Result res = new Result();
|
|
|
Integer pNo = 1;
|
|
|
Integer pSize = 10;
|
|
|
@@ -133,13 +198,13 @@ public class AdminTechProjectController extends BaseApiController{
|
|
|
if (StringUtils.isNumeric(pageNo)) {
|
|
|
pNo = Integer.parseInt(pageNo);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Pagination<TechWebsiteListBo> t = techWebsiteService.listTechWebsite(province, unitName, pNo, pSize);
|
|
|
- if (null != t){
|
|
|
- List<TechWebsiteListBo> l = (List<TechWebsiteListBo>) t.getList();
|
|
|
- for (TechWebsiteListBo w : l){
|
|
|
- if (!StringUtils.isBlank(w.getPassword())){
|
|
|
- w.setPassword(AesUtils.AesDecrypt(w.getPassword(), aesSecretKey));
|
|
|
+ if (null != t) {
|
|
|
+ List<TechWebsiteListBo> l = (List<TechWebsiteListBo>) t.getList();
|
|
|
+ for (TechWebsiteListBo w : l) {
|
|
|
+ if (!StringUtils.isBlank(w.getPassword())) {
|
|
|
+ w.setPassword(Base64Utils.decodeData(w.getPassword()));
|
|
|
}
|
|
|
}
|
|
|
t.setList(l);
|
|
|
@@ -147,33 +212,35 @@ public class AdminTechProjectController extends BaseApiController{
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 网址管理详情
|
|
|
+ *
|
|
|
* @param wid
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/techWebsiteDetail", method = RequestMethod.POST)
|
|
|
- public Result techWebsiteDetail(String id){
|
|
|
+ public Result techWebsiteDetail(String id) {
|
|
|
Result res = new Result();
|
|
|
TechWebsite w = techWebsiteService.selectByPrimaryKey(id);
|
|
|
- if (null != w && !StringUtils.isBlank(w.getPassword())){
|
|
|
- w.setPassword(AesUtils.AesDecrypt(w.getPassword(), aesSecretKey));
|
|
|
+ if (null != w && !StringUtils.isBlank(w.getPassword())) {
|
|
|
+ w.setPassword(Base64Utils.decodeData(w.getPassword()));
|
|
|
}
|
|
|
res.setData(w);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 科技单位网址add+update
|
|
|
+ *
|
|
|
* @param t
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/disposeTechWebsite", method = RequestMethod.POST)
|
|
|
- public Result disposeTechWebsite(TechWebsite w){
|
|
|
+ public Result disposeTechWebsite(TechWebsite w) {
|
|
|
Result res = new Result();
|
|
|
- if (null != w && null != w.getPassword()){
|
|
|
- w.setPassword(AesUtils.AesEncrypt(w.getPassword(), aesSecretKey));
|
|
|
+ if (null != w && null != (w.getPassword())) {
|
|
|
+ w.setPassword(Base64Utils.encodeData(w.getPassword().trim()));
|
|
|
}
|
|
|
res.setData(techWebsiteService.saveWebsite(w));
|
|
|
return res;
|