Commit 143c4c75 authored by Quxl's avatar Quxl

x

parent cae4d721
Pipeline #118 canceled with stages
......@@ -3,11 +3,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.egolm</groupId>
<artifactId>siff-film-api</artifactId>
<artifactId>sentinel</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<start-class>com.egolm.film.MVApplication</start-class>
<start-class>com.egolm.sentinel.SentinelApplication</start-class>
</properties>
<parent>
......@@ -17,11 +17,6 @@
</parent>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
<repository>
<id>pubmaven</id>
<name>pubmaven</name>
......@@ -36,16 +31,7 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
......@@ -57,21 +43,6 @@
<artifactId>common</artifactId>
<version>0.0.1-RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
......@@ -86,20 +57,23 @@
<artifactId>javax.mail</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.1.2</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-vod</artifactId>
<version>2.11.6</version>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<!-- <version>2.3.0</version> -->
<version>2.8.3</version>
<groupId>ch.ethz.ganymed</groupId>
<artifactId>ganymed-ssh2</artifactId>
<version>262</version>
</dependency>
</dependencies>
<build>
......
package com.egolm.film.api;
import java.util.HashMap;
import java.util.Map;
public class ExportConstant {
public static final Map<String, String> playactorTypes = new HashMap<String, String>();
static {
playactorTypes.put("director", "导演");
playactorTypes.put("producer", "制片人");
playactorTypes.put("actor", "男演员");
playactorTypes.put("actress", "女演员");
playactorTypes.put("photographer", "摄影");
playactorTypes.put("screenwriter", "编剧");
playactorTypes.put("issuser", "发行方");
}
public static final Map<String, String> filmTypes = new HashMap<String, String>();
static {
filmTypes.put("1", "剧情片");
filmTypes.put("2", "纪录片");
filmTypes.put("3", "动画片");
filmTypes.put("4", "短片");
}
public static final Map<String, String> filmShortTypes = new HashMap<String, String>();
static {
filmShortTypes.put("1", "欧洲");
filmShortTypes.put("2", "亚太");
filmShortTypes.put("3", "美非");
filmShortTypes.put("4", "华语");
filmShortTypes.put("5", "纪录片");
filmShortTypes.put("6", "动画片");
filmShortTypes.put("7", "真人短片");
filmShortTypes.put("8", "动画短片");
}
public static final Map<String, String> enrollTypes = new HashMap<String, String>();
static {
enrollTypes.put("1", "金爵");
enrollTypes.put("2", "亚新");
enrollTypes.put("3", "传媒");
enrollTypes.put("4", "展映");
}
public static final Map<String, String> enrollOtherTypes = new HashMap<String, String>();
static {
enrollOtherTypes.put("1", "最佳导演");
enrollOtherTypes.put("2", "最佳女演员");
enrollOtherTypes.put("3", "最佳男演员");
enrollOtherTypes.put("4", "最佳编剧");
enrollOtherTypes.put("5", "最佳摄影");
enrollOtherTypes.put("6", "真人短片");
enrollOtherTypes.put("7", "动画短片");
enrollOtherTypes.put("8", "最佳影片");
}
public static final Map<String, String> states = new HashMap<String, String>();
static {
states.put("1", "未提交");
states.put("2", "已提交");
}
public static final Map<String, String> applyStates = new HashMap<String, String>();
static {
applyStates.put("1", "未受理");
applyStates.put("2", "初审通过");
applyStates.put("3", "初审否决");
}
public static final Map<String, String> YN = new HashMap<String, String>();
static {
YN.put("0", "否");
YN.put("1", "是");
}
public static final Map<String, String> filmMedium = new HashMap<String, String>();
static {
filmMedium.put("1", "彩色");
filmMedium.put("2", "黑白");
filmMedium.put("3", "彩色+黑白");
}
public static final Map<String, String> filmFormat = new HashMap<String, String>();
static {
filmFormat.put("1", "移动存储");
filmFormat.put("2", "在线连接");
}
public static final Map<String, String> playShanghai = new HashMap<String, String>();
static {
playShanghai.put("1", "世界首映");
playShanghai.put("2", "国际首映");
playShanghai.put("3", "亚洲首映");
playShanghai.put("4", "中国首映");
playShanghai.put("5", "不符合任何首映");
}
public static final String[] rounds = new String[] {"", "一选", "二选", "三选", "影片把关", "选片委员会", "电影总局"};
public static final String[] reviewState = new String[] {"未评选", "通过", "否决", "参赛", "参赛备选", "参展"};
public static final String[] optState = new String[] {"未评选", "争议", "待分配", "已完成"};
public static final Map<String, String> currencys = new HashMap<String, String>();
static {
currencys.put("1", "人民币");
currencys.put("2", "美元");
}
public static final Map<String, String> copyopts = new HashMap<String, String>();
static {
copyopts.put("1", "安全");
copyopts.put("2", "不安全");
copyopts.put("3", "待定");
}
public static final Map<String, String> fmtopts = new HashMap<String, String>();
static {
fmtopts.put("1", "35mm");
fmtopts.put("2", "2D DCP");
fmtopts.put("3", "3D DCP");
}
public static final Map<String, String> resolutionopts = new HashMap<String, String>();
static {
resolutionopts.put("1", "2K");
resolutionopts.put("2", "4K");
}
public static final Map<String, String> aspectopts = new HashMap<String, String>();
static {
aspectopts.put("1", "1:1.78");
aspectopts.put("2", "1:1.85");
aspectopts.put("3", "1:2.35");
aspectopts.put("4", "1:2.39");
aspectopts.put("5", "Other");
}
public static final Map<String, String> soundopts = new HashMap<String, String>();
static {
soundopts.put("1", "2.0");
soundopts.put("2", "2.1");
soundopts.put("3", "5.1");
soundopts.put("4", "7.1");
soundopts.put("5", "Atmos");
soundopts.put("6", "Auro");
soundopts.put("7", "Other");
}
public static final Map<String, String> frameopts = new HashMap<String, String>();
static {
frameopts.put("1", "24");
frameopts.put("2", "25");
}
public static final Map<String, String> kdmopts = new HashMap<String, String>();
static {
kdmopts.put("1", "Encrypted");
kdmopts.put("2", "Unencrypted");
}
}
package com.egolm.film.api;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.CountryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api
@Controller
@RequestMapping("webapi")
public class WebApiController {
@Autowired
JdbcTemplate jdbcTemplate;
Map<String, String> countryMap;
@Resource
public void setCountryMap(CountryService countryService) {
countryMap = countryService.queryCountryMapReverse();
}
@ResponseBody
@RequestMapping(value="getFilmList", method= {RequestMethod.POST})
@ApiOperation("查询参与评审环节的评委组")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", dataType="string", name="timestamp"),
@ApiImplicitParam(paramType="query", dataType="string", name="sign"),
})
public Object getFilmList() {
String sql0 = "select mf.id, mf.film_no, mf.cn_name, mf.en_name, mf.film_country, r.enroll_type_id, r.review_state, mf.film_type_name_short from fc_member_film mf left join fc_review r on r.film_id = mf.id, fc_film_group fg where mf.state = 2 and mf.apply_state = 2 and mf.film_group_id = fg.id";
List<Map<String, Object>> filmList = jdbcTemplate.limitAll(sql0, new Page(1L, 1000L, "id desc"));
String sql1 = "select * from fc_member_film_ext";
List<Map<String, Object>> playactorList = jdbcTemplate.limitAll(sql1, new Page(1L, 1000L, "id desc"));
Map<String, Map<String, Object>> playactorMM = Util.listToMM(playactorList, "id");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for(Map<String, Object> filmMap : filmList) {
Map<String, Object> map = new HashMap<String, Object>();
Integer id = ((Number)filmMap.get("id")).intValue();
Integer film_no = (Integer)filmMap.get("film_no");
String cn_name = (String)filmMap.get("cn_name");
String en_name = (String)filmMap.get("en_name");
String film_country = (String)filmMap.get("film_country");
Integer enroll_type_id = (Integer)filmMap.get("enroll_type_id");
Integer review_state = (Integer)filmMap.get("review_state");
String film_type_name_short = (String)filmMap.get("film_type_name_short");
map.put("film_no", StringUtil.formatLength(film_no, "0000"));
map.put("cn_name", cn_name);
map.put("en_name", en_name);
map.put("film_country_en", film_country);
map.put("film_country_cn", countryMap.get(film_country));
map.put("film_type_name_short", film_type_name_short);
{
String review_state_text = "参赛";
if(review_state == 1) {
if(enroll_type_id == 4 || enroll_type_id == 3) {
review_state_text = "参展";
} else {
review_state_text = "参赛";
}
} else if(review_state == 3 || review_state == 4) {
review_state_text = "参赛";
} else if(review_state == 5) {
review_state_text = "参展";
} else {
continue;
}
map.put("review_state_text", review_state_text);
}
Map<String, Object> extMap = playactorMM.get(String.valueOf(id));
if(extMap != null) {
{
List<Map<String, Object>> directorList = new ArrayList<Map<String, Object>>();
String director_cn = (String)extMap.get("director_cn");
String director_en = (String)extMap.get("director_en");
if(StringUtil.isNotBlank(director_cn)) {
String[] directorCnArray = director_cn.split(",");
String[] directorEnArray = (director_en == null ? "" : director_en).split(",", directorCnArray.length);
for(int i = 0; i < directorCnArray.length; i++) {
Map<String, Object> directorMap = new HashMap<String,Object>();
directorMap.put("en_name", directorEnArray[i]);
directorMap.put("cn_name", directorCnArray[i]);
directorList.add(directorMap);
}
}
map.put("directorList", directorList);
}
{
List<String> producerList = new ArrayList<String>();
String producer_en = (String)extMap.get("producer_en");
if(StringUtil.isNotBlank(producer_en)) {
String[] producerArray = producer_en.split(",");
producerList.addAll(Arrays.asList(producerArray));
}
map.put("producerList", producerList);
}
{
List<String> productionList = new ArrayList<String>();
String production_en = (String)extMap.get("production_en");
if(StringUtil.isNotBlank(production_en)) {
String[] productionArray = production_en.split(",");
productionList.addAll(Arrays.asList(productionArray));
}
map.put("productionList", productionList);
}
}
list.add(map);
}
return Rjx.jsonOk().setData(list);
}
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_admin;
import com.egolm.film.bean.Fc_admin_group;
import com.egolm.film.bean.Fc_admin_menu;
public interface AdminAuthService {
void mergeGroup(Fc_admin_group group);
List<Map<String, Object>> queryGroupList(String keyword, Page page);
List<Map<String, Object>> queryAdminList(String keyword, Integer group_id, Page page);
void disableAdmin(Integer[] adminid);
void saveAdmin(Fc_admin admin);
void mergeAdmin(Fc_admin admin);
List<Map<String, Object>> queryGroupMenuList(Integer group_id);
List<Integer> queryGroupFilmtypeList(Integer group_id);
void updateGroupAuth(Integer group_id, Integer[] menu_ids, Integer[] film_types);
void saveOrUpdateMenu(Fc_admin_menu menu);
void enableAdmin(Integer[] adminid);
Fc_admin queryAdminById(Integer id);
boolean changePasswordByMemberId(Integer id, String password, String newPassword);
void delAdmin(Integer[] adminid);
}
package com.egolm.film.api.service;
public interface AdminTokenService extends TokenService {
final String LOGINID_COOKIE_NAME = "admin_token";
final String TOKEN_NAME = "FILM_ADMIN_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "ADMIN";
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_user;
import com.egolm.film.bean.Fc_user_group;
import com.egolm.film.bean.Fc_user_group_enroll;
import com.egolm.film.bean.Fc_user_group_funs;
import com.egolm.film.bean.Fc_user_group_round;
public interface AdminUserService {
List<Map<String, Object>> queryGroupList(String keyword, Page page);
void mergeGroup(Fc_user_group group);
List<Map<String, Object>> queryUserList(String keyword, Integer group_id, Page page);
void saveUser(Fc_user user);
void updateUserInfo(Fc_user user);
void changePassword(Integer uid, String password);
void saveGroupFuns(Integer group_id, Integer[] funs);
void saveGroupRound(Integer group_id, Integer[] rounds);
void saveGroupEnroll(Integer group_id, Integer[] enroll_types);
Fc_user_group queryGroupById(Integer group_id);
List<Fc_user_group_funs> queryGroupFunList(Integer group_id);
List<Fc_user_group_round> queryGroupRoundList(Integer group_id);
List<Fc_user_group_enroll> queryGroupEnrollList(Integer group_id);
void deleteUserById(Integer uid);
void deleteGroupById(Integer group_id);
List<Map<String, Object>> getReviewUserList(Integer review_id, Integer review_round);
List<Map<String, Object>> getReviewGroupList(Integer review_id, Integer review_round);
List<Map<String, Object>> getShowFilmGroupList();
List<Map<String, Object>> getShowFilmUserList();
}
package com.egolm.film.api.service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
public interface CinemaService {
List<Map<String, Object>> getCinemaListForSelected(String keyword);
List<Map<String, Object>> getCinemaList(String keyword, Page page);
void setTmpData(Integer cinemaId);
List<Map<String, Object>> queryShowtimeList(Integer cinemaId, Date start_date, Date end_date);
void deleteShowtimeByShowtime(Integer cinema_id, String show_time);
void deleteShowtimeByShowdate(Integer cinema_id, Date show_date);
void deleteShowtimeById(Integer id);
void deleteCinemaById(Integer id);
Integer queryMaxShowtimeNoByCinemaId(Integer cinema_id);
void setShowtimeNo(Integer showtimeId);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
public interface CountryService {
public List<Map<String, String>> queryCountryList();
public Map<String, String> queryCountryMap();
public Map<String, String> queryCountryMapReverse();
public Object queryAsiaCountryList();
}
package com.egolm.film.api.service;
import java.util.Map;
public interface EmailService {
void send(Integer sender_type_id, Integer sender_id, String subject, String content, String email);
/**
* {0} 姓名
* {1} 影片编号
* {2} 影片名称
* @param member_film_id
* @param template
*/
Map<String, Object> sendByTemplate_pass(Long member_film_id);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import com.egolm.film.bean.Fc_member_film;
public interface ExportService {
Map<String, String> getApplyListColumns();
void exportApplyList(ServletOutputStream os, String[] columns, List<Map<String, Object>> list);
Map<String, String> getApplyPassListColumns();
void exportApplyPassList(ServletOutputStream os, String[] columns, List<Map<String, Object>> list);
Map<String, String> getReviewPassListColumns();
void exportReviewPassList(ServletOutputStream os, String[] columns, List<Map<String, Object>> list);
void exportPublication(ServletOutputStream os, Fc_member_film film);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
public interface FilmGroupService {
List<Map<String, Object>> queryFilmGroupList();
List<Map<String, Object>> queryFilmListByGroupId(Integer film_group_id);
void updateFilmGroupId(Integer[] film_id, Integer group_id, String group_remark);
void removeFilmGroupById(Integer[] id);
List<Map<String, Object>> queryNoGroupFilmList(String keyword, Integer film_type_id, Integer enroll_type_id, String film_country, Integer film_type_name_short, Integer play_shanghai, Integer review_round, Integer review_state, Page page);
List<Map<String, Object>> queryGroupFilmList(Integer[] group_id, String keyword, Integer enroll_type_id, Integer film_type_name,
Integer film_type_name_short, Integer play_shanghai, Integer is_important, Integer review_state, Integer review_round,
String film_country, Page page);
List<Map<String, Object>> queryNotInviteList(Integer[] group_id, String keyword, Integer enroll_type_id,
Integer film_type_name, Integer film_type_name_short, Integer play_shanghai, Integer is_important,
Integer review_state, Integer review_round, String film_country, Page page);
void doNotInvite(Integer film_id, Integer not_invite, String not_invite_text);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
public interface FilmReportService {
Map<String, Object> uploadReport(String start_date, String end_date);
Map<String, Object> applyTypeReport();
List<Map<String, Object>> directorReport(String playactor_name, Page page);
Map<String, Object> directorDetail(String playactor_name);
List<Map<String, Object>> queryUserViewReport(String keyword, Page page);
List<Map<String, Object>> queryUserReiewReport(Integer user_id, Page page);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_enroll;
import com.egolm.film.bean.Fc_member_film_ext;
import com.egolm.film.bean.Fc_member_film_issuer;
import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.bean.model.Fc_member_film_base_model;
public interface FilmService {
Logger logger = LoggerFactory.getLogger(FilmService.class);
List<Fc_member_film_issuer> queryMemberFilmIssuerList(Long member_film_id);
List<Fc_member_film_playactor> queryMemberFilmPlayactorList(Long member_film_id);
List<Fc_member_film_show> queryMemberFilmShowList(Long member_film_id);
void doApply(
Integer member_id,
Long member_film_id);
Long saveMemberFilmType(
Integer member_id,
String film_type_name,
String enroll_type_name);
void saveMemberFilmBase(
Integer member_id,
Long member_film_id,
String[] enroll_type_name_other,
String cn_name,
String en_name,
String intro);
void saveMemberFilmInfo(
Integer member_id,
Long member_film_id,
String film_country,
String dialogue_lang,
String subtitle_lang,
String[] co_production_country,
String film_total_time,
String completion_date,
String show_date,
String first_show_date,
String first_show_city,
Integer is_apply_other_filmfest,
String other_filmfest_name,
String film_medium,
String film_format,
String film_format_url,
String film_format_passw,
String film_format_other);
void saveMemberFilmPlayactor(
Long member_film_id,
String[] playactor_type,
String[] playactor_role_name,
String[] playactor_name,
String[] playactor_film_nums,
String[] playactor_country,
String[] playactor_birthday,
String[] playactor_intro,
Integer[] is_play_shanghai);
void saveMemberFilmIssuer(
Long member_film_id,
String[] issuer_company,
String[] issuer_contacts,
String[] issuer_email,
String[] issuer_tel);
void saveMemberFilmShow(
Long member_film_id,
String play_shanghai,
String[] show_filmfest,
String[] show_filmfest_type,
String[] show_filmfest_intro);
void saveMemberFilmCompany(
Integer member_id,
Long member_film_id,
String film_apply_company,
String film_apply_realname,
String film_apply_email,
String film_apply_tel,
String film_apply_mobile,
String film_apply_country);
List<Map<String, Object>> queryListAll(String keyword);
List<Map<String, Object>> queryFilmList(
Integer admin_group_id,
String keyword,
Integer state,
Integer apply_state,
Integer upload_state,
Integer film_type,
Integer enroll_type,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
Integer[] film_group_id,
Page page);
Integer pass(Long member_film_id);
void reject(Boolean is_stop_apply, Long member_film_id, String apply_state_intro);
Fc_member_film queryMemberFilmById(Long member_film_id);
Object queryEnrollList();
Object queryTypeList();
void mergeMemberFilm(Fc_member_film film);
/**
* 更新影片基本信息
* @param filmBase
*/
void updateFilmBase(Fc_member_film_base_model filmBase);
void updateEnroll(Long member_film_id);
void saveUploadId(Long member_film_id, String upload_id);
void saveUploadState(Long member_film_id, Integer upload_state);
List<Fc_member_film_enroll> queryFilmEnrollList(Long member_film_id);
void verifyFilmDuplicate(Long member_film_id);
void updateFilmState(Long member_film_id, Integer state);
void saveCreateBase(Long id, Integer admin_id, Integer member_id, String create_ip);
void exchangeFilmNo(Integer id1, Integer id2);
void initKeywords(Long member_film_id);
List<Map<String, Object>> queryMonitorUploadList(String keyword,Integer upload_state, Page page);
public void updateFilmUploadState(String[] film_id,String[] number);
void saveOrUpdateFilmExt(Fc_member_film_ext filmExt);
Fc_member_film_ext queryFilmExt(Integer id);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
public interface LanguageService {
public List<Map<String, String>> queryLanguageList();
public Map<String, String> queryLanguageMap();
public Map<String, String> queryLanguageMapReverse();
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
public interface LogService {
List<Map<String, Object>> queryLogList(String type, String username, Page page);
void saveErrorLog(String path, Object params, Throwable ex);
List<Map<String, Object>> queryErrorList(Page page);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.film.bean.Fc_member;
public interface MemberService {
Fc_member getMemberByEmail(String email);
void resetPassword(Integer id, String newPassword);
void saveMember(Fc_member member);
Fc_member getMemberById(Integer id);
void mergeMember(Fc_member member);
void updateMember(
Integer id,
String email,
String realname,
String address,
String company,
String tel);
List<Map<String, Object>> queryListByMemberID(Integer member_id);
boolean exists(String email);
boolean changePasswordByMemberId(Integer member_id, String password, String newPassword);
Fc_member getMemberByToken(String token);
void updateLoginInfo(Integer member_id, String login_ip, String token_string);
void updateLanguage(Integer id, String string);
}
package com.egolm.film.api.service;
public interface MemberTokenService extends TokenService {
final String LOGINID_COOKIE_NAME = "member_token";
final String TOKEN_NAME = "FILM_MEMBER_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "MEMBER";
}
package com.egolm.film.api.service;
import java.util.Locale;
public interface Messages {
public String get(String name, String... args);
public String get(String name, Locale locale, String... args);
public Locale getLocale();
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_admin;
public interface NewsService {
List<Map<String, Object>> queryList(Page page, String key);
void merge(Object obj);
void save(Object obj);
void batchSave(List<?> objs);
Map<String, Object> queryById(Integer id);
List<Map<String, Object>> queryListForUser(Integer uid, Integer gid, Page page);
void sendAllotNews(Integer review_id, Integer review_round, Integer[] user_id, Fc_admin admin);
}
package com.egolm.film.api.service;
public interface OssService {
String getOssPath(String relativePath, Integer expiryTime);
}
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_film_upload;
public interface OtherUploadService {
public void batchSave(List<Fc_film_upload> fc_film_upload);
public void save(Fc_film_upload fc_film_upload);
public int checkExists(Integer film_no,Integer number);
public List<Map<String,Object>> getWaitUploadList(Page page);
public List<Fc_film_upload> getUploadListByFilmId(Integer film_id);
public void updateBegin(Integer film_id,Integer film_no, Integer number,String videoId,String taskName);
public void updateProgress(String videoId,String progress);
public void updateSuccess(String videoId,String film_no);
public void updateFail(String videoId,String errorMessage);
public void updateFail(Integer film_no,Integer number,String errorMessage);
public int getIdByNo(Integer film_no);
}
package com.egolm.film.api.service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_review;
import com.egolm.film.bean.Fc_review_doubtful;
import com.egolm.film.bean.Fc_review_record;
import com.egolm.film.bean.Fc_review_record_ext;
public interface ReviewService {
Object queryDoubtfulList();
/**
* 查询管理员选片列表
* @param keyword
* @param group_id 管理员所在的管理组ID
* @param enroll_type_id 影片性质
* @param film_type_name 影片类型
* @param film_type_name_short 影片扩展分类
* @param film_country 影片城市
* @param review_round 第几轮审片
* @param review_state 审片结论 1通过 2否决 3参赛 4参赛备选 5参展
* @param allot_state 评委分配状态 0未分配评委 1已分配评委评选中
* @param opt_state 评选状态 0未评选 1有争议 2管理员分配 3已完成
* @param page
* @return
*/
List<Map<String, Object>> queryReviewListForAdmin(
String keyword,
Integer group_id,
Integer enroll_type_id,
Integer film_type_name,
Integer film_type_name_short,
String film_country,
Integer review_round,
Integer review_state,
Integer allot_state,
Integer opt_state,
Page page);
List<Map<String, Object>> queryBestMvListByGroup(String keyword, Integer user_group_id, Integer review_round, Page page);
/**
* 查询评委审片列表
* @param is_review
* @param user_id
* @param keyword
* @param start_date
* @param end_date
* @param film_type_id
* @param enroll_type_id
* @param page
* @return
*/
List<Map<String, Object>> queryReviewListForUser(
boolean is_review,
Integer user_id,
String keyword,
Date start_date,
Date end_date,
Date review_start_date,
Date review_end_date,
Integer film_type_id,
Integer enroll_type_id,
Page page);
Fc_review queryReview(Integer film_id, Integer enroll_type_id);
Fc_review queryReviewById(Integer review_id);
void saveDoubtfulList(List<Fc_review_doubtful> doubtfulList);
List<Map<String, Object>> queryDoubtfulListByFilmIdForUser(Integer film_id, Integer user_id);
List<Map<String, Object>> queryDoubtfulListByFilmIdForUser(Integer film_id);
List<Map<String, Object>> queryDoubtfulListByFilmIdId(Integer film_id);
Fc_review_record queryCurrentReviewRecord(Integer user_id, Integer review_id);
Fc_review_record queryCurrentReviewRecord(Integer review_id);
void saveReviewRecord(Fc_review_record ru, List<Fc_review_record_ext> exts);
List<Fc_review_record_ext> queryReviewRecordExtList(Integer record_id);
List<Map<String, Object>> queryReviewRecordListByReviewId(Integer review_id);
void rmReviewData(Long member_film_id);
void toFirstRound(Long member_film_id);
void toRound(Integer review_id, Integer review_round);
void tryNextRound(Integer review_id);
void createAsiaNewReport(int review_id, int review_round);
void save(Object obj);
void saveReviewRecordIfNotExists(Integer review_id, Integer review_round, Integer[] user_id);
void deleteReviewRecord(Integer review_id, Integer review_round, Integer[] user_id);
void deleteDoubtfulById(Integer id);
Map<String, Object> queryReviewRecordMapById(Integer record_id);
Fc_review queryReview(int film_id);
List<Map<String, Object>> queryUserGroupListByReviewRecord(int enroll_type_id, Integer review_round);
List<Map<String, Object>> queryBestMvGroupList(Integer review_round);
List<Map<String, Object>> queryTimeoutList(String keyword, Page page);
List<Map<String, Object>> queryReviewRecordLogList(String username, Integer enroll_type_id, Integer review_state, Page page);
List<Map<String, Object>> queryReviewHistoryList(List<Integer> types, Page page);
List<Map<String, Object>> queryExhibitionList(String keyword, Integer enroll_type_id, Integer film_type_name,
Integer film_type_name_short, String film_country, Integer from_round, Page page);
void allotShowFilmUser(Integer review_id, Integer[] user_id);
List<Map<String, Object>> queryUserShowList(Integer user_id, Page page);
void toType4(Integer id);
List<Map<String, Object>> queryShowFilmUserListByReviewId(Integer review_id);
void deleteAsiaNewReport(int review_id, int review_round);
List<Map<String, Object>> queryDisputeCount();
boolean isBeginReview(Long film_id);
Map<String, Object> queryFilmReport(Integer user_id);
Fc_review_record queryReviewRecordById(Integer record_id);
}
\ No newline at end of file
package com.egolm.film.api.service;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.egolm.film.model.LoginToken;
public interface TokenService {
Logger logger = LoggerFactory.getLogger(TokenService.class);
LoginToken getToken();
Map<String, Object> getTokenObj();
LoginToken doLogin(String username, String password);
void doLogout();
boolean isLogin();
boolean isLoginByToken(String token);
}
package com.egolm.film.api.service;
public interface UserTokenService extends TokenService {
final String LOGINID_COOKIE_NAME = "user_token";
final String TOKEN_NAME = "FILM_USER_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "USER";
}
package com.egolm.film.api.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminAuthService;
import com.egolm.film.bean.Fc_admin;
import com.egolm.film.bean.Fc_admin_group;
import com.egolm.film.bean.Fc_admin_group_filmtype;
import com.egolm.film.bean.Fc_admin_group_menu;
import com.egolm.film.bean.Fc_admin_menu;
import com.egolm.film.config.XRException;
import com.egolm.film.util.Common;
import com.egolm.film.util.SqlWhere;
@Service
public class AdminAuthServiceImpl implements AdminAuthService {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public void mergeGroup(Fc_admin_group group) {
jdbcTemplate.merge(group);
}
@Override
public List<Map<String, Object>> queryGroupList(String keyword, Page page) {
SqlWhere argEdit = new SqlWhere().lk("ag.group_name", keyword);
String sql = "select ag.*, (select count(adminid) from fc_admin a where a.group_id = ag.group_id) user_count from fc_admin_group ag" + StringUtil.join(" and ", " where ", "", "", argEdit.getStringList());
return jdbcTemplate.limit(sql, page, argEdit.getObjectArray());
}
@Override
public List<Map<String, Object>> queryAdminList(String keyword, Integer group_id, Page page) {
SqlWhere argEdit = new SqlWhere().lk(new String[]{"realname", "username"}, keyword).eq("group_id", group_id).ne("state", 3);
String sql = "select * from fc_admin" + StringUtil.join(" and ", " where ", "", "", argEdit.getStringList());
return jdbcTemplate.limit(sql, page, argEdit.getObjectArray());
}
@Override
public void disableAdmin(Integer[] adminid) {
String sql = "update fc_admin set state = 2 where adminid in (" + StringUtil.join("?", ", ", adminid.length) + ")";
jdbcTemplate.executeUpdate(sql, (Object[])adminid);
}
@Override
public void delAdmin(Integer[] adminid) {
String sql = "update fc_admin set state = 3 where adminid in (" + StringUtil.join("?", ", ", adminid.length) + ")";
jdbcTemplate.executeUpdate(sql, (Object[])adminid);
}
@Override
public void enableAdmin(Integer[] adminid) {
String sql = "update fc_admin set state = 1 where adminid in (" + StringUtil.join("?", ", ", adminid.length) + ")";
jdbcTemplate.executeUpdate(sql, (Object[])adminid);
}
@Override
public void saveAdmin(Fc_admin admin) {
int count = jdbcTemplate.queryForInt("select count(*) from fc_admin where username = ?", admin.getUsername());
if(count == 0) {
jdbcTemplate.save(admin);
jdbcTemplate.executeUpdate("update fc_admin_group set user_num = user_num + 1 where group_id = ?", admin.getGroup_id());
} else {
throw new XRException("用户名已存在");
}
}
@Override
public void mergeAdmin(Fc_admin admin) {
jdbcTemplate.merge(admin);
}
@Override
public List<Map<String, Object>> queryGroupMenuList(Integer group_id) {
String s = "select am.*, agm.group_id from fc_admin_menu am left join fc_admin_group_menu agm on am.menu_id = agm.menu_id and agm.group_id = ? order by am.menu_type, am.parent_id, am.order_num";
List<Map<String, Object>> list = jdbcTemplate.queryForList(s, group_id);
return this.getTree(list, null);
}
private List<Map<String, Object>> getTree(List<Map<String, Object>> list, Integer id) {
List<Map<String, Object>> nodes = new ArrayList<Map<String, Object>>();
for(Map<String, Object> map : list) {
Number menu_id = (Number)map.get("menu_id");
Number parent_id = (Number)map.get("parent_id");
Number group_id = (Number)map.get("group_id");
if(group_id != null) {
map.put("is_show", true);
} else {
map.put("is_show", false);
}
if((id == null && parent_id == null) || (id != null && parent_id != null && id.intValue() == parent_id.intValue())) {
Number menu_type = (Number)map.get("menu_type");
if(menu_type.intValue() == 0 || menu_type.intValue() == 1) {
map.put("childs", this.getTree(list, menu_id.intValue()));
}
nodes.add(map);
}
}
return nodes;
}
@Override
public List<Integer> queryGroupFilmtypeList(Integer group_id) {
String s = "select film_type_id from fc_admin_group_filmtype where group_id = ?";
List<Integer> list = jdbcTemplate.queryForObjects(s, Integer.class, group_id);
return list;
}
@Override
@Transactional
public void updateGroupAuth(Integer group_id, Integer[] menu_ids, Integer[] film_types) {
jdbcTemplate.executeUpdate("delete from fc_admin_group_menu where group_id = ?", group_id);
jdbcTemplate.executeUpdate("delete from fc_admin_group_filmtype where group_id = ?", group_id);
if(menu_ids != null && menu_ids.length > 0) {
List<Fc_admin_group_menu> agmList = new ArrayList<Fc_admin_group_menu>();
for(Integer menu_id : menu_ids) {
Fc_admin_group_menu agm = new Fc_admin_group_menu();
agm.setGroup_id(group_id);
agm.setMenu_id(menu_id);
agmList.add(agm);
}
jdbcTemplate.batchSave(agmList);
}
if(film_types != null && film_types.length > 0) {
List<Fc_admin_group_filmtype> gtypeList = new ArrayList<Fc_admin_group_filmtype>();
for(Integer film_type : film_types) {
Fc_admin_group_filmtype gtype = new Fc_admin_group_filmtype();
gtype.setGroup_id(group_id);
gtype.setFilm_type_id(film_type);
gtypeList.add(gtype);
}
jdbcTemplate.batchSave(gtypeList);
}
}
@Override
public void saveOrUpdateMenu(Fc_admin_menu menu) {
jdbcTemplate.saveOrUpdate(menu);
}
public Fc_admin queryAdminById(Integer id) {
return jdbcTemplate.queryForBean("select * from fc_admin where adminid = ?", Fc_admin.class, id);
}
@Override
public boolean changePasswordByMemberId(Integer id, String password, String newPassword) {
Fc_admin admin = this.queryAdminById(id);
String encodePassword = Common.encodePassword(password, admin.getSalt());
if(encodePassword.equals(admin.getPassword())) {
String salt = Common.getGenerateString(6);
String encodeNewPassword = Common.encodePassword(newPassword, salt);
Integer count = jdbcTemplate.executeUpdate("update fc_admin set salt = ?, password = ? where adminid = ?", salt, encodeNewPassword, admin.getAdminid());
return count.compareTo(1) == 0;
}
return false;
}
}
package com.egolm.film.api.service.impl;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.bean.Fc_admin;
import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common;
@Service
public class AdminTokenServiceImpl implements AdminTokenService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public LoginToken doLogin(String username, String password) {
HttpSession session = WebMvcConfig.getSession();
String loginSql = "select * from fc_admin where username = ?";
List<Fc_admin> list = this.jdbcTemplate.queryForBeans(loginSql, Fc_admin.class, username);
if(list != null) {
if(list.size() == 1) {
Fc_admin admin = list.get(0);
Integer state = admin.getState();
String salt = admin.getSalt();
String pwd = admin.getPassword();
String encodePassword = Common.encodePassword(password, salt);
if(encodePassword.equals(pwd)) {
if(state == 1) {
Integer adminid = admin.getAdminid();
LoginToken token = new LoginToken(adminid);
session.setAttribute(TOKEN_NAME, token);
Cookie cookie = WebMvcConfig.getOrCreateUUIDCookie(LOGINID_COOKIE_NAME, "/", 60*60*24*5, true);
if(cookie != null) {
String sql = "update fc_admin set token = ?, login_ip = ?, login_time = ? where adminid = ?";
String loginIp = ServletUtil.remoteIp(WebMvcConfig.getRequest());
jdbcTemplate.executeUpdate(sql, cookie.getValue(), loginIp, System.currentTimeMillis()/1000, adminid);
logger.debug("admin login success: " + username);
}
return token;
} else if(state == 2) {
throw new XRException("用户已禁用");
} else {
throw new XRException("用户状态未知");
}
} else {
throw new XRException("用户名或密码错误");
}
} else if(list.size() == 0) {
throw new XRException("用户名或密码错误");
} else {
throw new XRException("用户登陆信息重复,请联系管理员");
}
} else {
throw new XRException("用户名或密码错误");
}
}
@Override
public LoginToken getToken() {
HttpSession session = WebMvcConfig.getSession();
LoginToken token = (LoginToken)session.getAttribute(TOKEN_NAME);
return token;
}
@Override
public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId();
return jdbcTemplate.queryForMap("select * from fc_admin where adminid = ?", id);
}
@Override
public void doLogout() {
String sql = "update fc_admin set token = ? where adminid = ?";
jdbcTemplate.executeUpdate(sql, null, this.getToken().getId());
HttpSession session = WebMvcConfig.getSession();
session.removeAttribute(TOKEN_NAME);
session.invalidate();
WebMvcConfig.removeCookie(LOGINID_COOKIE_NAME);
}
@Override
public boolean isLogin() {
return this.getToken() != null;
}
@Override
public boolean isLoginByToken(String token_string) {
HttpSession session = WebMvcConfig.getSession();
try {
String sql = "select adminid from fc_admin where token = ? and state = 1";
Integer adminid = jdbcTemplate.queryForInt(sql, token_string);
LoginToken token = new LoginToken(adminid);
session.setAttribute(TOKEN_NAME, token);
return true;
} catch (Exception e) {
return false;
}
}
}
package com.egolm.film.api.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminUserService;
import com.egolm.film.bean.Fc_user;
import com.egolm.film.bean.Fc_user_group;
import com.egolm.film.bean.Fc_user_group_enroll;
import com.egolm.film.bean.Fc_user_group_funs;
import com.egolm.film.bean.Fc_user_group_round;
import com.egolm.film.config.XRException;
import com.egolm.film.util.Common;
import com.egolm.film.util.SqlWhere;
@Service
public class AdminUserServiceImpl implements AdminUserService {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> queryGroupList(String keyword, Page page) {
SqlWhere argEdit = new SqlWhere().eq("ug.state", 1).lk(new String[]{"ug.group_id", "ug.group_name"}, keyword);
String sql = ""
+ "SELECT " +
"ug.group_id, " +
"ug.group_name, " +
"(SELECT count(u.uid) FROM fc_user u WHERE u.group_id = ug.group_id) count, " +
"(SELECT group_concat(ugf.fun_id) FROM fc_user_group_funs ugf WHERE ugf.group_id = ug.group_id GROUP BY ugf.group_id) funs, " +
"(SELECT group_concat(ugr.review_round) FROM fc_user_group_round ugr WHERE ugr.group_id = ug.group_id GROUP BY ugr.group_id) rounds, " +
"(SELECT group_concat(uge.enroll_type_id) FROM fc_user_group_enroll uge WHERE uge.group_id = ug.group_id GROUP BY uge.group_id) enrolls " +
"FROM " +
"fc_user_group ug" + StringUtil.join(" and ", " where ", " ", " ", argEdit.getStringList()) ;
return jdbcTemplate.limit(sql, page, argEdit.getObjectArray());
}
@Override
public void mergeGroup(Fc_user_group group) {
jdbcTemplate.merge(group);
}
@Override
public List<Map<String, Object>> queryUserList(String keyword, Integer group_id, Page page) {
SqlWhere w = new SqlWhere().lk(new String[]{"u.uid", "u.username", "u.realname"}, keyword).eq("u.group_id", group_id);
String sql = "select u.*, ug.group_name from fc_user u left join fc_user_group ug on ug.group_id = u.group_id" + StringUtil.join(" and ", " where ", "", "", w.getStringList());
return jdbcTemplate.limit(sql, page, w.getObjectArray());
}
@Override
public void saveUser(Fc_user user) {
try {
jdbcTemplate.save(user);
} catch (DuplicateKeyException e) {
throw new XRException("用户已存在");
}
}
@Override
public void updateUserInfo(Fc_user user) {
String sql = "update fc_user set realname = ?, group_id = ?, expire_date = ?, email = ?, tel = ?, lastuptime = ? where uid = ?";
jdbcTemplate.executeUpdate(sql, user.getRealname(), user.getGroup_id(), user.getExpire_date(), user.getEmail(), user.getTel(), new Date(), user.getUid());
}
@Override
public void changePassword(Integer uid, String password) {
String salt = Common.getGenerateString(6);
String encodePassword = Common.encodePassword(password, salt);
jdbcTemplate.executeUpdate("update fc_user set password = ?, salt = ? where uid = ?", encodePassword, salt, uid);
}
@Override
@Transactional
public void saveGroupFuns(Integer group_id, Integer[] fun_id) {
jdbcTemplate.executeUpdate("delete from fc_user_group_funs where group_id = ?", group_id);
if(fun_id != null && fun_id.length > 0) {
List<Fc_user_group_funs> list = new ArrayList<Fc_user_group_funs>();
for(Integer i : fun_id) {
Fc_user_group_funs gf = new Fc_user_group_funs();
gf.setGroup_id(group_id);
gf.setFun_id(i);
list.add(gf);
}
jdbcTemplate.batchSave(list);
}
}
@Override
public void saveGroupRound(Integer group_id, Integer[] rounds) {
jdbcTemplate.executeUpdate("delete from fc_user_group_round where group_id = ?", group_id);
if(rounds != null && rounds.length > 0) {
List<Fc_user_group_round> objs = new ArrayList<Fc_user_group_round>();
for(Integer round : rounds) {
Fc_user_group_round type = new Fc_user_group_round();
type.setGroup_id(group_id);
type.setReview_round(round);
objs.add(type);
}
jdbcTemplate.batchSave(objs);
}
}
@Override
public void saveGroupEnroll(Integer group_id, Integer[] enroll_types) {
jdbcTemplate.executeUpdate("delete from fc_user_group_enroll where group_id = ?", group_id);
if(enroll_types != null && enroll_types.length > 0) {
List<Fc_user_group_enroll> typeList = new ArrayList<Fc_user_group_enroll>();
for(Integer enrollType : enroll_types) {
Fc_user_group_enroll type = new Fc_user_group_enroll();
type.setGroup_id(group_id);
type.setEnroll_type_id(enrollType);
typeList.add(type);
}
jdbcTemplate.batchSave(typeList);
}
}
@Override
public Fc_user_group queryGroupById(Integer group_id) {
return jdbcTemplate.queryForBean("select * from fc_user_group where group_id = ?", Fc_user_group.class, group_id);
}
@Override
public List<Fc_user_group_funs> queryGroupFunList(Integer group_id) {
return jdbcTemplate.queryForBeans("select * from fc_user_group_funs where group_id = ?", Fc_user_group_funs.class, group_id);
}
@Override
public List<Fc_user_group_round> queryGroupRoundList(Integer group_id) {
return jdbcTemplate.queryForBeans("select * from fc_user_group_round where group_id = ?", Fc_user_group_round.class, group_id);
}
@Override
public List<Fc_user_group_enroll> queryGroupEnrollList(Integer group_id) {
return jdbcTemplate.queryForBeans("select * from fc_user_group_enroll where group_id = ?", Fc_user_group_enroll.class, group_id);
}
@Override
public void deleteUserById(Integer uid) {
jdbcTemplate.executeUpdate("delete from fc_user where uid = ?", uid);
}
@Override
public void deleteGroupById(Integer group_id) {
jdbcTemplate.executeUpdate("update fc_user_group set state = 2 where group_id = ?", group_id);
}
@Override
public List<Map<String, Object>> getReviewUserList(Integer review_id, Integer review_round) {
String sql = "select u.uid, u.username, u.realname, u.group_id, ug.group_name from fc_user u left join fc_user_group ug on ug.group_id = u.group_id, fc_user_group_round ugr, fc_user_group_enroll uge, fc_review r where u.group_id = ugr.group_id and u.group_id = uge.group_id and ugr.review_round = ? and uge.enroll_type_id = r.enroll_type_id and r.id = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, review_round, review_id);
List<String> ids = new ArrayList<String>();
for(Map<String, Object> map : list) {
ids.add(map.get("uid").toString());
}
String sql2 = ""
+ "select "
+ "rr.user_id, "
+ "count(rr.id) count_record, "
+ "count(case when review_state is not null then rr.id end) count_review_record "
+ "from "
+ "fc_review_record rr "
+ "where "
+ "rr.user_id in (" + StringUtil.join(", ", "", "", "''", ids) + ") "
+ "group by "
+ "rr.user_id";
List<Map<String, Object>> countList = jdbcTemplate.queryForList(sql2);
Map<String, Map<String, Object>> countMM = Util.listToMM(countList, "user_id");
for(Map<String, Object> map : list) {
String userid = map.get("uid").toString();
Map<String, Object> countMap = countMM.get(userid);
if(countMap != null) {
map.put("count_record", countMap.get("count_record"));
map.put("count_review_record", countMap.get("count_review_record"));
} else {
map.put("count_record", 0);
map.put("count_review_record", 0);
}
}
return list;
}
@Override
public List<Map<String, Object>> getReviewGroupList(Integer review_id, Integer review_round) {
String sql = "select ug.* from fc_user_group ug, fc_user_group_round ugr, fc_user_group_enroll uge, fc_review r where ug.group_id = ugr.group_id and ug.group_id = uge.group_id and ugr.review_round = ? and uge.enroll_type_id = r.enroll_type_id and r.id = ?";
return jdbcTemplate.queryForList(sql, review_round, review_id);
}
@Override
public List<Map<String, Object>> getShowFilmGroupList() {
String sql = "select ug.* from fc_user_group ug, fc_user_group_funs ugf where ug.group_id = ugf.group_id and ugf.fun_id = 2";
return jdbcTemplate.queryForList(sql);
}
@Override
public List<Map<String, Object>> getShowFilmUserList() {
String sql = "select u.uid, u.username, u.realname, u.group_id, ug.group_name from fc_user u left join fc_user_group ug on ug.group_id = u.group_id, fc_user_group_funs ugf where u.group_id = ugf.group_id and ugf.fun_id = 2";
return jdbcTemplate.queryForList(sql);
}
}
package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.CinemaService;
import com.egolm.film.api.service.CommonService;
import com.egolm.film.bean.Fc_cinema;
import com.egolm.film.bean.Fc_cinema_showtime;
import com.egolm.film.util.SqlWhere;
@Service
public class CinemaServiceImpl implements CinemaService {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
CommonService common;
@Override
public List<Map<String, Object>> getCinemaListForSelected(String keyword) {
SqlWhere where = new SqlWhere().lk(new String[] {"cinema_no", "cinema_name", "cinema_en_name"}, keyword);
String sql = ""
+ "select "
+ "cinema_no, "
+ "cinema_name, "
+ "cinema_en_name, "
+ "cinema_address, "
+ "cinema_en_address, "
+ "telphone "
+ "from "
+ "fc_cinema " + StringUtil.join(" and ", " where ", " ", " ", where.getStringList())
+ "group by "
+ "cinema_no, "
+ "cinema_name, "
+ "cinema_en_name, "
+ "cinema_address, "
+ "cinema_en_address, "
+ "telphone "
;
return jdbcTemplate.queryForList(sql, where.getObjectArray());
}
@Override
public List<Map<String, Object>> getCinemaList(String keyword, Page page) {
SqlWhere where = new SqlWhere().eq("status", 0).lk(new String[] {"cinema_no", "cinema_name", "cinema_en_name"}, keyword);
String sql = "select * from fc_cinema " + StringUtil.join(" and ", " where ", " ", " ", where.getStringList());
return jdbcTemplate.limit(sql, page, where.getObjectArray());
}
@Override
public void setTmpData(Integer cinemaId) {
String sql_tmp_count_show = "select count(*) from fc_cinema_showtime where cinema_id = ? and showtime_no is not null and showtime_no != '' and status = 0";
String sql_tmp_count_film = "select count(*) from (select film_id from fc_cinema_showtime where cinema_id = ? and film_id is not null and status = 0 group by film_id) t";
Integer tmp_count_show = jdbcTemplate.queryForInt(sql_tmp_count_show, cinemaId);
Integer tmp_count_film = jdbcTemplate.queryForInt(sql_tmp_count_film, cinemaId);
jdbcTemplate.executeUpdate("update fc_cinema set tmp_count_show = ?, tmp_count_film = ? where id = ?", tmp_count_show, tmp_count_film, cinemaId);
}
@Override
public List<Map<String, Object>> queryShowtimeList(Integer cinemaId, Date start_date, Date end_date) {
SqlWhere where = new SqlWhere().eq("status", 0).eq("cinema_id", cinemaId).ge("show_date", start_date).lt("show_date", end_date);
String sql = "select * from fc_cinema_showtime" + StringUtil.join(" and ", " where ", " ", " ", where.getStringList());
return jdbcTemplate.queryForList(sql, where.getObjectArray());
}
@Override
public void deleteShowtimeByShowtime(Integer cinema_id, String show_time) {
jdbcTemplate.executeUpdate("delete from fc_cinema_showtime where cinema_id = ? and show_time = ?", cinema_id, show_time);
}
@Override
public void deleteShowtimeByShowdate(Integer cinema_id, Date show_date) {
jdbcTemplate.executeUpdate("delete from fc_cinema_showtime where cinema_id = ? and show_date = ?", cinema_id, DateUtil.start(show_date));
}
@Override
public void deleteShowtimeById(Integer id) {
jdbcTemplate.executeUpdate("update fc_cinema_showtime set status = 2 where id = ?", id);
}
@Override
public void deleteCinemaById(Integer id) {
jdbcTemplate.executeUpdate("update fc_cinema set status = 2 where id = ?", id);
}
@Override
public Integer queryMaxShowtimeNoByCinemaId(Integer cinema_id) {
try {
String sql = "select max(showtime_no) from fc_cinema_showtime where cinema_id = ?";
Integer maxNo = jdbcTemplate.queryForInt(sql, cinema_id);
return maxNo;
} catch (NullPointerException | EmptyResultDataAccessException e) {
e.printStackTrace();
return null;
}
}
@Override
public void setShowtimeNo(Integer showtimeId) {
Fc_cinema_showtime showtime = common.queryById(showtimeId, Fc_cinema_showtime.class);
if(showtime.getShowtime_no() == null) {
Integer max_showtime_no = this.queryMaxShowtimeNoByCinemaId(showtime.getCinema_id());
if(max_showtime_no == null) {
Fc_cinema cinema = common.queryById(showtime.getCinema_id(), Fc_cinema.class);
max_showtime_no = Integer.valueOf(cinema.getCinema_no()) * 10000;
}
Integer nextNo = max_showtime_no + 1;
jdbcTemplate.executeUpdate("update fc_cinema_showtime set showtime_no = ? where id = ?", nextNo, showtimeId);
}
}
}
package com.egolm.film.api.service.impl;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.NoSuchMessageException;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import com.egolm.film.api.service.Messages;
import com.egolm.film.config.XException;
@Component
public class DefaultMessages implements Messages {
@Autowired
protected MessageSource messageSource;
@Override
public String get(String name, Locale locale, String... args) {
return messageSource.getMessage(name, args, locale);
}
public String get(String name, String... args) {
try {
Locale locale = LocaleContextHolder.getLocale();
locale = locale == null ? Locale.CHINA : locale;
return this.get(name, locale, args);
} catch (NoSuchMessageException e) {
return name;
} catch (Exception e) {
throw new XException("", e);
}
}
@Override
public Locale getLocale() {
Locale locale = LocaleContextHolder.getLocale();
locale = locale == null ? Locale.CHINA : locale;
return locale;
}
}
package com.egolm.film.api.service.impl;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import com.egolm.common.MailUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.EmailService;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.MemberService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Fc_email_record;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.util.Common;
@Service
public class EmailServiceImpl implements EmailService {
private static final Logger logger = Logger.getLogger(EmailService.class);
@Value("${com.egolm.film.email.smtp.host}") private String host;
@Value("${com.egolm.film.email.smtp.port}") private Integer port;
@Value("${com.egolm.film.email.smtp.from}") private String from;
@Value("${com.egolm.film.email.smtp.username}") private String username;
@Value("${com.egolm.film.email.smtp.password}") private String password;
@Value("${com.egolm.film.email.test}") private String testEmail;
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public void send(Integer sender_type_id, Integer sender_id, String subject, String content, String email) {
Fc_email_record record = new Fc_email_record();
record.setSender_id(sender_id);
record.setSender_type_id(sender_type_id);
record.setEmail(email);
record.setCreate_time(new Date());
record.setSubject(subject);
record.setContent(content);
record.setSend_state(0);
jdbcTemplate.save(record);
new Thread() {
public void run() {
try {
MailUtil.sendBySmtps(host, port, username, password, from, subject, content, null, StringUtil.isNotBlank(testEmail) ? testEmail : email);
record.setSend_state(1);
} catch (Exception e) {
logger.error("邮件发送失败", e);
record.setSend_state(2);
} finally {
jdbcTemplate.update(record);
}
}
}.start();
}
@Autowired
MemberService memberService;
@Autowired
FilmService filmService;
@Autowired
AdminTokenService adminTokenService;
@Autowired
Messages messages;
private static final String tpl_en = Common.getStringAsStream("doc/first_pass_en_US.txt");
private static final String tpl_zh = Common.getStringAsStream("doc/first_pass_zh_CN.txt");
public Map<String, Object> sendByTemplate_pass(Long member_film_id) {
Map<String, Object> map = new HashMap<String, Object>();
Integer adminid = (Integer)adminTokenService.getToken().getId();
Fc_member_film memberFilm = filmService.queryMemberFilmById(member_film_id);
String film_no = StringUtil.formatLength(memberFilm.getFilm_no(), "0000");
map.put("film_no", film_no);
Fc_member member = null;
try {
member = memberService.getMemberById(memberFilm.getMember_id());
} catch (EmptyResultDataAccessException e) {
member = null;
}
if(member != null) {
Locale locale = new Locale("zh", "CN");
if("en".equals(member.getLang())) {
locale = new Locale("en", "US");
}
String subject = messages.get("email.getPassword.subject", locale);
String language = locale.getLanguage().toLowerCase();
String content = tpl_zh;
if(language.equals("en")) {
content = tpl_en;
}
String filmName = null;
if(locale.getLanguage().toLowerCase().equals("zh")) {
filmName = memberFilm.getCn_name();
} else if(locale.getLanguage().toLowerCase().equals("en")) {
filmName = memberFilm.getEn_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getOrigion_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getEn_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getCn_name();
}
content = MessageFormat.format(content, member.getUsername(), film_no, filmName == null ? "" : filmName);
this.send(2, adminid, subject, content, member.getEmail());
map.put("email", member.getEmail());
return map;
} else {
map.put("email", "后台申报影片,未发送邮件");
}
return map;
}
public static void main(String[] args) {
String host = "smtp.siff.com";
Integer port = 25;
boolean is_auth = true;
String from = "filmpassword@siff.com";
String username = "filmpassword@siff.com";
String password = "siffstvf2018";
String subject = "Test";
String content = "Test";
String emailAddress = "747539993@qq.com";
MailUtil.sendBySmtp(host, port, is_auth, username, password, from, subject, content, null, emailAddress);
}
}
package com.egolm.film.api.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.FilmGroupService;
import com.egolm.film.util.SqlWhere;
@Service
public class FilmGroupServiceImpl implements FilmGroupService {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> queryFilmGroupList() {
return jdbcTemplate.queryForList("select * from fc_film_group");
}
@Override
public List<Map<String, Object>> queryFilmListByGroupId(Integer group_id) {
String sql = ""
+ "select "
+ "mf.id, "
+ "mf.film_group_id, "
+ "mf.create_time, "
+ "mf.enroll_type_name, "
+ "mf.film_type_name, "
+ "mf.last_modify_time, "
+ "mf.film_no, "
+ "mf.en_name, "
+ "mf.cn_name, "
+ "r.review_state, "
+ "r.id review_id "
+ "from "
+ "fc_member_film mf "
+ "left join fc_review r on r.film_id = mf.id and r.opt_state = 3 "
+ "where "
+ "mf.film_group_id is not null and mf.film_group_id = ?";
return jdbcTemplate.queryForList(sql, group_id);
}
@Override
public void updateFilmGroupId(Integer[] film_id, Integer group_id, String group_remark) {
Object[][] args = new Object[film_id.length][];
for(int i = 0; i < film_id.length; i++) {
args[i] = new Object[] {group_id, group_remark, film_id[i]};
}
jdbcTemplate.batchUpdate("update fc_member_film set film_group_id = ?, group_remark = ? where id = ?", args);
}
@Override
@Transactional
public void removeFilmGroupById(Integer[] id) {
Integer[][] args = new Integer[id.length][];
for(int i = 0; i < id.length; i++) {
args[i] = new Integer[] {id[i]};
}
jdbcTemplate.batchUpdate("delete from fc_film_group where id = ?", args);
jdbcTemplate.batchUpdate("update fc_member_film set film_group_id = null where film_group_id = ?", args);
}
@Override
public List<Map<String, Object>> queryNoGroupFilmList(String keyword, Integer film_type_id, Integer enroll_type_id, String film_country, Integer film_type_name_short, Integer play_shanghai, Integer review_round, Integer review_state, Page page) {
SqlWhere wehre = new SqlWhere()
.eq("t.film_country", film_country)
.eq("t.film_type_name", film_type_id)
.eq("t.film_type_name_short", film_type_name_short)
.eq("t.play_shanghai", play_shanghai)
.lk("t.keywords", keyword)
.eq("r.review_round", review_round)
.eq("r.review_state", review_state)
;
String table = "fc_member_film";
if(enroll_type_id != null) {
table = "(select mf.* from fc_member_film mf, fc_member_film_enroll mfe where mf.id = mfe.film_id and mfe.enroll_type_id = " + enroll_type_id + ")";
}
String sql = ""
+ "select "
+ "t.*, "
+ "r.review_round, "
+ "r.review_state "
+ "from "
+ "" + table + " t, fc_review r where r.film_id = t.id and r.opt_state = 3 and r.review_state != 2 and (t.film_group_id is null or t.film_group_id = 0) and (t.not_invite is null or t.not_invite = 0) " + StringUtil.join(" and ", " and ", "", "", wehre.getStringList());
return jdbcTemplate.limit(sql, page, wehre.getObjectArray());
}
@Override
public List<Map<String, Object>> queryGroupFilmList(Integer[] group_id, String keyword, Integer enroll_type_id,
Integer film_type_name, Integer film_type_name_short, Integer play_shanghai, Integer is_important,
Integer review_state, Integer review_round, String film_country, Page page) {
SqlWhere wehre = new SqlWhere()
.in("t.film_group_id", group_id)
.eq("t.film_type_name", film_type_name)
.eq("t.film_type_name_short", film_type_name_short)
.eq("t.play_shanghai", play_shanghai)
.eq("t.is_important", is_important)
.eq("t.film_country", film_country)
.eq("r.review_state", review_state)
.eq("r.review_round", review_round)
.lk("t.keywords", keyword);
;
String table = "fc_member_film";
if(enroll_type_id != null) {
table = "(select mf.* from fc_member_film mf, fc_member_film_enroll mfe where mf.id = mfe.film_id and mfe.enroll_type_id = " + enroll_type_id + ")";
}
String sql = ""
+ "select "
+ "t.*, "
+ "fg.group_name, "
+ "r.id review_id, "
+ "r.review_state, "
+ "r.review_round, "
+ "r.opt_state "
+ "from "
+ "" + table + " t left join fc_film_group fg on fg.id = t.film_group_id, fc_review r where r.film_id = t.id and r.opt_state = 3 and r.review_state != 2 and t.film_group_id is not null and t.film_group_id != 0 and (t.not_invite is null or t.not_invite = 0) " + StringUtil.join(" and ", " and ", "", "", wehre.getStringList());
return jdbcTemplate.limit(sql, page, wehre.getObjectArray());
}
@Override
public List<Map<String, Object>> queryNotInviteList(Integer[] group_id, String keyword, Integer enroll_type_id,
Integer film_type_name, Integer film_type_name_short, Integer play_shanghai, Integer is_important,
Integer review_state, Integer review_round, String film_country, Page page) {
SqlWhere wehre = new SqlWhere()
.in("t.film_group_id", group_id)
.eq("t.film_type_name", film_type_name)
.eq("t.film_type_name_short", film_type_name_short)
.eq("t.play_shanghai", play_shanghai)
.eq("t.is_important", is_important)
.eq("t.film_country", film_country)
.lk("t.keywords", keyword)
.eq("r.review_state", review_state)
.eq("r.review_round", review_round)
;
String table = "fc_member_film";
if(enroll_type_id != null) {
table = "(select mf.* from fc_member_film mf, fc_member_film_enroll mfe where mf.id = mfe.film_id and mfe.enroll_type_id = " + enroll_type_id + ")";
}
String sql = ""
+ "select "
+ "t.*, "
+ "r.review_state, "
+ "r.review_round, "
+ "r.opt_state "
+ "from "
+ "" + table + " t, fc_review r where r.film_id = t.id and r.opt_state = 3 and r.review_state != 2 and t.not_invite = 1 " + StringUtil.join(" and ", " and ", "", "", wehre.getStringList());
return jdbcTemplate.limit(sql, page, wehre.getObjectArray());
}
@Override
public void doNotInvite(Integer film_id, Integer not_invite, String not_invite_text) {
jdbcTemplate.executeUpdate("update fc_member_film set not_invite = ?, not_invite_text = ? where id = ?", not_invite, not_invite_text, film_id);
}
}
package com.egolm.film.api.service.impl;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.FilmReportService;
import com.egolm.film.util.SqlWhere;
@Service
public class FilmReportServiceImpl implements FilmReportService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public Map<String, Object> uploadReport(String start_date, String end_date) {
String createDateSql = "select count(id) count, DATE_FORMAT((select from_unixtime(create_time)),'%Y-%m-%d') date from fc_member_film where create_time >= ? and create_time < ? group by date";
String uploadDateSql = "select count(id) count, DATE_FORMAT(upload_time,'%Y-%m-%d') date from fc_member_film where upload_state = 1 and upload_time >= ? and upload_time < ? group by date";
String totalCountSql = "select count(id) from fc_member_film where upload_state = 1 and upload_time >= ? and upload_time < ?";
Date start = DateUtil.parse(start_date, DateUtil.FMT_DATE);
Date end = DateUtil.parse(end_date, DateUtil.FMT_DATE);
end = new Date(end.getTime()+1000*60*60*24);
List<Map<String, Object>> createCountDataLsit = jdbcTemplate.queryForList(createDateSql, start.getTime()/1000, end.getTime()/1000);
List<Map<String, Object>> uploadCountDataLsit = jdbcTemplate.queryForList(uploadDateSql, start, end);
Calendar c = Calendar.getInstance();
List<Object> dataLsit = new ArrayList<>();
Map<String, Object> res = new HashMap<>();
Long totalCount = jdbcTemplate.queryForLong(totalCountSql, start, end);
res.put("total_count", totalCount);
while (!start.equals(end)) {
c.setTime(end);
c.add(Calendar.DATE, -1);
end = c.getTime();
Map<String, Object> item = new HashMap<>();
Long createCount = 0L;
for(Map<String, Object> map : createCountDataLsit) {
if(map.get("date").equals(DateUtil.format(end, DateUtil.FMT_DATE))) {
createCount = (Long) map.get("count");
}
}
Long uploadCount = 0L;
for(Map<String, Object> map : uploadCountDataLsit) {
if(map.get("date").equals(DateUtil.format(end, DateUtil.FMT_DATE))) {
uploadCount = (Long) map.get("count");
}
}
item.put("apply_count", createCount);
item.put("upload_count", uploadCount);
item.put("total_count", totalCount);
item.put("date", DateUtil.format(end, DateUtil.FMT_DATE));
dataLsit.add(item);
}
res.put("list", dataLsit);
return res;
}
@Override
public Map<String, Object> applyTypeReport() {
Map<String, Object> res = new HashMap<>();
String applyTypeSql = "ee.enroll_type enroll_type_id, "
+ "ee.enroll_type_name enroll_type_name "
+ "from enum_enroll ee, "
+ "fc_member_film fmf, "
+ "fc_member_film_enroll fmfe "
+ "where fmf.id = fmfe.film_id "
+ "and fmfe.enroll_type_id = ee.enroll_type ";
Long applyTypeTotalCount = jdbcTemplate.queryForLong("select count(1) from (select "+applyTypeSql+") t");
List<Map<String, Object>> applyTypeGroup = jdbcTemplate.queryForList("select count(1) count, "+applyTypeSql+" group by ee.enroll_type");
String filmTypeSql = "ef.film_type, ef.film_type_name from enum_filmtype ef, fc_member_film fmf where ef.film_type = fmf.film_type_name";
Long filmTypeTotalCount = jdbcTemplate.queryForLong("select count(1) from (select "+filmTypeSql+") t");
List<Map<String, Object>> filmTypeGroup = jdbcTemplate.queryForList("select count(1) count, "+filmTypeSql+" group by ef.film_type");
String showTypeSql = "play_shanghai from fc_member_film where play_shanghai is not null";
Long showTypeTotalCount = jdbcTemplate.queryForLong("select count(1) from (select "+showTypeSql+") t");
List<Map<String, Object>> showTypeGroup = jdbcTemplate.queryForList("select count(1) count, "+showTypeSql+" group by play_shanghai");
for(Map<String, Object> map : applyTypeGroup) {
Long itemCount = (Long) map.get("count");
Double proportion = itemCount.doubleValue()/applyTypeTotalCount;
map.put("proportion", proportion);
}
for(Map<String, Object> map : filmTypeGroup) {
Long itemCount = (Long) map.get("count");
Double proportion = itemCount.doubleValue()/filmTypeTotalCount;
map.put("proportion", proportion);
}
for(Map<String, Object> map : showTypeGroup) {
Long itemCount = (Long) map.get("count");
Double proportion = itemCount.doubleValue()/showTypeTotalCount;
map.put("proportion", proportion);
}
res.put("apply_type_group_list", applyTypeGroup);
res.put("film_type_group_list", filmTypeGroup);
res.put("show_type_group_list", showTypeGroup);
return res;
}
@Override
public List<Map<String, Object>> directorReport(String playactor_name, Page page) {
String sql = "select * from (select count(1) count, t.playactor_name playactor_name, max(t.create_time) create_time from (select fmfp.playactor_name, fmf.create_time from fc_member_film_playactor fmfp, fc_member_film fmf where fmfp.film_id = fmf.id order by fmf.create_time desc) t group by t.playactor_name) t2 where t2.playactor_name like ? order by t2.create_time desc";
List<Map<String, Object>> res = jdbcTemplate.limit(sql, page, "%"+playactor_name+"%");
List<String> directors = new ArrayList<>();
List<String> placeholders = new ArrayList<String>();
for (Map<String, Object> map : res) {
directors.add((String)map.get("playactor_name"));
placeholders.add("?");
}
String sql2 = "select "
+ "fmf.origion_name origion_name, "
+ "fmf.en_name en_name, "
+ "fmf.cn_name cn_name, "
+ "fmfp.playactor_name playactor_name "
+ "from "
+ "fc_member_film_playactor fmfp, "
+ "fc_member_film fmf "
+ "where "
+ "fmfp.film_id = fmf.id "
+ "and "
+ "fmfp.playactor_name "
+ "in ( "
+ StringUtil.join(", ", placeholders)
+ ")";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql2, directors.toArray());
for (Map<String, Object> map : res) {
String playactoName = (String)map.get("playactor_name");
List<Map<String, Object>> itemList = new ArrayList<>();
for (Map<String, Object> map2 : list) {
if(map2.get("playactor_name").equals(playactoName)) {
itemList.add(map2);
}
}
map.put("film_list", itemList);
}
return res;
}
@Override
public Map<String, Object> directorDetail(String playactor_name) {
String sql = "select "
+ "fmf.origion_name origion_name, "
+ "fmf.en_name en_name, "
+ "fmf.cn_name cn_name, "
+ "fmfp.playactor_name playactor_name, "
+ "r.review_state, "
+ "r.review_round, "
+ "r.opt_state, "
+ "r.allot_state, "
+ "DATE_FORMAT(from_unixtime(fmf.create_time),'%Y') apply_year "
+ "from "
+ "fc_member_film_playactor fmfp, "
+ "fc_member_film fmf, "
+ "fc_review r "
+ "where "
+ "fmfp.film_id = fmf.id "
+ "and r.film_id = fmf.id "
+ "and fmfp.playactor_name = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, playactor_name);
Map<String, Object> res = new HashMap<>();
res.put("playactor_name", playactor_name);
res.put("list", list);
return res;
}
@Override
public List<Map<String, Object>> queryUserViewReport(String keyword, Page page) {
SqlWhere where = new SqlWhere();
where.lk(new String[] {"u.username", "u.realname"}, keyword);
String sql = ""
+ "select "
+ "u.uid, "
+ "u.username, "
+ "u.realname, "
+ "count(rr.id) count_all, "
+ "count(case when rr.view_time is not null then rr.id end) count_view, "
+ "count(case when rr.view_time is null then rr.id end) count_not_view, "
+ "count(case when rr.view_time is null and rr.create_time < '" + DateUtil.format(DateUtil.day(new Date(), -2)) + "' then rr.id end) count_timeout "
+ "from "
+ "fc_user u, "
+ "fc_review_record rr "
+ "where "
+ "rr.user_id = u.uid " + StringUtil.join(" and ", " and ", "", "", where.getStringList()) + " "
+ "group by "
+ "u.uid, "
+ "u.username, "
+ "u.realname ";
System.out.println(sql);
return jdbcTemplate.limit(sql, page, where.getObjectArray());
}
@Override
public List<Map<String, Object>> queryUserReiewReport(Integer user_id, Page page) {
String sql = ""
+ "select "
+ "rr.*, "
+ "DATEDIFF(now(), rr.create_time) push_days, "
+ "r.review_round review_round_now, "
+ "r.review_state review_state_now, "
+ "r.opt_state, "
+ "r.allot_state, "
+ "mf.id film_id, "
+ "mf.film_no, "
+ "mf.en_name, "
+ "mf.cn_name "
+ "from "
+ "fc_review_record rr "
+ "left join fc_review r on r.id = rr.review_id "
+ "left join fc_member_film mf on mf.id = r.film_id "
+ "where "
+ "rr.user_id = " + user_id;
return jdbcTemplate.limit(sql, page);
}
}
package com.egolm.film.api.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.egolm.film.api.service.LanguageService;
@Service
public class LanguageServiceImpl implements LanguageService {
private static String en = "Chinese,Dialect,French,Russian,Japanese,Portugal,Farsi,Italian,English,German,Spanish,Arabic,Hindi,Korean,Other";
private static String zh = "普通话,方言,法语,俄罗斯语,日语,葡萄牙语,波斯语,意大利语,英语,德语,西班牙语,阿拉伯语,印第语,韩语,其他";
public List<Map<String, String>> queryLanguageList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
String[] keys = en.split(",");
String[] vals = zh.split(",");
if(keys.length == vals.length) {
for(int i = 0; i < keys.length; i++) {
Map<String, String> map = new HashMap<String, String>();
map.put(vals[i], keys[i]);
list.add(map);
}
}
return list;
}
@Override
public Map<String, String> queryLanguageMap() {
List<Map<String, String>> list = this.queryLanguageList();
Map<String, String> countryMap = new HashMap<String, String>();
for(Map<String, String> map : list) {
for(String key : map.keySet()) {
countryMap.put(key, map.get(key));
}
}
return countryMap;
}
@Override
public Map<String, String> queryLanguageMapReverse() {
List<Map<String, String>> list = this.queryLanguageList();
Map<String, String> countryMap = new HashMap<String, String>();
for(Map<String, String> map : list) {
for(String key : map.keySet()) {
countryMap.put(map.get(key), key);
}
}
return countryMap;
}
}
package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.LogService;
import com.egolm.film.bean.Fc_logs_error;
import com.egolm.film.util.SqlWhere;
@Service
public class LogServiceImpl implements LogService {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> queryLogList(String type, String username, Page page) {
SqlWhere where = new SqlWhere().eq("t.type", type.toLowerCase()).eq("t.username", username);
String sql = "select l.*, le.ext, ifnull(ifnull(u.username, m.username), a.realname) username from fc_logs l left join fc_logs_ext le on le.path = l.path left join fc_user u on u.uid = l.loginid and l.type = 'user' left join fc_member m on m.id = l.loginid and l.type = 'member' left join fc_admin a on a.adminid = l.loginid and l.type = 'admin'";
sql = "select t.* from (" + sql + ") t" + StringUtil.join(" and ", " where ", "", "", where.getStringList()) + " order by t.create_time desc";
return jdbcTemplate.limit(sql, page, where.getObjectArray());
}
@Override
public void saveErrorLog(String path, Object params, Throwable ex) {
Fc_logs_error error = new Fc_logs_error();
error.setTitle(ex.getMessage());
error.setPath(path);
error.setParams(JSON.toJSONString(params));
error.setError(this.toStackString(ex).toString());
error.setCreate_time(new Date());
jdbcTemplate.save(error);
}
private StringBuffer toStackString(Throwable ex) {
StringBuffer stack = new StringBuffer();
if(ex != null) {
stack.append(ex.getClass().getName()).append(ex.getMessage());
StackTraceElement[] elms = ex.getStackTrace();
for(StackTraceElement elm : elms) {
stack.append("\t").append(elm.getClassName()).append(".").append(elm.getMethodName()).append("(").append(elm.getFileName()).append(" ").append(elm.getLineNumber()).append(")\n");
}
stack.append("\n\n").append("Cause By: \n").append(this.toStackString(ex.getCause()));
for(Throwable e : ex.getSuppressed()) {
stack.append("\n\n").append("Suppressed By: \n").append(this.toStackString(e));
}
}
return stack;
}
@Override
public List<Map<String, Object>> queryErrorList(Page page) {
return jdbcTemplate.limit("select * from fc_logs_error", page);
}
}
package com.egolm.film.api.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.film.api.service.MemberService;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.util.Common;
@Service
public class MemberServiceImpl implements MemberService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public void resetPassword(Integer id, String newPassword) {
String sql = "update fc_member set password = ? where id = ?";
jdbcTemplate.executeUpdate(sql, newPassword, id);
}
@Override
public Fc_member getMemberByEmail(String email) {
String sql = "select * from fc_member where email = ?";
return jdbcTemplate.queryForBean(sql, Fc_member.class, email);
}
@Override
public void saveMember(Fc_member member) {
jdbcTemplate.save(member);
}
@Override
public Fc_member getMemberById(Integer id) {
String sql = "select * from fc_member where id = ?";
return jdbcTemplate.queryForBean(sql, Fc_member.class, id);
}
@Override
public void mergeMember(Fc_member member) {
jdbcTemplate.merge(member);
}
@Override
public void updateMember(
Integer id,
String email,
String realname,
String address,
String company,
String tel) {
String sql = ""
+ "update "
+ "fc_member "
+ "set "
+ "email = ?, "
+ "realname = ?, "
+ "address = ?, "
+ "company = ?, "
+ "tel = ? "
+ "where "
+ "id = ?";
jdbcTemplate.executeUpdate(
sql,
email,
realname,
address,
company,
tel,
id);
}
@Override
public List<Map<String, Object>> queryListByMemberID(Integer member_id) {
String sql = "select * from fc_member_film where member_id = ?";
return jdbcTemplate.queryForList(sql, member_id);
}
@Override
public boolean exists(String email) {
return jdbcTemplate.queryForInt("select count(*) from fc_member where email = ?", email) > 0;
}
@Override
public boolean changePasswordByMemberId(Integer member_id, String password, String newPassword) {
Fc_member member = this.getMemberById(member_id);
String encodePassword = Common.encodePassword(password, member.getSalt());
if(encodePassword.equals(member.getPassword())) {
String encodeNewPassword = Common.encodePassword(newPassword, member.getSalt());
return jdbcTemplate.executeUpdate("update fc_member set password = ? where id = ?", encodeNewPassword, member.getId()) == 1;
}
return false;
}
@Override
public Fc_member getMemberByToken(String token) {
String sql = "select * from fc_member where token = ? and state = 1";
return jdbcTemplate.queryForBean(sql, Fc_member.class, token);
}
@Override
public void updateLoginInfo(Integer member_id, String login_ip, String token_string) {
String sql = "update fc_member set token = ?, login_time = ?, login_ip = ? where id = ?";
jdbcTemplate.executeUpdate(sql, token_string, System.currentTimeMillis()/1000, login_ip, member_id);
}
@Override
public void updateLanguage(Integer id, String lang) {
jdbcTemplate.executeUpdate("update fc_member set lang = ? where id = ?", lang, id);
}
}
package com.egolm.film.api.service.impl;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.MemberService;
import com.egolm.film.api.service.MemberTokenService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common;
@Service
public class MemberTokenServiceImpl implements MemberTokenService {
@Autowired
private Messages messages;
@Autowired
private MemberService memberService;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public LoginToken doLogin(String email, String password) {
HttpSession session = WebMvcConfig.getSession();
Fc_member member = null;
try {
member = memberService.getMemberByEmail(email);
} catch (Exception e) {
throw new XRException(messages.get("err.user_pwd_err"));
}
Integer state = member.getState();
if(state == 1) {
String salt = member.getSalt();
String dbPwd = member.getPassword();
String encodePassword = Common.encodePassword(password, salt);
if(encodePassword.equals(dbPwd)) {
Integer id = member.getId();
LoginToken token = new LoginToken(id);
session.setAttribute(TOKEN_NAME, token);
Cookie cookie = WebMvcConfig.getOrCreateUUIDCookie(LOGINID_COOKIE_NAME, "/", 60*60*24*5, true);
if(cookie != null) {
String loginIp = ServletUtil.remoteIp(WebMvcConfig.getRequest());
memberService.updateLoginInfo(id, loginIp, cookie.getValue());
}
logger.debug("member login success: " + email);
return token;
} else {
throw new XRException(messages.get("err.user_pwd_err"));
}
} else if(state == 2) {
throw new XRException(messages.get("err.user_disabled"));
} else {
throw new XRException(messages.get("err"));
}
}
@Override
public LoginToken getToken() {
HttpSession session = WebMvcConfig.getSession();
LoginToken token = (LoginToken)session.getAttribute(TOKEN_NAME);
return token;
}
@Override
public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId();
return jdbcTemplate.queryForMap("select * from fc_member where id = ?", id);
}
@Override
public void doLogout() {
String sql = "update fc_member set token = ? where id = ?";
jdbcTemplate.executeUpdate(sql, null, this.getToken().getId());
HttpSession session = WebMvcConfig.getSession();
session.removeAttribute(TOKEN_NAME);
session.invalidate();
WebMvcConfig.removeCookie(LOGINID_COOKIE_NAME);
}
@Override
public boolean isLogin() {
return this.getToken() != null;
}
@Override
public boolean isLoginByToken(String token_string) {
HttpSession session = WebMvcConfig.getSession();
try {
Fc_member member = memberService.getMemberByToken(token_string);
Integer state = member.getState();
if(state == 1) {
Integer id = member.getId();
LoginToken token = new LoginToken(id);
session.setAttribute(TOKEN_NAME, token);
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
package com.egolm.film.api.service.impl;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.NewsService;
import com.egolm.film.bean.Fc_admin;
import com.egolm.film.bean.Fc_news;
import com.egolm.film.bean.Fc_news_sender;
@Service
public class NewsServiceImpl implements NewsService {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> queryList(Page page, String key) {
String beforeSql = "select ns.*, a.realname creator_name from fc_news ns left join fc_admin a on a.adminid = ns.creator ";
String centerSql = "";
if(StringUtil.isNotBlank(key)) {
centerSql = " where ns.title like ? ";
}
String endSql = "order by ns.create_time desc";
String sql = beforeSql + centerSql + endSql;
if(!"".equals(centerSql)) {
return jdbcTemplate.limit(sql, page, "%"+key+"%");
}else {
return jdbcTemplate.limit(sql, page);
}
}
@Override
public void merge(Object obj) {
jdbcTemplate.merge(obj);
}
@Override
public void batchSave(List<?> objs) {
jdbcTemplate.batchSave(objs);
}
@Override
public Map<String, Object> queryById(Integer id) {
Map<String, Object> map = jdbcTemplate.queryForMap("select * from fc_news where id = ?", id);
String sql2 = "select user_group_id, user_id from fc_news_sender where news_id = ?";
List<Map<String, Object>> send = jdbcTemplate.queryForList(sql2, id);
List<Object> sendUserList = new ArrayList<>();
List<Object> sendGroupList = new ArrayList<>();
for (Map<String, Object> map2 : send) {
if(map2.get("user_id")!=null) {
sendUserList.add(map2.get("user_id"));
}
if(map2.get("user_group_id")!=null) {
sendGroupList.add(map2.get("user_group_id"));
}
}
map.put("userList", sendUserList);
map.put("groupList", sendGroupList);
return map;
}
@Override
public void save(Object obj) {
jdbcTemplate.save(obj);
}
@Override
public List<Map<String, Object>> queryListForUser(Integer uid, Integer gid, Page page) {
String sqlRead = "select t.user_id, t.news_id, max(t.read_time) read_time from fc_news_read t where t.user_id = ? group by t.user_id, t.news_id";
String sql = "select n.*, ns.sender, ns.send_time, nr.user_id, nr.read_time from fc_news n left join (" + sqlRead + ") nr on nr.news_id = n.id, fc_news_sender ns where n.id = ns.news_id and (ns.user_id = ? or ns.user_group_id = ?) order by n.create_time desc";
return jdbcTemplate.limit(sql, page, uid, uid, gid);
}
static String[] rounds = new String[] {"一选", "二选", "三选", "把关", "选片委员会", "总局审片"};
static Map<Integer, String> map = new HashMap<Integer, String>();
static {
map.put(1, "金爵奖国际影片评选");
map.put(2, "亚洲新人奖国际影片评选");
map.put(3, "国际电影展映");
}
@Override
@Transactional
public void sendAllotNews(Integer review_id, Integer review_round, Integer[] user_id, Fc_admin admin) {
Map<String, Object> film = jdbcTemplate.queryForMap("select mf.*, r.enroll_type_id from fc_member_film mf, fc_review r where mf.id = r.film_id and r.id = ?", review_id);
String cn_name = (String)film.get("cn_name");
String en_name = (String)film.get("en_name");
Integer enroll_type_id = ((Number)film.get("enroll_type_id")).intValue();
String enroll_type_name = map.get(enroll_type_id);
String round = rounds[review_round-1];
String content = "管理员 [{0}] 已经为您分配了新的审片任务 [{1} {2}] {3} {4},请按时处理.";
content = MessageFormat.format(content, admin.getRealname(), cn_name, en_name, enroll_type_name, round);
String title = "审片任务: [{0} {1}] {2} {3}";
title = MessageFormat.format(title, cn_name, en_name, enroll_type_name, round);
Fc_news news = new Fc_news();
news.setTitle(title);
news.setContent(content);
news.setCreate_time(new Date());
news.setCreator(admin.getAdminid());
news.setLevel(1);
news.setType("TEXT");
news.setUpdater(admin.getAdminid());
news.setLast_update_time(news.getCreate_time());
jdbcTemplate.save(news);
List<Fc_news_sender> senders = new ArrayList<Fc_news_sender>();
for(Integer uid : user_id) {
Fc_news_sender sender = new Fc_news_sender();
sender.setNews_id(news.getId());
sender.setSend_time(news.getCreate_time());
sender.setSender(admin.getAdminid());
sender.setUser_id(uid);
senders.add(sender);
}
jdbcTemplate.batchSave(senders);
}
}
package com.egolm.film.api.service.impl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.egolm.film.api.service.OssService;
import com.egolm.film.util.OSSUtils;
@Service
public class OssServiceImpl implements OssService {
@Value("${aliyun.sts.accessKeyId}")
private String accessKeyId;
@Value("${aliyun.sts.accessKeySecret}")
private String accessKeySecret;
@Value("${aliyun.oss.endpoint}")
private String endpoint;
@Value("${aliyun.oss.bucket}")
private String bucket;
@Override
public String getOssPath(String relativePath, Integer expiryTime) {
OSSUtils ossUtil = new OSSUtils(endpoint, accessKeyId, accessKeySecret);
String ossPicPath = ossUtil.urlSign(bucket, relativePath, expiryTime);
ossUtil.closeOssClient();
return ossPicPath;
}
}
package com.egolm.film.api.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.OtherUploadService;
import com.egolm.film.bean.Fc_film_upload;
import com.egolm.film.util.FilmContrants;
@Service
public class OtherUploadServiceImpl implements OtherUploadService {
@Autowired
private JdbcTemplate jdbcTemplate;
public void save(Fc_film_upload fc_film_upload) {
jdbcTemplate.saveOrUpdate(fc_film_upload);
}
public int getIdByNo(Integer film_no) {
try {
String sql = "select id from fc_member_film where film_no = ?";
return jdbcTemplate.queryForInt(sql, film_no);
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
public void batchSave(List<Fc_film_upload> fc_film_upload) {
jdbcTemplate.batchSave(fc_film_upload);
}
public int checkExists(Integer film_no,Integer number) {
String sql = "SELECT count(1) from fc_film_upload where film_no = ? and number = ?";
return jdbcTemplate.queryForInt(sql, film_no,number);
}
//开始上传
public void updateBegin(Integer film_id,Integer film_no, Integer number,String videoId,String taskName) {
if(StringUtil.isNotEmpty(taskName)) {
String sql = "update fc_film_upload set id = ? ,upload_state = ? ,upload_progress = '0%' ,taskName=? where film_no = ? and number = ? ";
jdbcTemplate.executeUpdate(sql,videoId,FilmContrants.UPLOAD_STATUS_ING,taskName,film_no,number);
}else {
String sql = "update fc_film_upload set id = ? ,upload_state = ? ,upload_progress = '0%' where film_no = ? and number = ? ";
jdbcTemplate.executeUpdate(sql,videoId,FilmContrants.UPLOAD_STATUS_ING,film_no,number);
}
String filmSql = "update fc_member_film set upload_id =?, upload_state = ? where film_no = ? ";
jdbcTemplate.executeUpdate(filmSql, videoId,FilmContrants.UPLOAD_STATUS_ING,film_no);
}
//修改进度
public void updateProgress(String videoId,String progress) {
String sql = "update fc_film_upload set upload_progress = ? where id = ? ";
jdbcTemplate.executeUpdate(sql,progress,videoId);
}
//上传成功
public void updateSuccess(String videoId,String film_no) {
String sql = "update fc_film_upload set upload_time = now() ,file_local_path = '' ,upload_state = ? where id = ? ";
jdbcTemplate.executeUpdate(sql,FilmContrants.UPLOAD_STATUS_COMPLETED,videoId);
String filmSql = "update fc_member_film set upload_state = ? ,upload_time =now() where upload_id = ? ";
jdbcTemplate.executeUpdate(filmSql, FilmContrants.UPLOAD_STATUS_COMPLETED,videoId);
}
//上传失败
public void updateFail(String videoId,String errorMessage) {
String sql = "update fc_film_upload set upload__error_message =? ,upload_state = ? where id = ? ";
jdbcTemplate.executeUpdate(sql, errorMessage,FilmContrants.UPLOAD_STATUS_FILE,videoId);
String filmSql = "update fc_member_film set upload_state = ? where upload_id = ? ";
jdbcTemplate.executeUpdate(filmSql,FilmContrants.UPLOAD_STATUS_FILE,videoId);
}
public void updateFail(Integer film_no,Integer number,String errorMessage) {
String sql = "update fc_film_upload set upload__error_message =? ,upload_state = ? where film_no = ? and number = ? ";
jdbcTemplate.executeUpdate(sql, errorMessage,FilmContrants.UPLOAD_STATUS_FILE,film_no,number);
}
/**
* 获取待上传的视频 一次1条
* @Title: getList
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public List<Map<String,Object>> getWaitUploadList(Page page){
String sql = "SELECT * from fc_film_upload where upload_state = 0";
return jdbcTemplate.limit(sql, page);
}
public List<Fc_film_upload> getUploadListByFilmId(Integer film_id){
String sql = "SELECT * from fc_film_upload where film_id = ?";
return jdbcTemplate.queryForBeans(sql, Fc_film_upload.class, film_id);
}
}
package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.Messages;
import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.bean.Fc_user;
import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common;
@Service
public class UserTokenServiceImpl implements UserTokenService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private Messages messages;
@Override
public LoginToken doLogin(String username, String password) {
HttpSession session = WebMvcConfig.getSession();
Fc_user user = null;
try {
user = this.jdbcTemplate.queryForBean("select * from fc_user where username = ?", Fc_user.class, username);
} catch (Exception e) {
throw new XRException(messages.get("err.user_pwd_err"));
}
Integer state = user.getState();
if(state == 1) {
String salt = user.getSalt();
String dbPwd = user.getPassword();
String encodePassword = Common.encodePassword(password, salt);
if(encodePassword.equals(dbPwd)) {
Integer uid = user.getUid();
LoginToken token = new LoginToken(uid);
session.setAttribute(TOKEN_NAME, token);
Cookie cookie = WebMvcConfig.getOrCreateUUIDCookie(LOGINID_COOKIE_NAME, "/", 60*60*24*5, true);
if(cookie != null) {
String sql = "update fc_user set token = ?, last_login_ip = ?, last_login_time = ? where uid = ?";
String loginIp = ServletUtil.remoteIp(WebMvcConfig.getRequest());
jdbcTemplate.executeUpdate(sql, cookie.getValue(), loginIp, new Date(), uid);
}
logger.debug("user login success: " + username);
return token;
} else {
throw new XRException(messages.get("err.user_pwd_err"));
}
} else if(state == 2) {
throw new XRException(messages.get("err.user_disabled"));
} else {
throw new XRException(messages.get("err"));
}
}
@Override
public LoginToken getToken() {
HttpSession session = WebMvcConfig.getSession();
LoginToken token = (LoginToken)session.getAttribute(TOKEN_NAME);
return token;
}
@Override
public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId();
return jdbcTemplate.queryForMap("select u.*, ug.group_name from fc_user u left join fc_user_group ug on ug.group_id = u.group_id where u.uid = ?", id);
}
@Override
public void doLogout() {
String sql = "update fc_user set token = ? where uid = ?";
jdbcTemplate.executeUpdate(sql, null, this.getToken().getId());
HttpSession session = WebMvcConfig.getSession();
session.removeAttribute(TOKEN_NAME);
session.invalidate();
WebMvcConfig.removeCookie(LOGINID_COOKIE_NAME);
}
@Override
public boolean isLogin() {
return this.getToken() != null;
}
@Override
public boolean isLoginByToken(String token_string) {
HttpSession session = WebMvcConfig.getSession();
try {
String sql = "select uid from fc_user where token = ? and state = 1";
Integer uid = jdbcTemplate.queryForInt(sql, token_string);
LoginToken token = new LoginToken(uid);
session.setAttribute(TOKEN_NAME, token);
return true;
} catch (Exception e) {
return false;
}
}
}
/**
* 1金爵 2亚新 4展映
* 1通过 2否决 3参赛 4参赛备选 5参展
* 0未评选 1有争议 2管理员分配 3审片完成
*/
@Override
@Transactional
public void tryNextRound(Integer review_id) {
Fc_review review = jdbcTemplate.queryForBean("select * from fc_review where id = ?", Fc_review.class, review_id);
List<Fc_review_record> records = jdbcTemplate.queryForBeans("select * from fc_review_record where review_id = ? and review_round = ?", Fc_review_record.class, review.getId(), review.getReview_round());
Integer review_round = review.getReview_round();
Integer enroll_type_id = review.getEnroll_type_id();
Integer review_state = this.reviewStateElection(records);
if(review_state == null) {//未完
return;
}
if(review_state.intValue() == 2) {//否决
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 2 where id = ?", review.getId());
} else if(review_state.intValue() == -1) {//争议
if(enroll_type_id.intValue() == 4 && review_round.intValue() == 4 && this.queryRoundReviewCount(review.getId(), review_round) >= 2) {//展映把关已经产生两次争议,需要审片委员会介入
this.toNextRound(review.getId());
} else if(enroll_type_id.intValue() == 4 && review_round.intValue() == 5) {
throw new XRException("展映影片把关存争议,选片委员会介入后不允许产生有争议结论");
} else {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 1, allot_state = 0 where id = ?", review.getId());
}
} else if(review_round.intValue() == 1) {//审片第一轮都一样
if(review_state.intValue() == 1) {
this.toNextRound(review.getId());
} else {
throw new XRException("第1轮审片结论错误,正确应为:通过,否决");
}
} else if(enroll_type_id.intValue() == 4) {//展映
if(review_round.intValue() == 2) {//二选
if(review_state.intValue() == 5) {
this.toNextStepRound(review.getId(), 2);
} else {
throw new XRException("展映第2轮审片结论错误");
}
} else if(review_round.intValue() == 4) {//把关
if(review_state.intValue() == 1) {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 1 where id = ?", review.getId());
} else {
throw new XRException("展映第4轮审片结论错误");
}
} else if(review_round.intValue() == 5) {//选片委员会
if(review_state.intValue() == 1) {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 1 where id = ?", review.getId());
} else {
throw new XRException("展映第5轮审片结论错误");
}
} else {
throw new XRException("展映审片轮数错误[" + review_round + "]");
}
} else if(enroll_type_id.intValue() == 2) {//亚新
if(review_round.intValue() == 2) {
if(review_state.intValue() == 3) {//参赛,等待管理员分配进入下一轮评选
jdbcTemplate.executeUpdate("update fc_review set opt_state = 2, review_state = 3 where id = ?", review.getId());
} else if(review_state.intValue() == 5) {//参展,结束当前流程,启动新参展流程
this.transfer_4_flow_4(review);
} else {
throw new XRException("亚新第2轮审片结论错误");
}
} else if(review_round.intValue() == 3) {
if(review_state.intValue() == 3) {//参赛,等待管理员分配进入下一轮评选
jdbcTemplate.executeUpdate("update fc_review set opt_state = 2, review_state = 3 where id = ?", review.getId());
} else {
throw new XRException("亚新第3轮审片结论错误");
}
} else if(review_round.intValue() == 4) {//把关
if(review_state.intValue() == 1) {
this.toNextRound(review.getId());
} else {
throw new XRException("亚新第4轮审片结论错误");
}
} else if(review_round.intValue() == 5) {//选片委员会
if(review_state.intValue() == 3) {//参赛,自动进入下一轮评选
this.toNextRound(review.getId());
} else if(review_state.intValue() == 5) {//参展,结束当前流程,启动新参展流程
this.transfer_4_flow_5(review);
} else {
throw new XRException("亚新第5轮审片结论错误");
}
} else if(review_round.intValue() == 6) {//总局审片
if(review_state.intValue() == 1) {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 1 where id = ?", review.getId());
} else {
throw new XRException("亚新第6轮审片结论错误");
}
} else {
throw new XRException("亚新审片轮数错误[" + review_round + "]");
}
} else if(enroll_type_id.intValue() == 1) {
Fc_member_film film = filmService.queryMemberFilmById(review.getFilm_id().longValue());
Integer film_type_id = Integer.valueOf(film.getFilm_type_name());
if(film_type_id == 4) {//金爵短片
if(review_round.intValue() == 2) {
if(review_state.intValue() == 3 || review_state.intValue() == 4) {//参赛 //参赛备选
this.toNextRound(review.getId());
} else {
throw new XRException("金爵短片2轮审片结论错误");
}
} else if(review_round.intValue() == 3) {
if(review_state.intValue() == 3) {
this.toNextRound(review.getId());
} else {
throw new XRException("金爵短片3轮审片结论错误");
}
} else if(review_round.intValue() == 4) {//把关
if(review_state.intValue() == 1) {
this.toNextRound(review.getId());
} else {
throw new XRException("金爵短片4轮审片结论错误");
}
} else if(review_round.intValue() == 5) {//选片委员会
if(review_state.intValue() == 3) {
this.toNextRound(review.getId());
} else if(review_state.intValue() == 5) {//参展,结束当前流程,启动新参展流程
this.transfer_4_flow_5(review);
} else {
throw new XRException("金爵短片5轮审片结论错误");
}
} else if(review_round.intValue() == 6) {//总局审片
if(review_state.intValue() == 1) {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 1 where id = ?", review.getId());
} else {
throw new XRException("金爵短片6轮审片结论错误");
}
} else {
throw new XRException("金爵短片审片轮数错误[" + review_round + "]");
}
} else {//金爵长片
if(review_round.intValue() == 2) {
if(review_state.intValue() == 3 || review_state.intValue() == 4) {//参赛 //参赛备选
this.toNextRound(review.getId());
} else if(review_state.intValue() == 5) {//参展,结束当前流程,启动新参展流程
this.transfer_4_flow_4(review);
} else {
throw new XRException("金爵长片2轮审片结论错误");
}
} else if(review_round.intValue() == 3) {
if(review_state.intValue() == 3) {
this.toNextRound(review.getId());
} else if(review_state.intValue() == 5) {//参展,结束当前流程,启动新参展流程
this.transfer_4_flow_4(review);
} else {
throw new XRException("金爵长片3轮审片结论错误");
}
} else if(review_round.intValue() == 4) {//把关
if(review_state.intValue() == 1) {
this.toNextRound(review.getId());
} else {
throw new XRException("金爵长片4轮审片结论错误");
}
} else if(review_round.intValue() == 5) {//选片委员会
if(review_state.intValue() == 3) {
this.toNextRound(review.getId());
} else if(review_state.intValue() == 5) {//参展,结束当前流程,启动新参展流程
this.transfer_4_flow_5(review);
} else {
throw new XRException("金爵长片5轮审片结论错误");
}
} else if(review_round.intValue() == 6) {//总局审片
if(review_state.intValue() == 1) {
jdbcTemplate.executeUpdate("update fc_review set opt_state = 3, review_state = 1 where id = ?", review.getId());
} else {
throw new XRException("金爵长片6轮审片结论错误");
}
} else {
throw new XRException("金爵长片审片轮数错误[" + review_round + "]");
}
}
}
Integer opt_state = jdbcTemplate.queryForInt("select opt_state from fc_review where id = ?", review.getId());
Fc_review_history history = new Fc_review_history();
history.setReview_id(review.getId());
history.setEnroll_type_id(enroll_type_id);
history.setFilm_id(review.getFilm_id());
history.setReview_round(review_round);
history.setReview_state(review_state);
history.setCreate_time(new Date());
history.setOpt_state(opt_state);
jdbcTemplate.save(history);
}
\ No newline at end of file
package com.egolm.film.api.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx;
import com.egolm.film.api.service.CountryService;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.LanguageService;
import com.egolm.film.api.service.ReviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Api
@Controller
@RequestMapping("common")
public class CommonApiController {
@Autowired
private CountryService countryService;
@Autowired
private LanguageService languageService;
@Autowired
private ReviewService reviewService;
@Autowired
private FilmService filmService;
@ResponseBody
@PostMapping("getCountryList")
@ApiOperation("获取国家对照表")
public Object getCountryList() {
return Rjx.jsonOk().setData(countryService.queryCountryList());
}
@ResponseBody
@PostMapping("getAsiaCountryList")
@ApiOperation("获取亚洲国家对照表")
public Object getAsiaCountryList() {
return Rjx.jsonOk().setData(countryService.queryAsiaCountryList());
}
@ResponseBody
@PostMapping("getLanguageList")
@ApiOperation("获取语言对照表")
public Object getLanguageList() {
return Rjx.jsonOk().setData(languageService.queryLanguageList());
}
@ResponseBody
@PostMapping("getEnrollList")
@ApiOperation("获取影片性质列表")
public Object getEnrollList() {
return Rjx.jsonOk().setData(filmService.queryEnrollList());
}
@ResponseBody
@PostMapping("getTypeList")
@ApiOperation("获取影片类型列表")
public Object getTypeList() {
return Rjx.jsonOk().setData(filmService.queryTypeList());
}
@ResponseBody
@PostMapping("getDoubtfulList")
@ApiOperation("获取疑点列表")
public Object getDoubtfulList() {
return Rjx.jsonOk().setData(reviewService.queryDoubtfulList());
}
}
package com.egolm.film.api.web;
import java.util.Locale;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.MailUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.EmailService;
import com.egolm.film.api.service.MemberService;
import com.egolm.film.api.service.MemberTokenService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.config.XException;
import com.egolm.film.config.interceptor.LocaleInterceptor;
import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api
@Controller
@RequestMapping("open/member")
public class OpenMemberApiController {
@Autowired
private EmailService emailService;
@Autowired
private Messages messages;
@Autowired
private MemberService memberService;
@Autowired
private MemberTokenService memberTokenService;
@ResponseBody
@PostMapping("register")
@ApiOperation("会员注册")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", dataType="string", name="i18n_language"),
@ApiImplicitParam(paramType = "query", dataType = "String", required = true, name = "username"),
@ApiImplicitParam(paramType = "query", dataType = "String", required = true, name = "password"),
@ApiImplicitParam(paramType = "query", dataType = "String", required = true, name = "email"),
})
public Object register(HttpServletRequest request, String username, String password, String email) {
XException.assertNotBlank(messages.get("err.email_null"), email);
XException.assertNotBlank(messages.get("err.name_null"), username);
XException.assertNotBlank(messages.get("err.pwd_null"), password);
Locale locale = LocaleContextHolder.getLocale();
String salt = Common.getGenerateString(6);
String encodePwd = Common.encodePassword(password, salt);
Fc_member member = new Fc_member();
member.setSalt(salt);
member.setUsername(username);
member.setPassword(encodePwd);
member.setEmail(email);
member.setCreate_ip(ServletUtil.remoteIp(request));
member.setCreate_time(System.currentTimeMillis());
member.setLang(locale == null ? "zh" : locale.getLanguage());
member.setState(1);
if(memberService.exists(email)) {
throw new XException(messages.get("err.user_exists"));
}
memberService.saveMember(member);
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("resetPassword")
@ApiOperation("找回密码")
@ApiImplicitParams({@ApiImplicitParam(paramType="header", dataType="string", name="i18n_language"),
@ApiImplicitParam(paramType = "query", dataType = "String", required = true, name = "email")
})
public Object resetPassword(String email) {
XException.assertNotBlank(messages.get("err.email_null"), email);
int code = (int) ((Math.random() * 9 + 1) * 10000000);
String password = String.valueOf(code);
Fc_member member = null;
try {
member = memberService.getMemberByEmail(email);
} catch (EmptyResultDataAccessException e) {
throw new XException(messages.get("err.user_not_exists"));
}
String encodePwd = Common.encodePassword(password, member.getSalt());
memberService.resetPassword(member.getId(), encodePwd);
String name = member.getUsername();
String subject = messages.get("email.getPassword.subject");
String content = messages.get("email.getPassword.content", name == null ? "" : name, password);
emailService.send(0, null, subject, content, email);
return Rjx.jsonOk();
}
public static void main(String[] args) {
/**
* com.egolm.film.email.smtp.host=mail.egolm.com
com.egolm.film.email.smtp.port=25
com.egolm.film.email.smtp.is_auth=true
com.egolm.film.email.smtp.from=qu.xinliang@egolm.com
com.egolm.film.email.smtp.password=Liang12345
*/
String host = "mail.egolm.com";
Integer port = 25;
Boolean is_auth = true;
String content = "测试邮件";
String from = "qu.xinliang@egolm.com";
String username = "qu.xinliang";
String password = "Liang12345";
String to = "747539993@qq.com";
String subject = "测试邮件";
MailUtil.sendBySmtp(host, port, is_auth, username, password, from, subject, content, null, to);
}
@ResponseBody
@PostMapping("setLocale")
@ApiOperation("设置语言环境,用户切换语言时调用,电影节相关提醒类邮件的发送语言种类都与此设置有关")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "string", required = true, name = "i18n_language", defaultValue="zh_CN")
})
public Object setLocale(HttpServletResponse response, String i18n_language) {
Cookie cookie = new Cookie(LocaleInterceptor.language, i18n_language);
cookie.setMaxAge(3600000);
cookie.setPath("/");
response.addCookie(cookie);
LoginToken token = memberTokenService.getToken();
if(token != null) {
memberService.updateLanguage((Integer)token.getId(), i18n_language.split("_")[0]);
}
return Rjx.jsonOk();
}
}
package com.egolm.film.api.web.admin;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.LogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api
@Controller
@RequestMapping("admin/log")
public class AdminLogController {
@Autowired
LogService service;
@ResponseBody
@PostMapping("list")
@ApiOperation("查询日志")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="type", value="ADMIN,MEMBER,USER"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="username"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="index", value="分页编号"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="limit", value="分页大小"),
})
public Object list(String type, String username, Long index, Long limit) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
List<Map<String, Object>> list = service.queryLogList(type, username, page);
return Rjx.jsonOk().setData(list).setPage(page);
}
@ResponseBody
@PostMapping("getErrorList")
@ApiOperation("查询日志")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", dataType="long", required=false, name="index", value="分页编号"),
@ApiImplicitParam(paramType="query", dataType="long", required=false, name="limit", value="分页大小"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="limitKey", value="排序"),
})
public Object getErrorList(String[] limitKey, Long index, Long limit) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit, limitKey == null || limitKey.length == 0 ? new String[] {"id desc"} : limitKey);
List<Map<String, Object>> list = service.queryErrorList(page);
return Rjx.jsonOk().setData(list).setPage(page);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment